QueryParser: comma-delimit multiple WITH clauses
authorDan Scott <dan@coffeecode.net>
Mon, 21 May 2012 18:46:53 +0000 (14:46 -0400)
committerDan Scott <dan@coffeecode.net>
Mon, 21 May 2012 19:12:33 +0000 (15:12 -0400)
Bill Erickson's fix for my breakage of QueryParser.pm for the speedup
via the WITH common table expression usage inadvertently left out
the commas required to delimit multiple WITH clauses, resulting in SQL
query errors.

This fixes that oversight. Note that the fts-replacement.pl script came
in quite handy for testing this; recommended.

Signed-off-by: Dan Scott <dan@coffeecode.net>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm

index cc4d914..3e9d10e 100644 (file)
@@ -746,8 +746,8 @@ sub flatten {
                 $from .= "\n\t\t\tJOIN config.metabib_field AS fe_weight ON (fe_weight.id = fe.field)";
 
                 if ($node->dummy_count < @{$node->only_atoms} ) {
-                    #$with.= "\n\t\t\tWITH ${talias}_xq AS (SELECT ". $node->tsquery ." AS tsq )";
-                    $with.= "${talias}_xq AS (SELECT ". $node->tsquery ." AS tsq )";
+                    $with .= ",\n" if $with;
+                    $with .= "${talias}_xq AS (SELECT ". $node->tsquery ." AS tsq )";
                     $from .= "\n\t\t\tJOIN ${talias}_xq ON (fe.index_vector @@ ${talias}_xq.tsq)";
                 } else {
                     $from .= "\n\t\t\t, (SELECT NULL::tsquery AS tsq ) AS x";