Skip to content

Commit

Permalink
Merge pull request darold#556 from topicus-education-ops/deferrable-u…
Browse files Browse the repository at this point in the history
…nique-constraint

deferrable pk/unique constraint
  • Loading branch information
darold authored Oct 6, 2017
2 parents ca3cbee + 4877698 commit fd91dae
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/Ora2Pg.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7312,6 +7312,8 @@ sub _create_unique_keys
my $constype = $unique_key->{$consname}{type};
my $constgen = $unique_key->{$consname}{generated};
my $index_name = $unique_key->{$consname}{index_name};
my $deferrable = $unique_key->{$consname}{deferrable};
my $deferred = $unique_key->{$consname}{deferred};
my @conscols = @{$unique_key->{$consname}{columns}};
# Exclude unique index used in PK when column list is the same
next if (($constype eq 'U') && exists $pkcollist{$table} && ($pkcollist{$table} eq join(",", @conscols)));
Expand All @@ -7336,6 +7338,12 @@ sub _create_unique_keys
if ($self->{use_tablespace} && $self->{tables}{$tbsaved}{idx_tbsp}{$index_name} && !grep(/^$self->{tables}{$tbsaved}{idx_tbsp}{$index_name}$/i, @{$self->{default_tablespaces}})) {
$out .= " USING INDEX TABLESPACE $self->{tables}{$tbsaved}{idx_tbsp}{$index_name}";
}
if ($deferrable eq "DEFERRABLE") {
$out .= " DEFERRABLE";
if ($deferred eq "DEFERRED") {
$out .= " INITIALLY DEFERRED"
}
}
$out .= ";\n";
}
}
Expand Down Expand Up @@ -8375,7 +8383,7 @@ END

while (my $row = $sth->fetch) {

my %constraint = (type => $row->[7], 'generated' => $row->[8], 'index_name' => $row->[11], columns => ());
my %constraint = (type => $row->[7], 'generated' => $row->[8], 'index_name' => $row->[11], 'deferrable' => $row->[4], 'deferred' => $row->[5], columns => ());
my @done = ();
foreach my $r (@cons_columns) {
# Skip constraints on system internal columns
Expand Down

0 comments on commit fd91dae

Please sign in to comment.