diff --git a/contrib/mysql/README b/contrib/mysql/README index 5511df6c67..953e204d42 100644 --- a/contrib/mysql/README +++ b/contrib/mysql/README @@ -2,7 +2,7 @@ Here are two conversion utilities for MySQL dumps. Use the one you prefer. The most recent version of my2pg.pl can be obtained from: - http://ziet.zhitomir.ua/~fonin/code/ + http://www.omnistarinc.com/~fonin/downloads.php#my2pg Another tool, mysql2pgsql, can be found at: diff --git a/contrib/mysql/my2pg.diff b/contrib/mysql/my2pg.diff new file mode 100644 index 0000000000..7c870b3b27 --- /dev/null +++ b/contrib/mysql/my2pg.diff @@ -0,0 +1,112 @@ +*** /laptop/my2pg.pl Mon Apr 19 18:51:44 2004 +--- my2pg.pl Mon Apr 19 18:59:09 2004 +*************** +*** 38,43 **** +--- 38,50 ---- + # $My2pg: my2pg.pl,v 1.28 2001/12/06 19:32:20 fonin Exp $ + # $Id: my2pg.diff,v 1.1 2004/04/19 23:18:12 momjian Exp $ + ++ # Custom patch ++ # Revision 1.9 2002/08/22 00:01:39 tgl ++ # Add a bunch of pseudo-types to replace the behavior formerly associated ++ # with OPAQUE, as per recent pghackers discussion. I still want to do some ++ # more work on the 'cstring' pseudo-type, but I'm going to commit the bulk ++ # of the changes now before the tree starts shifting under me ... ++ + # + # $Log: my2pg.diff,v $ + # Revision 1.1 2004/04/19 23:18:12 momjian + # Update to my2pg version 1.28, add docs, update URL for newest version. + # + # Create diff of custom changes Tom made to the utility for CREATE + # FUNCTION. + # + # This will make moving this utility out of CVS easier. + # + # Revision 1.28 2002/11/30 12:03:48 fonin +*************** +*** 332,342 **** + print LIBTYPES "\n * Types for table ".uc($table_name); + print LIBTYPES "\n */\n"; + +! $types.="\nCREATE FUNCTION $typename"."_in (opaque) + RETURNS $typename + AS '$libtypename' + LANGUAGE 'c' +! WITH (ISCACHABLE);\n"; + + # creating output function + my $func_out=" +--- 339,349 ---- + print LIBTYPES "\n * Types for table ".uc($table_name); + print LIBTYPES "\n */\n"; + +! $types.="\nCREATE FUNCTION $typename"."_in (cstring) + RETURNS $typename + AS '$libtypename' + LANGUAGE 'c' +! WITH (ISSTRICT, ISCACHABLE);\n"; + + # creating output function + my $func_out=" +*************** +*** 386,396 **** + return (*a>=*b); + }\n"; + +! $types.="\nCREATE FUNCTION $typename"."_out (opaque) +! RETURNS opaque + AS '$libtypename' + LANGUAGE 'c' +! WITH (ISCACHABLE);\n"; + + $types.="\nCREATE TYPE $typename ( + internallength = 2, +--- 393,403 ---- + return (*a>=*b); + }\n"; + +! $types.="\nCREATE FUNCTION $typename"."_out ($typename) +! RETURNS cstring + AS '$libtypename' + LANGUAGE 'c' +! WITH (ISSTRICT, ISCACHABLE);\n"; + + $types.="\nCREATE TYPE $typename ( + internallength = 2, +*************** +*** 532,538 **** + print LIBTYPES "\n * Types for table ".uc($table_name); + print LIBTYPES "\n */\n"; + +! $types.="\nCREATE FUNCTION $typename"."_in (opaque) + RETURNS $typename + AS '$libtypename' + LANGUAGE 'c';\n"; +--- 539,545 ---- + print LIBTYPES "\n * Types for table ".uc($table_name); + print LIBTYPES "\n */\n"; + +! $types.="\nCREATE FUNCTION $typename"."_in (cstring) + RETURNS $typename + AS '$libtypename' + LANGUAGE 'c';\n"; +*************** +*** 584,591 **** + + \n"; + +! $types.="\nCREATE FUNCTION $typename"."_out (opaque) +! RETURNS opaque + AS '$libtypename' + LANGUAGE 'c';\n"; + +--- 591,598 ---- + + \n"; + +! $types.="\nCREATE FUNCTION $typename"."_out ($typename) +! RETURNS cstring + AS '$libtypename' + LANGUAGE 'c';\n"; + diff --git a/contrib/mysql/my2pg.html b/contrib/mysql/my2pg.html new file mode 100755 index 0000000000..13704249aa --- /dev/null +++ b/contrib/mysql/my2pg.html @@ -0,0 +1,193 @@ + +
++
my2pg - MySQL -> PostgreSQL dump conversion utility.
++
+ mysqldump db | ./my2pg.pl [-nds] > pgsqldump.sql + vi libtypes.c + make + psql database < pgsqldump.txt +where+
+
my2pg utility attempts to convert MySQL database dump to Postgres's one. +my2pg performs such conversions:
+KEY(field)
to CREATE INDEX i_field on table (field);
+
+It encloses dump in transaction block to prevent single errors +during data load.
++
My2pg takes the following command-line options:
++
+
Known bugs are:
++ #include <postgres.h>+
This file may be located not in standard compiler +include path, you need to check it before compiling.
++
(c) 2000-2002 Maxim V. Rudensky (fonin@ziet.zhitomir.ua) (developer, maintainer)
+(c) 2000 Valentine V. Danilchuk (valdan@ziet.zhitomir.ua) (original script)
++
Great thanks to all those people who provided feedback and make development +of this tool easier.
+Jeff Waugh <jaw@ic.net>
+Joakim Lemström <jocke@bytewize.com> || <buddyh19@hotmail.com>
+Yunliang Yu <yu@math.duke.edu>
+Brad Hilton <bhilton@vpop.net>
+If you are not listed here please write to me.
++
BSD
+ + + + diff --git a/contrib/mysql/my2pg.pl b/contrib/mysql/my2pg.pl index b24e09d1dc..218a6a65ce 100755 --- a/contrib/mysql/my2pg.pl +++ b/contrib/mysql/my2pg.pl @@ -36,10 +36,25 @@ # SUCH DAMAGE. # # $My2pg: my2pg.pl,v 1.28 2001/12/06 19:32:20 fonin Exp $ -# $Id: my2pg.pl,v 1.12 2004/04/19 23:11:49 momjian Exp $ +# $Id: my2pg.pl,v 1.13 2004/04/19 23:18:12 momjian Exp $ + +# Custom patch +# Revision 1.9 2002/08/22 00:01:39 tgl +# Add a bunch of pseudo-types to replace the behavior formerly associated +# with OPAQUE, as per recent pghackers discussion. I still want to do some +# more work on the 'cstring' pseudo-type, but I'm going to commit the bulk +# of the changes now before the tree starts shifting under me ... # # $Log: my2pg.pl,v $ +# Revision 1.13 2004/04/19 23:18:12 momjian +# Update to my2pg version 1.28, add docs, update URL for newest version. +# +# Create diff of custom changes Tom made to the utility for CREATE +# FUNCTION. +# +# This will make moving this utility out of CVS easier. +# # Revision 1.12 2004/04/19 23:11:49 momjian # Update to my2pg 1.28, from: # @@ -337,11 +352,11 @@ int2* $typename"."_in (char *str) { print LIBTYPES "\n * Types for table ".uc($table_name); print LIBTYPES "\n */\n"; - $types.="\nCREATE FUNCTION $typename"."_in (opaque) + $types.="\nCREATE FUNCTION $typename"."_in (cstring) RETURNS $typename AS '$libtypename' LANGUAGE 'c' - WITH (ISCACHABLE);\n"; + WITH (ISSTRICT, ISCACHABLE);\n"; # creating output function my $func_out=" @@ -391,11 +406,11 @@ bool $typename"."_ge(int2* a, int2* b) { return (*a>=*b); }\n"; - $types.="\nCREATE FUNCTION $typename"."_out (opaque) - RETURNS opaque + $types.="\nCREATE FUNCTION $typename"."_out ($typename) + RETURNS cstring AS '$libtypename' LANGUAGE 'c' - WITH (ISCACHABLE);\n"; + WITH (ISSTRICT, ISCACHABLE);\n"; $types.="\nCREATE TYPE $typename ( internallength = 2, @@ -537,7 +552,7 @@ $typesize* $typename"."_in (char *str) { print LIBTYPES "\n * Types for table ".uc($table_name); print LIBTYPES "\n */\n"; - $types.="\nCREATE FUNCTION $typename"."_in (opaque) + $types.="\nCREATE FUNCTION $typename"."_in (cstring) RETURNS $typename AS '$libtypename' LANGUAGE 'c';\n"; @@ -589,8 +604,8 @@ $typesize find_in_set($typesize *a, $typesize *b) { \n"; - $types.="\nCREATE FUNCTION $typename"."_out (opaque) - RETURNS opaque + $types.="\nCREATE FUNCTION $typename"."_out ($typename) + RETURNS cstring AS '$libtypename' LANGUAGE 'c';\n"; @@ -762,7 +777,7 @@ close(LIBTYPES); open(MAKE,">Makefile"); print MAKE "# -# My2Pg \$Revision: 1.12 $ \translated dump +# My2Pg \$Revision: 1.13 $ \translated dump # Makefile #