|
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,Datumconstval) |
147 | 147 | { |
148 | 148 | Selectivityselec; |
| 149 | +TSQueryquery; |
| 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 | | -TSQueryquery; |
153 | 160 | Form_pg_statisticstats; |
154 | 161 | Datum*values; |
155 | 162 | intnvalues; |
156 | 163 | float4*numbers; |
157 | 164 | intnnumbers; |
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 */ |
|