Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
eb4e4fd2
Commit
eb4e4fd2
authored
Jun 23, 2002
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add indexing for isbn and issn.
Dan Weston
parent
407bd1c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
188 additions
and
2 deletions
+188
-2
contrib/isbn_issn/isbn_issn.sql.in
contrib/isbn_issn/isbn_issn.sql.in
+188
-2
No files found.
contrib/isbn_issn/isbn_issn.sql.in
View file @
eb4e4fd2
--
-- PostgreSQL code for ISSNs.
--
-- $Id: isbn_issn.sql.in,v 1.
2 2000/06/19 13:53:39
momjian Exp $
-- $Id: isbn_issn.sql.in,v 1.
3 2002/06/23 21:20:38
momjian Exp $
--
...
...
@@ -116,7 +116,7 @@ create operator <> (
--
-- PostgreSQL code for ISBNs.
--
-- $Id: isbn_issn.sql.in,v 1.
2 2000/06/19 13:53:39
momjian Exp $
-- $Id: isbn_issn.sql.in,v 1.
3 2002/06/23 21:20:38
momjian Exp $
--
--
-- Input and output functions and the type itself:
...
...
@@ -223,6 +223,192 @@ create operator <> (
procedure = isbn_ne
);
-------------------------------------------------
-- Create default operator class for 'isbn' --
-- Needed to create index or primary key --
-------------------------------------------------
-- Register new operator class with system catalog pg_opclass
insert into pg_opclass
(opcamid, opcname, opcintype, opcdefault, opckeytype)
values ((select oid from pg_am where amname = 'btree'),
'isbn_ops',
(select oid from pg_type where typname = 'isbn'),
true,
0);
-- Verify that new operator class was added to pg_opclass
-- select oid,* from pg_opclass where opcname = 'isbn_ops';
-- Identify comparison operators for 'isbn' type
select o.oid as opoid, o.oprname
into temp table isbn_ops_tmp
from pg_operator o, pg_type t
where o.oprleft = t.oid
and o.oprright = t.oid
and t.typname = 'isbn';
-- Make sure all 5 needed order ops are there (<, <=, =, >=, >)
-- Operator <> will be present but is not needed
-- select * from isbn_ops_tmp order by opoid;
-- Associate B-tree strategy 1 with <
insert into pg_amop
(amopclaid, amopstrategy, amopreqcheck, amopopr)
select opcl.oid, 1, false, c.opoid
from pg_opclass opcl, isbn_ops_tmp c
where opcamid = (select oid from pg_am where amname = 'btree')
and opcname = 'isbn_ops'
and c.oprname = '<';
-- Associate B-tree strategy 2 with <=
insert into pg_amop
(amopclaid, amopstrategy, amopreqcheck, amopopr)
select opcl.oid, 2, false, c.opoid
from pg_opclass opcl, isbn_ops_tmp c
where opcamid = (select oid from pg_am where amname = 'btree')
and opcname = 'isbn_ops'
and c.oprname = '<=';
-- Associate B-tree strategy 3 with =
insert into pg_amop
(amopclaid, amopstrategy, amopreqcheck, amopopr)
select opcl.oid, 3, false, c.opoid
from pg_opclass opcl, isbn_ops_tmp c
where opcamid = (select oid from pg_am where amname = 'btree')
and opcname = 'isbn_ops'
and c.oprname = '=';
-- Associate B-tree strategy 4 with >=
insert into pg_amop
(amopclaid, amopstrategy, amopreqcheck, amopopr)
select opcl.oid, 4, false, c.opoid
from pg_opclass opcl, isbn_ops_tmp c
where opcamid = (select oid from pg_am where amname = 'btree')
and opcname = 'isbn_ops'
and c.oprname = '>=';
-- Associate B-tree strategy 5 with >
insert into pg_amop
(amopclaid, amopstrategy, amopreqcheck, amopopr)
select opcl.oid, 5, false, c.opoid
from pg_opclass opcl, isbn_ops_tmp c
where opcamid = (select oid from pg_am where amname = 'btree')
and opcname = 'isbn_ops'
and c.oprname = '>';
-- Register 'isbn' comparison function
create function isbn_cmp(isbn, isbn)
returns integer
as '$libdir/isbn_issn'
language c;
-- Make sure that function was correctly registered
-- select oid, proname from pg_proc where proname = 'isbn_cmp';
-- Associate default btree operator class with 'isbn' comparison function
insert into pg_amproc
(amopclaid, amprocnum, amproc)
select opcl.oid, 1, p.oid
from pg_opclass opcl, pg_proc p
where opcamid = (select oid from pg_am where amname = 'btree')
and opcname = 'isbn_ops'
and p.proname = 'isbn_cmp';
-------------------------------------------------
-- Create default operator class for 'issn' --
-- Needed to create index or primary key --
-------------------------------------------------
-- Register new operator class with system catalog pg_opclass
insert into pg_opclass
(opcamid, opcname, opcintype, opcdefault, opckeytype)
values ((select oid from pg_am where amname = 'btree'),
'issn_ops',
(select oid from pg_type where typname = 'issn'),
true,
0);
-- Verify that new operator class was added to pg_opclass
-- select oid,* from pg_opclass where opcname = 'issn_ops';
-- Identify comparison operators for 'issn' type
select o.oid as opoid, o.oprname
into temp table issn_ops_tmp
from pg_operator o, pg_type t
where o.oprleft = t.oid
and o.oprright = t.oid
and t.typname = 'issn';
-- Make sure all 5 needed order ops are there (<, <=, =, >=, >)
-- Operator <> will be present but is not needed
-- select * from issn_ops_tmp order by opoid;
-- Associate B-tree strategy 1 with <
insert into pg_amop
(amopclaid, amopstrategy, amopreqcheck, amopopr)
select opcl.oid, 1, false, c.opoid
from pg_opclass opcl, issn_ops_tmp c
where opcamid = (select oid from pg_am where amname = 'btree')
and opcname = 'issn_ops'
and c.oprname = '<';
-- Associate B-tree strategy 2 with <=
insert into pg_amop
(amopclaid, amopstrategy, amopreqcheck, amopopr)
select opcl.oid, 2, false, c.opoid
from pg_opclass opcl, issn_ops_tmp c
where opcamid = (select oid from pg_am where amname = 'btree')
and opcname = 'issn_ops'
and c.oprname = '<=';
-- Associate B-tree strategy 3 with =
insert into pg_amop
(amopclaid, amopstrategy, amopreqcheck, amopopr)
select opcl.oid, 3, false, c.opoid
from pg_opclass opcl, issn_ops_tmp c
where opcamid = (select oid from pg_am where amname = 'btree')
and opcname = 'issn_ops'
and c.oprname = '=';
-- Associate B-tree strategy 4 with >=
insert into pg_amop
(amopclaid, amopstrategy, amopreqcheck, amopopr)
select opcl.oid, 4, false, c.opoid
from pg_opclass opcl, issn_ops_tmp c
where opcamid = (select oid from pg_am where amname = 'btree')
and opcname = 'issn_ops'
and c.oprname = '>=';
-- Associate B-tree strategy 5 with >
insert into pg_amop
(amopclaid, amopstrategy, amopreqcheck, amopopr)
select opcl.oid, 5, false, c.opoid
from pg_opclass opcl, issn_ops_tmp c
where opcamid = (select oid from pg_am where amname = 'btree')
and opcname = 'issn_ops'
and c.oprname = '>';
-- Register 'issn' comparison function
create function issn_cmp(issn, issn)
returns integer
as '$libdir/issn_issn'
language c;
-- Make sure that function was correctly registered
-- select oid, proname from pg_proc where proname = 'issn_cmp';
-- Associate default btree operator class with 'issn' comparison function
insert into pg_amproc
(amopclaid, amprocnum, amproc)
select opcl.oid, 1, p.oid
from pg_opclass opcl, pg_proc p
where opcamid = (select oid from pg_am where amname = 'btree')
and opcname = 'issn_ops'
and p.proname = 'issn_cmp';
--
-- eof
--
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment