diff options
author | Neil Conway | 2006-01-08 07:00:27 +0000 |
---|---|---|
committer | Neil Conway | 2006-01-08 07:00:27 +0000 |
commit | 44b928e876b06ba6801ec2c60d2cd914a2185c5d (patch) | |
tree | e15760f3f86aae4f3e782954b699444e2a1f4bc0 /src/include | |
parent | afa8f1971ae57b4d5091f77717f666d365545867 (diff) |
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')
-rw-r--r-- | src/include/catalog/catversion.h | 4 | ||||
-rw-r--r-- | src/include/catalog/pg_proc.h | 4 | ||||
-rw-r--r-- | src/include/catalog/pg_type.h | 3 | ||||
-rw-r--r-- | src/include/commands/prepare.h | 22 | ||||
-rw-r--r-- | src/include/utils/builtins.h | 5 |
5 files changed, 24 insertions, 14 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index a7bad3dfd9..6eb5f72d9f 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.308 2005/12/28 01:30:01 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.309 2006/01/08 07:00:25 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200512271 +#define CATALOG_VERSION_NO 200601081 #endif diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 824f7a3fba..7b78e78fcc 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.389 2005/11/17 22:14:54 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.390 2006/01/08 07:00:25 neilc Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -3617,6 +3617,8 @@ DATA(insert OID = 2508 ( pg_get_constraintdef PGNSP PGUID 12 f f t f s 2 25 "26 DESCR("constraint description with pretty-print option"); DATA(insert OID = 2509 ( pg_get_expr PGNSP PGUID 12 f f t f s 3 25 "25 26 16" _null_ _null_ _null_ pg_get_expr_ext - _null_ )); DESCR("deparse an encoded expression with pretty-print option"); +DATA(insert OID = 2510 ( pg_prepared_statement PGNSP PGUID 12 f f t t s 0 2249 "" _null_ _null_ _null_ pg_prepared_statement - _null_ )); +DESCR("get the prepared statements for this session"); /* non-persistent series generator */ DATA(insert OID = 1066 ( generate_series PGNSP PGUID 12 f f t t v 3 23 "23 23 23" _null_ _null_ _null_ generate_series_step_int4 - _null_ )); diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h index 4b7b7c2652..c6ca59c87e 100644 --- a/src/include/catalog/pg_type.h +++ b/src/include/catalog/pg_type.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.167 2005/11/22 18:17:30 momjian Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.168 2006/01/08 07:00:26 neilc Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -406,6 +406,7 @@ DATA(insert OID = 1007 ( _int4 PGNSP PGUID -1 f b t \054 0 23 array_in array_ DATA(insert OID = 1008 ( _regproc PGNSP PGUID -1 f b t \054 0 24 array_in array_out array_recv array_send - i x f 0 -1 0 _null_ _null_ )); DATA(insert OID = 1009 ( _text PGNSP PGUID -1 f b t \054 0 25 array_in array_out array_recv array_send - i x f 0 -1 0 _null_ _null_ )); DATA(insert OID = 1028 ( _oid PGNSP PGUID -1 f b t \054 0 26 array_in array_out array_recv array_send - i x f 0 -1 0 _null_ _null_ )); +#define OIDARRAYOID 1028 DATA(insert OID = 1010 ( _tid PGNSP PGUID -1 f b t \054 0 27 array_in array_out array_recv array_send - i x f 0 -1 0 _null_ _null_ )); DATA(insert OID = 1011 ( _xid PGNSP PGUID -1 f b t \054 0 28 array_in array_out array_recv array_send - i x f 0 -1 0 _null_ _null_ )); DATA(insert OID = 1012 ( _cid PGNSP PGUID -1 f b t \054 0 29 array_in array_out array_recv array_send - i x f 0 -1 0 _null_ _null_ )); 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); diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index 4d1349917c..97fbfdc341 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.268 2005/11/22 18:17:32 momjian Exp $ + * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.269 2006/01/08 07:00:26 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -861,4 +861,7 @@ extern Datum pg_prepared_xact(PG_FUNCTION_ARGS); /* catalog/pg_conversion.c */ extern Datum pg_convert_using(PG_FUNCTION_ARGS); +/* commands/prepare.c */ +extern Datum pg_prepared_statement(PG_FUNCTION_ARGS); + #endif /* BUILTINS_H */ |