aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2006-01-16 18:15:31 +0000
committerNeil Conway <neilc@samurai.com>2006-01-16 18:15:31 +0000
commitb06e6f1a9a8cdae98654eb984cd3a190e2b08a3d (patch)
treec1bf2f612e788529d7de366d550c264db9431253 /src
parent1ce4c9e9b4375886fb00f1c039617215f214d9f2 (diff)
downloadpostgresql-b06e6f1a9a8cdae98654eb984cd3a190e2b08a3d.tar.gz
postgresql-b06e6f1a9a8cdae98654eb984cd3a190e2b08a3d.zip
Change the parameter_types column of the pg_prepared_statements to be
an array of regtype, rather than an array of OIDs. This is likely to be more useful to user, and the type OID can easily be obtained by casting a regtype value to OID. Per suggestion from Tom. Update the documentation and regression tests, and bump the catversion.
Diffstat (limited to 'src')
-rw-r--r--src/backend/catalog/system_views.sql4
-rw-r--r--src/backend/commands/prepare.c41
-rw-r--r--src/include/catalog/catversion.h4
-rw-r--r--src/include/catalog/pg_type.h4
-rw-r--r--src/test/regress/expected/prepare.out14
-rw-r--r--src/test/regress/expected/rules.out2
6 files changed, 38 insertions, 31 deletions
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index a186c33b444..c44e9ed72f1 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -3,7 +3,7 @@
*
* Copyright (c) 1996-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.23 2006/01/08 07:00:25 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.24 2006/01/16 18:15:30 neilc Exp $
*/
CREATE VIEW pg_roles AS
@@ -160,7 +160,7 @@ CREATE VIEW pg_prepared_statements AS
SELECT P.name, P.statement, P.prepare_time, P.parameter_types, P.from_sql
FROM pg_prepared_statement() AS P
(name text, statement text, prepare_time timestamptz,
- parameter_types oid[], from_sql boolean);
+ parameter_types regtype[], from_sql boolean);
CREATE VIEW pg_settings AS
SELECT *
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c
index ccf8c297b21..f523984e5a8 100644
--- a/src/backend/commands/prepare.c
+++ b/src/backend/commands/prepare.c
@@ -10,7 +10,7 @@
* Copyright (c) 2002-2005, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.45 2006/01/08 07:00:25 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.46 2006/01/16 18:15:30 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -45,7 +45,7 @@ static HTAB *prepared_queries = NULL;
static void InitQueryHashTable(void);
static ParamListInfo EvaluateParams(EState *estate,
List *params, List *argtypes);
-static Datum build_oid_array(List *oid_list);
+static Datum build_regtype_array(List *oid_list);
/*
* Implements the 'PREPARE' utility statement.
@@ -674,7 +674,7 @@ ExplainExecuteQuery(ExplainStmt *stmt, ParamListInfo params,
/*
* This set returning function reads all the prepared statements and
- * returns a set of (name, statement, prepare_time, param_types).
+ * returns a set of (name, statement, prepare_time, param_types, from_sql).
*/
Datum
pg_prepared_statement(PG_FUNCTION_ARGS)
@@ -721,7 +721,7 @@ pg_prepared_statement(PG_FUNCTION_ARGS)
TupleDescInitEntry(tupdesc, (AttrNumber) 3, "prepare_time",
TIMESTAMPTZOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 4, "parameter_types",
- OIDARRAYOID, -1, 0);
+ REGTYPEARRAYOID, -1, 0);
TupleDescInitEntry(tupdesc, (AttrNumber) 5, "from_sql",
BOOLOID, -1, 0);
@@ -757,7 +757,7 @@ pg_prepared_statement(PG_FUNCTION_ARGS)
CStringGetDatum(prep_stmt->query_string));
values[2] = TimestampTzGetDatum(prep_stmt->prepare_time);
- values[3] = build_oid_array(prep_stmt->argtype_list);
+ values[3] = build_regtype_array(prep_stmt->argtype_list);
values[4] = BoolGetDatum(prep_stmt->from_sql);
tuple = heap_form_tuple(funcctx->tuple_desc, values, nulls);
@@ -770,26 +770,33 @@ pg_prepared_statement(PG_FUNCTION_ARGS)
/*
* This utility function takes a List of Oids, and returns a Datum
- * pointing to a Postgres array containing those OIDs. The empty list
- * is returned as a zero-element array, not NULL.
+ * pointing to a one-dimensional Postgres array of regtypes. The empty
+ * list is returned as a zero-element array, not NULL.
*/
static Datum
-build_oid_array(List *oid_list)
+build_regtype_array(List *oid_list)
{
- ListCell *lc;
- int len;
- int i;
- Datum *tmp_ary;
- ArrayType *ary;
+ ListCell *lc;
+ int len;
+ int i;
+ Datum *tmp_ary;
+ ArrayType *result;
len = list_length(oid_list);
tmp_ary = (Datum *) palloc(len * sizeof(Datum));
i = 0;
foreach(lc, oid_list)
- tmp_ary[i++] = ObjectIdGetDatum(lfirst_oid(lc));
+ {
+ Oid oid;
+ Datum oid_str;
+
+ oid = lfirst_oid(lc);
+ oid_str = DirectFunctionCall1(oidout, ObjectIdGetDatum(oid));
+ tmp_ary[i++] = DirectFunctionCall1(regtypein, oid_str);
+ }
- /* XXX: this hardcodes assumptions about the OID type... */
- ary = construct_array(tmp_ary, len, OIDOID, sizeof(Oid), true, 'i');
- return PointerGetDatum(ary);
+ /* XXX: this hardcodes assumptions about the regtype type */
+ result = construct_array(tmp_ary, len, REGTYPEOID, 4, true, 'i');
+ return PointerGetDatum(result);
}
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 258a9956f4a..b844196c4ff 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.310 2006/01/11 20:12:39 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.311 2006/01/16 18:15:30 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 200601111
+#define CATALOG_VERSION_NO 200601161
#endif
diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h
index c6ca59c87e2..dfaa69eca52 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.168 2006/01/08 07:00:26 neilc Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.169 2006/01/16 18:15:30 neilc Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@@ -406,7 +406,6 @@ 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_ ));
@@ -517,6 +516,7 @@ DATA(insert OID = 2208 ( _regoper PGNSP PGUID -1 f b t \054 0 2203 array_in a
DATA(insert OID = 2209 ( _regoperator PGNSP PGUID -1 f b t \054 0 2204 array_in array_out array_recv array_send - i x f 0 -1 0 _null_ _null_ ));
DATA(insert OID = 2210 ( _regclass PGNSP PGUID -1 f b t \054 0 2205 array_in array_out array_recv array_send - i x f 0 -1 0 _null_ _null_ ));
DATA(insert OID = 2211 ( _regtype PGNSP PGUID -1 f b t \054 0 2206 array_in array_out array_recv array_send - i x f 0 -1 0 _null_ _null_ ));
+#define REGTYPEARRAYOID 2211
/*
* pseudo-types
diff --git a/src/test/regress/expected/prepare.out b/src/test/regress/expected/prepare.out
index f7d1a758149..3532953f552 100644
--- a/src/test/regress/expected/prepare.out
+++ b/src/test/regress/expected/prepare.out
@@ -148,19 +148,19 @@ PREPARE q7(unknown) AS
SELECT * FROM road WHERE thepath = $1;
SELECT name, statement, parameter_types FROM pg_prepared_statements
ORDER BY name;
- name | statement | parameter_types
-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------
+ name | statement | parameter_types
+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------
q2 | PREPARE q2(text) AS
SELECT datname, datistemplate, datallowconn
- FROM pg_database WHERE datname = $1; | {25}
+ FROM pg_database WHERE datname = $1; | {text}
q3 | PREPARE q3(text, int, float, boolean, oid, smallint) AS
SELECT * FROM tenk1 WHERE string4 = $1 AND (four = $2 OR
- ten = $3::bigint OR true = $4 OR oid = $5 OR odd = $6::int); | {25,23,701,16,26,21}
+ ten = $3::bigint OR true = $4 OR oid = $5 OR odd = $6::int); | {text,integer,"double precision",boolean,oid,smallint}
q5 | PREPARE q5(int, text) AS
- SELECT * FROM tenk1 WHERE unique1 = $1 OR stringu1 = $2; | {23,25}
+ SELECT * FROM tenk1 WHERE unique1 = $1 OR stringu1 = $2; | {integer,text}
q6 | PREPARE q6 AS
- SELECT * FROM tenk1 WHERE unique1 = $1 AND stringu1 = $2; | {23,19}
+ SELECT * FROM tenk1 WHERE unique1 = $1 AND stringu1 = $2; | {integer,name}
q7 | PREPARE q7(unknown) AS
- SELECT * FROM road WHERE thepath = $1; | {602}
+ SELECT * FROM road WHERE thepath = $1; | {path}
(5 rows)
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index 67616b73335..63c06ec75ac 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -1280,7 +1280,7 @@ SELECT viewname, definition FROM pg_views WHERE schemaname <> 'information_schem
pg_group | SELECT pg_authid.rolname AS groname, pg_authid.oid AS grosysid, ARRAY(SELECT pg_auth_members.member FROM pg_auth_members WHERE (pg_auth_members.roleid = pg_authid.oid)) AS grolist FROM pg_authid WHERE (NOT pg_authid.rolcanlogin);
pg_indexes | SELECT n.nspname AS schemaname, c.relname AS tablename, i.relname AS indexname, t.spcname AS "tablespace", pg_get_indexdef(i.oid) AS indexdef FROM ((((pg_index x JOIN pg_class c ON ((c.oid = x.indrelid))) JOIN pg_class i ON ((i.oid = x.indexrelid))) LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) LEFT JOIN pg_tablespace t ON ((t.oid = i.reltablespace))) WHERE ((c.relkind = 'r'::"char") AND (i.relkind = 'i'::"char"));
pg_locks | SELECT l.locktype, l."database", l.relation, l.page, l.tuple, l.transactionid, l.classid, l.objid, l.objsubid, l."transaction", l.pid, l."mode", l."granted" FROM pg_lock_status() l(locktype text, "database" oid, relation oid, page integer, tuple smallint, transactionid xid, classid oid, objid oid, objsubid smallint, "transaction" xid, pid integer, "mode" text, "granted" boolean);
- pg_prepared_statements | SELECT p.name, p."statement", p.prepare_time, p.parameter_types, p.from_sql FROM pg_prepared_statement() p(name text, "statement" text, prepare_time timestamp with time zone, parameter_types oid[], from_sql boolean);
+ pg_prepared_statements | SELECT p.name, p."statement", p.prepare_time, p.parameter_types, p.from_sql FROM pg_prepared_statement() p(name text, "statement" text, prepare_time timestamp with time zone, parameter_types regtype[], from_sql boolean);
pg_prepared_xacts | SELECT p."transaction", p.gid, p."prepared", u.rolname AS "owner", d.datname AS "database" FROM ((pg_prepared_xact() p("transaction" xid, gid text, "prepared" timestamp with time zone, ownerid oid, dbid oid) LEFT JOIN pg_authid u ON ((p.ownerid = u.oid))) LEFT JOIN pg_database d ON ((p.dbid = d.oid)));
pg_roles | SELECT pg_authid.rolname, pg_authid.rolsuper, pg_authid.rolinherit, pg_authid.rolcreaterole, pg_authid.rolcreatedb, pg_authid.rolcatupdate, pg_authid.rolcanlogin, pg_authid.rolconnlimit, '********'::text AS rolpassword, pg_authid.rolvaliduntil, pg_authid.rolconfig, pg_authid.oid FROM pg_authid;
pg_rules | SELECT n.nspname AS schemaname, c.relname AS tablename, r.rulename, pg_get_ruledef(r.oid) AS definition FROM ((pg_rewrite r JOIN pg_class c ON ((c.oid = r.ev_class))) LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) WHERE (r.rulename <> '_RETURN'::name);