49#define JUMBLE_SIZE 1024
70 int location,
int len);
106 query_len =
strlen(query);
189 jstate->clocations_buf_size = 32;
192 jstate->clocations_count = 0;
193 jstate->highest_extern_param_id = 0;
194 jstate->pending_nulls = 0;
195 jstate->has_squashed_lists =
false;
196#ifdef USE_ASSERT_CHECKING
197 jstate->total_jumble_len = 0;
215 if (
jstate->pending_nulls > 0)
219 if (
jstate->has_squashed_lists)
220 jstate->highest_extern_param_id = 0;
237 unsigned char *jumble =
jstate->jumble;
250 memcpy(jumble + jumble_len, item, size);
251 jstate->jumble_len += size;
253#ifdef USE_ASSERT_CHECKING
254 jstate->total_jumble_len += size;
284#ifdef USE_ASSERT_CHECKING
289 jstate->jumble_len = jumble_len;
299 if (
jstate->pending_nulls > 0)
322 if (
jstate->pending_nulls > 0)
336 if (
jstate->pending_nulls > 0)
350 if (
jstate->pending_nulls > 0)
364 if (
jstate->pending_nulls > 0)
382 (
const unsigned char *) &
jstate->pending_nulls, 4);
383 jstate->pending_nulls = 0;
404 if (
jstate->clocations_count >=
jstate->clocations_buf_size)
406 jstate->clocations_buf_size *= 2;
409 jstate->clocations_buf_size *
412 jstate->clocations[
jstate->clocations_count].location = location;
421 jstate->clocations[
jstate->clocations_count].extern_param = extern_param;
422 jstate->clocations_count++;
519 foreach(
temp, elements)
528#define JUMBLE_NODE(item) \
529 _jumbleNode(jstate, (Node *) expr->item)
530#define JUMBLE_ELEMENTS(list, node) \
531 _jumbleElements(jstate, (List *) expr->list, node)
532#define JUMBLE_LOCATION(location) \
533 RecordConstLocation(jstate, false, expr->location, -1)
534#define JUMBLE_FIELD(item) \
536 if (sizeof(expr->item) == 8) \
537 AppendJumble64(jstate, (const unsigned char *) &(expr->item)); \
538 else if (sizeof(expr->item) == 4) \
539 AppendJumble32(jstate, (const unsigned char *) &(expr->item)); \
540 else if (sizeof(expr->item) == 2) \
541 AppendJumble16(jstate, (const unsigned char *) &(expr->item)); \
542 else if (sizeof(expr->item) == 1) \
543 AppendJumble8(jstate, (const unsigned char *) &(expr->item)); \
545 AppendJumble(jstate, (const unsigned char *) &(expr->item), sizeof(expr->item)); \
547#define JUMBLE_STRING(str) \
550 AppendJumble(jstate, (const unsigned char *) (expr->str), strlen(expr->str) + 1); \
552 AppendJumbleNull(jstate); \
555#define JUMBLE_CUSTOM(nodetype, item) \
556 _jumble##nodetype##_##item(jstate, expr, expr->item)
558#include "queryjumblefuncs.funcs.c"
564#ifdef USE_ASSERT_CHECKING
585#include "queryjumblefuncs.switch.c"
630 elog(
ERROR,
"unrecognized list node type: %d",
657 if (
aexpr->list_start > 0 &&
aexpr->list_end > 0)
661 aexpr->list_start + 1,
664 jstate->has_squashed_lists =
true;
736 elog(
ERROR,
"unrecognized node type: %d",
#define Assert(condition)
#define pg_attribute_always_inline
#define palloc_object(type)
static Datum hash_any_extended(const unsigned char *k, int keylen, uint64 seed)
void * repalloc(void *pointer, Size size)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
static int list_length(const List *l)
#define foreach_current_index(var_or_cell)
static int64 DatumGetInt64(Datum X)
static bool IsQueryIdEnabled(void)
#define JUMBLE_NODE(item)
JumbleState * JumbleQuery(Query *query)
static void _jumbleNode(JumbleState *jstate, Node *node)
static void _jumbleVariableSetStmt(JumbleState *jstate, Node *node)
static bool IsSquashableConstantList(List *elements)
static bool IsSquashableConstant(Node *element)
static pg_attribute_always_inline void AppendJumbleInternal(JumbleState *jstate, const unsigned char *item, Size size)
static pg_attribute_always_inline void AppendJumbleNull(JumbleState *jstate)
static pg_noinline void AppendJumble8(JumbleState *jstate, const unsigned char *value)
#define JUMBLE_LOCATION(location)
static void _jumbleParam(JumbleState *jstate, Node *node)
const char * CleanQuerytext(const char *query, int *location, int *len)
static void _jumbleList(JumbleState *jstate, Node *node)
static void FlushPendingNulls(JumbleState *jstate)
static void RecordConstLocation(JumbleState *jstate, bool extern_param, int location, int len)
#define JUMBLE_STRING(str)
static pg_noinline void AppendJumble32(JumbleState *jstate, const unsigned char *value)
static pg_noinline void AppendJumble64(JumbleState *jstate, const unsigned char *value)
static void _jumbleA_Const(JumbleState *jstate, Node *node)
static void AppendJumble(JumbleState *jstate, const unsigned char *value, Size size)
static void _jumbleElements(JumbleState *jstate, List *elements, Node *node)
static pg_noinline void AppendJumble16(JumbleState *jstate, const unsigned char *value)
static int64 DoJumble(JumbleState *jstate, Node *node)
static void _jumbleRangeTblEntry_eref(JumbleState *jstate, RangeTblEntry *rte, Alias *expr)
static JumbleState * InitJumble(void)
#define JUMBLE_FIELD(item)
static chr element(struct vars *v, const chr *startp, const chr *endp)
bool scanner_isspace(char ch)
bool stack_is_too_deep(void)
void check_stack_depth(void)
#define FirstGenbkiObjectId