Skip to content

Commit 004c737

Browse files
committed
oracle translation is incomplete for DROP ... IF EXISTS
1 parent 8db1876 commit 004c737

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

t/lib/DodTestUtil.pm

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,25 @@ sub create_sql {
196196
add_drop_table => $drop_table,
197197
);
198198
$sql = $sqlt->translate(\$sql) or die $sqlt->error;
199-
return split_sql_for_oracle($sql) if $driver eq 'Oracle';
199+
return split_sql_for_oracle(patch_oracle_drop($sql)) if $driver eq 'Oracle';
200200
return split_sql($sql);
201201
}
202202
$sql;
203203
}
204204

205+
sub patch_oracle_drop {
206+
my $sql = shift;
207+
$sql =~ s{(DROP (TABLE|SEQUENCE) "(.+)".*);}{
208+
BEGIN
209+
EXECUTE IMMEDIATE '$1';
210+
EXCEPTION
211+
WHEN OTHERS THEN IF SQLCODE != -942 AND SQLCODE != -2289 THEN RAISE; END IF;
212+
END;
213+
/
214+
}g;
215+
return $sql;
216+
}
217+
205218
sub split_sql_for_oracle {
206219
my ($sql) = @_;
207220
return map { split_sql($_) } split(/\s*\/\s*/, $sql);

0 commit comments

Comments
 (0)