Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita77d34f

Browse files
committed
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, nochanges in functionality.Neil Conway
1 parentbda4595 commita77d34f

File tree

4 files changed

+25
-22
lines changed

4 files changed

+25
-22
lines changed

‎src/backend/utils/adt/lockfuncs.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,24 @@
55
* Copyright (c) 2002, PostgreSQL Global Development Group
66
*
77
* IDENTIFICATION
8-
*$Header: /cvsroot/pgsql/src/backend/utils/adt/lockfuncs.c,v 1.1 2002/08/17 13:11:43 momjian Exp $
8+
*$Header: /cvsroot/pgsql/src/backend/utils/adt/lockfuncs.c,v 1.2 2002/08/27 04:00:28 momjian Exp $
99
*/
1010

1111
#include"postgres.h"
1212
#include"fmgr.h"
1313
#include"funcapi.h"
14+
#include"catalog/pg_type.h"
1415
#include"storage/lmgr.h"
1516
#include"storage/lock.h"
1617
#include"storage/lwlock.h"
1718
#include"storage/proc.h"
1819

19-
Datumlock_status_srf(PG_FUNCTION_ARGS);
20+
Datumpg_lock_status(PG_FUNCTION_ARGS);
2021

2122
staticintnext_lock(intlocks[]);
2223

2324
Datum
24-
lock_status_srf(PG_FUNCTION_ARGS)
25+
pg_lock_status(PG_FUNCTION_ARGS)
2526
{
2627
FuncCallContext*funccxt;
2728
LockData*lockData;
@@ -32,7 +33,18 @@ lock_status_srf(PG_FUNCTION_ARGS)
3233
TupleDesctupdesc;
3334

3435
funccxt=SRF_FIRSTCALL_INIT();
35-
tupdesc=RelationNameGetTupleDesc("pg_catalog.pg_locks_result");
36+
tupdesc=CreateTemplateTupleDesc(5,WITHOUTOID);
37+
TupleDescInitEntry(tupdesc, (AttrNumber)1,"relation",
38+
OIDOID,-1,0, false);
39+
TupleDescInitEntry(tupdesc, (AttrNumber)2,"database",
40+
OIDOID,-1,0, false);
41+
TupleDescInitEntry(tupdesc, (AttrNumber)3,"backendpid",
42+
INT4OID,-1,0, false);
43+
TupleDescInitEntry(tupdesc, (AttrNumber)4,"mode",
44+
TEXTOID,-1,0, false);
45+
TupleDescInitEntry(tupdesc, (AttrNumber)5,"isgranted",
46+
BOOLOID,-1,0, false);
47+
3648
funccxt->slot=TupleDescGetSlot(tupdesc);
3749
funccxt->attinmeta=TupleDescGetAttInMetadata(tupdesc);
3850

‎src/bin/initdb/initdb.sh

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
2828
# Portions Copyright (c) 1994, Regents of the University of California
2929
#
30-
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.168 2002/08/17 15:12:07 momjian Exp $
30+
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.169 2002/08/27 04:00:28 momjian Exp $
3131
#
3232
#-------------------------------------------------------------------------
3333

@@ -977,20 +977,11 @@ CREATE VIEW pg_stat_database AS \
977977
pg_stat_get_db_blocks_hit(D.oid) AS blks_hit\
978978
FROM pg_database D;
979979
980-
CREATE VIEWpg_locks_result AS\
980+
CREATE VIEWpg_locks AS\
981981
SELECT\
982-
''::oid AS relation,\
983-
''::oid AS database,\
984-
''::int4 AS backendpid,\
985-
''::text AS mode,\
986-
NULL::bool AS isgranted;
987-
988-
UPDATE pg_proc SET\
989-
prorettype = (SELECT oid FROM pg_type\
990-
WHERE typname = 'pg_locks_result')\
991-
WHERE proname = 'pg_lock_status';
992-
993-
CREATE VIEW pg_locks AS SELECT * FROM pg_lock_status();
982+
L.relation, L.database, L.backendpid, L.mode, L.isgranted\
983+
FROM pg_lock_status() AS L(relation oid, database oid,\
984+
backendpid int4, mode text, isgranted boolean);
994985
995986
CREATE VIEW pg_settings AS\
996987
SELECT\

‎src/include/catalog/catversion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
3838
* Portions Copyright (c) 1994, Regents of the University of California
3939
*
40-
* $Id: catversion.h,v 1.153 2002/08/26 17:53:59 tgl Exp $
40+
* $Id: catversion.h,v 1.154 2002/08/27 04:00:28 momjian Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO200208251
56+
#defineCATALOG_VERSION_NO200208271
5757

5858
#endif

‎src/include/catalog/pg_proc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: pg_proc.h,v 1.265 2002/08/26 17:53:59 tgl Exp $
10+
* $Id: pg_proc.h,v 1.266 2002/08/27 04:00:28 momjian Exp $
1111
*
1212
* NOTES
1313
* The script catalog/genbki.sh reads this file and generates .bki
@@ -2902,7 +2902,7 @@ DATA(insert OID = 2078 ( set_configPGNSP PGUID 12 f f f f v 3 25 "25 25 16" s
29022902
DESCR("SET X as a function");
29032903
DATA(insertOID=2084 (pg_show_all_settingsPGNSPPGUID12fftts02249""show_all_settings-_null_ ));
29042904
DESCR("SHOW ALL as a function");
2905-
DATA(insertOID=1371 (pg_lock_statusPGNSPPGUID12ffftv00""lock_status_srf-_null_ ));
2905+
DATA(insertOID=1371 (pg_lock_statusPGNSPPGUID12ffftv02249""pg_lock_status-_null_ ));
29062906
DESCR("view system lock information");
29072907

29082908
DATA(insertOID=2079 (pg_table_is_visiblePGNSPPGUID12fftfs116"26"pg_table_is_visible-_null_ ));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp