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

Commitf933766

Browse files
committed
Restructure pg_opclass, pg_amop, and pg_amproc per previous discussions in
pgsql-hackers. pg_opclass now has a row for each opclass supported by eachindex AM, not a row for each opclass name. This allows pg_opclass to showdirectly whether an AM supports an opclass, and furthermore makes it possibleto store additional information about an opclass that might be AM-dependent.pg_opclass and pg_amop now store "lossy" and "haskeytype" information that wepreviously expected the user to remember to provide in CREATE INDEX commands.Lossiness is no longer an index-level property, but is associated with theuse of a particular operator in a particular index opclass.Along the way, IndexSupportInitialize now uses the syscaches to retrievepg_amop and pg_amproc entries. I find this reduces backend launch time byabout ten percent, at the cost of a couple more special cases in catcache.c'sIndexScanOK.Initial work by Oleg Bartunov and Teodor Sigaev, further hacking by Tom Lane.initdb forced.
1 parentc2d1566 commitf933766

File tree

60 files changed

+1913
-1924
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1913
-1924
lines changed

‎contrib/cube/cube.sql.in

Lines changed: 98 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,18 @@ CREATE FUNCTION g_cube_same(cube, cube, opaque) RETURNS opaque
212212

213213

214214
-- register the default opclass for indexing
215-
INSERT INTO pg_opclass (opcname, opcdeftype)
216-
SELECT 'gist_cube_ops', oid
217-
FROM pg_type
218-
WHERE typname = 'cube';
215+
INSERT INTO pg_opclass (opcamid, opcname, opcintype, opcdefault, opckeytype)
216+
VALUES (
217+
(SELECT oid FROM pg_am WHERE amname = 'gist'),
218+
'gist_cube_ops',
219+
(SELECT oid FROM pg_type WHERE typname = 'cube'),
220+
true,
221+
0);
219222

220223

221224
-- get the comparators for boxes and store them in a tmp table
222225
SELECT o.oid AS opoid, o.oprname
223-
INTO TABLE gist_cube_ops_tmp
226+
INTOTEMPTABLE gist_cube_ops_tmp
224227
FROM pg_operator o, pg_type t
225228
WHERE o.oprleft = t.oid and o.oprright = t.oid
226229
and t.typname = 'cube';
@@ -231,59 +234,75 @@ WHERE o.oprleft = t.oid and o.oprright = t.oid
231234
-- using the tmp table, generate the amop entries
232235

233236
-- cube_left
234-
INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy)
235-
SELECT am.oid, opcl.oid, c.opoid, 1
236-
FROM pg_am am, pg_opclass opcl, gist_cube_ops_tmp c
237-
WHERE amname = 'gist' and opcname = 'gist_cube_ops'
237+
INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr)
238+
SELECT opcl.oid, 1, false, c.opoid
239+
FROM pg_opclass opcl, gist_cube_ops_tmp c
240+
WHERE
241+
opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
242+
and opcname = 'gist_cube_ops'
238243
and c.oprname = '<<';
239244

240245
-- cube_over_left
241-
INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy)
242-
SELECT am.oid, opcl.oid, c.opoid, 2
243-
FROM pg_am am, pg_opclass opcl, gist_cube_ops_tmp c
244-
WHERE amname = 'gist' and opcname = 'gist_cube_ops'
246+
INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr)
247+
SELECT opcl.oid, 2, false, c.opoid
248+
FROM pg_opclass opcl, gist_cube_ops_tmp c
249+
WHERE
250+
opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
251+
and opcname = 'gist_cube_ops'
245252
and c.oprname = '&<';
246253

247254
-- cube_overlap
248-
INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy)
249-
SELECT am.oid, opcl.oid, c.opoid, 3
250-
FROM pg_am am, pg_opclass opcl, gist_cube_ops_tmp c
251-
WHERE amname = 'gist' and opcname = 'gist_cube_ops'
255+
INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr)
256+
SELECT opcl.oid, 3, false, c.opoid
257+
FROM pg_opclass opcl, gist_cube_ops_tmp c
258+
WHERE
259+
opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
260+
and opcname = 'gist_cube_ops'
252261
and c.oprname = '&&';
253262

