From c24cc165a43c2ea8e234c2f7d17256f66281d1b1 Mon Sep 17 00:00:00 2001 From: madtibo Date: Fri, 19 Mar 2021 17:37:18 +0100 Subject: [PATCH 1/2] permit max in typequal in CREATE TYPE --- sqlserver2pgsql.pl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sqlserver2pgsql.pl b/sqlserver2pgsql.pl index e5a5ea8..0344cff 100755 --- a/sqlserver2pgsql.pl +++ b/sqlserver2pgsql.pl @@ -1824,14 +1824,18 @@ sub parse_dump my $newtype; TYPE: while (my $typeline= read_and_clean($file)) { - if ($typeline =~ /^\t\[(.*)\] \[(.*)\](?:\s*?\((\d+(?:,\d+)?)\))?(?:\s+?(?:NOT\s+?)?NULL),?$/) + if ($typeline =~ /^\t\[(.*)\] \[(.+?)\](?:\s*?\((\d+|max(?:,\d+)?)\))?(?:\s+?(?:NOT\s+?)?NULL),?$/) { # This is another column for this type $colname=$1; $type=$2; $typequal=$3; + if ($typequal eq 'max') { + # max in SqlServer is the same as no typequal in pg + $typequal = undef; + } $newtype = - convert_type($type, $typequal, undef, undef, undef, undef); + convert_type($type, $typequal, undef, undef, undef, undef); push @cols_newbasetype,(format_identifier($colname) . ' ' . $newtype); } elsif ( $typeline =~ /PRIMARY KEY/) From d3700ba157f08016c807e65ff3c78c0432addc55 Mon Sep 17 00:00:00 2001 From: madtibo Date: Tue, 23 Mar 2021 14:25:44 +0100 Subject: [PATCH 2/2] check $typequal definition before comparison --- sqlserver2pgsql.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlserver2pgsql.pl b/sqlserver2pgsql.pl index 0344cff..5311002 100755 --- a/sqlserver2pgsql.pl +++ b/sqlserver2pgsql.pl @@ -1830,7 +1830,7 @@ sub parse_dump $colname=$1; $type=$2; $typequal=$3; - if ($typequal eq 'max') { + if (defined $typequal and $typequal eq 'max') { # max in SqlServer is the same as no typequal in pg $typequal = undef; }