/[sql]/mysql2pgsql
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 /mysql2pgsql

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

revision 1.8 by dpavlin, Thu Feb 1 15:15:48 2001 UTC revision 1.9 by dpavlin, Thu Apr 12 12:41:12 2001 UTC
# Line 78  $table=""; Line 78  $table="";
78  open(DUMP,"$dump") || die "can't open dump file $dump";  open(DUMP,"$dump") || die "can't open dump file $dump";
79    
80  while(<DUMP>) {  while(<DUMP>) {
81          chomp;          chomp; s/\r//g;
82          print "Processing line: $_\n" if $DEBUG;          print "Processing line: $_\n" if $DEBUG;
83    
84  # nuke comments or empty lines  # nuke comments or empty lines
# Line 91  while(<DUMP>) { Line 91  while(<DUMP>) {
91    
92          if ($create) {                  # are we inside create table?          if ($create) {                  # are we inside create table?
93    
                 # FIX: nuke keys  
                 next if (/^\s+key/i && !/^\s+primary key/i);  
   
94                  # int,auto_increment -> serial                  # int,auto_increment -> serial
95                  if (/int.*auto_increment/i) {                  if (/int.*auto_increment/i) {
96    
97    
98                          # this was simple solution, but squence isn't                          # this was simple solution, but squence isn't
99                          # initialized correctly so I have to do a work-around                          # initialized correctly so I have to do a work-around
100                          #                          #
# Line 105  while(<DUMP>) { Line 103  while(<DUMP>) {
103                          if (/^\s*(\w+)\s+/) {                          if (/^\s*(\w+)\s+/) {
104                                  $seq="${table}_${1}_seq";                                  $seq="${table}_${1}_seq";
105                                  push @sequences,"$table.$1";                                  push @sequences,"$table.$1";
106                                  s/(\w+) \w*int.*auto_increment/$1 int4 default nextval('$seq') not null/ig;                                  s/(\s+)\w*int.*auto_increment[^,]*/$1int4 default nextval('$seq') not null/ig;
107                          } else {                          } else {
108                                  die "can't get name of field!";                                  die "can't get name of field!";
109                          }                          }
# Line 161  while(<DUMP>) { Line 159  while(<DUMP>) {
159                  # FIX: unique for multipe columns (col1,col2) are unsupported!                  # FIX: unique for multipe columns (col1,col2) are unsupported!
160                  next if (/unique/i);                  next if (/unique/i);
161    
162                    # FIX: nuke keys
163                    next if (/^\s+key/i && !/^\s+primary key/i);
164    
165                  # quote column names                  # quote column names
166                  s/(^\s*)(\S+)(\s*)/$1"$2"$3/gi if (!/key/i);                  s/(^\s*)(\S+)(\s*)/$1"$2"$3/gi if (!/key/i);
167    

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.26