Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3e40ff5

Browse files
committed
Upgrade to my2pg 1.9
1 parenta24104e commit3e40ff5

File tree

1 file changed

+37
-34
lines changed

1 file changed

+37
-34
lines changed

‎contrib/mysql/my2pg.pl

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,27 @@
3535
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3636
# SUCH DAMAGE.
3737
#
38-
# $My2pg: my2pg.pl,v 1.24 2001/12/06 19:32:20 fonin Exp $
39-
# $Id: my2pg.pl,v 1.9 2002/08/22 00:01:39 tgl Exp $
40-
41-
# TODO:
42-
# + Handle SETs
43-
# - LIKE implementation
44-
# - memory use optimisation in SET_output function
45-
# - raw integer values as input values must be OK
46-
# - Use autoconf & automake to auto-build makefiles
38+
# $My2pg: my2pg.pl,v 1.27 2001/12/06 19:32:20 fonin Exp $
39+
# $Id: my2pg.pl,v 1.10 2003/01/07 22:18:43 momjian Exp $
4740

4841
#
4942
# $Log: my2pg.pl,v $
50-
# Revision 1.9 2002/08/22 00:01:39 tgl
51-
# Add a bunch of pseudo-types to replace the behavior formerly associated
52-
# with OPAQUE, as per recent pghackers discussion. I still want to do some
53-
# more work on the 'cstring' pseudo-type, but I'm going to commit the bulk
54-
# of the changes now before the tree starts shifting under me ...
43+
# Revision 1.10 2003/01/07 22:18:43 momjian
44+
# Upgrade to my2pg 1.9
45+
#
46+
# Revision 1.27 2002/07/16 14:54:07 fonin
47+
# Bugfix - didn't quote the fields inside PRIMARY KEY with -d option.
48+
# Fix by Milan P. Stanic <mps@rns-nis.co.yu>.
5549
#
56-
# Revision 1.8 2002/04/24 01:42:29 momjian
57-
# Update to my2pg 1.24.
50+
# Revision 1.26 2002/07/14 10:30:27 fonin
51+
# Bugfix - MySQL keywords inside data (INSERT INTO sentence) were replaced
52+
# with Postgres keywords and therefore messed up the data.
53+
#
54+
# Revision 1.25 2002/07/05 09:20:25 fonin
55+
# - fixed data that contains two consecutive timestamps - thanks to
56+
# Ben Darnell <bdarnell@google.com>
57+
# - word 'default' was converted to upper case inside the data - fixed.
58+
# Thanks to Madsen Wikholm <madsen@iki.fi>
5859
#
5960
# Revision 1.24 2002/04/20 14:15:43 fonin
6061
# Patch by Felipe Nievinski <fnievinski@terra.com.br>.
@@ -177,7 +178,7 @@
177178
$|=1;
178179

179180
print("------------------------------------------------------------------");
180-
print("\n-- My2Pg 1.24 translated dump");
181+
print("\n-- My2Pg 1.27 translated dump");
181182
print("\n--");
182183
print("\n------------------------------------------------------------------");
183184

@@ -199,7 +200,7 @@
199200
# push header to libtypes.c
200201
open(LIBTYPES,">$libtypesource");
201202
print LIBTYPES"/******************************************************";
202-
print LIBTYPES"\n * My2Pg\$Revision: 1.9 $\translated dump";
203+
print LIBTYPES"\n * My2Pg1.27\translated dump";
203204
print LIBTYPES"\n * User types definitions";
204205
print LIBTYPES"\n ******************************************************/";
205206
print LIBTYPES"\n\n#include <postgres.h>\n";
@@ -211,7 +212,7 @@
211212

212213
if(!$tabledef &&/^CREATE TABLE\S+/i){
213214
$tabledef=1;
214-
}elsif($tabledef &&/^\);/i){# /^\w/i
215+
}elsif($tabledef &&/^\) type=\w*;/i){# /^\w/i
215216
$tabledef=0;
216217
}
217218

@@ -253,7 +254,9 @@
253254

254255
# small hack - convert "default" to uppercase, because below we
255256
# enclose all lowercase words in double quotes
256-
s/default/DEFAULT/;
257+
if(!/^INSERT/) {
258+
s/default/DEFAULT/;
259+
}
257260

