summaryrefslogtreecommitdiff
path: root/src/include/commands
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2006-01-08 07:00:27 +0000
committerNeil Conway <neilc@samurai.com>2006-01-08 07:00:27 +0000
commit44b928e876b06ba6801ec2c60d2cd914a2185c5d (patch)
treee15760f3f86aae4f3e782954b699444e2a1f4bc0 /src/include/commands
parentafa8f1971ae57b4d5091f77717f666d365545867 (diff)
downloadpostgresql-44b928e876b06ba6801ec2c60d2cd914a2185c5d.tar.gz
Add a new system view, pg_prepared_statements, that can be used to
access information about the prepared statements that are available in the current session. Original patch from Joachim Wieland, various improvements by Neil Conway. The "statement" column of the view contains the literal query string sent by the client, without any rewriting or pretty printing. This means that prepared statements created via SQL will be prefixed with "PREPARE ... AS ", whereas those prepared via the FE/BE protocol will not. That is unfortunate, but discussion on -patches did not yield an efficient way to improve this, and there is some merit in returning exactly what the client sent to the backend. Catalog version bumped, regression tests updated.
Diffstat (limited to 'src/include/commands')
-rw-r--r--src/include/commands/prepare.h22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/include/commands/prepare.h b/src/include/commands/prepare.h
index 50767740cc..503f27e4bc 100644
--- a/src/include/commands/prepare.h
+++ b/src/include/commands/prepare.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 2002-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/include/commands/prepare.h,v 1.16 2005/12/14 17:06:28 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/commands/prepare.h,v 1.17 2006/01/08 07:00:26 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -30,13 +30,16 @@
typedef struct
{
/* dynahash.c requires key to be first field */
- char stmt_name[NAMEDATALEN];
- char *query_string; /* text of query, or NULL */
- const char *commandTag; /* command tag (a constant!), or NULL */
- List *query_list; /* list of queries */
- List *plan_list; /* list of plans */
- List *argtype_list; /* list of parameter type OIDs */
- MemoryContext context; /* context containing this query */
+ char stmt_name[NAMEDATALEN];
+ char *query_string; /* text of query, or NULL */
+ const char *commandTag; /* command tag (a constant!), or NULL */
+ List *query_list; /* list of queries, rewritten */
+ List *plan_list; /* list of plans */
+ List *argtype_list; /* list of parameter type OIDs */
+ TimestampTz prepare_time; /* the time when the stmt was prepared */
+ bool from_sql; /* stmt prepared via SQL, not
+ * FE/BE protocol? */
+ MemoryContext context; /* context containing this query */
} PreparedStatement;
@@ -54,7 +57,8 @@ extern void StorePreparedStatement(const char *stmt_name,
const char *commandTag,
List *query_list,
List *plan_list,
- List *argtype_list);
+ List *argtype_list,
+ bool from_sql);
extern PreparedStatement *FetchPreparedStatement(const char *stmt_name,
bool throwError);
extern void DropPreparedStatement(const char *stmt_name, bool showError);