poc-fixme-heap_getattr.diff
text/x-diff
Filename: poc-fixme-heap_getattr.diff
Type: text/x-diff
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/access/common/heaptuple.c | 1 | 3 |
| src/backend/commands/trigger.c | 5 | 0 |
| src/include/access/htup_details.h | 5 | 2 |
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c
index ed4549ca579..783b04a3cb9 100644
--- a/src/backend/access/common/heaptuple.c
+++ b/src/backend/access/common/heaptuple.c
@@ -71,8 +71,6 @@
#define VARLENA_ATT_IS_PACKABLE(att) \
((att)->attstorage != 'p')
-static Datum getmissingattr(TupleDesc tupleDesc, int attnum, bool *isnull);
-
/* ----------------------------------------------------------------
* misc support routines
@@ -82,7 +80,7 @@ static Datum getmissingattr(TupleDesc tupleDesc, int attnum, bool *isnull);
/*
* Return the missing value of an attribute, or NULL if there isn't one.
*/
-static Datum
+Datum
getmissingattr(TupleDesc tupleDesc,
int attnum, bool *isnull)
{
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 7b5896b98f9..b412c81d141 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -3412,10 +3412,15 @@ ltrmark:;
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
}
+#ifdef IAM_THE_WRONG_FIX
if (HeapTupleHeaderGetNatts(tuple.t_data) < relation->rd_att->natts)
result = heap_expand_tuple(&tuple, relation->rd_att);
else
result = heap_copytuple(&tuple);
+#else
+ result = heap_copytuple(&tuple);
+#endif
+
ReleaseBuffer(buffer);
return result;
diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h
index 873a3015fc4..81546ab46c7 100644
--- a/src/include/access/htup_details.h
+++ b/src/include/access/htup_details.h
@@ -744,6 +744,10 @@ extern Datum fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
#endif /* defined(DISABLE_COMPLEX_MACRO) */
+extern Datum
+getmissingattr(TupleDesc tupleDesc,
+ int attnum, bool *isnull);
+
/* ----------------
* heap_getattr
*
@@ -765,8 +769,7 @@ extern Datum fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
( \
((attnum) > (int) HeapTupleHeaderGetNatts((tup)->t_data)) ? \
( \
- (*(isnull) = true), \
- (Datum)NULL \
+ getmissingattr(tupleDesc, attnum, isnull) \
) \
: \
fastgetattr((tup), (attnum), (tupleDesc), (isnull)) \