/[papo]/papo/zot/zot2sql.pl
ViewVC logotype

Diff of /papo/zot/zot2sql.pl

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

revision 1.6 by apronotti, Tue Dec 3 18:08:51 2002 UTC revision 1.7 by jlenton, Tue Feb 4 21:16:19 2003 UTC
# Line 39  $config{'^PostgreSQL 7\.2\.'} = Line 39  $config{'^PostgreSQL 7\.2\.'} =
39          return( ( sprintf("dbi:Pg:dbname=%s;host=%s", $db_name, $db_host),          return( ( sprintf("dbi:Pg:dbname=%s;host=%s", $db_name, $db_host),
40                    $user, $password, { 'RaiseError' => 1 } ) );                    $user, $password, { 'RaiseError' => 1 } ) );
41      },      },
42      'delay' => sub { system('sync'); select(undef, undef, undef, 0.005) },      'delay' => sub { system('sync'); select(undef, undef, undef, 0.5) },
43        'delay' => sub {  },
44      'datatypes' => {},      'datatypes' => {},
45      'relational' => sub {      'relational' => sub {
46          my $table = shift;          my $table = shift;
# Line 148  foreach my $table (sort keys %structure) Line 149  foreach my $table (sort keys %structure)
149          }          }
150          else          else
151          {          {
152                if ($r =~ /^_start_t\s/)
153                {
154                    $r .= ' NOT NULL';
155                }
156              push @r, $r;              push @r, $r;
157          }          }
158      }      }
# Line 161  foreach my $table (sort keys %structure) Line 166  foreach my $table (sort keys %structure)
166          $type = ($type eq 'bigserial') ? 'bigint' : 'int';          $type = ($type eq 'bigserial') ? 'bigint' : 'int';
167          $type = $config{$db_conf}{'datatypes'}{lc $type} || $type;          $type = $config{$db_conf}{'datatypes'}{lc $type} || $type;
168    
169            if ($rel eq '_table')
170            {
171                $type .= " NOT NULL";
172            }
173    
174          push @r, "$rel $type";          push @r, "$rel $type";
175      }      }
176    
177      my $sql = "CREATE TABLE $table (\n" . join(",\n", map("    $_", @r)) . "\n);\n";      my $sql = "CREATE TABLE $table (\n" . join(",\n", map("    $_", @r)) . "\n);\n";
178    
179      print $sql if $db_conf ne 'stdout';      print STDERR $sql;
180      $db->do( $sql );      $db->do( $sql );
181      $config{$db_conf}{'delay'}->();      $config{$db_conf}{'delay'}->();
182  }  }
# Line 187  if ($config{$db_conf}{'relational'}) Line 197  if ($config{$db_conf}{'relational'})
197              {              {
198                  $sql = $config{$db_conf}{'relational'}->($table, $rel, $structure{$table}{REL}{$rel});                  $sql = $config{$db_conf}{'relational'}->($table, $rel, $structure{$table}{REL}{$rel});
199              }              }
200              print $sql if $db_conf ne 'stdout';              print STDERR $sql;
201              $db->do($sql);              $db->do($sql);
202              $config{$db_conf}{'delay'}->();              $config{$db_conf}{'delay'}->();
203          }          }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26