7
7
*
8
8
*
9
9
* 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 $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
14
14
15
15
#include "postgres.h"
16
16
17
17
#include "libpq/pqformat.h"
18
+ #include "miscadmin.h"
18
19
#include "tsearch/ts_locale.h"
19
20
#include "tsearch/ts_type.h"
20
21
#include "tsearch/ts_utils.h"
21
22
#include "utils/memutils.h"
22
23
#include "utils/pg_crc.h"
23
24
25
+
24
26
/* parser's states */
25
27
#define WAITOPERAND 1
26
28
#define WAITOPERATOR 2
@@ -234,11 +236,13 @@ pushval_asis(TSQueryParserState * state, int type, char *strval, int lenval, int
234
236
}
235
237
236
238
#define STACKDEPTH 32
239
+
237
240
/*
238
241
* make polish notation of query
239
242
*/
240
243
static int4
241
- makepol (TSQueryParserState * state , void (* pushval ) (TSQueryParserState * , int , char * , int , int2 ))
244
+ makepol (TSQueryParserState * state ,
245
+ void (* pushval ) (TSQueryParserState * , int , char * , int , int2 ))
242
246
{
243
247
int4 val = 0 ,
244
248
type ;
@@ -248,6 +252,9 @@ makepol(TSQueryParserState * state, void (*pushval) (TSQueryParserState *, int,
248
252
int4 lenstack = 0 ;
249
253
int2 weight = 0 ;
250
254
255
+ /* since this function recurses, it could be driven to stack overflow */
256
+ check_stack_depth ();
257
+
251
258
while ((type = gettoken_query (state , & val , & lenval , & strval , & weight )) != END )
252
259
{
253
260
switch (type )
0 commit comments