--- mysql2pgsql 2001/02/01 15:15:48 1.8 +++ mysql2pgsql 2001/04/12 12:41:12 1.9 @@ -78,7 +78,7 @@ open(DUMP,"$dump") || die "can't open dump file $dump"; while() { - chomp; + chomp; s/\r//g; print "Processing line: $_\n" if $DEBUG; # nuke comments or empty lines @@ -91,12 +91,10 @@ if ($create) { # are we inside create table? - # FIX: nuke keys - next if (/^\s+key/i && !/^\s+primary key/i); - # int,auto_increment -> serial if (/int.*auto_increment/i) { + # this was simple solution, but squence isn't # initialized correctly so I have to do a work-around # @@ -105,7 +103,7 @@ if (/^\s*(\w+)\s+/) { $seq="${table}_${1}_seq"; push @sequences,"$table.$1"; - 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; } else { die "can't get name of field!"; } @@ -161,6 +159,9 @@ # FIX: unique for multipe columns (col1,col2) are unsupported! next if (/unique/i); + # FIX: nuke keys + next if (/^\s+key/i && !/^\s+primary key/i); + # quote column names s/(^\s*)(\S+)(\s*)/$1"$2"$3/gi if (!/key/i);