From a77d34f0b8f02e8b24bb79792521f0b196b556f1 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 27 Aug 2002 04:00:28 +0000 Subject: [PATCH] This patch updates the lock listing code to use Joe Conway's new 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 | 20 ++++++++++++++++---- src/bin/initdb/initdb.sh | 19 +++++-------------- src/include/catalog/catversion.h | 4 ++-- src/include/catalog/pg_proc.h | 4 ++-- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/backend/utils/adt/lockfuncs.c b/src/backend/utils/adt/lockfuncs.c index 0b1933aad1..38e540e3c8 100644 --- a/src/backend/utils/adt/lockfuncs.c +++ b/src/backend/utils/adt/lockfuncs.c @@ -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); diff --git a/src/bin/initdb/initdb.sh b/src/bin/initdb/initdb.sh index f361d0ace7..33264050c8 100644 --- a/src/bin/initdb/initdb.sh +++ b/src/bin/initdb/initdb.sh @@ -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 \ diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 4656f2ee97..f122c835f3 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -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 diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 1e0c775b53..a1c8115717 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -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_ )); -- 2.40.0