本文整理汇总了C++中check_stack_depth函数的典型用法代码示例。如果您正苦于以下问题:C++ check_stack_depth函数的具体用法?C++ check_stack_depth怎么用?C++ check_stack_depth使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_stack_depth函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: TS_execute_ternary
/*
* Evaluate tsquery boolean expression using ternary logic.
*
* chkcond is a callback function used to evaluate each VAL node in the query.
* checkval can be used to pass information to the callback. TS_execute doesn't
* do anything with it.
*/
static GinTernaryValue
TS_execute_ternary(QueryItem *curitem, void *checkval,
GinTernaryValue (*chkcond) (void *checkval, QueryOperand *val))
{
GinTernaryValue val1,
val2,
result;
/* since this function recurses, it could be driven to stack overflow */
check_stack_depth();
if (curitem->type == QI_VAL)
return chkcond(checkval, (QueryOperand *) curitem);
switch (curitem->qoperator.oper)
{
case OP_NOT:
result = TS_execute_ternary(curitem + 1, checkval, chkcond);
if (result == GIN_MAYBE)
return result;
return !result;
case OP_AND:
val1 = TS_execute_ternary(curitem + curitem->qoperator.left,
checkval, chkcond);
if (val1 == GIN_FALSE)
return GIN_FALSE;
val2 = TS_execute_ternary(curitem + 1, checkval, chkcond);
if (val2 == GIN_FALSE)
return GIN_FALSE;
if (val1 == GIN_TRUE && val2 == GIN_TRUE)
return GIN_TRUE;
else
return GIN_MAYBE;
case OP_OR:
val1 = TS_execute_ternary(curitem + curitem->qoperator.left,
checkval, chkcond);
if (val1 == GIN_TRUE)
return GIN_TRUE;
val2 = TS_execute_ternary(curitem + 1, checkval, chkcond);
if (val2 == GIN_TRUE)
return GIN_TRUE;
if (val1 == GIN_FALSE && val2 == GIN_FALSE)
return GIN_FALSE;
else
return GIN_MAYBE;
default:
elog(ERROR, "unrecognized operator___: %d", curitem->qoperator.oper);
}
/* not reachable, but keep compiler quiet */
return false;
}
开发者ID:EccentricLoggers,项目名称:peloton,代码行数:62,代码来源:tsginidx.cpp
示例2: clean_NOT_intree
/*
* clean tree for ! operator.
* It's useful for debug, but in
* other case, such view is used with search in index.
* Operator ! always return TRUE
*/
static NODE *
clean_NOT_intree(NODE *node)
{
/* since this function recurses, it could be driven to stack overflow. */
check_stack_depth();
if (node->valnode->type == QI_VAL)
return node;
if (node->valnode->qoperator.oper == OP_NOT)
{
freetree(node);
return NULL;
}
/* operator & or | */
if (node->valnode->qoperator.oper == OP_OR)
{
if ((node->left = clean_NOT_intree(node->left)) == NULL ||
(node->right = clean_NOT_intree(node->right)) == NULL)
{
freetree(node);
return NULL;
}
}
else
{
NODE *res = node;
Assert(node->valnode->qoperator.oper == OP_AND ||
node->valnode->qoperator.oper == OP_PHRASE);
node->left = clean_NOT_intree(node->left);
node->right = clean_NOT_intree(node->right);
if (node->left == NULL && node->right == NULL)
{
pfree(node);
res = NULL;
}
else if (node->left == NULL)
{
res = node->right;
pfree(node);
}
else if (node->right == NULL)
{
res = node->left;
pfree(node);
}
return res;
}
return node;
}
开发者ID:winlibs,项目名称:postgresql,代码行数:59,代码来源:tsquery_cleanup.c
示例3: QTNodeCompare
/*
* Sort comparator for QTNodes.
*
* The sort order is somewhat arbitrary.
*/
int
QTNodeCompare(QTNode *an, QTNode *bn)
{
/* since this function recurses, it could be driven to stack overflow. */
check_stack_depth();
if (an->valnode->type != bn->valnode->type)
return (an->valnode->type > bn->valnode->type) ? -1 : 1;
if (an->valnode->type == QI_OPR)
{
QueryOperator *ao = &an->valnode->qoperator;
QueryOperator *bo = &bn->valnode->qoperator;
if (ao->oper != bo->oper)
return (ao->oper > bo->oper) ? -1 : 1;
if (an->nchild != bn->nchild)
return (an->nchild > bn->nchild) ? -1 : 1;
{
int i,
res;
for (i = 0; i < an->nchild; i++)
if ((res = QTNodeCompare(an->child[i], bn->child[i])) != 0)
return res;
}
if (ao->oper == OP_PHRASE && ao->distance != bo->distance)
return (ao->distance > bo->distance) ? -1 : 1;
return 0;
}
else if (an->valnode->type == QI_VAL)
{
QueryOperand *ao = &an->valnode->qoperand;
QueryOperand *bo = &bn->valnode->qoperand;
if (ao->valcrc != bo->valcrc)
{
return (ao->valcrc > bo->valcrc) ? -1 : 1;
}
return tsCompareString(an->word, ao->length, bn->word, bo->length, false);
}
else
{
elog(ERROR, "unrecognized QueryItem type: %d", an->valnode->type);
return 0; /* keep compiler quiet */
}
}
开发者ID:Tao-Ma,项目名称:postgres,代码行数:57,代码来源:tsquery_util.c
示例4: freetree
static void
freetree(NODE *node)
{
/* since this function recurses, it could be driven to stack overflow. */
check_stack_depth();
if (!node)
return;
if (node->left)
freetree(node->left);
if (node->right)
freetree(node->right);
pfree(node);
}
开发者ID:AllenDou,项目名称:postgresql,代码行数:14,代码来源:tsquery_cleanup.c
示例5: QTNSort
void
QTNSort(QTNode *in)
{
int i;
/* since this function recurses, it could be driven to stack overflow. */
check_stack_depth();
if (in->valnode->type != QI_OPR)
return;
for (i = 0; i < in->nchild; i++)
QTNSort(in->child[i]);
if (in->nchild > 1)
qsort((void *) in->child, in->nchild, sizeof(QTNode *), cmpQTN);
}
开发者ID:5A68656E67,项目名称:postgres,代码行数:16,代码来源:tsquery_util.c
示例6: QTNClearFlags
void
QTNClearFlags(QTNode *in, uint32 flags)
{
/* since this function recurses, it could be driven to stack overflow. */
check_stack_depth();
in->flags &= ~flags;
if (in->valnode->type != QI_VAL)
{
int i;
for (i = 0; i < in->nchild; i++)
QTNClearFlags(in->child[i], flags);
}
}
开发者ID:5A68656E67,项目名称:postgres,代码行数:16,代码来源:tsquery_util.c
示例7: addone
static int
addone(int *counters, int last, int total)
{
/* since this function recurses, it could be driven to stack overflow. */
check_stack_depth();
counters[last]++;
if (counters[last] >= total)
{
if (last == 0)
return 0;
if (addone(counters, last - 1, total - 1) == 0)
return 0;
counters[last] = counters[last - 1] + 1;
}
return 1;
}
开发者ID:0x0FFF,项目名称:postgres,代码行数:17,代码来源:tsquery_rewrite.c
示例8: QTNodeCompare
int
QTNodeCompare(QTNode *an, QTNode *bn)
{
/* since this function recurses, it could be driven to stack overflow. */
check_stack_depth();
if (an->valnode->type != bn->valnode->type)
return (an->valnode->type > bn->valnode->type) ? -1 : 1;
if (an->valnode->type == QI_OPR)
{
QueryOperator *ao = &an->valnode->qoperator;
QueryOperator *bo = &bn->valnode->qoperator;
if (ao->oper != bo->oper)
return (ao->oper > bo->oper) ? -1 : 1;
if (an->nchild != bn->nchild)
return (an->nchild > bn->nchild) ? -1 : 1;
{
int i,
res;
for (i = 0; i < an->nchild; i++)
if ((res = QTNodeCompare(an->child[i], bn->child[i])) != 0)
return res;
}
return 0;
}
else
{
QueryOperand *ao = &an->valnode->qoperand;
QueryOperand *bo = &bn->valnode->qoperand;
Assert(an->valnode->type == QI_VAL);
if (ao->valcrc != bo->valcrc)
{
return (ao->valcrc > bo->valcrc) ? -1 : 1;
}
return tsCompareString(an->word, ao->length, bn->word, bo->length, false);
}
}
开发者ID:joshuawingfield,项目名称:pgsql,代码行数:45,代码来源:tsquery_util.c
示例9: dofindsubquery
static QTNode *
dofindsubquery(QTNode *root, QTNode *ex, QTNode *subs, bool *isfind)
{
/* since this function recurses, it could be driven to stack overflow. */
check_stack_depth();
root = findeq(root, ex, subs, isfind);
if (root && (root->flags & QTN_NOCHANGE) == 0 && root->valnode->type == QI_OPR)
{
int i;
for (i = 0; i < root->nchild; i++)
root->child[i] = dofindsubquery(root->child[i], ex, subs, isfind);
}
return root;
}
开发者ID:0x0FFF,项目名称:postgres,代码行数:18,代码来源:tsquery_rewrite.c
示例10: maketree
/*
* make query tree from plain view of query
*/
static NODE *
maketree(QueryItem *in)
{
NODE *node = (NODE *) palloc(sizeof(NODE));
/* since this function recurses, it could be driven to stack overflow. */
check_stack_depth();
node->valnode = in;
node->right = node->left = NULL;
if (in->type == QI_OPR)
{
node->right = maketree(in + 1);
if (in->qoperator.oper != OP_NOT)
node->left = maketree(in + in->qoperator.left);
}
return node;
}
开发者ID:winlibs,项目名称:postgresql,代码行数:21,代码来源:tsquery_cleanup.c
示例11: QTNTernary
/*
* Remove unnecessary intermediate nodes. For example:
*
* OR OR
* a OR -> a b c
* b c
*/
void
QTNTernary(QTNode *in)
{
int i;
/* since this function recurses, it could be driven to stack overflow. */
check_stack_depth();
if (in->valnode->type != QI_OPR)
return;
for (i = 0; i < in->nchild; i++)
QTNTernary(in->child[i]);
/* Only AND and OR are associative, so don't flatten other node types */
if (in->valnode->qoperator.oper != OP_AND &&
in->valnode->qoperator.oper != OP_OR)
return;
for (i = 0; i < in->nchild; i++)
{
QTNode *cc = in->child[i];
if (cc->valnode->type == QI_OPR &&
in->valnode->qoperator.oper == cc->valnode->qoperator.oper)
{
int oldnchild = in->nchild;
in->nchild += cc->nchild - 1;
in->child = (QTNode **) repalloc(in->child, in->nchild * sizeof(QTNode *));
if (i + 1 != oldnchild)
memmove(in->child + i + cc->nchild, in->child + i + 1,
(oldnchild - i - 1) * sizeof(QTNode *));
memcpy(in->child + i, cc->child, cc->nchild * sizeof(QTNode *));
i += cc->nchild - 1;
if (cc->flags & QTN_NEEDFREE)
pfree(cc->valnode);
pfree(cc);
}
}
}
开发者ID:Tao-Ma,项目名称:postgres,代码行数:51,代码来源:tsquery_util.c
示例12: cntsize
/*
* Count the total length of operand string in tree, including '\0'-
* terminators.
*/
static void
cntsize(QTNode *in, int *sumlen, int *nnode)
{
/* since this function recurses, it could be driven to stack overflow. */
check_stack_depth();
*nnode += 1;
if (in->valnode->type == QI_OPR)
{
int i;
for (i = 0; i < in->nchild; i++)
cntsize(in->child[i], sumlen, nnode);
}
else
{
*sumlen += in->valnode->qoperand.length + 1;
}
}
开发者ID:5A68656E67,项目名称:postgres,代码行数:23,代码来源:tsquery_util.c
示例13: tsquery_requires_match
/*
* Detect whether a tsquery boolean expression requires any positive matches
* to values shown in the tsquery.
*
* This is needed to know whether a GIN index search requires full index scan.
* For example, 'x & !y' requires a match of x, so it's sufficient to scan
* entries for x; but 'x | !y' could match rows containing neither x nor y.
*/
bool
tsquery_requires_match(QueryItem *curitem)
{
/* since this function recurses, it could be driven to stack overflow */
check_stack_depth();
if (curitem->type == QI_VAL)
return true;
switch (curitem->qoperator.oper)
{
case OP_NOT:
/*
* Assume there are no required matches underneath a NOT. For
* some cases with nested NOTs, we could prove there's a required
* match, but it seems unlikely to be worth the trouble.
*/
return false;
case OP_AND:
/* If either side requires a match, we're good */
if (tsquery_requires_match(curitem + curitem->qoperator.left))
return true;
else
return tsquery_requires_match(curitem + 1);
case OP_OR:
/* Both sides must require a match */
if (tsquery_requires_match(curitem + curitem->qoperator.left))
return tsquery_requires_match(curitem + 1);
else
return false;
default:
elog(ERROR, "unrecognized operator: %d", curitem->qoperator.oper);
}
/* not reachable, but keep compiler quiet */
return false;
}
开发者ID:bocap,项目名称:postgres,代码行数:49,代码来源:tsvector_op.c
示例14: executeExpr
static bool
executeExpr(char *jqBase, int32 jqPos, int32 op, JsonbValue *jb)
{
int32 type;
int32 nextPos;
check_stack_depth();
/*
* read arg type
*/
jqPos = readJsQueryHeader(jqBase, jqPos, &type, &nextPos);
Assert(nextPos == 0);
Assert(type == jqiAny || type == jqiString || type == jqiNumeric ||
type == jqiNull || type == jqiBool || type == jqiArray);
switch(op)
{
case jqiEqual:
if (jb->type == jbvBinary && type == jqiArray)
return checkArrayEquality(jqBase, jqPos, type, jb);
return checkEquality(jqBase, jqPos, type, jb);
case jqiIn:
return checkIn(jqBase, jqPos, type, jb);
case jqiOverlap:
case jqiContains:
case jqiContained:
return executeArrayOp(jqBase, jqPos, type, op, jb);
case jqiLess:
case jqiGreater:
case jqiLessOrEqual:
case jqiGreaterOrEqual:
return makeCompare(jqBase, jqPos, type, op, jb);
default:
elog(ERROR, "Unknown operation");
}
return false;
}
开发者ID:niquola,项目名称:fhir_cases_for_jsonp,代码行数:40,代码来源:jsquery_op.c
示例15: QTNBinary
/*
* Convert a tree to binary tree by inserting intermediate nodes.
* (Opposite of QTNTernary)
*/
void
QTNBinary(QTNode *in)
{
int i;
/* since this function recurses, it could be driven to stack overflow. */
check_stack_depth();
if (in->valnode->type != QI_OPR)
return;
for (i = 0; i < in->nchild; i++)
QTNBinary(in->child[i]);
if (in->nchild <= 2)
return;
while (in->nchild > 2)
{
QTNode *nn = (QTNode *) palloc0(sizeof(QTNode));
nn->valnode = (QueryItem *) palloc0(sizeof(QueryItem));
nn->child = (QTNode **) palloc0(sizeof(QTNode *) * 2);
nn->nchild = 2;
nn->flags = QTN_NEEDFREE;
nn->child[0] = in->child[0];
nn->child[1] = in->child[1];
nn->sign = nn->child[0]->sign | nn->child[1]->sign;
nn->valnode->type = in->valnode->type;
nn->valnode->qoperator.oper = in->valnode->qoperator.oper;
in->child[0] = nn;
in->child[1] = in->child[in->nchild - 1];
in->nchild--;
}
}
开发者ID:5A68656E67,项目名称:postgres,代码行数:43,代码来源:tsquery_util.c
示例16: traverse_lacons
/*
* pg_reg_getnumoutarcs() and pg_reg_getoutarcs() mask the existence of LACON
* arcs from the caller, treating any LACON as being automatically satisfied.
* Since the output representation does not support arcs that consume no
* character when traversed, we have to recursively traverse LACON arcs here,
* and report whatever normal arcs are reachable by traversing LACON arcs.
* Note that this wouldn't work if it were possible to reach the final state
* via LACON traversal, but the regex library never builds NFAs that have
* LACON arcs leading directly to the final state. (This is because the
* regex executor is designed to consume one character beyond the nominal
* match end --- possibly an EOS indicator --- so there is always a set of
* ordinary arcs leading to the final state.)
*
* traverse_lacons is a recursive subroutine used by both exported functions
* to count and then emit the reachable regular arcs. *arcs_count is
* incremented by the number of reachable arcs, and as many as will fit in
* arcs_len (possibly 0) are emitted into arcs[].
*/
static void
traverse_lacons(struct cnfa *cnfa, int st,
int *arcs_count,
regex_arc_t *arcs, int arcs_len)
{
struct carc *ca;
/*
* Since this function recurses, it could theoretically be driven to stack
* overflow. In practice, this is mostly useful to backstop against a
* failure of the regex compiler to remove a loop of LACON arcs.
*/
check_stack_depth();
for (ca = cnfa->states[st]; ca->co != COLORLESS; ca++)
{
if (ca->co < cnfa->ncolors)
{
/* Ordinary arc, so count and possibly emit it */
int ndx = (*arcs_count)++;
if (ndx < arcs_len)
{
arcs[ndx].co = ca->co;
arcs[ndx].to = ca->to;
}
}
else
{
/* LACON arc --- assume it's satisfied and recurse... */
/* ... but first, assert it doesn't lead directly to post state */
Assert(ca->to != cnfa->post);
traverse_lacons(cnfa, ca->to, arcs_count, arcs, arcs_len);
}
}
}
开发者ID:AmiGanguli,项目名称:postgres,代码行数:55,代码来源:regexport.c
示例17: TS_execute
/*
* Evaluate tsquery boolean expression.
*
* chkcond is a callback function used to evaluate each VAL node in the query.
* checkval can be used to pass information to the callback. TS_execute doesn't
* do anything with it.
* if calcnot is false, NOT expressions are always evaluated to be true. This
* is used in ranking.
*/
bool
TS_execute(QueryItem *curitem, void *checkval, bool calcnot,
bool (*chkcond) (void *checkval, QueryOperand *val))
{
/* since this function recurses, it could be driven to stack overflow */
check_stack_depth();
if (curitem->type == QI_VAL)
return chkcond(checkval, (QueryOperand *) curitem);
switch (curitem->qoperator.oper)
{
case OP_NOT:
if (calcnot)
return !TS_execute(curitem + 1, checkval, calcnot, chkcond);
else
return true;
case OP_AND:
if (TS_execute(curitem + curitem->qoperator.left, checkval, calcnot, chkcond))
return TS_execute(curitem + 1, checkval, calcnot, chkcond);
else
return false;
case OP_OR:
if (TS_execute(curitem + curitem->qoperator.left, checkval, calcnot, chkcond))
return true;
else
return TS_execute(curitem + 1, checkval, calcnot, chkcond);
default:
elog(ERROR, "unrecognized operator: %d", curitem->qoperator.oper);
}
/* not reachable, but keep compiler quiet */
return false;
}
开发者ID:bocap,项目名称:postgres,代码行数:46,代码来源:tsvector_op.c
示例18: fillQT
static void
fillQT(QTN2QTState *state, QTNode *in)
{
/* since this function recurses, it could be driven to stack overflow. */
check_stack_depth();
if (in->valnode->type == QI_VAL)
{
memcpy(state->curitem, in->valnode, sizeof(QueryOperand));
memcpy(state->curoperand, in->word, in->valnode->qoperand.length);
state->curitem->qoperand.distance = state->curoperand - state->operand;
state->curoperand[in->valnode->qoperand.length] = '\0';
state->curoperand += in->valnode->qoperand.length + 1;
state->curitem++;
}
else
{
QueryItem *curitem = state->curitem;
Assert(in->valnode->type == QI_OPR);
memcpy(state->curitem, in->valnode, sizeof(QueryOperator));
Assert(in->nchild <= 2);
state->curitem++;
fillQT(state, in->child[0]);
if (in->nchild == 2)
{
curitem->qoperator.left = state->curitem - curitem;
fillQT(state, in->child[1]);
}
}
}
开发者ID:5A68656E67,项目名称:postgres,代码行数:36,代码来源:tsquery_util.c
示例19: emit_jsp_gin_entries
/* Recursively emit all GIN entries found in the node tree */
static void
emit_jsp_gin_entries(JsonPathGinNode *node, GinEntries *entries)
{
check_stack_depth();
switch (node->type)
{
case JSP_GIN_ENTRY:
/* replace datum with its index in the array */
node->val.entryIndex = add_gin_entry(entries, node->val.entryDatum);
break;
case JSP_GIN_OR:
case JSP_GIN_AND:
{
int i;
for (i = 0; i < node->val.nargs; i++)
emit_jsp_gin_entries(node->args[i], entries);
break;
}
}
}
开发者ID:davidfetter,项目名称:postgresql_projects,代码行数:25,代码来源:jsonb_gin.c
示例20: makepol
/*
* make polish notation of query
*/
static int4
makepol(WORKSTATE *state)
{
int4 val,
type;
int4 stack[STACKDEPTH];
int4 lenstack = 0;
/* since this function recurses, it could be driven to stack overflow */
check_stack_depth();
while ((type = gettoken(state, &val)) != END)
{
switch (type)
{
case VAL:
pushquery(state, type, val);
while (lenstack && (stack[lenstack - 1] == (int4) '&' ||
stack[lenstack - 1] == (int4) '!'))
{
lenstack--;
pushquery(state, OPR, stack[lenstack]);
}
break;
case OPR:
if (lenstack && val == (int4) '|')
pushquery(state, OPR, val);
else
{
if (lenstack == STACKDEPTH)
ereport(ERROR,
(errcode(ERRCODE_STATEMENT_TOO_COMPLEX),
errmsg("statement too complex")));
stack[lenstack] = val;
lenstack++;
}
break;
case OPEN:
if (makepol(state) == ERR)
return ERR;
while (lenstack && (stack[lenstack - 1] == (int4) '&' ||
stack[lenstack - 1] == (int4) '!'))
{
lenstack--;
pushquery(state, OPR, stack[lenstack]);
}
break;
case CLOSE:
while (lenstack)
{
lenstack--;
pushquery(state, OPR, stack[lenstack]);
};
return END;
break;
case ERR:
default:
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("syntax error")));
return ERR;
}
}
while (lenstack)
{
lenstack--;
pushquery(state, OPR, stack[lenstack]);
};
return END;
}
开发者ID:cbbrowne,项目名称:postgres,代码行数:75,代码来源:_int_bool.c
注:本文中的check_stack_depth函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论