consolidating IN and PGIN blocks in delete_rows
authorRosser Schwarz <rosser.schwarz@gmail.com>
Wed, 26 Sep 2012 04:25:24 +0000 (21:25 -0700)
committerRosser Schwarz <rosser.schwarz@gmail.com>
Wed, 26 Sep 2012 04:25:24 +0000 (21:25 -0700)
Bucardo.pm

index a496fd40a74f045c8bec53ef6bf57f56b7e43d41..ad853078f4d9430e49d6381710ca792c52289917 100644 (file)
@@ -7978,7 +7978,7 @@ sub delete_rows {
         ## Set the type of SQL we are using: IN vs ANY
         my $sqltype = '';
         if ('postgres' eq $type) {
-            $sqltype = (1 == $numpks) ? 'ANY' : 'PGIN';
+            $sqltype = (1 == $numpks) ? 'ANY' : 'IN';
         }
         elsif ('mysql' eq $type or 'drizzle' eq $type or 'mariadb' eq $type) {
             $sqltype = 'MYIN';
@@ -7991,7 +7991,7 @@ sub delete_rows {
         }
         elsif ($type =~ /flatpg/o) {
             ## XXX Worth the trouble to allow building an ANY someday for flatpg?
-            $sqltype = 'PGIN';
+            $sqltype = 'IN';
         }
         elsif ($type =~ /flat/o) {
             $sqltype = 'IN';
@@ -8081,29 +8081,6 @@ sub delete_rows {
             }
             $SQL{MYIN} = \@SQL;
         }
-        ## Postgres-specific IN clause (schemas)
-        elsif ($sqltype eq 'PGIN') {
-            $SQL = sprintf '%sDELETE FROM %s WHERE %s IN (',
-                $self->{sqlprefix},
-                $tname,
-                $pkcols;
-            ## The array where we store each chunk
-            my @SQL;
-            for my $key (keys %$rows) {
-                my $inner = join ',' => map { s/\'/''/go; s{\\}{\\\\}; qq{'$_'}; } split '\0', $key, -1;
-                $SQL[$round] .= "($inner),";
-                if (++$roundtotal >= $chunksize) {
-                    $roundtotal = 0;
-                    $round++;
-                }
-            }
-            ## Cleanup
-            for (@SQL) {
-                chop;
-                $_ = "$SQL $_)";
-            }
-            $SQL{PGIN} = \@SQL;
-        }
     }
 
     ## Do each target in turn