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

Commit27a54ae

Browse files
committed
Opclasses live in namespaces. I also took the opportunity to create
an 'opclass owner' column in pg_opclass. Nothing is done with it atpresent, but since there are plans to invent a CREATE OPERATOR CLASScommand soon, we'll probably want DROP OPERATOR CLASS too, whichsuggests that a notion of ownership would be a good idea.
1 parentd85a81c commit27a54ae

File tree

25 files changed

+445
-170
lines changed

25 files changed

+445
-170
lines changed

‎contrib/btree_gist/btree_gist.sql.in

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,15 @@ create function gint4_union(bytea, opaque) returns int4 as 'MODULE_PATHNAME' lan
4141
create function gint4_same(opaque, opaque, opaque) returns opaque as 'MODULE_PATHNAME' language 'C';
4242

4343
-- add a new opclass
44-
INSERT INTO pg_opclass (opcamid, opcname, opcintype, opckeytype, opcdefault)
45-
SELECT pg_am.oid, 'gist_int4_ops', pg_type.oid, pg_key.oid, true
46-
FROM pg_type, pg_am, pg_type pg_key
47-
WHERE pg_type.typname = 'int4' and
48-
pg_key.typname = 'int4key' and
49-
pg_am.amname='gist';
44+
INSERT INTO pg_opclass (opcamid, opcname, opcnamespace, opcowner, opcintype, opcdefault, opckeytype)
45+
VALUES (
46+
(SELECT oid FROM pg_am WHERE amname = 'gist'),
47+
'gist_int4_ops',
48+
(SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog'),
49+
1,-- UID of superuser is hardwired to 1 as of PG 7.3
50+
(SELECT oid FROM pg_type WHERE typname = 'int4'),
51+
true,
52+
(SELECT oid FROM pg_type WHERE typname = 'int4key'));
5053

5154

5255
SELECT o.oid AS opoid, o.oprname
@@ -170,12 +173,16 @@ create function gts_union(bytea, opaque) returns int4 as 'MODULE_PATHNAME' langu
170173

171174
create function gts_same(opaque, opaque, opaque) returns opaque as 'MODULE_PATHNAME' language 'C';
172175

173-
INSERT INTO pg_opclass (opcamid, opcname, opcintype, opckeytype, opcdefault)
174-
SELECT pg_am.oid, 'gist_timestamp_ops', pg_type.oid, pg_key.oid, true
175-
FROM pg_type, pg_am, pg_type pg_key
176-
WHERE pg_type.typname = 'timestamp' and
177-
pg_key.typname = 'tskey' and
178-
pg_am.amname='gist';
176+
-- add a new opclass
177+
INSERT INTO pg_opclass (opcamid, opcname, opcnamespace, opcowner, opcintype, opcdefault, opckeytype)
178+
VALUES (
179+
(SELECT oid FROM pg_am WHERE amname = 'gist'),
180+
'gist_timestamp_ops',
181+
(SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog'),
182+
1,-- UID of superuser is hardwired to 1 as of PG 7.3
183+
(SELECT oid FROM pg_type WHERE typname = 'timestamp'),
184+
true,
185+
(SELECT oid FROM pg_type WHERE typname = 'tskey'));
179186

180187
SELECT o.oid AS opoid, o.oprname
181188
INTO TABLE timestamp_ops_tmp

‎contrib/cube/cube.sql.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,12 @@ CREATE FUNCTION g_cube_same(cube, cube, opaque) RETURNS opaque
212212

213213

214214
-- register the default opclass for indexing
215-
INSERT INTO pg_opclass (opcamid, opcname, opcintype, opcdefault, opckeytype)
215+
INSERT INTO pg_opclass (opcamid, opcname,opcnamespace, opcowner,opcintype, opcdefault, opckeytype)
216216
VALUES (
217217
(SELECT oid FROM pg_am WHERE amname = 'gist'),
218218
'gist_cube_ops',
219+
(SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog'),
220+
1,-- UID of superuser is hardwired to 1 as of PG 7.3
219221
(SELECT oid FROM pg_type WHERE typname = 'cube'),
220222
true,
221223
0);

‎contrib/intarray/_int.sql.in

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,12 @@ CREATE FUNCTION g_int_same(_int4, _int4, opaque) RETURNS opaque
144144

145145

146146
-- register the default opclass for indexing
147-
INSERT INTO pg_opclass (opcamid, opcname, opcintype, opcdefault, opckeytype)
147+
INSERT INTO pg_opclass (opcamid, opcname,opcnamespace, opcowner,opcintype, opcdefault, opckeytype)
148148
VALUES (
149149
(SELECT oid FROM pg_am WHERE amname = 'gist'),
150150
'gist__int_ops',
151+
(SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog'),
152+
1,-- UID of superuser is hardwired to 1 as of PG 7.3
151153
(SELECT oid FROM pg_type WHERE typname = '_int4'),
152154
true,
153155
0);
@@ -300,10 +302,12 @@ CREATE FUNCTION g_intbig_same(_int4, _int4, opaque) RETURNS opaque
300302
AS 'MODULE_PATHNAME' LANGUAGE 'c';
301303

302304
-- register the opclass for indexing (not as default)
303-
INSERT INTO pg_opclass (opcamid, opcname, opcintype, opcdefault, opckeytype)
305+
INSERT INTO pg_opclass (opcamid, opcname,opcnamespace, opcowner,opcintype, opcdefault, opckeytype)
304306
VALUES (
305307
(SELECT oid FROM pg_am WHERE amname = 'gist'),
306308
'gist__intbig_ops',
309+
(SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog'),
310+
1,-- UID of superuser is hardwired to 1 as of PG 7.3
307311
(SELECT oid FROM pg_type WHERE typname = '_int4'),
308312
false,
309313
0);

‎contrib/rtree_gist/rtree_gist.sql.in

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ create function gbox_union(bytea, opaque) returns box as 'MODULE_PATHNAME' langu
2121

2222
create function gbox_same(box, box, opaque) returns opaque as 'MODULE_PATHNAME' language 'C';
2323

24-
-- add a new opclass (non-default)
25-
INSERT INTO pg_opclass (opcamid, opcname, opcintype, opcdefault, opckeytype)
24+
-- add a new opclass
25+
INSERT INTO pg_opclass (opcamid, opcname,opcnamespace, opcowner,opcintype, opcdefault, opckeytype)
2626
VALUES (
2727
(SELECT oid FROM pg_am WHERE amname = 'gist'),
2828
'gist_box_ops',
29+
(SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog'),
30+
1,-- UID of superuser is hardwired to 1 as of PG 7.3
2931
(SELECT oid FROM pg_type WHERE typname = 'box'),
3032
true,
3133
0);
@@ -183,11 +185,13 @@ create function gpoly_consistent(opaque,polygon,int4) returns bool as 'MODULE_PA
183185

184186
create function gpoly_compress(opaque) returns opaque as 'MODULE_PATHNAME' language 'C';
185187

186-
-- add a new opclass (non-default)
187-
INSERT INTO pg_opclass (opcamid, opcname, opcintype, opcdefault, opckeytype)
188+
-- add a new opclass
189+
INSERT INTO pg_opclass (opcamid, opcname,opcnamespace, opcowner,opcintype, opcdefault, opckeytype)
188190
VALUES (
189191
(SELECT oid FROM pg_am WHERE amname = 'gist'),
190192
'gist_poly_ops',
193+
(SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog'),
194+
1,-- UID of superuser is hardwired to 1 as of PG 7.3
191195
(SELECT oid FROM pg_type WHERE typname = 'polygon'),
192196
true,
193197
(SELECT oid FROM pg_type WHERE typname = 'box'));

‎contrib/seg/seg.sql.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,12 @@ CREATE FUNCTION gseg_same(seg, seg, opaque) RETURNS opaque
236236

237237

238238
-- register the default opclass for indexing
239-
INSERT INTO pg_opclass (opcamid, opcname, opcintype, opcdefault, opckeytype)
239+
INSERT INTO pg_opclass (opcamid, opcname,opcnamespace, opcowner,opcintype, opcdefault, opckeytype)
240240
VALUES (
241241
(SELECT oid FROM pg_am WHERE amname = 'gist'),
242242
'gist_seg_ops',
243+
(SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog'),
244+
1,-- UID of superuser is hardwired to 1 as of PG 7.3
243245
(SELECT oid FROM pg_type WHERE typname = 'seg'),
244246
true,
245247
0);

‎contrib/tsearch/tsearch.sql.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,12 @@ CREATE FUNCTION gtxtidx_union(bytea, opaque) RETURNS _int4
155155
CREATE FUNCTION gtxtidx_same(gtxtidx, gtxtidx, opaque) RETURNS opaque
156156
AS 'MODULE_PATHNAME' LANGUAGE 'c';
157157

158-
INSERT INTO pg_opclass (opcamid, opcname, opcintype, opcdefault, opckeytype)
158+
INSERT INTO pg_opclass (opcamid, opcname,opcnamespace, opcowner,opcintype, opcdefault, opckeytype)
159159
VALUES (
160160
(SELECT oid FROM pg_am WHERE amname = 'gist'),
161161
'gist_txtidx_ops',
162+
(SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog'),
163+
1,-- UID of superuser is hardwired to 1 as of PG 7.3
162164
(SELECT oid FROM pg_type WHERE typname = 'txtidx'),
163165
true,
164166
(SELECT oid FROM pg_type WHERE typname = 'gtxtidx'));

‎doc/src/sgml/xindex.sgml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/xindex.sgml,v 1.23 2002/03/27 19:19:23 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/xindex.sgml,v 1.24 2002/04/17 20:57:56 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -280,10 +280,12 @@ SELECT oid FROM pg_am WHERE amname = 'btree';
280280
<classname>pg_opclass</classname>:
281281

282282
<programlisting>
283-
INSERT INTO pg_opclass (opcamid, opcname, opcintype, opcdefault, opckeytype)
283+
INSERT INTO pg_opclass (opcamid, opcname,opcnamespace, opcowner,opcintype, opcdefault, opckeytype)
284284
VALUES (
285285
(SELECT oid FROM pg_am WHERE amname = 'btree'),
286286
'complex_abs_ops',
287+
(SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog'),
288+
1,-- UID of superuser is hardwired to 1 as of PG 7.3
287289
(SELECT oid FROM pg_type WHERE typname = 'complex'),
288290
true,
289291
0);
@@ -292,9 +294,9 @@ SELECT oid, *
292294
FROM pg_opclass
293295
WHERE opcname = 'complex_abs_ops';
294296

295-
oid | opcamid | opcname | opcintype | opcdefault | opckeytype
296-
--------+---------+-----------------+-----------+------------+------------
297-
277975 | 403 | complex_abs_ops | 277946 | t | 0
297+
oid | opcamid | opcname |opcnamespace | opcowner |opcintype | opcdefault | opckeytype
298+
--------+---------+-----------------+--------------+----------+-----------+------------+------------
299+
277975 | 403 | complex_abs_ops | 11 | 1 |277946 | t | 0
298300
(1 row)
299301
</programlisting>
300302

‎src/backend/access/index/indexam.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.56 2002/03/26 19:15:14 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.57 2002/04/17 20:57:56 tgl Exp $
1212
*
1313
* INTERFACE ROUTINES
1414
*index_open- open an index relation by relation OID
@@ -498,10 +498,23 @@ index_getprocinfo(Relation irel,
498498
if (locinfo->fn_oid==InvalidOid)
499499
{
500500
RegProcedure*loc=irel->rd_support;
501+
RegProcedureprocId;
501502

502503
Assert(loc!=NULL);
503504

504-
fmgr_info_cxt(loc[procindex],locinfo,irel->rd_indexcxt);
505+
procId=loc[procindex];
506+
507+
/*
508+
* Complain if function was not found during IndexSupportInitialize.
509+
* This should not happen unless the system tables contain bogus
510+
* entries for the index opclass. (If an AM wants to allow a
511+
* support function to be optional, it can use index_getprocid.)
512+
*/
513+
if (!RegProcedureIsValid(procId))
514+
elog(ERROR,"Missing support function %d for attribute %d of index %s",
515+
procnum,attnum,RelationGetRelationName(irel));
516+
517+
fmgr_info_cxt(procId,locinfo,irel->rd_indexcxt);
505518
}
506519

507520
returnlocinfo;

‎src/backend/bootstrap/bootparse.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.44 2002/04/09 20:35:46 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.45 2002/04/17 20:57:56 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -273,7 +273,7 @@ boot_index_param:
273273
IndexElem *n =makeNode(IndexElem);
274274
n->name =LexIDStr($1);
275275
n->funcname = n->args = NIL;/* no func indexes*/
276-
n->class =LexIDStr($2);
276+
n->opclass =makeList1(makeString(LexIDStr($2)));
277277
$$ = n;
278278
}
279279
;

‎src/backend/catalog/indexing.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.89 2002/04/16 23:08:10 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.90 2002/04/17 20:57:56 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -60,7 +60,7 @@ char *Name_pg_largeobject_indices[Num_pg_largeobject_indices] =
6060
char*Name_pg_namespace_indices[Num_pg_namespace_indices]=
6161
{NamespaceNameIndex,NamespaceOidIndex};
6262
char*Name_pg_opclass_indices[Num_pg_opclass_indices]=
63-
{OpclassAmNameIndex,OpclassOidIndex};
63+
{OpclassAmNameNspIndex,OpclassOidIndex};
6464
char*Name_pg_operator_indices[Num_pg_operator_indices]=
6565
{OperatorOidIndex,OperatorNameNspIndex};
6666
char*Name_pg_proc_indices[Num_pg_proc_indices]=

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp