From d6a7ebb2ac805d7f2e6ed7366f715bfc561d67f0 Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Sun, 17 Jun 2007 02:09:21 +0000 Subject: [PATCH] Add checks for common comma errors. --- maintenance/postgres/compare_schemas.pl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/maintenance/postgres/compare_schemas.pl b/maintenance/postgres/compare_schemas.pl index ce045fef32..fb21077dda 100644 --- a/maintenance/postgres/compare_schemas.pl +++ b/maintenance/postgres/compare_schemas.pl @@ -155,7 +155,7 @@ CIDR ); $dtype = qr{($dtype)}; my %new; -my ($infunction,$inview,$inrule) = (0,0,0); +my ($infunction,$inview,$inrule,$lastcomma) = (0,0,0,0); seek $newfh, 0, 0; while (<$newfh>) { next if /^\s*\-\-/ or /^\s*$/; @@ -190,11 +190,19 @@ while (<$newfh>) { if (/^CREATE TABLE "?(\w+)"? \($/) { $table = $1; $new{$table}{name}=$table; + $lastcomma = 1; } elsif (/^\);$/) { + if ($lastcomma) { + warn "Stray comma before line $.\n"; + } } - elsif (/^ (\w+) +$dtype/) { + elsif (/^ (\w+) +$dtype.*?(,?)(?: --.*)?$/) { $new{$table}{column}{$1} = $2; + if (!$lastcomma) { + print "Missing comma before line $. of $new\n"; + } + $lastcomma = $3 ? 1 : 0; } else { die "Cannot parse line $. of $new:\n$_\n"; -- 2.20.1