Datum _ltxtq_exec(PG_FUNCTION_ARGS) { ArrayType *la = PG_GETARG_ARRAYTYPE_P(0); ltxtquery *query = PG_GETARG_LTXTQUERY(1); bool res = array_iterator(la, ltxtq_exec, (void *) query, NULL); PG_FREE_IF_COPY(la, 0); PG_FREE_IF_COPY(query, 1); PG_RETURN_BOOL(res); }
Datum ltxtq_exec(PG_FUNCTION_ARGS) { ltree *val = PG_GETARG_LTREE(0); ltxtquery *query = PG_GETARG_LTXTQUERY(1); CHKVAL chkval; bool result; chkval.node = val; chkval.operand = GETOPERAND(query); result = ltree_execute( GETQUERY(query), &chkval, true, checkcondition_str ); PG_FREE_IF_COPY(val, 0); PG_FREE_IF_COPY(query, 1); PG_RETURN_BOOL(result); }
Datum ltxtq_out(PG_FUNCTION_ARGS) { ltxtquery *query = PG_GETARG_LTXTQUERY(0); INFIX nrm; if (query->size == 0) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("syntax error"), errdetail("Empty query."))); nrm.curpol = GETQUERY(query); nrm.buflen = 32; nrm.cur = nrm.buf = (char *) palloc(sizeof(char) * nrm.buflen); *(nrm.cur) = '\0'; nrm.op = GETOPERAND(query); infix(&nrm, true); PG_FREE_IF_COPY(query, 0); PG_RETURN_POINTER(nrm.buf); }
Datum _ltxtq_extract_exec(PG_FUNCTION_ARGS) { ArrayType *la = PG_GETARG_ARRAYTYPE_P(0); ltxtquery *query = PG_GETARG_LTXTQUERY(1); ltree *found, *item; if (!array_iterator(la, ltxtq_exec, (void *) query, &found)) { PG_FREE_IF_COPY(la, 0); PG_FREE_IF_COPY(query, 1); PG_RETURN_NULL(); } item = (ltree *) palloc(VARSIZE(found)); memcpy(item, found, VARSIZE(found)); PG_FREE_IF_COPY(la, 0); PG_FREE_IF_COPY(query, 1); PG_RETURN_POINTER(item); }