Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/spock.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ extern int restart_delay_default;
extern int restart_delay_on_exception;
extern int spock_replay_queue_size; /* Deprecated - no longer used */
extern bool check_all_uc_indexes;
extern bool spock_enable_quiet_mode;

extern char *shorten_hash(const char *str, int maxlen);

extern List *textarray_to_list(ArrayType *textarray);
Expand Down
39 changes: 23 additions & 16 deletions patches/15/pg15-015-attoptions.diff
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c
index 5b696043c5..16ec985928 100644
index 620602fba2d..8eebc4cde65 100644
--- a/src/backend/access/common/reloptions.c
+++ b/src/backend/access/common/reloptions.c
@@ -168,6 +168,15 @@ static relopt_bool boolRelOpts[] =
Expand Down Expand Up @@ -38,7 +38,7 @@ index 5b696043c5..16ec985928 100644
/* list terminator */
{{NULL}}
};
@@ -2076,7 +2098,9 @@ attribute_reloptions(Datum reloptions, bool validate)
@@ -2085,7 +2107,9 @@ attribute_reloptions(Datum reloptions, bool validate)
{
static const relopt_parse_elt tab[] = {
{"n_distinct", RELOPT_TYPE_REAL, offsetof(AttributeOpts, n_distinct)},
Expand All @@ -50,34 +50,34 @@ index 5b696043c5..16ec985928 100644

return (bytea *) build_reloptions(reloptions, validate,
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 88ab5f99c8..161333c5e0 100644
index 64044de67b2..d2a86a98987 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -66,6 +66,7 @@
@@ -67,6 +67,7 @@
#include "storage/smgr.h"
#include "storage/spin.h"
#include "storage/standby.h"
+#include "utils/attoptcache.h"
#include "utils/datum.h"
#include "utils/inval.h"
#include "utils/lsyscache.h"
@@ -86,6 +87,7 @@ static void check_lock_if_inplace_updateable_rel(Relation relation,
@@ -88,6 +89,7 @@ static void check_lock_if_inplace_updateable_rel(Relation relation,
HeapTuple newtup);
static void check_inplace_rel_lock(HeapTuple oldtup);
#endif
+static Bitmapset *HeapDetermineLogOldColumns(Relation relation);
static Bitmapset *HeapDetermineColumnsInfo(Relation relation,
Bitmapset *interesting_cols,
Bitmapset *external_cols,
@@ -117,6 +119,7 @@ static void index_delete_sort(TM_IndexDeleteOp *delstate);
@@ -119,6 +121,7 @@ static void index_delete_sort(TM_IndexDeleteOp *delstate);
static int bottomup_sort_and_shrink(TM_IndexDeleteOp *delstate);
static XLogRecPtr log_heap_new_cid(Relation relation, HeapTuple tup);
static HeapTuple ExtractReplicaIdentity(Relation rel, HeapTuple tup, bool key_required,
+ Bitmapset *logged_old_attrs,
bool *copy);


@@ -2919,7 +2922,7 @@ l1:
@@ -2959,7 +2962,7 @@ l1:
* Compute replica identity tuple before entering the critical section so
* we don't PANIC upon a memory allocation failure.
*/
Expand All @@ -86,47 +86,47 @@ index 88ab5f99c8..161333c5e0 100644

/*
* If this is the first possibly-multixact-able operation in the current
@@ -3150,6 +3153,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
@@ -3190,6 +3193,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
Bitmapset *id_attrs;
Bitmapset *interesting_attrs;
Bitmapset *modified_attrs;
+ Bitmapset *logged_old_attrs;
ItemId lp;
HeapTupleData oldtup;
HeapTuple heaptup;
@@ -3267,6 +3271,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
@@ -3351,6 +3355,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
modified_attrs = HeapDetermineColumnsInfo(relation, interesting_attrs,
id_attrs, &oldtup,
newtup, &id_has_external);
+ logged_old_attrs = HeapDetermineLogOldColumns(relation);

/*
* If we're not updating any "key" column, we can grab a weaker lock type.
@@ -3538,6 +3543,7 @@ l2:
@@ -3622,6 +3627,7 @@ l2:
bms_free(key_attrs);
bms_free(id_attrs);
bms_free(modified_attrs);
+ bms_free(logged_old_attrs);
bms_free(interesting_attrs);
return result;
}
@@ -3874,6 +3880,7 @@ l2:
@@ -3958,6 +3964,7 @@ l2:
old_key_tuple = ExtractReplicaIdentity(relation, &oldtup,
bms_overlap(modified_attrs, id_attrs) ||
id_has_external,
+ logged_old_attrs,
&old_key_copied);

/* NO EREPORT(ERROR) from here till changes are logged */
@@ -4023,6 +4030,7 @@ l2:
@@ -4107,6 +4114,7 @@ l2:
bms_free(key_attrs);
bms_free(id_attrs);
bms_free(modified_attrs);
+ bms_free(logged_old_attrs);
bms_free(interesting_attrs);

return TM_Ok;
@@ -4195,6 +4203,26 @@ heap_attr_equals(TupleDesc tupdesc, int attrnum, Datum value1, Datum value2,
@@ -4279,6 +4287,33 @@ heap_attr_equals(TupleDesc tupdesc, int attrnum, Datum value1, Datum value2,
}
}

Expand All @@ -138,6 +138,13 @@ index 88ab5f99c8..161333c5e0 100644
+ TupleDesc tupdesc = RelationGetDescr(relation);
+ AttributeOpts *aopt;
+
+ /*
+ * Catalog relations are never sent by LR, no chance to use the delta_apply
+ * feature
+ */
+ if (IsCatalogRelation(relation))
+ return NULL;
+
+ for (attnum = 1; attnum <= tupdesc->natts; attnum++)
+ {
+ aopt = get_attribute_options(relation->rd_id, attnum);
Expand All @@ -153,15 +160,15 @@ index 88ab5f99c8..161333c5e0 100644
/*
* Check which columns are being updated.
*
@@ -8913,6 +8941,7 @@ log_heap_new_cid(Relation relation, HeapTuple tup)
@@ -9069,6 +9104,7 @@ log_heap_new_cid(Relation relation, HeapTuple tup)
*/
static HeapTuple
ExtractReplicaIdentity(Relation relation, HeapTuple tp, bool key_required,
+ Bitmapset *logged_old_attrs,
bool *copy)
{
TupleDesc desc = RelationGetDescr(relation);
@@ -8945,13 +8974,16 @@ ExtractReplicaIdentity(Relation relation, HeapTuple tp, bool key_required,
@@ -9101,13 +9137,16 @@ ExtractReplicaIdentity(Relation relation, HeapTuple tp, bool key_required,
}

/* if the key isn't required and we're only logging the key, we're done */
Expand All @@ -180,7 +187,7 @@ index 88ab5f99c8..161333c5e0 100644
* If there's no defined replica identity columns, treat as !key_required.
* (This case should not be reachable from heap_update, since that should
diff --git a/src/include/utils/attoptcache.h b/src/include/utils/attoptcache.h
index ee37af9500..98b48a8fd8 100644
index ee37af95001..98b48a8fd89 100644
--- a/src/include/utils/attoptcache.h
+++ b/src/include/utils/attoptcache.h
@@ -21,6 +21,8 @@ typedef struct AttributeOpts
Expand Down
41 changes: 24 additions & 17 deletions patches/16/pg16-015-attoptions.diff
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c
index 469de9bb49..0119e5aa7c 100644
index 620602fba2d..8eebc4cde65 100644
--- a/src/backend/access/common/reloptions.c
+++ b/src/backend/access/common/reloptions.c
@@ -168,6 +168,15 @@ static relopt_bool boolRelOpts[] =
Expand Down Expand Up @@ -38,7 +38,7 @@ index 469de9bb49..0119e5aa7c 100644
/* list terminator */
{{NULL}}
};
@@ -2072,7 +2094,9 @@ attribute_reloptions(Datum reloptions, bool validate)
@@ -2085,7 +2107,9 @@ attribute_reloptions(Datum reloptions, bool validate)
{
static const relopt_parse_elt tab[] = {
{"n_distinct", RELOPT_TYPE_REAL, offsetof(AttributeOpts, n_distinct)},
Expand All @@ -50,7 +50,7 @@ index 469de9bb49..0119e5aa7c 100644

return (bytea *) build_reloptions(reloptions, validate,
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 723e34e464..b2f845211d 100644
index 64044de67b2..d2a86a98987 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -67,6 +67,7 @@
Expand All @@ -61,23 +61,23 @@ index 723e34e464..b2f845211d 100644
#include "utils/datum.h"
#include "utils/inval.h"
#include "utils/lsyscache.h"
@@ -87,6 +88,7 @@ static void check_lock_if_inplace_updateable_rel(Relation relation,
@@ -88,6 +89,7 @@ static void check_lock_if_inplace_updateable_rel(Relation relation,
HeapTuple newtup);
static void check_inplace_rel_lock(HeapTuple oldtup);
#endif
+static Bitmapset *HeapDetermineLogOldColumns(Relation relation);
static Bitmapset *HeapDetermineColumnsInfo(Relation relation,
Bitmapset *interesting_cols,
Bitmapset *external_cols,
@@ -121,6 +123,7 @@ static void index_delete_sort(TM_IndexDeleteOp *delstate);
@@ -119,6 +121,7 @@ static void index_delete_sort(TM_IndexDeleteOp *delstate);
static int bottomup_sort_and_shrink(TM_IndexDeleteOp *delstate);
static XLogRecPtr log_heap_new_cid(Relation relation, HeapTuple tup);
static HeapTuple ExtractReplicaIdentity(Relation relation, HeapTuple tp, bool key_required,
static HeapTuple ExtractReplicaIdentity(Relation rel, HeapTuple tup, bool key_required,
+ Bitmapset *logged_old_attrs,
bool *copy);


@@ -2780,7 +2783,7 @@ l1:
@@ -2959,7 +2962,7 @@ l1:
* Compute replica identity tuple before entering the critical section so
* we don't PANIC upon a memory allocation failure.
*/
Expand All @@ -86,47 +86,47 @@ index 723e34e464..b2f845211d 100644

/*
* If this is the first possibly-multixact-able operation in the current
@@ -3013,6 +3016,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
@@ -3190,6 +3193,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
Bitmapset *id_attrs;
Bitmapset *interesting_attrs;
Bitmapset *modified_attrs;
+ Bitmapset *logged_old_attrs;
ItemId lp;
HeapTupleData oldtup;
HeapTuple heaptup;
@@ -3135,6 +3139,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
@@ -3351,6 +3355,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
modified_attrs = HeapDetermineColumnsInfo(relation, interesting_attrs,
id_attrs, &oldtup,
newtup, &id_has_external);
+ logged_old_attrs = HeapDetermineLogOldColumns(relation);

/*
* If we're not updating any "key" column, we can grab a weaker lock type.
@@ -3409,6 +3414,7 @@ l2:
@@ -3622,6 +3627,7 @@ l2:
bms_free(key_attrs);
bms_free(id_attrs);
bms_free(modified_attrs);
+ bms_free(logged_old_attrs);
bms_free(interesting_attrs);
return result;
}
@@ -3758,6 +3764,7 @@ l2:
@@ -3958,6 +3964,7 @@ l2:
old_key_tuple = ExtractReplicaIdentity(relation, &oldtup,
bms_overlap(modified_attrs, id_attrs) ||
id_has_external,
+ logged_old_attrs,
&old_key_copied);

/* NO EREPORT(ERROR) from here till changes are logged */
@@ -3924,6 +3931,7 @@ l2:
@@ -4107,6 +4114,7 @@ l2:
bms_free(key_attrs);
bms_free(id_attrs);
bms_free(modified_attrs);
+ bms_free(logged_old_attrs);
bms_free(interesting_attrs);

return TM_Ok;
@@ -4096,6 +4104,26 @@ heap_attr_equals(TupleDesc tupdesc, int attrnum, Datum value1, Datum value2,
@@ -4279,6 +4287,33 @@ heap_attr_equals(TupleDesc tupdesc, int attrnum, Datum value1, Datum value2,
}
}

Expand All @@ -138,6 +138,13 @@ index 723e34e464..b2f845211d 100644
+ TupleDesc tupdesc = RelationGetDescr(relation);
+ AttributeOpts *aopt;
+
+ /*
+ * Catalog relations are never sent by LR, no chance to use the delta_apply
+ * feature
+ */
+ if (IsCatalogRelation(relation))
+ return NULL;
+
+ for (attnum = 1; attnum <= tupdesc->natts; attnum++)
+ {
+ aopt = get_attribute_options(relation->rd_id, attnum);
Expand All @@ -153,15 +160,15 @@ index 723e34e464..b2f845211d 100644
/*
* Check which columns are being updated.
*
@@ -9051,6 +9079,7 @@ log_heap_new_cid(Relation relation, HeapTuple tup)
@@ -9069,6 +9104,7 @@ log_heap_new_cid(Relation relation, HeapTuple tup)
*/
static HeapTuple
ExtractReplicaIdentity(Relation relation, HeapTuple tp, bool key_required,
+ Bitmapset *logged_old_attrs,
bool *copy)
{
TupleDesc desc = RelationGetDescr(relation);
@@ -9083,13 +9112,16 @@ ExtractReplicaIdentity(Relation relation, HeapTuple tp, bool key_required,
@@ -9101,13 +9137,16 @@ ExtractReplicaIdentity(Relation relation, HeapTuple tp, bool key_required,
}

/* if the key isn't required and we're only logging the key, we're done */
Expand All @@ -180,7 +187,7 @@ index 723e34e464..b2f845211d 100644
* If there's no defined replica identity columns, treat as !key_required.
* (This case should not be reachable from heap_update, since that should
diff --git a/src/include/utils/attoptcache.h b/src/include/utils/attoptcache.h
index e4119b6aa2..6354a98157 100644
index ee37af95001..98b48a8fd89 100644
--- a/src/include/utils/attoptcache.h
+++ b/src/include/utils/attoptcache.h
@@ -21,6 +21,8 @@ typedef struct AttributeOpts
Expand All @@ -191,4 +198,4 @@ index e4119b6aa2..6354a98157 100644
+ Oid delta_apply_function;
} AttributeOpts;

extern AttributeOpts *get_attribute_options(Oid attrelid, int attnum);
extern AttributeOpts *get_attribute_options(Oid spcid, int attnum);
Loading
Loading