/[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.1 by dpavlin, Mon Mar 6 07:13:23 2000 UTC revision 1.2 by dpavlin, Tue Apr 25 13:48:56 2000 UTC
# Line 11  Line 11 
11  # 1999-12-26 DbP don't make serial from auto_increment, create all manually  # 1999-12-26 DbP don't make serial from auto_increment, create all manually
12  #                (to set start value right)  #                (to set start value right)
13  # 2000-01-11 DbP now creates sequences with correct value  # 2000-01-11 DbP now creates sequences with correct value
14    # 2000-04-25 DbP import into CVS (at cvs.linux.hr)
15    
16  use DBI;  use DBI;
17    
# Line 93  while(<DUMP>) { Line 94  while(<DUMP>) {
94    
95                  # nuke date representation (not supported in PostgreSQL)                  # nuke date representation (not supported in PostgreSQL)
96                  s/datetime default '[^']+'/datetime/i;                  s/datetime default '[^']+'/datetime/i;
97                    s/date default '[^']+'/datetime/i;
98                    s/time default '[^']+'/datetime/i;
99    
100                  # change not null datetime filend to null valid ones                  # change not null datetime filend to null valid ones
101                  # (to support remapping of "zaro time" to null                  # (to support remapping of "zaro time" to null
102                  s/datetime not null/datetime/i;                  s/datetime not null/datetime/i;
103    
104                    # add unique to definition of type (MySQL separates this)
105                    if (/unique \w+ \((\w+)\)/i) {
106                            $sql=~s/($1)([^,]+)/$1$2 unique/gi;
107                            next;
108                    }
109    
110            } else {        # not inside create table
111    
112                  #---- fix data in inserted data: (from MS world)                  #---- fix data in inserted data: (from MS world)
113                  # FIX: disabled for now                  # FIX: disabled for now
114                  if (00 && /insert into/i) {                  if (00 && /insert into/i) {
# Line 108  while(<DUMP>) { Line 119  while(<DUMP>) {
119                          s!\x92!`!g;                          s!\x92!`!g;
120                  }                  }
121    
         } else {        # not inside create table  
   
122                  # fix dates '0000-00-00 00:00:00' (should be null)                  # fix dates '0000-00-00 00:00:00' (should be null)
123                  s/'0000-00-00 00:00:00'/null/gi;                  s/'0000-00-00 00:00:00'/null/gi;
124                    s/'0000-00-00'/null/gi;
125                    s/'00:00:00'/null/gi;
126          }          }
127    
128          $sql.="$_";          $sql.="$_";

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.26