/[webpac2]/trunk/sql/mkindex.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/sql/mkindex.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 34 by dpavlin, Tue Aug 2 00:42:04 2005 UTC revision 37 by dpavlin, Tue Aug 2 15:20:44 2005 UTC
# Line 34  while (<>) { Line 34  while (<>) {
34                  $out->{inherits}->{$table} = $1;                  $out->{inherits}->{$table} = $1;
35          }          }
36    
37          if (s/^\s*(\S+)(.+?)references\s+(\S+)\s*\((\S+)\)/\t$1$2/i) {          if (s/^\s*(\S+)(.+?)references\s+(\S+)\s*\((\S+)\)([^,]*)([,\s]*)$/\t$1$2$6/i) {
38  #       if (/^\s*(\S+)(.+?)references\s+(\S+)\s*\((\S+)\)/) {  #       if (/^\s*(\S+)(.+?)references\s+(\S+)\s*\((\S+)\)/) {
39                  @{ $out->{references}->{$table}->{$1} } = ( $3, $4 );                  @{ $out->{references}->{$table}->{$1} } = ( $3, $4, $5 );
40          }          }
41    
42          print "$_\n";          print "$_\n";
# Line 47  while (<>) { Line 47  while (<>) {
47  print STDERR Dumper($out);  print STDERR Dumper($out);
48    
49  foreach my $table (keys %{ $out->{inherits} }) {  foreach my $table (keys %{ $out->{inherits} }) {
50          my $parent = $out->{inherits}->{$table} || die;          my $parent = $out->{inherits}->{$table} || die "$table doesn't inherit anything";
51          my $pk = $out->{table_pk}->{$parent} || die;          my $pk = $out->{table_pk}->{$parent} || die "$parent doesn't have primary key";
52          my $seq = $parent . '_' . $pk . '_seq';          my $seq = $parent . '_' . $pk . '_seq';
53          print qq{alter table $table alter column $pk set default nextval('$seq');\n};          print qq{alter table $table alter column $pk set default nextval('$seq');\n};
54  }  }

Legend:
Removed from v.34  
changed lines
  Added in v.37

  ViewVC Help
Powered by ViewVC 1.1.26