mirror of
https://github.com/postgres/postgres.git
synced 2025-05-31 00:01:57 -04:00
Fix ts_stat's failure on empty tsvector.
Also insert a couple of Asserts that check for stack overflow. Bogus coding appears to be new in 8.4 --- older releases had a much simpler algorithm here. Per bug #5111.
This commit is contained in:
parent
09a12ef929
commit
3d70b5d01a
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/tsvector_op.c,v 1.23 2009/06/11 14:49:04 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/tsvector_op.c,v 1.23.2.1 2009/10/13 14:33:21 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -959,6 +959,9 @@ ts_setup_firstcall(FunctionCallInfo fcinfo, FuncCallContext *funcctx,
|
|||||||
|
|
||||||
node = stat->root;
|
node = stat->root;
|
||||||
/* find leftmost value */
|
/* find leftmost value */
|
||||||
|
if (node == NULL)
|
||||||
|
stat->stack[stat->stackpos] = NULL;
|
||||||
|
else
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
stat->stack[stat->stackpos] = node;
|
stat->stack[stat->stackpos] = node;
|
||||||
@ -970,6 +973,7 @@ ts_setup_firstcall(FunctionCallInfo fcinfo, FuncCallContext *funcctx,
|
|||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Assert(stat->stackpos <= stat->maxdepth);
|
||||||
|
|
||||||
tupdesc = CreateTemplateTupleDesc(3, false);
|
tupdesc = CreateTemplateTupleDesc(3, false);
|
||||||
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "word",
|
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "word",
|
||||||
@ -1015,6 +1019,7 @@ walkStatEntryTree(TSVectorStat *stat)
|
|||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Assert(stat->stackpos <= stat->maxdepth);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user