aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2023-08-12 10:44:15 +0900
committerMichael Paquier <michael@paquier.xyz>2023-08-12 10:44:15 +0900
commit638d42a3c52081cf4882520f0622161bad69b40f (patch)
tree397a7b97a73df3a82476b948374fa115028f278b /src
parent5dc456b7dda4f7d0d7735b066607c190c74d174a (diff)
downloadpostgresql-638d42a3c52081cf4882520f0622161bad69b40f.tar.gz
postgresql-638d42a3c52081cf4882520f0622161bad69b40f.zip
Show GIDs of two-phase commit commands as constants in pg_stat_statements
This relies on the "location" field added to TransactionStmt in 31de7e6, now applied to the "gid" field used by 2PC commands. These commands are now reported like: COMMIT PREPARED $1 PREPARE TRANSACTION $1 ROLLBACK PREPARED $1 Applying constants for these commands is a huge advantage for workloads that rely a lot on 2PC commands with different GIDs. Some tests are added to track the new behavior. Reviewed-by: Julien Rouhaud Discussion: https://postgr.es/m/ZMhT9kNtJJsHw6jK@paquier.xyz
Diffstat (limited to 'src')
-rw-r--r--src/backend/parser/gram.y6
-rw-r--r--src/include/nodes/parsenodes.h3
2 files changed, 5 insertions, 4 deletions
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 15ece871a01..b3bdf947b6e 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -10924,7 +10924,7 @@ TransactionStmt:
n->kind = TRANS_STMT_PREPARE;
n->gid = $3;
- n->location = -1;
+ n->location = @3;
$$ = (Node *) n;
}
| COMMIT PREPARED Sconst
@@ -10933,7 +10933,7 @@ TransactionStmt:
n->kind = TRANS_STMT_COMMIT_PREPARED;
n->gid = $3;
- n->location = -1;
+ n->location = @3;
$$ = (Node *) n;
}
| ROLLBACK PREPARED Sconst
@@ -10942,7 +10942,7 @@ TransactionStmt:
n->kind = TRANS_STMT_ROLLBACK_PREPARED;
n->gid = $3;
- n->location = -1;
+ n->location = @3;
$$ = (Node *) n;
}
;
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index fe003ded504..25653483032 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -3540,7 +3540,8 @@ typedef struct TransactionStmt
List *options; /* for BEGIN/START commands */
/* for savepoint commands */
char *savepoint_name pg_node_attr(query_jumble_ignore);
- char *gid; /* for two-phase-commit related commands */
+ /* for two-phase-commit related commands */
+ char *gid pg_node_attr(query_jumble_ignore);
bool chain; /* AND CHAIN option */
/* token location, or -1 if unknown */
int location pg_node_attr(query_jumble_location);