#include "postgres.h"
#include "libpq/pqformat.h"
+#include "miscadmin.h"
#include "tsearch/ts_locale.h"
#include "tsearch/ts_type.h"
#include "tsearch/ts_utils.h"
#include "utils/memutils.h"
#include "utils/pg_crc.h"
+
/* parser's states */
#define WAITOPERAND 1
#define WAITOPERATOR 2
}
#define STACKDEPTH 32
+
/*
* make polish notation of query
*/
static int4
-makepol(TSQueryParserState * state, void (*pushval) (TSQueryParserState *, int, char *, int, int2))
+makepol(TSQueryParserState * state,
+ void (*pushval) (TSQueryParserState *, int, char *, int, int2))
{
int4 val = 0,
type;
int4 lenstack = 0;
int2 weight = 0;
+ /* since this function recurses, it could be driven to stack overflow */
+ check_stack_depth();
+
while ((type = gettoken_query(state, &val, &lenval, &strval, &weight)) != END)
{
switch (type)
#include "executor/spi.h"
#include "funcapi.h"
#include "mb/pg_wchar.h"
+#include "miscadmin.h"
#include "tsearch/ts_type.h"
#include "tsearch/ts_utils.h"
#include "utils/builtins.h"
* check for boolean condition
*/
bool
-TS_execute(QueryItem * curitem, void *checkval, bool calcnot, bool (*chkcond) (void *checkval, QueryItem * val))
+TS_execute(QueryItem * curitem, void *checkval, bool calcnot,
+ bool (*chkcond) (void *checkval, QueryItem * val))
{
+ /* since this function recurses, it could be driven to stack overflow */
+ check_stack_depth();
+
if (curitem->type == VAL)
return chkcond(checkval, curitem);
else if (curitem->val == (int4) '!')
{
return (calcnot) ?
- ((TS_execute(curitem + 1, checkval, calcnot, chkcond)) ? false : true)
+ !TS_execute(curitem + 1, checkval, calcnot, chkcond)
: true;
}
else if (curitem->val == (int4) '&')