Commit a77d34f0 authored by Bruce Momjian's avatar Bruce Momjian

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
parent bda45958
......@@ -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);
......
......@@ -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 \
......
......@@ -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
......@@ -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_ ));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment