MCPcopy Create free account
hub / github.com/apache/cloudberry / bqarr_in

Function bqarr_in

contrib/intarray/_int_bool.c:476–542  ·  view source on GitHub ↗

* input */

Source from the content-addressed store, hash-verified

474 * input
475 */
476Datum
477bqarr_in(PG_FUNCTION_ARGS)
478{
479 char *buf = (char *) PG_GETARG_POINTER(0);
480 WORKSTATE state;
481 int32 i;
482 QUERYTYPE *query;
483 int32 commonlen;
484 ITEM *ptr;
485 NODE *tmp;
486 int32 pos = 0;
487
488#ifdef BS_DEBUG
489 StringInfoData pbuf;
490#endif
491
492 state.buf = buf;
493 state.state = WAITOPERAND;
494 state.count = 0;
495 state.num = 0;
496 state.str = NULL;
497
498 /* make polish notation (postfix, but in reverse order) */
499 makepol(&state);
500 if (!state.num)
501 ereport(ERROR,
502 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
503 errmsg("empty query")));
504
505 if (state.num > QUERYTYPEMAXITEMS)
506 ereport(ERROR,
507 (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
508 errmsg("number of query items (%d) exceeds the maximum allowed (%d)",
509 state.num, (int) QUERYTYPEMAXITEMS)));
510 commonlen = COMPUTESIZE(state.num);
511
512 query = (QUERYTYPE *) palloc(commonlen);
513 SET_VARSIZE(query, commonlen);
514 query->size = state.num;
515 ptr = GETQUERY(query);
516
517 for (i = state.num - 1; i >= 0; i--)
518 {
519 ptr[i].type = state.str->type;
520 ptr[i].val = state.str->val;
521 tmp = state.str->next;
522 pfree(state.str);
523 state.str = tmp;
524 }
525
526 pos = query->size - 1;
527 findoprnd(ptr, &pos);
528#ifdef BS_DEBUG
529 initStringInfo(&pbuf);
530 for (i = 0; i < query->size; i++)
531 {
532 if (ptr[i].type == OPR)
533 appendStringInfo(&pbuf, "%c(%d) ", ptr[i].val, ptr[i].left);

Callers

nothing calls this directly

Calls 8

initStringInfoFunction · 0.85
appendStringInfoFunction · 0.85
makepolFunction · 0.70
findoprndFunction · 0.70
errcodeFunction · 0.50
errmsgFunction · 0.50
pallocFunction · 0.50
pfreeFunction · 0.50

Tested by

no test coverage detected