Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita734979

Browse files
committed
Fix tsquerysel() to not fail on an empty TSQuery. Per report from
Tatsuo Ishii.
1 parenta7a7f5c commita734979

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

‎src/backend/tsearch/ts_selfuncs.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* 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 $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -146,19 +146,23 @@ static Selectivity
146146
tsquerysel(VariableStatData*vardata,Datumconstval)
147147
{
148148
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;
149157

150158
if (HeapTupleIsValid(vardata->statsTuple))
151159
{
152-
TSQueryquery;
153160
Form_pg_statisticstats;
154161
Datum*values;
155162
intnvalues;
156163
float4*numbers;
157164
intnnumbers;
158165

159-
/* The caller made sure the const is a TSQuery, so get it now */
160-
query=DatumGetTSQuery(constval);
161-
162166
stats= (Form_pg_statistic)GETSTRUCT(vardata->statsTuple);
163167

164168
/* MCELEM will be an array of TEXT elements for a tsvector column */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp