This is an automated email from the ASF dual-hosted git repository.
chenjinbao1989 pushed a commit to branch cbdb-postgres-merge
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
The following commit(s) were added to refs/heads/cbdb-postgres-merge by this
push:
new 1fa41def9a6 Fix compile errors for linking
1fa41def9a6 is described below
commit 1fa41def9a68d3cc8672375388cc41c8f41e193a
Author: Jinbao Chen <[email protected]>
AuthorDate: Wed Oct 8 14:20:34 2025 +0800
Fix compile errors for linking
---
src/backend/nodes/Makefile | 1 +
src/backend/storage/lmgr/lock.c | 96 +++++++++++++++++++++++++++++++++++++
src/backend/utils/adt/pgstatfuncs.c | 10 ++++
src/backend/utils/sort/tuplestore.c | 2 +-
src/include/catalog/pg_proc.dat | 12 -----
src/include/storage/buffile.h | 2 -
6 files changed, 108 insertions(+), 15 deletions(-)
diff --git a/src/backend/nodes/Makefile b/src/backend/nodes/Makefile
index 93dc5538c96..6111b2855cf 100644
--- a/src/backend/nodes/Makefile
+++ b/src/backend/nodes/Makefile
@@ -19,6 +19,7 @@ OBJS = \
extensible.o \
list.o \
makefuncs.o \
+ multibitmapset.o \
nodeFuncs.o \
nodes.o \
outfast.o \
diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c
index 8dbeda3facf..08f129ba1aa 100644
--- a/src/backend/storage/lmgr/lock.c
+++ b/src/backend/storage/lmgr/lock.c
@@ -3540,6 +3540,102 @@ LockRefindAndRelease(LockMethod lockMethodTable, PGPROC
*proc,
}
}
+/*
+ * Prepare for prepare, while we're still in a transaction.
+ *
+ * This marks LOCALLOCK objects on temporary tables, so that we can
+ * ignore them while writing the prepare record. Figuring out which
+ * tables are temporary requires catalog access, hence we must do this
+ * before we start actually preparing.
+ *
+ * If new locks are taken after this, they will be considered as
+ * not temp.
+ */
+void
+PrePrepare_Locks(void)
+{
+ HASH_SEQ_STATUS status;
+ LOCALLOCK *locallock;
+
+ /*
+ * Scan the local locks, and set the 'istemptable' flags.
+ */
+ hash_seq_init(&status, LockMethodLocalHash);
+ while ((locallock = (LOCALLOCK *) hash_seq_search(&status)) != NULL)
+ {
+ LOCALLOCKOWNER *lockOwners = locallock->lockOwners;
+ bool haveSessionLock;
+ bool haveXactLock;
+ int i;
+
+ locallock->istemptable = false;
+
+ /*
+ * Skip locks that would be ignored by AtPrepare_Locks() anyway.
+ *
+ * NOTE: these conditions should be kept in sync with
AtPrepare_Locks()!
+ */
+
+ /*
+ * Ignore VXID locks. We don't want those to be held by
prepared
+ * transactions, since they aren't meaningful after a restart.
+ */
+ if (locallock->tag.lock.locktag_type ==
LOCKTAG_VIRTUALTRANSACTION)
+ continue;
+
+ /* Ignore it if we don't actually hold the lock */
+ if (locallock->nLocks <= 0)
+ continue;
+
+ /* Scan to see whether we hold it at session or transaction
level */
+ haveSessionLock = haveXactLock = false;
+ for (i = locallock->numLockOwners - 1; i >= 0; i--)
+ {
+ if (lockOwners[i].owner == NULL)
+ haveSessionLock = true;
+ else
+ haveXactLock = true;
+ }
+
+ /* Ignore it if we have only session lock */
+ if (!haveXactLock)
+ continue;
+
+ /*
+ * If we have both session- and transaction-level locks, fail.
This
+ * should never happen with regular locks, since we only take
those at
+ * session level in some special operations like VACUUM. It's
+ * possible to hit this with advisory locks, though.
+ *
+ * It would be nice if we could keep the session hold and give
away
+ * the transactional hold to the prepared xact. However, that
would
+ * require two PROCLOCK objects, and we cannot be sure that
another
+ * PROCLOCK will be available when it comes time for
PostPrepare_Locks
+ * to do the deed. So for now, we error out while we can still
do so
+ * safely.
+ */
+ if (haveSessionLock)
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot PREPARE
while holding both session-level and transaction-level locks on the same
object")));
+
+ /* gp-change
+ *
+ * We allow 2PC commit transactions to include temp objects.
+ * After PREPARE we WILL NOT transfer locks on the temp objects
+ * into our 2PC record. Instead, we will keep them with the
proc which
+ * will be released at the end of the session.
+ *
+ * There doesn't seem to be any reason not to do this. Once
the txn
+ * is prepared, it will be committed or aborted regardless of
the state
+ * of the temp table. and quite possibly, the temp table will
be
+ * destroyed at the end of the session, while the transaction
will be
+ * committed from another session.
+ */
+ locallock->istemptable = LockTagIsTemp(&locallock->tag.lock);
+ }
+}
+
/*
* CheckForSessionAndXactLocks
* Check to see if transaction holds both session-level and
xact-level
diff --git a/src/backend/utils/adt/pgstatfuncs.c
b/src/backend/utils/adt/pgstatfuncs.c
index bb2b4db93db..f1c3e1f5866 100644
--- a/src/backend/utils/adt/pgstatfuncs.c
+++ b/src/backend/utils/adt/pgstatfuncs.c
@@ -1771,6 +1771,16 @@ pg_stat_get_snapshot_timestamp(PG_FUNCTION_ARGS)
PG_RETURN_TIMESTAMPTZ(ts);
}
+/* Discard the active statistics snapshot */
+Datum
+pg_stat_clear_snapshot(PG_FUNCTION_ARGS)
+{
+ pgstat_clear_snapshot();
+
+ PG_RETURN_VOID();
+}
+
+
/* Force statistics to be reported at the next occasion */
Datum
pg_stat_force_next_flush(PG_FUNCTION_ARGS)
diff --git a/src/backend/utils/sort/tuplestore.c
b/src/backend/utils/sort/tuplestore.c
index eda911a0851..48d76388d06 100644
--- a/src/backend/utils/sort/tuplestore.c
+++ b/src/backend/utils/sort/tuplestore.c
@@ -547,7 +547,7 @@ tuplestore_end(Tuplestorestate *state)
if (state->myfile)
BufFileClose(state->myfile);
if (state->share_status == TSHARE_WRITER)
- BufFileDeleteShared(state->fileset, state->shared_filename);
+ BufFileDeleteFileSet(&state->fileset->fs,
state->shared_filename, false);
if (state->work_set)
workfile_mgr_close_set(state->work_set);
if (state->shared_filename)
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 04bae2c659e..835c4848fc2 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -12197,18 +12197,6 @@
proname => 'interval_bound', proisstrict => 'f', prorettype =>
'timestamptz', proargtypes => 'timestamptz interval int4 timestamptz', prosrc
=> 'timestamptz_interval_bound_shift_reg' },
# Aggregate-related functions
-{ oid => 6031, descr => 'Statistics: Number of queries that executed in queue',
- proname => 'pg_stat_get_queue_num_exec', provolatile => 's', proparallel =>
'r', prorettype => 'int8', proargtypes => 'oid', prosrc =>
'pg_stat_get_queue_num_exec' },
-
-{ oid => 6032, descr => 'Statistics: Number of queries that waited in queue',
- proname => 'pg_stat_get_queue_num_wait', provolatile => 's', proparallel =>
'r', prorettype => 'int8', proargtypes => 'oid', prosrc =>
'pg_stat_get_queue_num_wait' },
-
-{ oid => 6033, descr => 'Statistics: Elapsed seconds for queries that executed
in queue',
- proname => 'pg_stat_get_queue_elapsed_exec', provolatile => 's',
proparallel => 'r', prorettype => 'int8', proargtypes => 'oid', prosrc =>
'pg_stat_get_queue_elapsed_exec' },
-
-{ oid => 6034, descr => 'Statistics: Elapsed seconds for queries that waited
in queue',
- proname => 'pg_stat_get_queue_elapsed_wait', provolatile => 's',
proparallel => 'r', prorettype => 'int8', proargtypes => 'oid', prosrc =>
'pg_stat_get_queue_elapsed_wait' },
-
{ oid => 6039, descr => 'Statistics: Cloudberry session id of backend',
proname => 'pg_stat_get_backend_session_id', provolatile => 's',
proparallel => 'r', prorettype => 'int4', proargtypes => 'int4', prosrc =>
'pg_stat_get_backend_session_id' },
diff --git a/src/include/storage/buffile.h b/src/include/storage/buffile.h
index 1accb0617cc..4c49e50814c 100644
--- a/src/include/storage/buffile.h
+++ b/src/include/storage/buffile.h
@@ -59,8 +59,6 @@ extern BufFile *BufFileCreateShared(SharedFileSet *fileset,
const char *name, st
extern void BufFileExportShared(BufFile *file);
extern BufFile *BufFileOpenShared(SharedFileSet *fileset, const char *name,
int mode);
-extern void BufFileDeleteShared(SharedFileSet *fileset, const char *name);
-extern void BufFileTruncateShared(BufFile *file, int fileno, off_t offset);
extern BufFile *BufFileCreateFileSet(FileSet *fileset, const char *name,
workfile_set *work_set);
extern void BufFileExportFileSet(BufFile *file);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]