diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-06-03 18:42:13 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-06-03 18:42:13 +0000 |
commit | a734979e0a786276e3dc1d4755f025d664a4a4de (patch) | |
tree | d7a77f163ed1c89370cde3b93641f16e166e02d0 /src/backend/tsearch/ts_selfuncs.c | |
parent | a7a7f5caaaf97665c07d0323a339277c92a8fc83 (diff) | |
download | postgresql-a734979e0a786276e3dc1d4755f025d664a4a4de.tar.gz |
Fix tsquerysel() to not fail on an empty TSQuery. Per report from
Tatsuo Ishii.
Diffstat (limited to 'src/backend/tsearch/ts_selfuncs.c')
-rw-r--r-- | src/backend/tsearch/ts_selfuncs.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/backend/tsearch/ts_selfuncs.c b/src/backend/tsearch/ts_selfuncs.c index 27cb30f77b..890019c058 100644 --- a/src/backend/tsearch/ts_selfuncs.c +++ b/src/backend/tsearch/ts_selfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tsearch/ts_selfuncs.c,v 1.2 2009/01/01 17:23:48 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/tsearch/ts_selfuncs.c,v 1.3 2009/06/03 18:42:13 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -146,19 +146,23 @@ static Selectivity tsquerysel(VariableStatData *vardata, Datum constval) { Selectivity selec; + TSQuery query; + + /* The caller made sure the const is a TSQuery, so get it now */ + query = DatumGetTSQuery(constval); + + /* Empty query matches nothing */ + if (query->size == 0) + return (Selectivity) 0.0; if (HeapTupleIsValid(vardata->statsTuple)) { - TSQuery query; Form_pg_statistic stats; Datum *values; int nvalues; float4 *numbers; int nnumbers; - /* The caller made sure the const is a TSQuery, so get it now */ - query = DatumGetTSQuery(constval); - stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple); /* MCELEM will be an array of TEXT elements for a tsvector column */ |