77 *
88 *
99 * IDENTIFICATION
10- * $PostgreSQL: pgsql/src/backend/utils/adt/tsquery.c,v 1.1 2007/08/21 01:11:19 tgl Exp $
10+ * $PostgreSQL: pgsql/src/backend/utils/adt/tsquery.c,v 1.2 2007/08/31 02:26:29 tgl Exp $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
1414
1515#include "postgres.h"
1616
1717#include "libpq/pqformat.h"
18+ #include "miscadmin.h"
1819#include "tsearch/ts_locale.h"
1920#include "tsearch/ts_type.h"
2021#include "tsearch/ts_utils.h"
2122#include "utils/memutils.h"
2223#include "utils/pg_crc.h"
2324
25+
2426/* parser's states */
2527#define WAITOPERAND 1
2628#define WAITOPERATOR 2
@@ -234,11 +236,13 @@ pushval_asis(TSQueryParserState * state, int type, char *strval, int lenval, int
234236}
235237
236238#define STACKDEPTH 32
239+
237240/*
238241 * make polish notation of query
239242 */
240243static int4
241- makepol (TSQueryParserState * state , void (* pushval ) (TSQueryParserState * , int , char * , int , int2 ))
244+ makepol (TSQueryParserState * state ,
245+ void (* pushval ) (TSQueryParserState * , int , char * , int , int2 ))
242246{
243247 int4 val = 0 ,
244248 type ;
@@ -248,6 +252,9 @@ makepol(TSQueryParserState * state, void (*pushval) (TSQueryParserState *, int,
248252 int4 lenstack = 0 ;
249253 int2 weight = 0 ;
250254
255+ /* since this function recurses, it could be driven to stack overflow */
256+ check_stack_depth ();
257+
251258 while ((type = gettoken_query (state , & val , & lenval , & strval , & weight )) != END )
252259 {
253260 switch (type )
0 commit comments