254263
-- cube_over_right
255-
INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy)
256-
SELECT am.oid, opcl.oid, c.opoid, 4
257-
FROM pg_am am, pg_opclass opcl, gist_cube_ops_tmp c
258-
WHERE amname = 'gist' and opcname = 'gist_cube_ops'
264+
INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr)
265+
SELECT opcl.oid, 4, false, c.opoid
266+
FROM pg_opclass opcl, gist_cube_ops_tmp c
267+
WHERE
268+
opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
269+
and opcname = 'gist_cube_ops'
259270
and c.oprname = '&>';
260271

261272
-- cube_right
262-
INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy)
263-
SELECT am.oid, opcl.oid, c.opoid, 5
264-
FROM pg_am am, pg_opclass opcl, gist_cube_ops_tmp c
265-
WHERE amname = 'gist' and opcname = 'gist_cube_ops'
273+
INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr)
274+
SELECT opcl.oid, 5, false, c.opoid
275+
FROM pg_opclass opcl, gist_cube_ops_tmp c
276+
WHERE
277+
opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
278+
and opcname = 'gist_cube_ops'
266279
and c.oprname = '>>';
267280

268281
-- cube_same
269-
INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy)
270-
SELECT am.oid, opcl.oid, c.opoid, 6
271-
FROM pg_am am, pg_opclass opcl, gist_cube_ops_tmp c
272-
WHERE amname = 'gist' and opcname = 'gist_cube_ops'
282+
INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr)
283+
SELECT opcl.oid, 6, false, c.opoid
284+
FROM pg_opclass opcl, gist_cube_ops_tmp c
285+
WHERE
286+
opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
287+
and opcname = 'gist_cube_ops'
273288
and c.oprname = '=';
274289

275290
-- cube_contains
276-
INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy)
277-
SELECT am.oid, opcl.oid, c.opoid, 7
278-
FROM pg_am am, pg_opclass opcl, gist_cube_ops_tmp c
279-
WHERE amname = 'gist' and opcname = 'gist_cube_ops'
291+
INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr)
292+
SELECT opcl.oid, 7, false, c.opoid
293+
FROM pg_opclass opcl, gist_cube_ops_tmp c
294+
WHERE
295+
opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
296+
and opcname = 'gist_cube_ops'
280297
and c.oprname = '@';
281298

282299
-- cube_contained
283-
INSERT INTO pg_amop (amopid, amopclaid, amopopr, amopstrategy)
284-
SELECT am.oid, opcl.oid, c.opoid, 8
285-
FROM pg_am am, pg_opclass opcl, gist_cube_ops_tmp c
286-
WHERE amname = 'gist' and opcname = 'gist_cube_ops'
300+
INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr)
301+
SELECT opcl.oid, 8, false, c.opoid
302+
FROM pg_opclass opcl, gist_cube_ops_tmp c
303+
WHERE
304+
opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
305+
and opcname = 'gist_cube_ops'
287306
and c.oprname = '~';
288307

289308
DROP TABLE gist_cube_ops_tmp;
@@ -292,46 +311,60 @@ DROP TABLE gist_cube_ops_tmp;
292311
-- add the entries to amproc for the support methods
293312
-- note the amprocnum numbers associated with each are specific!
294313

295-
INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
296-
SELECT am.oid, opcl.oid, pro.oid, 1
297-
FROM pg_am am, pg_opclass opcl, pg_proc pro
298-
WHERE amname = 'gist' and opcname = 'gist_cube_ops'
314+
INSERT INTO pg_amproc (amopclaid, amprocnum, amproc)
315+
SELECT opcl.oid, 1, pro.oid
316+
FROM pg_opclass opcl, pg_proc pro
317+
WHERE
318+
opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
319+
and opcname = 'gist_cube_ops'
299320
and proname = 'g_cube_consistent';
300321

301-
INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
302-
SELECT am.oid, opcl.oid, pro.oid, 2
303-
FROM pg_am am, pg_opclass opcl, pg_proc pro
304-
WHERE amname = 'gist' and opcname = 'gist_cube_ops'
322+
INSERT INTO pg_amproc (amopclaid, amprocnum, amproc)
323+
SELECT opcl.oid, 2, pro.oid
324+
FROM pg_opclass opcl, pg_proc pro
325+
WHERE
326+
opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
327+
and opcname = 'gist_cube_ops'
305328
and proname = 'g_cube_union';
306329

307-
INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
308-
SELECT am.oid, opcl.oid, pro.oid, 3
309-
FROM pg_am am, pg_opclass opcl, pg_proc pro
310-
WHERE amname = 'gist' and opcname = 'gist_cube_ops'
330+
INSERT INTO pg_amproc (amopclaid, amprocnum, amproc)
331+
SELECT opcl.oid, 3, pro.oid
332+
FROM pg_opclass opcl, pg_proc pro
333+
WHERE
334+
opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
335+
and opcname = 'gist_cube_ops'
311336
and proname = 'g_cube_compress';
312337

313-
INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
314-
SELECT am.oid, opcl.oid, pro.oid, 4
315-
FROM pg_am am, pg_opclass opcl, pg_proc pro
316-
WHERE amname = 'gist' and opcname = 'gist_cube_ops'
338+
INSERT INTO pg_amproc (amopclaid, amprocnum, amproc)
339+
SELECT opcl.oid, 4, pro.oid
340+
FROM pg_opclass opcl, pg_proc pro
341+
WHERE
342+
opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
343+
and opcname = 'gist_cube_ops'
317344
and proname = 'g_cube_decompress';
318345

319-
INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
320-
SELECT am.oid, opcl.oid, pro.oid, 5
321-
FROM pg_am am, pg_opclass opcl, pg_proc pro
322-
WHERE amname = 'gist' and opcname = 'gist_cube_ops'
346+
INSERT INTO pg_amproc (amopclaid, amprocnum, amproc)
347+
SELECT opcl.oid, 5, pro.oid
348+
FROM pg_opclass opcl, pg_proc pro
349+
WHERE
350+
opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
351+
and opcname = 'gist_cube_ops'
323352
and proname = 'g_cube_penalty';
324353

325-
INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
326-
SELECT am.oid, opcl.oid, pro.oid, 6
327-
FROM pg_am am, pg_opclass opcl, pg_proc pro
328-
WHERE amname = 'gist' and opcname = 'gist_cube_ops'
354+
INSERT INTO pg_amproc (amopclaid, amprocnum, amproc)
355+
SELECT opcl.oid, 6, pro.oid
356+
FROM pg_opclass opcl, pg_proc pro
357+
WHERE
358+
opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
359+
and opcname = 'gist_cube_ops'
329360
and proname = 'g_cube_picksplit';
330361

331-
INSERT INTO pg_amproc (amid, amopclaid, amproc, amprocnum)
332-
SELECT am.oid, opcl.oid, pro.oid, 7
333-
FROM pg_am am, pg_opclass opcl, pg_proc pro
334-
WHERE amname = 'gist' and opcname = 'gist_cube_ops'
362+
INSERT INTO pg_amproc (amopclaid, amprocnum, amproc)
363+
SELECT opcl.oid, 7, pro.oid
364+
FROM pg_opclass opcl, pg_proc pro
365+
WHERE
366+
opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist')
367+
and opcname = 'gist_cube_ops'
335368
and proname = 'g_cube_same';
336369

337370
END TRANSACTION;

‎contrib/findoidjoins/README.findoidjoins

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,8 @@ Join pg_am.amrestrpos => pg_proc.oid
4848
Join pg_am.ambuild => pg_proc.oid
4949
Join pg_am.ambulkdelete => pg_proc.oid
5050
Join pg_am.amcostestimate => pg_proc.oid
51-
Join pg_amop.amopid => pg_am.oid
5251
Join pg_amop.amopclaid => pg_opclass.oid
5352
Join pg_amop.amopopr => pg_operator.oid
54-
Join pg_amproc.amid => pg_am.oid
5553
Join pg_amproc.amopclaid => pg_opclass.oid
5654
Join pg_amproc.amproc => pg_proc.oid
5755
Join pg_attribute.attrelid => pg_class.oid
@@ -63,7 +61,8 @@ Join pg_class.reltoastidxid => pg_class.oid
6361
Join pg_description.classoid => pg_class.oid
6462
Join pg_index.indexrelid => pg_class.oid
6563
Join pg_index.indrelid => pg_class.oid
66-
Join pg_opclass.opcdeftype => pg_type.oid
64+
Join pg_opclass.opcamid => pg_am.oid
65+
Join pg_opclass.opcintype => pg_type.oid
6766
Join pg_operator.oprleft => pg_type.oid
6867
Join pg_operator.oprright => pg_type.oid
6968
Join pg_operator.oprresult => pg_type.oid

‎contrib/findoidjoins/findoidjoins.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,17 @@ main(int argc, char **argv)
6868
if (strcmp(typname,"oid")==0)
6969
sprintf(query,"\
7070
DECLARE c_matches BINARY CURSOR FOR \
71-
SELECTcount(*) \
71+
SELECTcount(*)::int4 \
7272
FROM \"%s\" t1, \"%s\" t2 \
73-
WHERE t1.\"%s\" = t2.oid ",relname,relname2,attname);
73+
WHERE t1.\"%s\" = t2.oid ",
74+
relname,relname2,attname);
7475
else
7576
sprintf(query,"\
7677
DECLARE c_matches BINARY CURSOR FOR \
77-
SELECTcount(*) \
78-
FROM \"%s\" t1, \"%s\" t2 \
79-
WHERE RegprocToOid(t1.\"%s\") = t2.oid ",relname,relname2,attname);
78+
SELECTcount(*)::int4 \
79+
FROM \"%s\" t1, \"%s\" t2 \
80+
WHERE RegprocToOid(t1.\"%s\") = t2.oid ",
81+
relname,relname2,attname);
8082

8183
doquery(query);
8284
doquery("FETCH ALL IN c_matches");

‎contrib/intarray/README.intarray

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
This is an implementation of RD-tree data structure using GiST interface
2-
of PostgreSQL. It has built-in lossy compression - must be declared
3-
in index creation - with (islossy). Current implementation provides index
4-
support for one-dimensional array of int4's - gist__int_ops, suitable for
5-
small and medium size of arrays (used on default), and gist__intbig_ops for
6-
indexing large arrays (we use superimposed signature with length of 4096
7-
bits to represent sets).
2+
of PostgreSQL. It has built-in lossy compression.
3+
4+
Current implementation provides indexsupport for one-dimensional array of
5+
int4's - gist__int_ops, suitable forsmall and medium size of arrays (used on
6+
default), and gist__intbig_ops forindexing large arrays (we use superimposed
7+
signature with length of 4096bits to represent sets).
88

99
All work was done by Teodor Sigaev (teodor@stack.net) and Oleg Bartunov
1010
(oleg@sai.msu.su). See http://www.sai.msu.su/~megera/postgres/gist
@@ -35,7 +35,7 @@ EXAMPLE USAGE:
3535
-- create indices
3636
CREATE unique index message_key on message ( mid );
3737
CREATE unique index message_section_map_key2 on message_section_map (sid, mid );
38-
CREATE INDEX message_rdtree_idx on message using gist ( sections gist__int_ops) with ( islossy );
38+
CREATE INDEX message_rdtree_idx on message using gist ( sections gist__int_ops);
3939

4040
-- select some messages with section in 1 OR 2 - OVERLAP operator
4141
select message.mid from message where message.sections && '{1,2}';

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp