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

Commit5f4745a

Browse files
committed
Further cleanups for relations in schemas: teach nextval and other
sequence functions how to cope with qualified names. Same code isalso used for int4notin, currtid_byrelname, pgstattuple. Also,move TOAST tables into special pg_toast namespace.
1 parent25004ee commit5f4745a

File tree

14 files changed

+261
-178
lines changed

14 files changed

+261
-178
lines changed

‎contrib/pgstattuple/README.pgstattuple

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ NOTICE: physical length: 0.08MB live tuples: 20 (0.00MB, 1.17%) dead tuples: 32
3333

3434
pgstattuple can be called as a function:
3535

36-
pgstattuple(NAME) RETURNS FLOAT8
36+
pgstattuple(TEXT) RETURNS FLOAT8
3737

3838
The argument is the table name. pgstattuple returns the percentage
3939
of the "dead" tuples of a table.

‎contrib/pgstattuple/pgstattuple.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $Header: /cvsroot/pgsql/contrib/pgstattuple/pgstattuple.c,v 1.4 2002/03/06 06:09:10 momjian Exp $
2+
* $Header: /cvsroot/pgsql/contrib/pgstattuple/pgstattuple.c,v 1.5 2002/03/30 01:02:41 tgl Exp $
33
*
44
* Copyright (c) 2001 Tatsuo Ishii
55
*
@@ -27,6 +27,9 @@
2727
#include"fmgr.h"
2828
#include"access/heapam.h"
2929
#include"access/transam.h"
30+
#include"catalog/namespace.h"
31+
#include"utils/builtins.h"
32+
3033

3134
PG_FUNCTION_INFO_V1(pgstattuple);
3235

@@ -43,8 +46,8 @@ extern Datum pgstattuple(PG_FUNCTION_ARGS);
4346
Datum
4447
pgstattuple(PG_FUNCTION_ARGS)
4548
{
46-
Namep=PG_GETARG_NAME(0);
47-
49+
text*relname=PG_GETARG_TEXT_P(0);
50+
RangeVar*relrv;
4851
Relationrel;
4952
HeapScanDescscan;
5053
HeapTupletuple;
@@ -59,11 +62,13 @@ pgstattuple(PG_FUNCTION_ARGS)
5962
uint64dead_tuple_count=0;
6063
doubletuple_percent;
6164
doubledead_tuple_percent;
62-
6365
uint64free_space=0;/* free/reusable space in bytes */
6466
doublefree_percent;/* free/reusable space in % */
6567

66-
rel=heap_openr(NameStr(*p),AccessShareLock);
68+
relrv=makeRangeVarFromNameList(textToQualifiedNameList(relname,
69+
"pgstattuple"));
70+
rel=heap_openrv(relrv,AccessShareLock);
71+
6772
nblocks=RelationGetNumberOfBlocks(rel);
6873
scan=heap_beginscan(rel, false,SnapshotAny,0,NULL);
6974

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
DROP FUNCTION pgstattuple(NAME);
2-
CREATE FUNCTION pgstattuple(NAME) RETURNSFLOAT8
1+
DROP FUNCTION pgstattuple(text);
2+
CREATE FUNCTION pgstattuple(text) RETURNSfloat8
33
AS 'MODULE_PATHNAME', 'pgstattuple'
44
LANGUAGE 'c' WITH (isstrict);

‎src/backend/catalog/namespace.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
1515
* IDENTIFICATION
16-
* $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.2 2002/03/29 19:06:01 tgl Exp $
16+
* $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.3 2002/03/30 01:02:41 tgl Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -81,6 +81,10 @@ RangeVarGetRelid(const RangeVar *relation, bool failOK)
8181
* RangeVarGetCreationNamespace
8282
*Given a RangeVar describing a to-be-created relation,
8383
*choose which namespace to create it in.
84+
*
85+
* Note: calling this may result in a CommandCounterIncrement operation.
86+
* That will happen on the first request for a temp table in any particular
87+
* backend run; we will need to either create or clean out the temp schema.
8488
*/
8589
Oid
8690
RangeVarGetCreationNamespace(constRangeVar*newRelation)
@@ -126,6 +130,21 @@ RelnameGetRelid(const char *relname)
126130
returnget_relname_relid(relname,PG_CATALOG_NAMESPACE);
127131
}
128132

133+
/*
134+
* TypenameGetTypid
135+
*Try to resolve an unqualified datatype name.
136+
*Returns OID if type found in search path, else InvalidOid.
137+
*/
138+
Oid
139+
TypenameGetTypid(constchar*typname)
140+
{
141+
/* XXX wrong, should use namespace search */
142+
returnGetSysCacheOid(TYPENAMENSP,
143+
PointerGetDatum(typname),
144+
ObjectIdGetDatum(PG_CATALOG_NAMESPACE),
145+
0,0);
146+
}
147+
129148
/*
130149
* QualifiedNameGetCreationNamespace
131150
*Given a possibly-qualified name for an object (in List-of-Values

‎src/backend/commands/command.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.167 2002/03/29 19:06:03 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.168 2002/03/30 01:02:41 tgl Exp $
1212
*
1313
* NOTES
1414
* The PerformAddAttribute() code, like most of the relation
@@ -1755,13 +1755,13 @@ AlterTableCreateToastTable(Oid relOid, bool silent)
17551755
tupdesc->attrs[2]->attstorage='p';
17561756

17571757
/*
1758-
* Note: the toast relation isconsidered a "normal" relation even if
1759-
* its master relation is a temp table. There cannot be any naming
1760-
* collision, and the toast rel will be destroyed when its master is,
1761-
* so there's no need to handle the toast rel as temp.
1758+
* Note: the toast relation isplaced in the regular pg_toast namespace
1759+
*even ifits master relation is a temp table. There cannot be any
1760+
*namingcollision, and the toast rel will be destroyed when its master
1761+
*is,so there's no need to handle the toast rel as temp.
17621762
*/
17631763
toast_relid=heap_create_with_catalog(toast_relname,
1764-
RelationGetNamespace(rel),
1764+
PG_TOAST_NAMESPACE,
17651765
tupdesc,
17661766
RELKIND_TOASTVALUE, false,
17671767
false, true);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp