Support per-version SQL for same_schema action.
authorGreg Sabino Mullane <[email protected]>
Tue, 12 Jul 2011 12:26:19 +0000 (08:26 -0400)
committerGreg Sabino Mullane <[email protected]>
Tue, 12 Jul 2011 12:26:19 +0000 (08:26 -0400)
check_postgres.pl
t/CP_Testing.pm

index 592b7e3c70f1b0dd7af775e2afd5c75123d55e63..390de9cfe968c34454a4c2ae3678d8acfc0a7291 100755 (executable)
@@ -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}) {
index 3e79454b1100a423b2803604a17e9ff774bf62a2..1c60f39592b562d5a1f344597308fc9459510713 100644 (file)
@@ -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];