From da5e628a2ebeb2e17aa51f32622e7028fd69e7fa Mon Sep 17 00:00:00 2001 From: Gilles Darold Date: Wed, 26 Sep 2018 20:20:24 +0200 Subject: [PATCH] Fix automatic quoting of table or partition name starting with a number. Thanks to Barzaqh for the report. --- lib/Ora2Pg.pm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/Ora2Pg.pm b/lib/Ora2Pg.pm index 61501342..a3230ce8 100644 --- a/lib/Ora2Pg.pm +++ b/lib/Ora2Pg.pm @@ -698,7 +698,7 @@ sub quote_object_name if (!$self->{preserve_case}) { $obj_name = lc($obj_name); # then if there is non alphanumeric or the object name is a reserved word - if ($obj_name =~ /[^a-z0-9\_\.]/ || ($self->{use_reserved_words} && $self->is_reserved_words($obj_name))) { + if ($obj_name =~ /[^a-z0-9\_\.]/ || ($self->{use_reserved_words} && $self->is_reserved_words($obj_name)) || $obj_name =~ /^\d+/) { # Add double quote to [schema.] object name if ($obj_name !~ /^[^\.]+\.[^\.]+$/) { $obj_name = '"' . $obj_name . '"'; @@ -6065,7 +6065,6 @@ BEGIN my $old_part = ''; my $owner = ''; foreach my $pos (sort {$a <=> $b} keys %{$self->{partitions}{$table}}) { - print STDERR "PARTITION: $table :: $pos :: $self->{partitions}{$table}{$pos}{name}\n"; next if (!$self->{partitions}{$table}{$pos}{name}); my $part = $self->{partitions}{$table}{$pos}{name}; if (!$self->{quiet} && !$self->{debug}) { @@ -8502,9 +8501,9 @@ VARCHAR2 if ($part_name) { if ($is_subpart) { - $alias = "SUBPARTITION($part_name) a"; + $alias = "SUBPARTITION(" . $self->quote_object_name($part_name) . ") a"; } else { - $alias = "PARTITION($part_name) a"; + $alias = "PARTITION(". $self->quote_object_name($part_name) . ") a"; } } # Force parallelism on Oracle side