0002-Change-type-of-plan-IDs-from-uint64-to-int64.patch
text/x-diff
Filename: 0002-Change-type-of-plan-IDs-from-uint64-to-int64.patch
Type: text/x-diff
Part: 1
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch 0002
Subject: Change type of plan IDs from uint64 to int64
| File | + | − |
|---|---|---|
| src/backend/tcop/postgres.c | 2 | 2 |
| src/backend/utils/activity/backend_status.c | 5 | 5 |
| src/include/nodes/plannodes.h | 1 | 1 |
| src/include/utils/backend_status.h | 3 | 3 |
From 3d3a7cc46fb6358c8fc501a7f35608bb9579c701 Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@paquier.xyz>
Date: Tue, 20 May 2025 15:29:39 +0900
Subject: [PATCH 2/2] Change type of plan IDs from uint64 to int64
---
src/include/nodes/plannodes.h | 2 +-
src/include/utils/backend_status.h | 6 +++---
src/backend/tcop/postgres.c | 4 ++--
src/backend/utils/activity/backend_status.c | 10 +++++-----
4 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
index 56cfdca074de..fdd3deb4f6d5 100644
--- a/src/include/nodes/plannodes.h
+++ b/src/include/nodes/plannodes.h
@@ -56,7 +56,7 @@ typedef struct PlannedStmt
int64 queryId;
/* plan identifier (can be set by plugins) */
- uint64 planId;
+ int64 planId;
/* is it insert|update|delete|merge RETURNING? */
bool hasReturning;
diff --git a/src/include/utils/backend_status.h b/src/include/utils/backend_status.h
index bbebe517501f..3016501ac059 100644
--- a/src/include/utils/backend_status.h
+++ b/src/include/utils/backend_status.h
@@ -173,7 +173,7 @@ typedef struct PgBackendStatus
int64 st_query_id;
/* plan identifier, optionally computed using planner_hook */
- uint64 st_plan_id;
+ int64 st_plan_id;
} PgBackendStatus;
@@ -322,7 +322,7 @@ extern void pgstat_clear_backend_activity_snapshot(void);
/* Activity reporting functions */
extern void pgstat_report_activity(BackendState state, const char *cmd_str);
extern void pgstat_report_query_id(int64 query_id, bool force);
-extern void pgstat_report_plan_id(uint64 plan_id, bool force);
+extern void pgstat_report_plan_id(int64 plan_id, bool force);
extern void pgstat_report_tempfile(size_t filesize);
extern void pgstat_report_appname(const char *appname);
extern void pgstat_report_xact_timestamp(TimestampTz tstamp);
@@ -330,7 +330,7 @@ extern const char *pgstat_get_backend_current_activity(int pid, bool checkUser);
extern const char *pgstat_get_crashed_backend_activity(int pid, char *buffer,
int buflen);
extern int64 pgstat_get_my_query_id(void);
-extern uint64 pgstat_get_my_plan_id(void);
+extern int64 pgstat_get_my_plan_id(void);
extern BackendType pgstat_get_backend_type_by_proc_number(ProcNumber procNumber);
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 7caf740d396c..2ed6b82c7c8f 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -2036,7 +2036,7 @@ exec_bind_message(StringInfo input_message)
{
PlannedStmt *plan = lfirst_node(PlannedStmt, lc);
- if (plan->planId != UINT64CONST(0))
+ if (plan->planId != INT64CONST(0))
{
pgstat_report_plan_id(plan->planId, false);
break;
@@ -2187,7 +2187,7 @@ exec_execute_message(const char *portal_name, long max_rows)
{
PlannedStmt *stmt = lfirst_node(PlannedStmt, lc);
- if (stmt->planId != UINT64CONST(0))
+ if (stmt->planId != INT64CONST(0))
{
pgstat_report_plan_id(stmt->planId, false);
break;
diff --git a/src/backend/utils/activity/backend_status.c b/src/backend/utils/activity/backend_status.c
index 9c2ed2cb9e0b..a290cc4c9750 100644
--- a/src/backend/utils/activity/backend_status.c
+++ b/src/backend/utils/activity/backend_status.c
@@ -321,7 +321,7 @@ pgstat_bestart_initial(void)
lbeentry.st_progress_command = PROGRESS_COMMAND_INVALID;
lbeentry.st_progress_command_target = InvalidOid;
lbeentry.st_query_id = INT64CONST(0);
- lbeentry.st_plan_id = UINT64CONST(0);
+ lbeentry.st_plan_id = INT64CONST(0);
/*
* we don't zero st_progress_param here to save cycles; nobody should
@@ -600,7 +600,7 @@ pgstat_report_activity(BackendState state, const char *cmd_str)
/* st_xact_start_timestamp and wait_event_info are also disabled */
beentry->st_xact_start_timestamp = 0;
beentry->st_query_id = INT64CONST(0);
- beentry->st_plan_id = UINT64CONST(0);
+ beentry->st_plan_id = INT64CONST(0);
proc->wait_event_info = 0;
PGSTAT_END_WRITE_ACTIVITY(beentry);
}
@@ -663,7 +663,7 @@ pgstat_report_activity(BackendState state, const char *cmd_str)
if (state == STATE_RUNNING)
{
beentry->st_query_id = INT64CONST(0);
- beentry->st_plan_id = UINT64CONST(0);
+ beentry->st_plan_id = INT64CONST(0);
}
if (cmd_str != NULL)
@@ -722,7 +722,7 @@ pgstat_report_query_id(int64 query_id, bool force)
* --------
*/
void
-pgstat_report_plan_id(uint64 plan_id, bool force)
+pgstat_report_plan_id(int64 plan_id, bool force)
{
volatile PgBackendStatus *beentry = MyBEEntry;
@@ -1154,7 +1154,7 @@ pgstat_get_my_query_id(void)
*
* Return current backend's plan identifier.
*/
-uint64
+int64
pgstat_get_my_plan_id(void)
{
if (!MyBEEntry)
--
2.49.0