mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Fix tsquerysel() to not fail on an empty TSQuery. Per report from
Tatsuo Ishii.
This commit is contained in:
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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)
|
tsquerysel(VariableStatData *vardata, Datum constval)
|
||||||
{
|
{
|
||||||
Selectivity selec;
|
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))
|
if (HeapTupleIsValid(vardata->statsTuple))
|
||||||
{
|
{
|
||||||
TSQuery query;
|
|
||||||
Form_pg_statistic stats;
|
Form_pg_statistic stats;
|
||||||
Datum *values;
|
Datum *values;
|
||||||
int nvalues;
|
int nvalues;
|
||||||
float4 *numbers;
|
float4 *numbers;
|
||||||
int nnumbers;
|
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);
|
stats = (Form_pg_statistic) GETSTRUCT(vardata->statsTuple);
|
||||||
|
|
||||||
/* MCELEM will be an array of TEXT elements for a tsvector column */
|
/* MCELEM will be an array of TEXT elements for a tsvector column */
|
||||||
|
Reference in New Issue
Block a user