Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
3e40ff58
Commit
3e40ff58
authored
Jan 07, 2003
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upgrade to my2pg 1.9
parent
a24104eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
34 deletions
+37
-34
contrib/mysql/my2pg.pl
contrib/mysql/my2pg.pl
+37
-34
No files found.
contrib/mysql/my2pg.pl
View file @
3e40ff58
...
...
@@ -35,26 +35,27 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $My2pg: my2pg.pl,v 1.24 2001/12/06 19:32:20 fonin Exp $
# $Id: my2pg.pl,v 1.9 2002/08/22 00:01:39 tgl 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
# $My2pg: my2pg.pl,v 1.27 2001/12/06 19:32:20 fonin Exp $
# $Id: my2pg.pl,v 1.10 2003/01/07 22:18:43 momjian Exp $
#
# $Log: my2pg.pl,v $
# 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 ...
# Revision 1.10 2003/01/07 22:18:43 momjian
# Upgrade to my2pg 1.9
#
# Revision 1.27 2002/07/16 14:54:07 fonin
# Bugfix - didn't quote the fields inside PRIMARY KEY with -d option.
# Fix by Milan P. Stanic <mps@rns-nis.co.yu>.
#
# Revision 1.8 2002/04/24 01:42:29 momjian
# Update to my2pg 1.24.
# 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
# Patch by Felipe Nievinski <fnievinski@terra.com.br>.
...
...
@@ -177,7 +178,7 @@ if($opts{d} ne '') {
$|
=
1
;
print
("
------------------------------------------------------------------
");
print
("
\n
-- My2Pg 1.2
4
translated dump
");
print
("
\n
-- My2Pg 1.2
7
translated dump
");
print
("
\n
--
");
print
("
\n
------------------------------------------------------------------
");
...
...
@@ -199,7 +200,7 @@ $libtypename.='/libtypes.so';
# push header to libtypes.c
open
(
LIBTYPES
,"
>
$libtypesource
");
print
LIBTYPES
"
/******************************************************
";
print
LIBTYPES
"
\n
* My2Pg
\
$Revision
: 1.9 $
\t
ranslated dump
";
print
LIBTYPES
"
\n
* My2Pg
1.27
\t
ranslated dump
";
print
LIBTYPES
"
\n
* User types definitions
";
print
LIBTYPES
"
\n
******************************************************/
";
print
LIBTYPES
"
\n\n
#include <postgres.h>
\n
";
...
...
@@ -211,7 +212,7 @@ while (<>) {
if
(
!
$tabledef
&&
/^CREATE TABLE \S+/i
){
$tabledef
=
1
;
}
elsif
(
$tabledef
&&
/^\)
;/i
){
# /^\w/i
}
elsif
(
$tabledef
&&
/^\) type=\w*
;/i
){
# /^\w/i
$tabledef
=
0
;
}
...
...
@@ -253,7 +254,9 @@ while (<>) {
# small hack - convert "default" to uppercase, because below we
# enclose all lowercase words in double quotes
s/default/DEFAULT/
;
if
(
!
/^INSERT/
)
{
s/default/DEFAULT/
;
}
# Change all AUTO_INCREMENT fields to SERIAL ones with a pre-defined sequence
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
*/
\n
";
$types
.=
"
\n
CREATE FUNCTION
$typename
"
.
"
_in (
cstring
)
$types
.=
"
\n
CREATE FUNCTION
$typename
"
.
"
_in (
opaque
)
RETURNS
$typename
AS '
$libtypename
'
LANGUAGE 'c'
WITH (IS
STRICT, IS
CACHABLE);
\n
";
WITH (ISCACHABLE);
\n
";
# creating output function
my
$func_out
=
"
...
...
@@ -368,11 +371,11 @@ bool $typename"."_ge(int2* a, int2* b) {
return (*a>=*b);
}
\n
";
$types
.=
"
\n
CREATE FUNCTION
$typename
"
.
"
_out (
$typenam
e
)
RETURNS
cstring
$types
.=
"
\n
CREATE FUNCTION
$typename
"
.
"
_out (
opaqu
e)
RETURNS
opaque
AS '
$libtypename
'
LANGUAGE 'c'
WITH (IS
STRICT, IS
CACHABLE);
\n
";
WITH (ISCACHABLE);
\n
";
$types
.=
"
\n
CREATE TYPE
$typename
(
internallength = 2,
...
...
@@ -515,7 +518,7 @@ $typesize* $typename"."_in (char *str) {
print
LIBTYPES
"
\n
* Types for table
"
.
uc
(
$table_name
);
print
LIBTYPES
"
\n
*/
\n
";
$types
.=
"
\n
CREATE FUNCTION
$typename
"
.
"
_in (
cstring
)
$types
.=
"
\n
CREATE FUNCTION
$typename
"
.
"
_in (
opaque
)
RETURNS
$typename
AS '
$libtypename
'
LANGUAGE 'c';
\n
";
...
...
@@ -567,8 +570,8 @@ $typesize find_in_set($typesize *a, $typesize *b) {
\n
";
$types
.=
"
\n
CREATE FUNCTION
$typename
"
.
"
_out (
$typenam
e
)
RETURNS
cstring
$types
.=
"
\n
CREATE FUNCTION
$typename
"
.
"
_out (
opaqu
e)
RETURNS
opaque
AS '
$libtypename
'
LANGUAGE 'c';
\n
";
...
...
@@ -651,11 +654,11 @@ CREATE OPERATOR <> (
}
# output CHECK constraints instead UNSIGNED modifiers
if
(
/PRIMARY KEY
\((.*)\)/i
)
{
if
(
/PRIMARY KEY
\s+
\((.*)\)/i
)
{
my
$tmpfld
=
$1
;
$tmpfld
=~
s/,/","/g
if
$dq
;
$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
;
}
...
...
@@ -685,9 +688,9 @@ CREATE OPERATOR <> (
# Fix timestamps
s/'0000-00-00/'0001-01-01/g
;
# may work wrong !!!
s/([,(])00000000000000(
[,)])/$1'00010101 000000'$2
/g
;
s/([,(])(\d{8})(\d{6})(
[,)])/$1'$2 $3'$4
/g
;
s/([,(])(\d{4})(\d{2})(\d{2})(
[,)])/$1'$2-$3-$4 00:00:00'$5
/g
;
s/([,(])00000000000000(
?=[,)])/$1'00010101 000000'
/g
;
s/([,(])(\d{8})(\d{6})(
?=[,)])/$1'$2 $3'
/g
;
s/([,(])(\d{4})(\d{2})(\d{2})(
?=[,)])/$1'$2-$3-$4 00:00:00'
/g
;
#<Hackzone> ---------------------------------------------------
#</Hackzone> --------------------------------------------------
$dump
.=
$_
;
...
...
@@ -731,7 +734,7 @@ close(LIBTYPES);
open
(
MAKE
,"
>Makefile
");
print
MAKE
"
#
# My2Pg
\
$Revision
: 1.
9
$
\t
ranslated dump
# My2Pg
\
$Revision
: 1.
10
$
\t
ranslated dump
# Makefile
#
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment