@@ -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
222225SELECT o.oid AS opoid, o.oprname
223- INTO TABLE gist_cube_ops_tmp
226+ INTOTEMP TABLE gist_cube_ops_tmp
224227FROM pg_operator o, pg_type t
225228WHERE 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
289308DROP 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
337370END TRANSACTION;