Commit a598708f authored by Andres Freund's avatar Andres Freund

Change TupleTableSlot->tts_nvalid to type AttrNumber.

Previously it was an int / 4 bytes. The maximum number of attributes
in a tuple is restricted by the maximum value Var->varattno, which is
an AttrNumber/int16. Hence use the same data type for
TupleTableSlot->tts_nvalid.

Author: Ashutosh Bapat
Discussion: https://postgr.es/m/20180220224318.gw4oe5jadhpmcdnm@alap3.anarazel.de
parent 5913b9bb
...@@ -304,7 +304,7 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc, int natts) ...@@ -304,7 +304,7 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc, int natts)
for (attnum = 0; attnum < natts; attnum++) for (attnum = 0; attnum < natts; attnum++)
{ {
LLVMValueRef v_attno = l_int32_const(attnum); LLVMValueRef v_attno = l_int16_const(attnum);
LLVMAddCase(v_switch, v_attno, attcheckattnoblocks[attnum]); LLVMAddCase(v_switch, v_attno, attcheckattnoblocks[attnum]);
} }
...@@ -691,7 +691,7 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc, int natts) ...@@ -691,7 +691,7 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc, int natts)
{ {
LLVMValueRef v_off = LLVMBuildLoad(b, v_offp, ""); LLVMValueRef v_off = LLVMBuildLoad(b, v_offp, "");
LLVMBuildStore(b, l_int32_const(natts), v_nvalidp); LLVMBuildStore(b, l_int16_const(natts), v_nvalidp);
v_off = LLVMBuildTrunc(b, v_off, LLVMInt32Type(), ""); v_off = LLVMBuildTrunc(b, v_off, LLVMInt32Type(), "");
LLVMBuildStore(b, v_off, v_slotoffp); LLVMBuildStore(b, v_off, v_slotoffp);
LLVMBuildStore(b, l_int8_const(1), v_slowp); LLVMBuildStore(b, l_int8_const(1), v_slowp);
......
...@@ -324,7 +324,7 @@ llvm_compile_expr(ExprState *state) ...@@ -324,7 +324,7 @@ llvm_compile_expr(ExprState *state)
""); "");
LLVMBuildCondBr(b, LLVMBuildCondBr(b,
LLVMBuildICmp(b, LLVMIntUGE, v_nvalid, LLVMBuildICmp(b, LLVMIntUGE, v_nvalid,
l_int32_const(op->d.fetch.last_var), l_int16_const(op->d.fetch.last_var),
""), ""),
opblocks[i + 1], b_fetch); opblocks[i + 1], b_fetch);
......
...@@ -125,7 +125,7 @@ typedef struct TupleTableSlot ...@@ -125,7 +125,7 @@ typedef struct TupleTableSlot
MemoryContext tts_mcxt; /* slot itself is in this context */ MemoryContext tts_mcxt; /* slot itself is in this context */
Buffer tts_buffer; /* tuple's buffer, or InvalidBuffer */ Buffer tts_buffer; /* tuple's buffer, or InvalidBuffer */
#define FIELDNO_TUPLETABLESLOT_NVALID 9 #define FIELDNO_TUPLETABLESLOT_NVALID 9
int tts_nvalid; /* # of valid values in tts_values */ AttrNumber tts_nvalid; /* # of valid values in tts_values */
#define FIELDNO_TUPLETABLESLOT_VALUES 10 #define FIELDNO_TUPLETABLESLOT_VALUES 10
Datum *tts_values; /* current per-attribute values */ Datum *tts_values; /* current per-attribute values */
#define FIELDNO_TUPLETABLESLOT_ISNULL 11 #define FIELDNO_TUPLETABLESLOT_ISNULL 11
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment