aboutsummaryrefslogtreecommitdiff
path: root/src/backend/jit/llvm/llvmjit_deform.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/jit/llvm/llvmjit_deform.c')
-rw-r--r--src/backend/jit/llvm/llvmjit_deform.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/backend/jit/llvm/llvmjit_deform.c b/src/backend/jit/llvm/llvmjit_deform.c
index e406d392d4e..6384ac940d8 100644
--- a/src/backend/jit/llvm/llvmjit_deform.c
+++ b/src/backend/jit/llvm/llvmjit_deform.c
@@ -22,12 +22,28 @@
#include "access/htup_details.h"
#include "access/tupdesc_details.h"
+#include "catalog/pg_subscription.h"
+#include "catalog/pg_subscription_rel.h"
#include "executor/tuptable.h"
#include "jit/llvmjit.h"
#include "jit/llvmjit_emit.h"
/*
+ * Through an embarrassing oversight, pre-v13 installations may have
+ * pg_subscription.subslotname and pg_subscription_rel.srsublsn marked as
+ * attnotnull, which they should not be. To avoid possible crashes, use
+ * this macro instead of testing attnotnull directly.
+ */
+#define ATTNOTNULL(att) \
+ ((att)->attnotnull && \
+ !(((att)->attrelid == SubscriptionRelationId && \
+ (att)->attnum == Anum_pg_subscription_subslotname) || \
+ ((att)->attrelid == SubscriptionRelRelationId && \
+ (att)->attnum == Anum_pg_subscription_rel_srsublsn)))
+
+
+/*
* Create a function that deforms a tuple of type desc up to natts columns.
*/
LLVMValueRef
@@ -113,7 +129,7 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc, int natts)
* it's guaranteed that all columns up to here exist at least in the
* NULL bitmap.
*/
- if (att->attnotnull)
+ if (ATTNOTNULL(att))
guaranteed_column_number = attnum;
}
@@ -376,7 +392,7 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc, int natts)
* into account, because in case they're present the heaptuple's natts
* would have indicated that a slot_getmissingattrs() is needed.
*/
- if (!att->attnotnull)
+ if (!ATTNOTNULL(att))
{
LLVMBasicBlockRef b_ifnotnull;
LLVMBasicBlockRef b_ifnull;
@@ -557,7 +573,7 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc, int natts)
known_alignment = -1;
attguaranteedalign = false;
}
- else if (att->attnotnull && attguaranteedalign && known_alignment >= 0)
+ else if (ATTNOTNULL(att) && attguaranteedalign && known_alignment >= 0)
{
/*
* If the offset to the column was previously known a NOT NULL &
@@ -567,7 +583,7 @@ slot_compile_deform(LLVMJitContext *context, TupleDesc desc, int natts)
Assert(att->attlen > 0);
known_alignment += att->attlen;
}
- else if (att->attnotnull && (att->attlen % alignto) == 0)
+ else if (ATTNOTNULL(att) && (att->attlen % alignto) == 0)
{
/*
* After a NOT NULL fixed-width column with a length that is a