aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/sequence.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2024-08-30 08:49:24 +0900
committerMichael Paquier <michael@paquier.xyz>2024-08-30 08:49:24 +0900
commita83a944e9fdd573802c82d961126ba07bfb65f98 (patch)
tree0d72e09dd3d9acc8b40537b064da18d49d787b00 /src/backend/commands/sequence.c
parent43f2e7634d838b39fd3fa3aaddb6964392d98312 (diff)
downloadpostgresql-a83a944e9fdd573802c82d961126ba07bfb65f98.tar.gz
postgresql-a83a944e9fdd573802c82d961126ba07bfb65f98.zip
Rename pg_sequence_read_tuple() to pg_get_sequence_data()
This commit removes log_cnt from the tuple returned by the SQL function. This field is an internal counter that tracks when a WAL record should be generated for a sequence, and it is reset each time the sequence is restored or recovered. It is not necessary to rebuild the sequence DDL commands for pg_dump and pg_upgrade where this function is used. The field can still be queried with a scan of the "table" created under-the-hood for a sequence. Issue noticed while hacking on a feature that can rely on this new function rather than pg_sequence_last_value(), aimed at making sequence computation more easily pluggable. Bump catalog version. Reviewed-by: Nathan Bossart Discussion: https://postgr.es/m/Zsvka3r-y2ZoXAdH@paquier.xyz
Diffstat (limited to 'src/backend/commands/sequence.c')
-rw-r--r--src/backend/commands/sequence.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index 8c1131f0202..b37fd688d34 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -1781,23 +1781,22 @@ pg_sequence_parameters(PG_FUNCTION_ARGS)
* without needing to individually query each sequence relation.
*/
Datum
-pg_sequence_read_tuple(PG_FUNCTION_ARGS)
+pg_get_sequence_data(PG_FUNCTION_ARGS)
{
+#define PG_GET_SEQUENCE_DATA_COLS 2
Oid relid = PG_GETARG_OID(0);
SeqTable elm;
Relation seqrel;
- Datum values[SEQ_COL_LASTCOL] = {0};
- bool isnull[SEQ_COL_LASTCOL] = {0};
+ Datum values[PG_GET_SEQUENCE_DATA_COLS] = {0};
+ bool isnull[PG_GET_SEQUENCE_DATA_COLS] = {0};
TupleDesc resultTupleDesc;
HeapTuple resultHeapTuple;
Datum result;
- resultTupleDesc = CreateTemplateTupleDesc(SEQ_COL_LASTCOL);
+ resultTupleDesc = CreateTemplateTupleDesc(PG_GET_SEQUENCE_DATA_COLS);
TupleDescInitEntry(resultTupleDesc, (AttrNumber) 1, "last_value",
INT8OID, -1, 0);
- TupleDescInitEntry(resultTupleDesc, (AttrNumber) 2, "log_cnt",
- INT8OID, -1, 0);
- TupleDescInitEntry(resultTupleDesc, (AttrNumber) 3, "is_called",
+ TupleDescInitEntry(resultTupleDesc, (AttrNumber) 2, "is_called",
BOOLOID, -1, 0);
resultTupleDesc = BlessTupleDesc(resultTupleDesc);
@@ -1818,8 +1817,7 @@ pg_sequence_read_tuple(PG_FUNCTION_ARGS)
seq = read_seq_tuple(seqrel, &buf, &seqtuple);
values[0] = Int64GetDatum(seq->last_value);
- values[1] = Int64GetDatum(seq->log_cnt);
- values[2] = BoolGetDatum(seq->is_called);
+ values[1] = BoolGetDatum(seq->is_called);
UnlockReleaseBuffer(buf);
}
@@ -1831,6 +1829,7 @@ pg_sequence_read_tuple(PG_FUNCTION_ARGS)
resultHeapTuple = heap_form_tuple(resultTupleDesc, values, isnull);
result = HeapTupleGetDatum(resultHeapTuple);
PG_RETURN_DATUM(result);
+#undef PG_GET_SEQUENCE_DATA_COLS
}