diff options
author | Greg Sabino Mullane | 2011-07-12 12:26:19 +0000 |
---|---|---|
committer | Greg Sabino Mullane | 2011-07-12 12:26:19 +0000 |
commit | 21f086d74f84e62521883e943734e45e81b1b6d6 (patch) | |
tree | 0e9a8e5dfc1949f1cf3116be100f12d0da7804b2 | |
parent | a3e0dc97939c0e2a4de067c3b0a7ead3203c3fb2 (diff) |
Support per-version SQL for same_schema action.
-rwxr-xr-x | check_postgres.pl | 23 | ||||
-rw-r--r-- | t/CP_Testing.pm | 2 |
2 files changed, 23 insertions, 2 deletions
diff --git a/check_postgres.pl b/check_postgres.pl index 592b7e3c7..390de9cfe 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -708,6 +708,10 @@ JOIN pg_user u ON (u.usesysid = n.nspowner)}, SELECT l.*, lanname AS name, quote_ident(usename) AS owner FROM pg_language l JOIN pg_user u ON (u.usesysid = l.lanowner)}, + SQL2 => q{ +SELECT l.*, lanname AS name +FROM pg_language l + }, }, type => { SQL => q{ @@ -6121,7 +6125,7 @@ sub check_same_schema { for (@catalog_items) { my $name = $_->[0]; - $dbinfo->{$name} = find_catalog_info($name, $x); + $dbinfo->{$name} = find_catalog_info($name, $x, $dbver{$x}); } ## TODO: @@ -6680,6 +6684,11 @@ sub find_catalog_info { ## Grab information from one or more catalog tables ## Convert into a happy hashref and return it + ## Arguments: three + ## 1. Type of object + ## 2. Database number + ## 3. Version information for the database + ## Returns: large hashref of information ## What type of catalog object this is my $type = shift; @@ -6699,8 +6708,18 @@ sub find_catalog_info { ## Which database to run this against my $dbnum = shift or die; + ## The version information + my $dbver = shift or die; + ## The SQL we use - my $SQL = $ci->{SQL} or die; + my $SQL = $ci->{SQL} or die "No SQL found for type '$type'\n"; + + ## Switch to alternate SQL for different versions + if ($type eq 'language') { + if (int $dbver->{major} <= 8.2) { + $SQL = $ci->{SQL2}; + } + } if (exists $ci->{exclude}) { if ('temp_schemas' eq $ci->{exclude}) { diff --git a/t/CP_Testing.pm b/t/CP_Testing.pm index 3e79454b1..1c60f3959 100644 --- a/t/CP_Testing.pm +++ b/t/CP_Testing.pm @@ -332,6 +332,7 @@ sub test_database_handle { $dbh->do('CREATE DATABASE ardala'); $dbh->do('CREATE LANGUAGE plpgsql'); $dbh->do('CREATE LANGUAGE plperlu'); + $dbh->do("CREATE SCHEMA $fakeschema"); $dbh->{AutoCommit} = 0; $dbh->{RaiseError} = 1; @@ -589,6 +590,7 @@ sub drop_schema_if_exists { my $dbh = $self->{dbh} || die; $name ||= $fakeschema; + return; if (! exists $self->{keep_old_schema}) { $SQL = 'SELECT count(*) FROM pg_namespace WHERE nspname = ' . $dbh->quote($name); my $count = $dbh->selectall_arrayref($SQL)->[0][0]; |