mirror of
https://github.com/postgres/postgres.git
synced 2025-04-20 00:42:27 +03:00
Upgrade to my2pg 1.9
This commit is contained in:
parent
b2353a3db6
commit
9ee86665ef
@ -35,26 +35,27 @@
|
|||||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
# SUCH DAMAGE.
|
# SUCH DAMAGE.
|
||||||
#
|
#
|
||||||
# $My2pg: my2pg.pl,v 1.24 2001/12/06 19:32:20 fonin Exp $
|
# $My2pg: my2pg.pl,v 1.27 2001/12/06 19:32:20 fonin Exp $
|
||||||
# $Id: my2pg.pl,v 1.9 2002/08/22 00:01:39 tgl Exp $
|
# $Id: my2pg.pl,v 1.9.2.1 2003/01/07 22:18:49 momjian Exp $
|
||||||
|
|
||||||
# TODO:
|
|
||||||
# + Handle SETs
|
|
||||||
# - LIKE implementation
|
|
||||||
# - memory use optimisation in SET_output function
|
|
||||||
# - raw integer values as input values must be OK
|
|
||||||
# - Use autoconf & automake to auto-build makefiles
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# $Log: my2pg.pl,v $
|
# $Log: my2pg.pl,v $
|
||||||
# Revision 1.9 2002/08/22 00:01:39 tgl
|
# Revision 1.9.2.1 2003/01/07 22:18:49 momjian
|
||||||
# Add a bunch of pseudo-types to replace the behavior formerly associated
|
# Upgrade to my2pg 1.9
|
||||||
# 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 ...
|
|
||||||
#
|
#
|
||||||
# Revision 1.8 2002/04/24 01:42:29 momjian
|
# Revision 1.27 2002/07/16 14:54:07 fonin
|
||||||
# Update to my2pg 1.24.
|
# Bugfix - didn't quote the fields inside PRIMARY KEY with -d option.
|
||||||
|
# Fix by Milan P. Stanic <mps@rns-nis.co.yu>.
|
||||||
|
#
|
||||||
|
# Revision 1.26 2002/07/14 10:30:27 fonin
|
||||||
|
# Bugfix - MySQL keywords inside data (INSERT INTO sentence) were replaced
|
||||||
|
# with Postgres keywords and therefore messed up the data.
|
||||||
|
#
|
||||||
|
# Revision 1.25 2002/07/05 09:20:25 fonin
|
||||||
|
# - fixed data that contains two consecutive timestamps - thanks to
|
||||||
|
# Ben Darnell <bdarnell@google.com>
|
||||||
|
# - word 'default' was converted to upper case inside the data - fixed.
|
||||||
|
# Thanks to Madsen Wikholm <madsen@iki.fi>
|
||||||
#
|
#
|
||||||
# Revision 1.24 2002/04/20 14:15:43 fonin
|
# Revision 1.24 2002/04/20 14:15:43 fonin
|
||||||
# Patch by Felipe Nievinski <fnievinski@terra.com.br>.
|
# Patch by Felipe Nievinski <fnievinski@terra.com.br>.
|
||||||
@ -177,7 +178,7 @@ if($opts{d} ne '') {
|
|||||||
$|=1;
|
$|=1;
|
||||||
|
|
||||||
print("------------------------------------------------------------------");
|
print("------------------------------------------------------------------");
|
||||||
print("\n-- My2Pg 1.24 translated dump");
|
print("\n-- My2Pg 1.27 translated dump");
|
||||||
print("\n--");
|
print("\n--");
|
||||||
print("\n------------------------------------------------------------------");
|
print("\n------------------------------------------------------------------");
|
||||||
|
|
||||||
@ -199,7 +200,7 @@ $libtypename.='/libtypes.so';
|
|||||||
# push header to libtypes.c
|
# push header to libtypes.c
|
||||||
open(LIBTYPES,">$libtypesource");
|
open(LIBTYPES,">$libtypesource");
|
||||||
print LIBTYPES "/******************************************************";
|
print LIBTYPES "/******************************************************";
|
||||||
print LIBTYPES "\n * My2Pg \$Revision: 1.9 $ \translated dump";
|
print LIBTYPES "\n * My2Pg 1.27 \translated dump";
|
||||||
print LIBTYPES "\n * User types definitions";
|
print LIBTYPES "\n * User types definitions";
|
||||||
print LIBTYPES "\n ******************************************************/";
|
print LIBTYPES "\n ******************************************************/";
|
||||||
print LIBTYPES "\n\n#include <postgres.h>\n";
|
print LIBTYPES "\n\n#include <postgres.h>\n";
|
||||||
@ -211,7 +212,7 @@ while (<>) {
|
|||||||
|
|
||||||
if(!$tabledef && /^CREATE TABLE \S+/i){
|
if(!$tabledef && /^CREATE TABLE \S+/i){
|
||||||
$tabledef=1;
|
$tabledef=1;
|
||||||
}elsif($tabledef && /^\);/i){ # /^\w/i
|
} elsif($tabledef && /^\) type=\w*;/i){ # /^\w/i
|
||||||
$tabledef=0;
|
$tabledef=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,7 +254,9 @@ while (<>) {
|
|||||||
|
|
||||||
# small hack - convert "default" to uppercase, because below we
|
# small hack - convert "default" to uppercase, because below we
|
||||||
# enclose all lowercase words in double quotes
|
# enclose all lowercase words in double quotes
|
||||||
|
if(!/^INSERT/) {
|
||||||
s/default/DEFAULT/;
|
s/default/DEFAULT/;
|
||||||
|
}
|
||||||
|
|
||||||
# Change all AUTO_INCREMENT fields to SERIAL ones with a pre-defined sequence
|
# Change all AUTO_INCREMENT fields to SERIAL ones with a pre-defined sequence
|
||||||
if(/([\w\d]+)\sint.*auto_increment/i) {
|
if(/([\w\d]+)\sint.*auto_increment/i) {
|
||||||
@ -314,11 +317,11 @@ int2* $typename"."_in (char *str) {
|
|||||||
print LIBTYPES "\n * Types for table ".uc($table_name);
|
print LIBTYPES "\n * Types for table ".uc($table_name);
|
||||||
print LIBTYPES "\n */\n";
|
print LIBTYPES "\n */\n";
|
||||||
|
|
||||||
$types.="\nCREATE FUNCTION $typename"."_in (cstring)
|
$types.="\nCREATE FUNCTION $typename"."_in (opaque)
|
||||||
RETURNS $typename
|
RETURNS $typename
|
||||||
AS '$libtypename'
|
AS '$libtypename'
|
||||||
LANGUAGE 'c'
|
LANGUAGE 'c'
|
||||||
WITH (ISSTRICT, ISCACHABLE);\n";
|
WITH (ISCACHABLE);\n";
|
||||||
|
|
||||||
# creating output function
|
# creating output function
|
||||||
my $func_out="
|
my $func_out="
|
||||||
@ -368,11 +371,11 @@ bool $typename"."_ge(int2* a, int2* b) {
|
|||||||
return (*a>=*b);
|
return (*a>=*b);
|
||||||
}\n";
|
}\n";
|
||||||
|
|
||||||
$types.="\nCREATE FUNCTION $typename"."_out ($typename)
|
$types.="\nCREATE FUNCTION $typename"."_out (opaque)
|
||||||
RETURNS cstring
|
RETURNS opaque
|
||||||
AS '$libtypename'
|
AS '$libtypename'
|
||||||
LANGUAGE 'c'
|
LANGUAGE 'c'
|
||||||
WITH (ISSTRICT, ISCACHABLE);\n";
|
WITH (ISCACHABLE);\n";
|
||||||
|
|
||||||
$types.="\nCREATE TYPE $typename (
|
$types.="\nCREATE TYPE $typename (
|
||||||
internallength = 2,
|
internallength = 2,
|
||||||
@ -515,7 +518,7 @@ $typesize* $typename"."_in (char *str) {
|
|||||||
print LIBTYPES "\n * Types for table ".uc($table_name);
|
print LIBTYPES "\n * Types for table ".uc($table_name);
|
||||||
print LIBTYPES "\n */\n";
|
print LIBTYPES "\n */\n";
|
||||||
|
|
||||||
$types.="\nCREATE FUNCTION $typename"."_in (cstring)
|
$types.="\nCREATE FUNCTION $typename"."_in (opaque)
|
||||||
RETURNS $typename
|
RETURNS $typename
|
||||||
AS '$libtypename'
|
AS '$libtypename'
|
||||||
LANGUAGE 'c';\n";
|
LANGUAGE 'c';\n";
|
||||||
@ -567,8 +570,8 @@ $typesize find_in_set($typesize *a, $typesize *b) {
|
|||||||
|
|
||||||
\n";
|
\n";
|
||||||
|
|
||||||
$types.="\nCREATE FUNCTION $typename"."_out ($typename)
|
$types.="\nCREATE FUNCTION $typename"."_out (opaque)
|
||||||
RETURNS cstring
|
RETURNS opaque
|
||||||
AS '$libtypename'
|
AS '$libtypename'
|
||||||
LANGUAGE 'c';\n";
|
LANGUAGE 'c';\n";
|
||||||
|
|
||||||
@ -651,11 +654,11 @@ CREATE OPERATOR <> (
|
|||||||
}
|
}
|
||||||
|
|
||||||
# output CHECK constraints instead UNSIGNED modifiers
|
# output CHECK constraints instead UNSIGNED modifiers
|
||||||
if(/PRIMARY KEY \((.*)\)/i) {
|
if(/PRIMARY KEY\s+\((.*)\)/i) {
|
||||||
my $tmpfld=$1;
|
my $tmpfld=$1;
|
||||||
$tmpfld=~s/,/","/g if $dq;
|
$tmpfld=~s/,/","/g if $dq;
|
||||||
$tmpfld=~s/ //g;
|
$tmpfld=~s/ //g;
|
||||||
s/PRIMARY KEY (\(.*\))/PRIMARY KEY \($dq$tmpfld$dq\)/i;
|
s/PRIMARY KEY\s+(\(.*\))/PRIMARY KEY \($dq$tmpfld$dq\)/i;
|
||||||
s/(PRIMARY KEY \(.*\)).*/$1$check\n/i;
|
s/(PRIMARY KEY \(.*\)).*/$1$check\n/i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -685,9 +688,9 @@ CREATE OPERATOR <> (
|
|||||||
# Fix timestamps
|
# Fix timestamps
|
||||||
s/'0000-00-00/'0001-01-01/g;
|
s/'0000-00-00/'0001-01-01/g;
|
||||||
# may work wrong !!!
|
# may work wrong !!!
|
||||||
s/([,(])00000000000000([,)])/$1'00010101 000000'$2/g;
|
s/([,(])00000000000000(?=[,)])/$1'00010101 000000'/g;
|
||||||
s/([,(])(\d{8})(\d{6})([,)])/$1'$2 $3'$4/g;
|
s/([,(])(\d{8})(\d{6})(?=[,)])/$1'$2 $3'/g;
|
||||||
s/([,(])(\d{4})(\d{2})(\d{2})([,)])/$1'$2-$3-$4 00:00:00'$5/g;
|
s/([,(])(\d{4})(\d{2})(\d{2})(?=[,)])/$1'$2-$3-$4 00:00:00'/g;
|
||||||
#<Hackzone> ---------------------------------------------------
|
#<Hackzone> ---------------------------------------------------
|
||||||
#</Hackzone> --------------------------------------------------
|
#</Hackzone> --------------------------------------------------
|
||||||
$dump.=$_;
|
$dump.=$_;
|
||||||
@ -731,7 +734,7 @@ close(LIBTYPES);
|
|||||||
|
|
||||||
open(MAKE,">Makefile");
|
open(MAKE,">Makefile");
|
||||||
print MAKE "#
|
print MAKE "#
|
||||||
# My2Pg \$Revision: 1.9 $ \translated dump
|
# My2Pg \$Revision: 1.9.2.1 $ \translated dump
|
||||||
# Makefile
|
# Makefile
|
||||||
#
|
#
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user