]> granicus.if.org Git - postgresql/commitdiff
This patch updates the lock listing code to use Joe Conway's new
authorBruce Momjian <bruce@momjian.us>
Tue, 27 Aug 2002 04:00:28 +0000 (04:00 +0000)
committerBruce Momjian <bruce@momjian.us>
Tue, 27 Aug 2002 04:00:28 +0000 (04:00 +0000)
anonymous return type SRF code. It gets rid of the superflous
'pg_locks_result' that Bruce/Tom had commented on. Otherwise, no
changes in functionality.

Neil Conway

src/backend/utils/adt/lockfuncs.c
src/bin/initdb/initdb.sh
src/include/catalog/catversion.h
src/include/catalog/pg_proc.h

index 0b1933aad1c8f927f970928b5ec965e835c0e0d9..38e540e3c85f161d2731682955c87b827d7b21ee 100644 (file)
@@ -5,23 +5,24 @@
  * Copyright (c) 2002, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *             $Header: /cvsroot/pgsql/src/backend/utils/adt/lockfuncs.c,v 1.1 2002/08/17 13:11:43 momjian Exp $
+ *             $Header: /cvsroot/pgsql/src/backend/utils/adt/lockfuncs.c,v 1.2 2002/08/27 04:00:28 momjian Exp $
  */
 
 #include "postgres.h"
 #include "fmgr.h"
 #include "funcapi.h"
+#include "catalog/pg_type.h"
 #include "storage/lmgr.h"
 #include "storage/lock.h"
 #include "storage/lwlock.h"
 #include "storage/proc.h"
 
-Datum lock_status_srf(PG_FUNCTION_ARGS);
+Datum pg_lock_status(PG_FUNCTION_ARGS);
 
 static int next_lock(int locks[]);
 
 Datum
-lock_status_srf(PG_FUNCTION_ARGS)
+pg_lock_status(PG_FUNCTION_ARGS)
 {
        FuncCallContext         *funccxt;
        LockData                        *lockData;
@@ -32,7 +33,18 @@ lock_status_srf(PG_FUNCTION_ARGS)
                TupleDesc               tupdesc;
 
                funccxt = SRF_FIRSTCALL_INIT();
-               tupdesc = RelationNameGetTupleDesc("pg_catalog.pg_locks_result");
+               tupdesc = CreateTemplateTupleDesc(5, WITHOUTOID);
+               TupleDescInitEntry(tupdesc, (AttrNumber) 1, "relation",
+                                                  OIDOID, -1, 0, false);
+               TupleDescInitEntry(tupdesc, (AttrNumber) 2, "database",
+                                                  OIDOID, -1, 0, false);
+               TupleDescInitEntry(tupdesc, (AttrNumber) 3, "backendpid",
+                                                  INT4OID, -1, 0, false);
+               TupleDescInitEntry(tupdesc, (AttrNumber) 4, "mode",
+                                                  TEXTOID, -1, 0, false);
+               TupleDescInitEntry(tupdesc, (AttrNumber) 5, "isgranted",
+                                                  BOOLOID, -1, 0, false);
+
                funccxt->slot = TupleDescGetSlot(tupdesc);
                funccxt->attinmeta = TupleDescGetAttInMetadata(tupdesc);
 
index f361d0ace75e4a0caf0283d10f42087c1b815d01..33264050c8edfbeec3df485d58f1d4a2f0ba13f1 100644 (file)
@@ -27,7 +27,7 @@
 # Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.168 2002/08/17 15:12:07 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.169 2002/08/27 04:00:28 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -977,20 +977,11 @@ CREATE VIEW pg_stat_database AS \
             pg_stat_get_db_blocks_hit(D.oid) AS blks_hit \
     FROM pg_database D;
 
-CREATE VIEW pg_locks_result AS \
+CREATE VIEW pg_locks AS \
        SELECT \
-                       ''::oid AS relation, \
-                       ''::oid AS database, \
-                       ''::int4 AS backendpid, \
-                       ''::text AS mode, \
-                       NULL::bool AS isgranted;
-
-UPDATE pg_proc SET \
-       prorettype = (SELECT oid FROM pg_type \
-               WHERE typname = 'pg_locks_result') \
-       WHERE proname = 'pg_lock_status';
-
-CREATE VIEW pg_locks AS SELECT * FROM pg_lock_status();
+               L.relation, L.database, L.backendpid, L.mode, L.isgranted \
+       FROM pg_lock_status() AS L(relation oid, database oid, \
+       backendpid int4, mode text, isgranted boolean);
 
 CREATE VIEW pg_settings AS \
     SELECT \
index 4656f2ee97bb27ebf5aff3181a0212c6b93d46b9..f122c835f38c7e73e5755d27916f21a5a143f951 100644 (file)
@@ -37,7 +37,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: catversion.h,v 1.153 2002/08/26 17:53:59 tgl Exp $
+ * $Id: catversion.h,v 1.154 2002/08/27 04:00:28 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -53,6 +53,6 @@
  */
 
 /*                                                     yyyymmddN */
-#define CATALOG_VERSION_NO     200208251
+#define CATALOG_VERSION_NO     200208271
 
 #endif
index 1e0c775b5373cce49c3977f512ff7621235e8d2a..a1c8115717fe5f55d14e433afec738527714ee9e 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_proc.h,v 1.265 2002/08/26 17:53:59 tgl Exp $
+ * $Id: pg_proc.h,v 1.266 2002/08/27 04:00:28 momjian Exp $
  *
  * NOTES
  *       The script catalog/genbki.sh reads this file and generates .bki
@@ -2902,7 +2902,7 @@ DATA(insert OID = 2078 (  set_config              PGNSP PGUID 12 f f f f v 3 25 "25 25 16" s
 DESCR("SET X as a function");
 DATA(insert OID = 2084 (  pg_show_all_settings PGNSP PGUID 12 f f t t s 0 2249 "" show_all_settings - _null_ ));
 DESCR("SHOW ALL as a function");
-DATA(insert OID = 1371 (  pg_lock_status   PGNSP PGUID 12 f f f t v 0 0 "" lock_status_srf - _null_ ));
+DATA(insert OID = 1371 (  pg_lock_status   PGNSP PGUID 12 f f f t v 0 2249 "" pg_lock_status - _null_ ));
 DESCR("view system lock information");
 
 DATA(insert OID = 2079 (  pg_table_is_visible          PGNSP PGUID 12 f f t f s 1 16 "26"  pg_table_is_visible - _null_ ));