258261
# Change all AUTO_INCREMENT fields to SERIAL ones with a pre-defined sequence
259262
if(/([\w\d]+)\sint.*auto_increment/i) {
@@ -314,11 +317,11 @@
314317
print LIBTYPES"\n * Types for table".uc($table_name);
315318
print LIBTYPES"\n */\n";
316319

317-
$types.="\nCREATE FUNCTION$typename"."_in (cstring)
320+
$types.="\nCREATE FUNCTION$typename"."_in (opaque)
318321
RETURNS$typename
319322
AS '$libtypename'
320323
LANGUAGE 'c'
321-
WITH (ISSTRICT,ISCACHABLE);\n";
324+
WITH (ISCACHABLE);\n";
322325

323326
# creating output function
324327
my$func_out="
@@ -368,11 +371,11 @@
368371
return (*a>=*b);
369372
}\n";
370373

371-
$types.="\nCREATE FUNCTION$typename"."_out ($typename)
372-
RETURNScstring
374+
$types.="\nCREATE FUNCTION$typename"."_out (opaque)
375+
RETURNSopaque
373376
AS '$libtypename'
374377
LANGUAGE 'c'
375-
WITH (ISSTRICT,ISCACHABLE);\n";
378+
WITH (ISCACHABLE);\n";
376379

377380
$types.="\nCREATE TYPE$typename (
378381
internallength = 2,
@@ -515,7 +518,7 @@
515518
print LIBTYPES"\n * Types for table".uc($table_name);
516519
print LIBTYPES"\n */\n";
517520

518-
$types.="\nCREATE FUNCTION$typename"."_in (cstring)
521+
$types.="\nCREATE FUNCTION$typename"."_in (opaque)
519522
RETURNS$typename
520523
AS '$libtypename'
521524
LANGUAGE 'c';\n";
@@ -567,8 +570,8 @@
567570
568571
\n";
569572

570-
$types.="\nCREATE FUNCTION$typename"."_out ($typename)
571-
RETURNScstring
573+
$types.="\nCREATE FUNCTION$typename"."_out (opaque)
574+
RETURNSopaque
572575
AS '$libtypename'
573576
LANGUAGE 'c';\n";
574577

@@ -651,11 +654,11 @@
651654
}
652655

653656
# output CHECK constraints instead UNSIGNED modifiers
654-
if(/PRIMARY KEY\((.*)\)/i) {
657+
if(/PRIMARY KEY\s+\((.*)\)/i) {
655658
my$tmpfld=$1;
656659
$tmpfld=~s/,/","/gif$dq;
657660
$tmpfld=~s///g;
658-
s/PRIMARY KEY(\(.*\))/PRIMARY KEY\($dq$tmpfld$dq\)/i;
661+
s/PRIMARY KEY\s+(\(.*\))/PRIMARY KEY\($dq$tmpfld$dq\)/i;
659662
s/(PRIMARY KEY\(.*\)).*/$1$check\n/i;
660663
}
661664

@@ -685,9 +688,9 @@
685688
# Fix timestamps
686689
s/'0000-00-00/'0001-01-01/g;
687690
# may work wrong !!!
688-
s/([,(])00000000000000([,)])/$1'00010101 000000'$2/g;
689-
s/([,(])(\d{8})(\d{6})([,)])/$1'$2$3'$4/g;
690-
s/([,(])(\d{4})(\d{2})(\d{2})([,)])/$1'$2-$3-$4 00:00:00'$5/g;
691+
s/([,(])00000000000000(?=[,)])/$1'00010101 000000'/g;
692+
s/([,(])(\d{8})(\d{6})(?=[,)])/$1'$2$3'/g;
693+
s/([,(])(\d{4})(\d{2})(\d{2})(?=[,)])/$1'$2-$3-$4 00:00:00'/g;
691694
#<Hackzone> ---------------------------------------------------
692695
#</Hackzone> --------------------------------------------------
693696
$dump.=$_;
@@ -731,7 +734,7 @@
731734

732735
open(MAKE,">Makefile");
733736
print MAKE"#
734-
# My2Pg\$Revision: 1.9 $\translated dump
737+
# My2Pg\$Revision: 1.10 $\translated dump
735738
# Makefile
736739
#
737740

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp