diff options
| author | Tom Lane | 2002-07-30 17:34:37 +0000 |
|---|---|---|
| committer | Tom Lane | 2002-07-30 17:34:37 +0000 |
| commit | 65b6868b132a970ec1160e03833e9c117b05280f (patch) | |
| tree | 0f1660f1b8debf37c67592d7ca86a4a2d7c9cc00 /contrib/seg | |
| parent | ea2d97414c58bd28af5516047d76239e6ec7bef6 (diff) | |
Replace ad-hoc insertions into pg_opclass and friends with CREATE
OPERATOR CLASS commands. Further tweaking of documentation for same.
Diffstat (limited to 'contrib/seg')
| -rw-r--r-- | contrib/seg/seg.sql.in | 180 |
1 files changed, 23 insertions, 157 deletions
diff --git a/contrib/seg/seg.sql.in b/contrib/seg/seg.sql.in index f8acddeb352..2da70ac682b 100644 --- a/contrib/seg/seg.sql.in +++ b/contrib/seg/seg.sql.in @@ -2,6 +2,9 @@ -- BEGIN TRANSACTION; +-- Adjust this setting to control where the objects get created. +SET search_path = public; + CREATE FUNCTION seg_in(opaque) RETURNS opaque AS 'MODULE_PATHNAME' @@ -235,162 +238,25 @@ CREATE FUNCTION gseg_same(seg, seg, opaque) RETURNS opaque AS 'MODULE_PATHNAME' LANGUAGE 'c'; --- register the default opclass for indexing -INSERT INTO pg_opclass (opcamid, opcname, opcnamespace, opcowner, opcintype, opcdefault, opckeytype) - VALUES ( - (SELECT oid FROM pg_am WHERE amname = 'gist'), - 'gist_seg_ops', - (SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog'), - 1, -- UID of superuser is hardwired to 1 as of PG 7.3 - (SELECT oid FROM pg_type WHERE typname = 'seg'), - true, - 0); - - --- get the comparators for segments and store them in a tmp table -SELECT o.oid AS opoid, o.oprname -INTO TEMP TABLE seg_ops_tmp -FROM pg_operator o, pg_type t -WHERE o.oprleft = t.oid and o.oprright = t.oid - and t.typname = 'seg'; - --- make sure we have the right operators --- SELECT * from seg_ops_tmp; - --- using the tmp table, generate the amop entries - --- seg_left -INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr) - SELECT opcl.oid, 1, false, c.opoid - FROM pg_opclass opcl, seg_ops_tmp c - WHERE - opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist') - and opcname = 'gist_seg_ops' - and c.oprname = '<<'; - --- seg_overleft -INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr) - SELECT opcl.oid, 2, false, c.opoid - FROM pg_opclass opcl, seg_ops_tmp c - WHERE - opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist') - and opcname = 'gist_seg_ops' - and c.oprname = '&<'; - --- seg_overlap -INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr) - SELECT opcl.oid, 3, false, c.opoid - FROM pg_opclass opcl, seg_ops_tmp c - WHERE - opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist') - and opcname = 'gist_seg_ops' - and c.oprname = '&&'; - --- seg_overright -INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr) - SELECT opcl.oid, 4, false, c.opoid - FROM pg_opclass opcl, seg_ops_tmp c - WHERE - opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist') - and opcname = 'gist_seg_ops' - and c.oprname = '&>'; - --- seg_right -INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr) - SELECT opcl.oid, 5, false, c.opoid - FROM pg_opclass opcl, seg_ops_tmp c - WHERE - opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist') - and opcname = 'gist_seg_ops' - and c.oprname = '>>'; - --- seg_same -INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr) - SELECT opcl.oid, 6, false, c.opoid - FROM pg_opclass opcl, seg_ops_tmp c - WHERE - opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist') - and opcname = 'gist_seg_ops' - and c.oprname = '='; - --- seg_contains -INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr) - SELECT opcl.oid, 7, false, c.opoid - FROM pg_opclass opcl, seg_ops_tmp c - WHERE - opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist') - and opcname = 'gist_seg_ops' - and c.oprname = '@'; - --- seg_contained -INSERT INTO pg_amop (amopclaid, amopstrategy, amopreqcheck, amopopr) - SELECT opcl.oid, 8, false, c.opoid - FROM pg_opclass opcl, seg_ops_tmp c - WHERE - opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist') - and opcname = 'gist_seg_ops' - and c.oprname = '~'; - -DROP TABLE seg_ops_tmp; - - --- add the entries to amproc for the support methods --- note the amprocnum numbers associated with each are specific! - -INSERT INTO pg_amproc (amopclaid, amprocnum, amproc) - SELECT opcl.oid, 1, pro.oid - FROM pg_opclass opcl, pg_proc pro - WHERE - opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist') - and opcname = 'gist_seg_ops' - and proname = 'gseg_consistent'; - -INSERT INTO pg_amproc (amopclaid, amprocnum, amproc) - SELECT opcl.oid, 2, pro.oid - FROM pg_opclass opcl, pg_proc pro - WHERE - opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist') - and opcname = 'gist_seg_ops' - and proname = 'gseg_union'; - -INSERT INTO pg_amproc (amopclaid, amprocnum, amproc) - SELECT opcl.oid, 3, pro.oid - FROM pg_opclass opcl, pg_proc pro - WHERE - opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist') - and opcname = 'gist_seg_ops' - and proname = 'gseg_compress'; - -INSERT INTO pg_amproc (amopclaid, amprocnum, amproc) - SELECT opcl.oid, 4, pro.oid - FROM pg_opclass opcl, pg_proc pro - WHERE - opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist') - and opcname = 'gist_seg_ops' - and proname = 'gseg_decompress'; - -INSERT INTO pg_amproc (amopclaid, amprocnum, amproc) - SELECT opcl.oid, 5, pro.oid - FROM pg_opclass opcl, pg_proc pro - WHERE - opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist') - and opcname = 'gist_seg_ops' - and proname = 'gseg_penalty'; - -INSERT INTO pg_amproc (amopclaid, amprocnum, amproc) - SELECT opcl.oid, 6, pro.oid - FROM pg_opclass opcl, pg_proc pro - WHERE - opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist') - and opcname = 'gist_seg_ops' - and proname = 'gseg_picksplit'; - -INSERT INTO pg_amproc (amopclaid, amprocnum, amproc) - SELECT opcl.oid, 7, pro.oid - FROM pg_opclass opcl, pg_proc pro - WHERE - opcamid = (SELECT oid FROM pg_am WHERE amname = 'gist') - and opcname = 'gist_seg_ops' - and proname = 'gseg_same'; +-- Create the operator class for indexing + +CREATE OPERATOR CLASS gist_seg_ops + DEFAULT FOR TYPE seg USING gist AS + OPERATOR 1 << , + OPERATOR 2 &< , + OPERATOR 3 && , + OPERATOR 4 &> , + OPERATOR 5 >> , + OPERATOR 6 = , + OPERATOR 7 @ , + OPERATOR 8 ~ , + FUNCTION 1 gseg_consistent (opaque, seg, int4), + FUNCTION 2 gseg_union (bytea, opaque), + FUNCTION 3 gseg_compress (opaque), + FUNCTION 4 gseg_decompress (opaque), + FUNCTION 5 gseg_penalty (opaque, opaque, opaque), + FUNCTION 6 gseg_picksplit (opaque, opaque), + FUNCTION 7 gseg_same (seg, seg, opaque); + END TRANSACTION; |
