File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $PostgreSQL: pgsql/src/backend/tsearch/ts_selfuncs.c,v 1.2 2009/01/01 17:23:48 momjian Exp $
10
+ * $PostgreSQL: pgsql/src/backend/tsearch/ts_selfuncs.c,v 1.3 2009/06/03 18:42:13 tgl Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -146,19 +146,23 @@ static Selectivity
146
146
tsquerysel (VariableStatData * vardata , Datum constval )
147
147
{
148
148
Selectivity selec ;
149
+ TSQuery query ;
150
+
151
+ /* The caller made sure the const is a TSQuery, so get it now */
152
+ query = DatumGetTSQuery (constval );
153
+
154
+ /* Empty query matches nothing */
155
+ if (query -> size == 0 )
156
+ return (Selectivity ) 0.0 ;
149
157
150
158
if (HeapTupleIsValid (vardata -> statsTuple ))
151
159
{
152
- TSQuery query ;
153
160
Form_pg_statistic stats ;
154
161
Datum * values ;
155
162
int nvalues ;
156
163
float4 * numbers ;
157
164
int nnumbers ;
158
165
159
- /* The caller made sure the const is a TSQuery, so get it now */
160
- query = DatumGetTSQuery (constval );
161
-
162
166
stats = (Form_pg_statistic ) GETSTRUCT (vardata -> statsTuple );
163
167
164
168
/* MCELEM will be an array of TEXT elements for a tsvector column */
You can’t perform that action at this time.
0 commit comments