Commit aa4c702e authored by Bruce Momjian's avatar Bruce Momjian

Update /contrib for "autocommit TO 'on'".

Create objects in public schema.

Make spacing/capitalization consistent.

Remove transaction block use for object creation.

Remove unneeded function GRANTs.
parent fb9bc342
#!/usr/bin/perl #!/usr/bin/perl
# $Id: adddepend,v 1.1 2002/09/18 20:38:59 momjian Exp $ # $Id: adddepend,v 1.2 2002/10/18 18:41:19 momjian Exp $
# Project exists to assist PostgreSQL users with their structural upgrade # Project exists to assist PostgreSQL users with their structural upgrade
# from 7.2 (or prior) to 7.3 (possibly later). Must be run against a 7.3 # from 7.2 (or prior) to 7.3 (possibly later). Must be run against a 7.3
...@@ -125,6 +125,20 @@ my $dbh = DBI->connect($dsn, $dbuser, $dbpass); ...@@ -125,6 +125,20 @@ my $dbh = DBI->connect($dsn, $dbuser, $dbpass);
# We want to control commits # We want to control commits
$dbh->{'AutoCommit'} = 0; $dbh->{'AutoCommit'} = 0;
# turn on autocommit
my $sql = qq{
SET search_path = public;
};
my $sth = $dbh->prepare($sql);
$sth->execute();
# turn on autocommit
my $sql2 = qq{
SET autocommit TO 'on';
};
my $sth2 = $dbh->prepare($sql2);
$sth2->execute();
END { END {
$dbh->disconnect() if $dbh; $dbh->disconnect() if $dbh;
} }
......
...@@ -2,287 +2,353 @@ ...@@ -2,287 +2,353 @@
-- define the array operators *=, **=, *~ and **~ for type _text -- define the array operators *=, **=, *~ and **~ for type _text
-- --
create or replace function array_texteq(_text, text) returns bool
as 'MODULE_PATHNAME'
language C with (isStrict);
create or replace function array_all_texteq(_text, text) returns bool -- Adjust this setting to control where the objects get created.
as 'MODULE_PATHNAME' SET search_path = public;
language C with (isStrict);
create or replace function array_textregexeq(_text, text) returns bool SET autocommit TO 'on';
as 'MODULE_PATHNAME'
language C with (isStrict);
create or replace function array_all_textregexeq(_text, text) returns bool CREATE OR REPLACE FUNCTION array_texteq(_text, text)
as 'MODULE_PATHNAME' RETURNS bool
language C with (isStrict); AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict);
create operator *= ( CREATE OR REPLACE FUNCTION array_all_texteq(_text, text)
leftarg=_text, RETURNS bool
rightarg=text, AS 'MODULE_PATHNAME'
procedure=array_texteq); LANGUAGE 'C' WITH (isStrict);
create operator **= ( CREATE OR REPLACE FUNCTION array_textregexeq(_text, text)
leftarg=_text, RETURNS bool
rightarg=text, AS 'MODULE_PATHNAME'
procedure=array_all_texteq); LANGUAGE 'C' WITH (isStrict);
create operator *~ ( CREATE OR REPLACE FUNCTION array_all_textregexeq(_text, text)
leftarg=_text, RETURNS bool
rightarg=text, AS 'MODULE_PATHNAME'
procedure=array_textregexeq); LANGUAGE 'C' WITH (isStrict);
create operator **~ ( CREATE OPERATOR *= (
leftarg=_text, LEFTARG=_text,
rightarg=text, RIGHTARG=text,
procedure=array_all_textregexeq); PROCEDURE=array_texteq
);
CREATE OPERATOR **= (
LEFTARG=_text,
RIGHTARG=text,
PROCEDURE=array_all_texteq
);
CREATE OPERATOR *~ (
LEFTARG=_text,
RIGHTARG=text,
PROCEDURE=array_textregexeq
);
CREATE OPERATOR **~ (
LEFTARG=_text,
RIGHTARG=text,
PROCEDURE=array_all_textregexeq
);
-- define the array operators *=, **=, *~ and **~ for type _varchar -- define the array operators *=, **=, *~ and **~ for type _varchar
-- --
-- NOTE: "varchar" is also a reserved word and must be quoted. -- NOTE: "varchar" is also a reserved word and must be quoted.
-- --
create or replace function array_varchareq(_varchar, varchar) returns bool CREATE OR REPLACE FUNCTION array_varchareq(_varchar, varchar)
as 'MODULE_PATHNAME' RETURNS bool
language C with (isStrict); AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict);
create or replace function array_all_varchareq(_varchar, varchar) returns bool
as 'MODULE_PATHNAME' CREATE OR REPLACE FUNCTION array_all_varchareq(_varchar, varchar)
language C with (isStrict); RETURNS bool
AS 'MODULE_PATHNAME'
create or replace function array_varcharregexeq(_varchar, varchar) returns bool LANGUAGE 'C' WITH (isStrict);
as 'MODULE_PATHNAME'
language C with (isStrict); CREATE OR REPLACE FUNCTION array_varcharregexeq(_varchar, varchar)
RETURNS bool
create or replace function array_all_varcharregexeq(_varchar, varchar) returns bool AS 'MODULE_PATHNAME'
as 'MODULE_PATHNAME' LANGUAGE 'C' WITH (isStrict);
language C with (isStrict);
CREATE OR REPLACE FUNCTION array_all_varcharregexeq(_varchar, varchar)
create operator *= ( RETURNS bool
leftarg=_varchar, AS 'MODULE_PATHNAME'
rightarg="varchar", LANGUAGE 'C' WITH (isStrict);
procedure=array_varchareq);
CREATE OPERATOR *= (
create operator **= ( LEFTARG=_varchar,
leftarg=_varchar, RIGHTARG="varchar",
rightarg="varchar", PROCEDURE=array_varchareq
procedure=array_all_varchareq); );
create operator *~ ( CREATE OPERATOR **= (
leftarg=_varchar, LEFTARG=_varchar,
rightarg="varchar", RIGHTARG="varchar",
procedure=array_varcharregexeq); PROCEDURE=array_all_varchareq
);
create operator **~ (
leftarg=_varchar, CREATE OPERATOR *~ (
rightarg="varchar", LEFTARG=_varchar,
procedure=array_all_varcharregexeq); RIGHTARG="varchar",
PROCEDURE=array_varcharregexeq
);
CREATE OPERATOR **~ (
LEFTARG=_varchar,
RIGHTARG="varchar",
PROCEDURE=array_all_varcharregexeq
);
-- define the array operators *=, **=, *~ and **~ for type _bpchar -- define the array operators *=, **=, *~ and **~ for type _bpchar
-- --
create or replace function array_bpchareq(_bpchar, bpchar) returns bool CREATE OR REPLACE FUNCTION array_bpchareq(_bpchar, bpchar)
as 'MODULE_PATHNAME' RETURNS bool
language C with (isStrict); AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict);
create or replace function array_all_bpchareq(_bpchar, bpchar) returns bool
as 'MODULE_PATHNAME' CREATE OR REPLACE FUNCTION array_all_bpchareq(_bpchar, bpchar)
language C with (isStrict); RETURNS bool
AS 'MODULE_PATHNAME'
create or replace function array_bpcharregexeq(_bpchar, bpchar) returns bool LANGUAGE 'C' WITH (isStrict);
as 'MODULE_PATHNAME'
language C with (isStrict); CREATE OR REPLACE FUNCTION array_bpcharregexeq(_bpchar, bpchar)
RETURNS bool
create or replace function array_all_bpcharregexeq(_bpchar, bpchar) returns bool AS 'MODULE_PATHNAME'
as 'MODULE_PATHNAME' LANGUAGE 'C' WITH (isStrict);
language C with (isStrict);
CREATE OR REPLACE FUNCTION array_all_bpcharregexeq(_bpchar, bpchar)
create operator *= ( RETURNS bool
leftarg=_bpchar, AS 'MODULE_PATHNAME'
rightarg=bpchar, LANGUAGE 'C' WITH (isStrict);
procedure=array_bpchareq);
CREATE OPERATOR *= (
create operator **= ( LEFTARG=_bpchar,
leftarg=_bpchar, RIGHTARG=bpchar,
rightarg=bpchar, PROCEDURE=array_bpchareq
procedure=array_all_bpchareq); );
create operator *~ ( CREATE OPERATOR **= (
leftarg=_bpchar, LEFTARG=_bpchar,
rightarg=bpchar, RIGHTARG=bpchar,
procedure=array_bpcharregexeq); PROCEDURE=array_all_bpchareq
);
create operator **~ (
leftarg=_bpchar, CREATE OPERATOR *~ (
rightarg=bpchar, LEFTARG=_bpchar,
procedure=array_all_bpcharregexeq); RIGHTARG=bpchar,
PROCEDURE=array_bpcharregexeq
);
CREATE OPERATOR **~ (
LEFTARG=_bpchar,
RIGHTARG=bpchar,
PROCEDURE=array_all_bpcharregexeq
);
-- define the array operators *=, **=, *> and **> for type _int4 -- define the array operators *=, **=, *> and **> for type _int4
-- --
create or replace function array_int4eq(_int4, int4) returns bool CREATE OR REPLACE FUNCTION array_int4eq(_int4, int4)
as 'MODULE_PATHNAME' RETURNS bool
language C with (isStrict); AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict);
create or replace function array_all_int4eq(_int4, int4) returns bool
as 'MODULE_PATHNAME' CREATE OR REPLACE FUNCTION array_all_int4eq(_int4, int4)
language C with (isStrict); RETURNS bool
AS 'MODULE_PATHNAME'
create or replace function array_int4ne(_int4, int4) returns bool LANGUAGE 'C' WITH (isStrict);
as 'MODULE_PATHNAME'
language C with (isStrict); CREATE OR REPLACE FUNCTION array_int4ne(_int4, int4)
RETURNS bool
create or replace function array_all_int4ne(_int4, int4) returns bool AS 'MODULE_PATHNAME'
as 'MODULE_PATHNAME' LANGUAGE 'C' WITH (isStrict);
language C with (isStrict);
CREATE OR REPLACE FUNCTION array_all_int4ne(_int4, int4)
create or replace function array_int4gt(_int4, int4) returns bool RETURNS bool
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language C with (isStrict); LANGUAGE 'C' WITH (isStrict);
create or replace function array_all_int4gt(_int4, int4) returns bool CREATE OR REPLACE FUNCTION array_int4gt(_int4, int4)
as 'MODULE_PATHNAME' RETURNS bool
language C with (isStrict); AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict);
create or replace function array_int4ge(_int4, int4) returns bool
as 'MODULE_PATHNAME' CREATE OR REPLACE FUNCTION array_all_int4gt(_int4, int4)
language C with (isStrict); RETURNS bool
AS 'MODULE_PATHNAME'
create or replace function array_all_int4ge(_int4, int4) returns bool LANGUAGE 'C' WITH (isStrict);
as 'MODULE_PATHNAME'
language C with (isStrict); CREATE OR REPLACE FUNCTION array_int4ge(_int4, int4)
RETURNS bool
create or replace function array_int4lt(_int4, int4) returns bool AS 'MODULE_PATHNAME'
as 'MODULE_PATHNAME' LANGUAGE 'C' WITH (isStrict);
language C with (isStrict);
CREATE OR REPLACE FUNCTION array_all_int4ge(_int4, int4)
create or replace function array_all_int4lt(_int4, int4) returns bool RETURNS bool
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language C with (isStrict); LANGUAGE 'C' WITH (isStrict);
create or replace function array_int4le(_int4, int4) returns bool CREATE OR REPLACE FUNCTION array_int4lt(_int4, int4)
as 'MODULE_PATHNAME' RETURNS bool
language C with (isStrict); AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict);
create or replace function array_all_int4le(_int4, int4) returns bool
as 'MODULE_PATHNAME' CREATE OR REPLACE FUNCTION array_all_int4lt(_int4, int4)
language C with (isStrict); RETURNS bool
AS 'MODULE_PATHNAME'
create operator *= ( LANGUAGE 'C' WITH (isStrict);
leftarg=_int4,
rightarg=int4, CREATE OR REPLACE FUNCTION array_int4le(_int4, int4)
procedure=array_int4eq); RETURNS bool
AS 'MODULE_PATHNAME'
create operator **= ( LANGUAGE 'C' WITH (isStrict);
leftarg=_int4,
rightarg=int4, CREATE OR REPLACE FUNCTION array_all_int4le(_int4, int4)
procedure=array_all_int4eq); RETURNS bool
AS 'MODULE_PATHNAME'
create operator *<> ( LANGUAGE 'C' WITH (isStrict);
leftarg=_int4,
rightarg=int4, CREATE OPERATOR *= (
procedure=array_int4ne); LEFTARG=_int4,
RIGHTARG=int4,
create operator **<> ( PROCEDURE=array_int4eq
leftarg=_int4, );
rightarg=int4,
procedure=array_all_int4ne); CREATE OPERATOR **= (
LEFTARG=_int4,
create operator *> ( RIGHTARG=int4,
leftarg=_int4, PROCEDURE=array_all_int4eq
rightarg=int4, );
procedure=array_int4gt);
CREATE OPERATOR *<> (
create operator **> ( LEFTARG=_int4,
leftarg=_int4, RIGHTARG=int4,
rightarg=int4, PROCEDURE=array_int4ne
procedure=array_all_int4gt); );
create operator *>= ( CREATE OPERATOR **<> (
leftarg=_int4, LEFTARG=_int4,
rightarg=int4, RIGHTARG=int4,
procedure=array_int4ge); PROCEDURE=array_all_int4ne
);
create operator **>= (
leftarg=_int4, CREATE OPERATOR *> (
rightarg=int4, LEFTARG=_int4,
procedure=array_all_int4ge); RIGHTARG=int4,
PROCEDURE=array_int4gt
create operator *< ( );
leftarg=_int4,
rightarg=int4, CREATE OPERATOR **> (
procedure=array_int4lt); LEFTARG=_int4,
RIGHTARG=int4,
create operator **< ( PROCEDURE=array_all_int4gt
leftarg=_int4, );
rightarg=int4,
procedure=array_all_int4lt); CREATE OPERATOR *>= (
LEFTARG=_int4,
create operator *<= ( RIGHTARG=int4,
leftarg=_int4, PROCEDURE=array_int4ge
rightarg=int4, );
procedure=array_int4le);
CREATE OPERATOR **>= (
create operator **<= ( LEFTARG=_int4,
leftarg=_int4, RIGHTARG=int4,
rightarg=int4, PROCEDURE=array_all_int4ge
procedure=array_all_int4le); );
CREATE OPERATOR *< (
LEFTARG=_int4,
RIGHTARG=int4,
PROCEDURE=array_int4lt
);
CREATE OPERATOR **< (
LEFTARG=_int4,
RIGHTARG=int4,
PROCEDURE=array_all_int4lt
);
CREATE OPERATOR *<= (
LEFTARG=_int4,
RIGHTARG=int4,
PROCEDURE=array_int4le
);
CREATE OPERATOR **<= (
LEFTARG=_int4,
RIGHTARG=int4,
PROCEDURE=array_all_int4le
);
-- define the array operators *=, **<> for type _oid (added tobias 1. 1999) -- define the array operators *=, **<> for type _oid (added tobias 1. 1999)
-- --
create or replace function array_oideq(_oid, oid) returns bool CREATE OR REPLACE FUNCTION array_oideq(_oid, oid)
as 'MODULE_PATHNAME' RETURNS bool
language C with (isStrict); AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict);
create or replace function array_all_oidne(_oid, oid) returns bool
as 'MODULE_PATHNAME' CREATE OR REPLACE FUNCTION array_all_oidne(_oid, oid)
language C with (isStrict); RETURNS bool
AS 'MODULE_PATHNAME'
create operator *= ( LANGUAGE 'C' WITH (isStrict);
leftarg=_oid,
rightarg=oid, CREATE OPERATOR *= (
procedure=array_oideq); LEFTARG=_oid,
RIGHTARG=oid,
create operator **<> ( PROCEDURE=array_oideq
leftarg=_oid, );
rightarg=oid,
procedure=array_all_oidne); CREATE OPERATOR **<> (
LEFTARG=_oid,
RIGHTARG=oid,
PROCEDURE=array_all_oidne
);
-- define the array operators *=, **=, *<>, **<> for type _inet -- define the array operators *=, **=, *<>, **<> for type _inet
create or replace function array_ineteq(_inet, inet) returns bool CREATE OR REPLACE FUNCTION array_ineteq(_inet, inet)
as 'MODULE_PATHNAME' RETURNS bool
language C with (isStrict); AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict);
create or replace function array_all_ineteq(_inet, inet) returns bool
as 'MODULE_PATHNAME' CREATE OR REPLACE FUNCTION array_all_ineteq(_inet, inet)
language C with (isStrict); RETURNS bool
AS 'MODULE_PATHNAME'
create or replace function array_inetne(_inet, inet) returns bool LANGUAGE 'C' WITH (isStrict);
as 'MODULE_PATHNAME'
language C with (isStrict); CREATE OR REPLACE FUNCTION array_inetne(_inet, inet)
RETURNS bool
create or replace function array_all_inetne(_inet, inet) returns bool AS 'MODULE_PATHNAME'
as 'MODULE_PATHNAME' LANGUAGE 'C' WITH (isStrict);
language C with (isStrict);
CREATE OR REPLACE FUNCTION array_all_inetne(_inet, inet)
create operator *= ( RETURNS bool
leftarg=_inet, AS 'MODULE_PATHNAME'
rightarg=inet, LANGUAGE 'C' WITH (isStrict);
procedure=array_ineteq);
CREATE OPERATOR *= (
create operator **= ( LEFTARG=_inet,
leftarg=_inet, RIGHTARG=inet,
rightarg=inet, PROCEDURE=array_ineteq
procedure=array_all_ineteq); );
create operator *<> ( CREATE OPERATOR **= (
leftarg=_inet, LEFTARG=_inet,
rightarg=inet, RIGHTARG=inet,
procedure=array_inetne); PROCEDURE=array_all_ineteq
);
create operator **<> (
leftarg=_inet, CREATE OPERATOR *<> (
rightarg=inet, LEFTARG=_inet,
procedure=array_all_inetne); RIGHTARG=inet,
PROCEDURE=array_inetne
);
CREATE OPERATOR **<> (
LEFTARG=_inet,
RIGHTARG=inet,
PROCEDURE=array_all_inetne
);
begin transaction;
-- Adjust this setting to control where the objects get created. -- Adjust this setting to control where the objects get created.
SET search_path = public; SET search_path = public;
SET autocommit TO 'on';
-- create type of int4 key -- create type of int4 key
CREATE FUNCTION int4key_in(cstring) CREATE FUNCTION int4key_in(cstring)
RETURNS int4key RETURNS int4key
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' WITH (isstrict);
CREATE FUNCTION int4key_out(int4key) CREATE FUNCTION int4key_out(int4key)
RETURNS cstring RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' WITH (isstrict);
CREATE TYPE int4key ( CREATE TYPE int4key (
internallength = 8, INTERNALLENGTH = 8,
input = int4key_in, INPUT = int4key_in,
output = int4key_out OUTPUT = int4key_out
); );
...@@ -29,23 +29,45 @@ output = int4key_out ...@@ -29,23 +29,45 @@ output = int4key_out
-- --
-- --
-- define the GiST support methods -- define the GiST support methods
create function gint4_consistent(internal,int4,int2) returns bool as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION gint4_consistent(internal,int4,int2)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
create function gint4_compress(internal) returns internal as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION gint4_compress(internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
create function btree_decompress(internal) returns internal as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION btree_decompress(internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
create function gint4_penalty(internal,internal,internal) returns internal as 'MODULE_PATHNAME' language 'C' with(isstrict); CREATE FUNCTION gint4_penalty(internal,internal,internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isstrict);
create function gint4_picksplit(internal, internal) returns internal as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION gint4_picksplit(internal, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
create function gint4_union(bytea, internal) returns int4 as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION gint4_union(bytea, internal)
RETURNS int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
create function gint4_same(internal, internal, internal) returns internal as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION gint4_same(internal, internal, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- Create the operator class -- Create the operator class
CREATE OPERATOR CLASS gist_int4_ops CREATE OPERATOR CLASS gist_int4_ops
DEFAULT FOR TYPE int4 USING gist AS DEFAULT FOR TYPE int4 USING gist
AS
OPERATOR 1 < , OPERATOR 1 < ,
OPERATOR 2 <= , OPERATOR 2 <= ,
OPERATOR 3 = , OPERATOR 3 = ,
...@@ -73,34 +95,53 @@ CREATE OPERATOR CLASS gist_int4_ops ...@@ -73,34 +95,53 @@ CREATE OPERATOR CLASS gist_int4_ops
CREATE FUNCTION tskey_in(cstring) CREATE FUNCTION tskey_in(cstring)
RETURNS tskey RETURNS tskey
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' WITH (isstrict);
CREATE FUNCTION tskey_out(tskey) CREATE FUNCTION tskey_out(tskey)
RETURNS cstring RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'c' WITH (isstrict);
CREATE TYPE tskey ( CREATE TYPE tskey (
internallength = 16, INTERNALLENGTH = 16,
input = tskey_in, INPUT = tskey_in,
output = tskey_out OUTPUT = tskey_out
); );
create function gts_consistent(internal,timestamp,int2) returns bool as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION gts_consistent(internal,timestamp,int2)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
create function gts_compress(internal) returns internal as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION gts_compress(internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
create function gts_penalty(internal,internal,internal) returns internal as 'MODULE_PATHNAME' language 'C' with(isstrict); CREATE FUNCTION gts_penalty(internal,internal,internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isstrict);
create function gts_picksplit(internal, internal) returns internal as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION gts_picksplit(internal, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
create function gts_union(bytea, internal) returns int4 as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION gts_union(bytea, internal)
RETURNS int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
create function gts_same(internal, internal, internal) returns internal as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION gts_same(internal, internal, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- Create the operator class -- Create the operator class
CREATE OPERATOR CLASS gist_timestamp_ops CREATE OPERATOR CLASS gist_timestamp_ops
DEFAULT FOR TYPE timestamp USING gist AS DEFAULT FOR TYPE timestamp USING gist
AS
OPERATOR 1 < , OPERATOR 1 < ,
OPERATOR 2 <= , OPERATOR 2 <= ,
OPERATOR 3 = , OPERATOR 3 = ,
...@@ -114,6 +155,3 @@ CREATE OPERATOR CLASS gist_timestamp_ops ...@@ -114,6 +155,3 @@ CREATE OPERATOR CLASS gist_timestamp_ops
FUNCTION 6 gts_picksplit (internal, internal), FUNCTION 6 gts_picksplit (internal, internal),
FUNCTION 7 gts_same (internal, internal, internal), FUNCTION 7 gts_same (internal, internal, internal),
STORAGE tskey; STORAGE tskey;
end transaction;
...@@ -7,35 +7,35 @@ psql:btree_gist.sql:10: WARNING: ProcedureCreate: type int4key is not yet defin ...@@ -7,35 +7,35 @@ psql:btree_gist.sql:10: WARNING: ProcedureCreate: type int4key is not yet defin
psql:btree_gist.sql:15: WARNING: Argument type "int4key" is only a shell psql:btree_gist.sql:15: WARNING: Argument type "int4key" is only a shell
psql:btree_gist.sql:76: WARNING: ProcedureCreate: type tskey is not yet defined psql:btree_gist.sql:76: WARNING: ProcedureCreate: type tskey is not yet defined
psql:btree_gist.sql:81: WARNING: Argument type "tskey" is only a shell psql:btree_gist.sql:81: WARNING: Argument type "tskey" is only a shell
create table inttmp (b int4); CREATE TABLE inttmp (b int4);
\copy inttmp from 'data/test_btree.data' \copy inttmp from 'data/test_btree.data'
create table tstmp ( t timestamp without time zone ); CREATE TABLE tstmp ( t timestamp without time zone );
\copy tstmp from 'data/test_btree_ts.data' \copy tstmp from 'data/test_btree_ts.data'
-- without idx -- without idx
select count(*) from inttmp where b <=10; SELECT count(*) FROM inttmp WHERE b <=10;
count count
------- -------
11 11
(1 row) (1 row)
select count(*) from tstmp where t < '2001-05-29 08:33:09'; SELECT count(*) FROM tstmp WHERE t < '2001-05-29 08:33:09';
count count
------- -------
66 66
(1 row) (1 row)
-- create idx -- create idx
create index aaaidx on inttmp using gist ( b ); CREATE INDEX aaaidx ON inttmp USING gist ( b );
create index tsidx on tstmp using gist ( t ); CREATE INDEX tsidx ON tstmp USING gist ( t );
--with idx --with idx
set enable_seqscan=off; SET enable_seqscan=off;
select count(*) from inttmp where b <=10; SELECT count(*) FROM inttmp WHERE b <=10;
count count
------- -------
11 11
(1 row) (1 row)
select count(*) from tstmp where t < '2001-05-29 08:33:09'; SELECT count(*) FROM tstmp WHERE t < '2001-05-29 08:33:09';
count count
------- -------
66 66
......
...@@ -3,34 +3,35 @@ ...@@ -3,34 +3,35 @@
-- does not depend on contents of seg.sql. -- does not depend on contents of seg.sql.
-- --
\set ECHO none \set ECHO none
SET autocommit TO 'on';
\i btree_gist.sql \i btree_gist.sql
\set ECHO all \set ECHO all
create table inttmp (b int4); CREATE TABLE inttmp (b int4);
\copy inttmp from 'data/test_btree.data' \copy inttmp from 'data/test_btree.data'
create table tstmp ( t timestamp without time zone ); CREATE TABLE tstmp ( t timestamp without time zone );
\copy tstmp from 'data/test_btree_ts.data' \copy tstmp from 'data/test_btree_ts.data'
-- without idx -- without idx
select count(*) from inttmp where b <=10; SELECT count(*) FROM inttmp WHERE b <=10;
select count(*) from tstmp where t < '2001-05-29 08:33:09'; SELECT count(*) FROM tstmp WHERE t < '2001-05-29 08:33:09';
-- create idx -- create idx
create index aaaidx on inttmp using gist ( b ); CREATE INDEX aaaidx ON inttmp USING gist ( b );
create index tsidx on tstmp using gist ( t ); CREATE INDEX tsidx ON tstmp USING gist ( t );
--with idx --with idx
set enable_seqscan=off; SET enable_seqscan=off;
select count(*) from inttmp where b <=10; SELECT count(*) FROM inttmp WHERE b <=10;
select count(*) from tstmp where t < '2001-05-29 08:33:09'; SELECT count(*) FROM tstmp WHERE t < '2001-05-29 08:33:09';
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
-- darcy@druid.net -- darcy@druid.net
-- http://www.druid.net/darcy/ -- http://www.druid.net/darcy/
-- --
-- $Header: /cvsroot/pgsql/contrib/chkpass/chkpass.sql.in,v 1.2 2002/08/22 00:01:38 tgl Exp $ -- $Header: /cvsroot/pgsql/contrib/chkpass/chkpass.sql.in,v 1.3 2002/10/18 18:41:19 momjian Exp $
-- --
-- best viewed with tabs set to 4 -- best viewed with tabs set to 4
-- --
...@@ -13,41 +13,46 @@ ...@@ -13,41 +13,46 @@
-- Input and output functions and the type itself: -- Input and output functions and the type itself:
-- --
create function chkpass_in(cstring) -- Adjust this setting to control where the objects get created.
returns chkpass SET search_path = public;
as 'MODULE_PATHNAME'
language 'c';
create function chkpass_out(chkpass) SET autocommit TO 'on';
returns cstring
as 'MODULE_PATHNAME'
language 'c';
create type chkpass ( CREATE FUNCTION chkpass_in(cstring)
RETURNS chkpass
AS 'MODULE_PATHNAME'
LANGUAGE 'c';
CREATE FUNCTION chkpass_out(chkpass)
RETURNS cstring
AS 'MODULE_PATHNAME'
LANGUAGE 'c';
CREATE TYPE chkpass (
internallength = 16, internallength = 16,
externallength = 13, externallength = 13,
input = chkpass_in, input = chkpass_in,
output = chkpass_out output = chkpass_out
); );
create function raw(chkpass) CREATE FUNCTION raw(chkpass)
returns text RETURNS text
as 'MODULE_PATHNAME', 'chkpass_rout' AS 'MODULE_PATHNAME', 'chkpass_rout'
language 'c'; LANGUAGE 'c';
-- --
-- The various boolean tests: -- The various boolean tests:
-- --
create function eq(chkpass, text) CREATE FUNCTION eq(chkpass, text)
returns bool RETURNS bool
as 'MODULE_PATHNAME', 'chkpass_eq' AS 'MODULE_PATHNAME', 'chkpass_eq'
language 'c'; LANGUAGE 'c';
create function ne(chkpass, text) CREATE FUNCTION ne(chkpass, text)
returns bool RETURNS bool
as 'MODULE_PATHNAME', 'chkpass_ne' AS 'MODULE_PATHNAME', 'chkpass_ne'
language 'c'; LANGUAGE 'c';
-- --
-- Now the operators. Note how some of the parameters to some -- Now the operators. Note how some of the parameters to some
...@@ -56,7 +61,7 @@ create function ne(chkpass, text) ...@@ -56,7 +61,7 @@ create function ne(chkpass, text)
-- will be implicitly defined when those are, further down. -- will be implicitly defined when those are, further down.
-- --
create operator = ( CREATE OPERATOR = (
leftarg = chkpass, leftarg = chkpass,
rightarg = text, rightarg = text,
commutator = =, commutator = =,
...@@ -64,7 +69,7 @@ create operator = ( ...@@ -64,7 +69,7 @@ create operator = (
procedure = eq procedure = eq
); );
create operator <> ( CREATE OPERATOR <> (
leftarg = chkpass, leftarg = chkpass,
rightarg = text, rightarg = text,
negator = =, negator = =,
......
-- Create the user-defined type for N-dimensional boxes -- Create the user-defined type for N-dimensional boxes
-- --
BEGIN;
-- Adjust this setting to control where the objects get created. -- Adjust this setting to control where the objects get created.
SET search_path = public; SET search_path = public;
SET autocommit TO 'on';
CREATE OR REPLACE FUNCTION cube_in(cstring) CREATE OR REPLACE FUNCTION cube_in(cstring)
RETURNS cube RETURNS cube
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c'IMMUTABLE STRICT; LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION cube_out(cube) CREATE OR REPLACE FUNCTION cube_out(cube)
RETURNS cstring RETURNS cstring
...@@ -16,22 +17,20 @@ AS 'MODULE_PATHNAME' ...@@ -16,22 +17,20 @@ AS 'MODULE_PATHNAME'
LANGUAGE 'c'IMMUTABLE STRICT; LANGUAGE 'c'IMMUTABLE STRICT;
CREATE TYPE cube ( CREATE TYPE cube (
internallength = variable, INTERNALLENGTH = variable,
input = cube_in, INPUT = cube_in,
output = cube_out OUTPUT = cube_out
); );
COMMENT ON TYPE cube IS COMMENT ON TYPE cube IS 'multi-dimensional cube ''(FLOAT-1, FLOAT-2, ..., FLOAT-N), (FLOAT-1, FLOAT-2, ..., FLOAT-N)''';
'multi-dimensional cube ''(FLOAT-1, FLOAT-2, ..., FLOAT-N), (FLOAT-1, FLOAT-2, ..., FLOAT-N)''';
-- Convert from text to cube -- Convert from text to cube
CREATE OR REPLACE FUNCTION cube(text) RETURNS cube CREATE OR REPLACE FUNCTION cube(text) RETURNS cube
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' IMMUTABLE STRICT; LANGUAGE 'C' IMMUTABLE STRICT;
COMMENT ON FUNCTION cube(text) IS COMMENT ON FUNCTION cube(text) IS 'convert text to cube';
'convert text to cube';
-- --
-- External C-functions for R-tree methods -- External C-functions for R-tree methods
...@@ -39,114 +38,144 @@ COMMENT ON FUNCTION cube(text) IS ...@@ -39,114 +38,144 @@ COMMENT ON FUNCTION cube(text) IS
-- Left/Right methods -- Left/Right methods
CREATE OR REPLACE FUNCTION cube_over_left(cube, cube) RETURNS bool CREATE OR REPLACE FUNCTION cube_over_left(cube, cube)
AS 'MODULE_PATHNAME' LANGUAGE 'c' IMMUTABLE STRICT; RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;
COMMENT ON FUNCTION cube_over_left(cube, cube) IS COMMENT ON FUNCTION cube_over_left(cube, cube) IS 'is over and left of (NOT IMPLEMENTED)';
'is over and left of (NOT IMPLEMENTED)';
CREATE OR REPLACE FUNCTION cube_over_right(cube, cube) RETURNS bool CREATE OR REPLACE FUNCTION cube_over_right(cube, cube)
AS 'MODULE_PATHNAME' LANGUAGE 'c' IMMUTABLE STRICT; RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;
COMMENT ON FUNCTION cube_over_right(cube, cube) IS COMMENT ON FUNCTION cube_over_right(cube, cube) IS 'is over and right of (NOT IMPLEMENTED)';
'is over and right of (NOT IMPLEMENTED)';
CREATE OR REPLACE FUNCTION cube_left(cube, cube) RETURNS bool CREATE OR REPLACE FUNCTION cube_left(cube, cube)
AS 'MODULE_PATHNAME' LANGUAGE 'c' IMMUTABLE STRICT; RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;
COMMENT ON FUNCTION cube_left(cube, cube) IS COMMENT ON FUNCTION cube_left(cube, cube) IS
'is left of (NOT IMPLEMENTED)'; 'is left of (NOT IMPLEMENTED)';
CREATE OR REPLACE FUNCTION cube_right(cube, cube) RETURNS bool CREATE OR REPLACE FUNCTION cube_right(cube, cube)
AS 'MODULE_PATHNAME' LANGUAGE 'c' IMMUTABLE STRICT; RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;
COMMENT ON FUNCTION cube_right(cube, cube) IS COMMENT ON FUNCTION cube_right(cube, cube) IS 'is right of (NOT IMPLEMENTED)';
'is right of (NOT IMPLEMENTED)';
-- Comparison methods -- Comparison methods
CREATE OR REPLACE FUNCTION cube_lt(cube, cube) RETURNS bool CREATE OR REPLACE FUNCTION cube_lt(cube, cube)
AS 'MODULE_PATHNAME' LANGUAGE 'c' IMMUTABLE STRICT; RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;
COMMENT ON FUNCTION cube_lt(cube, cube) IS COMMENT ON FUNCTION cube_lt(cube, cube) IS 'lower than';
'lower than';
CREATE OR REPLACE FUNCTION cube_gt(cube, cube) RETURNS bool CREATE OR REPLACE FUNCTION cube_gt(cube, cube)
AS 'MODULE_PATHNAME' LANGUAGE 'c' IMMUTABLE STRICT; RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;
COMMENT ON FUNCTION cube_gt(cube, cube) IS COMMENT ON FUNCTION cube_gt(cube, cube) IS 'greater than';
'greater than';
CREATE OR REPLACE FUNCTION cube_contains(cube, cube) RETURNS bool CREATE OR REPLACE FUNCTION cube_contains(cube, cube)
AS 'MODULE_PATHNAME' LANGUAGE 'c' IMMUTABLE STRICT; RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;
COMMENT ON FUNCTION cube_contains(cube, cube) IS COMMENT ON FUNCTION cube_contains(cube, cube) IS 'contains';
'contains';
CREATE OR REPLACE FUNCTION cube_contained(cube, cube) RETURNS bool CREATE OR REPLACE FUNCTION cube_contained(cube, cube)
AS 'MODULE_PATHNAME' LANGUAGE 'c' IMMUTABLE STRICT; RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;
COMMENT ON FUNCTION cube_contained(cube, cube) IS COMMENT ON FUNCTION cube_contained(cube, cube) IS 'contained in';
'contained in';
CREATE OR REPLACE FUNCTION cube_overlap(cube, cube) RETURNS bool CREATE OR REPLACE FUNCTION cube_overlap(cube, cube)
AS 'MODULE_PATHNAME' LANGUAGE 'c' IMMUTABLE STRICT; RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;
COMMENT ON FUNCTION cube_overlap(cube, cube) IS COMMENT ON FUNCTION cube_overlap(cube, cube) IS 'overlaps';
'overlaps';
CREATE OR REPLACE FUNCTION cube_same(cube, cube) RETURNS bool CREATE OR REPLACE FUNCTION cube_same(cube, cube)
AS 'MODULE_PATHNAME' LANGUAGE 'c' IMMUTABLE STRICT; RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;
COMMENT ON FUNCTION cube_same(cube, cube) IS COMMENT ON FUNCTION cube_same(cube, cube) IS 'same as';
'same as';
CREATE OR REPLACE FUNCTION cube_different(cube, cube) RETURNS bool CREATE OR REPLACE FUNCTION cube_different(cube, cube)
AS 'MODULE_PATHNAME' LANGUAGE 'c' IMMUTABLE STRICT; RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;
COMMENT ON FUNCTION cube_different(cube, cube) IS COMMENT ON FUNCTION cube_different(cube, cube) IS 'different';
'different';
-- support routines for indexing -- support routines for indexing
CREATE OR REPLACE FUNCTION cube_union(cube, cube) RETURNS cube CREATE OR REPLACE FUNCTION cube_union(cube, cube)
AS 'MODULE_PATHNAME' LANGUAGE 'c' IMMUTABLE STRICT; RETURNS cube
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION cube_inter(cube, cube) RETURNS cube CREATE OR REPLACE FUNCTION cube_inter(cube, cube)
AS 'MODULE_PATHNAME' LANGUAGE 'c' IMMUTABLE STRICT; RETURNS cube
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION cube_size(cube) RETURNS float8 CREATE OR REPLACE FUNCTION cube_size(cube)
AS 'MODULE_PATHNAME' LANGUAGE 'c' IMMUTABLE STRICT; RETURNS float8
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;
-- Misc N-dimensional functions -- Misc N-dimensional functions
-- proximity routines -- proximity routines
CREATE OR REPLACE FUNCTION cube_distance(cube, cube) RETURNS float8 CREATE OR REPLACE FUNCTION cube_distance(cube, cube)
AS 'MODULE_PATHNAME' LANGUAGE 'c' IMMUTABLE STRICT; RETURNS float8
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;
-- Extracting elements functions -- Extracting elements functions
CREATE OR REPLACE FUNCTION cube_dim(cube) RETURNS int4 CREATE OR REPLACE FUNCTION cube_dim(cube)
AS 'MODULE_PATHNAME' LANGUAGE 'c' IMMUTABLE STRICT; RETURNS int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION cube_ll_coord(cube, int4) RETURNS float8 CREATE OR REPLACE FUNCTION cube_ll_coord(cube, int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' IMMUTABLE STRICT; RETURNS float8
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION cube_ur_coord(cube, int4) RETURNS float8 CREATE OR REPLACE FUNCTION cube_ur_coord(cube, int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' IMMUTABLE STRICT; RETURNS float8
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;
-- Test if cube is also a point -- Test if cube is also a point
CREATE OR REPLACE FUNCTION cube_is_point(cube) RETURNS bool CREATE OR REPLACE FUNCTION cube_is_point(cube)
AS 'MODULE_PATHNAME' LANGUAGE 'c' IMMUTABLE STRICT; RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;
-- Increasing the size of a cube by a radius in at least n dimensions -- Increasing the size of a cube by a radius in at least n dimensions
CREATE OR REPLACE FUNCTION cube_enlarge(cube, float8, int4) RETURNS cube CREATE OR REPLACE FUNCTION cube_enlarge(cube, float8, int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' IMMUTABLE STRICT; RETURNS cube
AS 'MODULE_PATHNAME'
LANGUAGE 'C' IMMUTABLE STRICT;
-- --
-- OPERATORS -- OPERATORS
...@@ -221,26 +250,40 @@ CREATE OPERATOR ~ ( ...@@ -221,26 +250,40 @@ CREATE OPERATOR ~ (
-- define the GiST support methods -- define the GiST support methods
CREATE OR REPLACE FUNCTION g_cube_consistent(internal,cube,int4) RETURNS bool CREATE OR REPLACE FUNCTION g_cube_consistent(internal,cube,int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE OR REPLACE FUNCTION g_cube_compress(internal) RETURNS internal CREATE OR REPLACE FUNCTION g_cube_compress(internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE OR REPLACE FUNCTION g_cube_decompress(internal) RETURNS internal CREATE OR REPLACE FUNCTION g_cube_decompress(internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE OR REPLACE FUNCTION g_cube_penalty(internal,internal,internal) RETURNS internal CREATE OR REPLACE FUNCTION g_cube_penalty(internal,internal,internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c' STRICT; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C' STRICT;
CREATE OR REPLACE FUNCTION g_cube_picksplit(internal, internal) RETURNS internal CREATE OR REPLACE FUNCTION g_cube_picksplit(internal, internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE OR REPLACE FUNCTION g_cube_union(bytea, internal) RETURNS cube CREATE OR REPLACE FUNCTION g_cube_union(bytea, internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS cube
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE OR REPLACE FUNCTION g_cube_same(cube, cube, internal) RETURNS internal CREATE OR REPLACE FUNCTION g_cube_same(cube, cube, internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- Create the operator class for indexing -- Create the operator class for indexing
...@@ -262,32 +305,3 @@ CREATE OPERATOR CLASS gist_cube_ops ...@@ -262,32 +305,3 @@ CREATE OPERATOR CLASS gist_cube_ops
FUNCTION 5 g_cube_penalty (internal, internal, internal), FUNCTION 5 g_cube_penalty (internal, internal, internal),
FUNCTION 6 g_cube_picksplit (internal, internal), FUNCTION 6 g_cube_picksplit (internal, internal),
FUNCTION 7 g_cube_same (cube, cube, internal); FUNCTION 7 g_cube_same (cube, cube, internal);
--
-- By default the externally visible functions are made executable by
-- anyone. To restrict their access comment out the following grant commands.
--
GRANT EXECUTE ON FUNCTION cube(text) TO PUBLIC;
GRANT EXECUTE ON FUNCTION cube_over_left(cube, cube) TO PUBLIC;
GRANT EXECUTE ON FUNCTION cube_over_right(cube, cube) TO PUBLIC;
GRANT EXECUTE ON FUNCTION cube_left(cube, cube) TO PUBLIC;
GRANT EXECUTE ON FUNCTION cube_right(cube, cube) TO PUBLIC;
GRANT EXECUTE ON FUNCTION cube_lt(cube, cube) TO PUBLIC;
GRANT EXECUTE ON FUNCTION cube_gt(cube, cube) TO PUBLIC;
GRANT EXECUTE ON FUNCTION cube_contains(cube, cube) TO PUBLIC;
GRANT EXECUTE ON FUNCTION cube_contained(cube, cube) TO PUBLIC;
GRANT EXECUTE ON FUNCTION cube_overlap(cube, cube) TO PUBLIC;
GRANT EXECUTE ON FUNCTION cube_same(cube, cube) TO PUBLIC;
GRANT EXECUTE ON FUNCTION cube_different(cube, cube) TO PUBLIC;
GRANT EXECUTE ON FUNCTION cube_union(cube, cube) TO PUBLIC;
GRANT EXECUTE ON FUNCTION cube_inter(cube, cube) TO PUBLIC;
GRANT EXECUTE ON FUNCTION cube_size(cube) TO PUBLIC;
GRANT EXECUTE ON FUNCTION cube_distance(cube, cube) TO PUBLIC;
GRANT EXECUTE ON FUNCTION cube_dim(cube) TO PUBLIC;
GRANT EXECUTE ON FUNCTION cube_ll_coord(cube, int4) TO PUBLIC;
GRANT EXECUTE ON FUNCTION cube_ur_coord(cube, int4) TO PUBLIC;
GRANT EXECUTE ON FUNCTION cube_is_point(cube) TO PUBLIC;
GRANT EXECUTE ON FUNCTION cube_enlarge(cube, float8, int4) TO PUBLIC;
COMMIT;
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
-- does not depend on contents of cube.sql. -- does not depend on contents of cube.sql.
-- --
\set ECHO none \set ECHO none
psql:cube.sql:11: WARNING: ProcedureCreate: type cube is not yet defined psql:cube.sql:12: WARNING: ProcedureCreate: type cube is not yet defined
psql:cube.sql:16: WARNING: Argument type "cube" is only a shell psql:cube.sql:17: WARNING: Argument type "cube" is only a shell
-- --
-- testing the input and output functions -- testing the input and output functions
-- --
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
-- does not depend on contents of cube.sql. -- does not depend on contents of cube.sql.
-- --
\set ECHO none \set ECHO none
SET autocommit TO 'on';
\i cube.sql \i cube.sql
\set ECHO all \set ECHO all
......
...@@ -858,6 +858,10 @@ main(int argc, char **argv) ...@@ -858,6 +858,10 @@ main(int argc, char **argv)
exit(1); exit(1);
} }
PQexec(conn, "SET search_path = public");
PQexec(conn, "SET autocommit TO 'on'");
/* Substitute field names */ /* Substitute field names */
do_substitute(subarg, dbh); do_substitute(subarg, dbh);
......
-- Uncomment the following 9 lines to use original DEPRECATED functions --
--CREATE OR REPLACE FUNCTION dblink (text,text) RETURNS setof int -- Uncomment the following commented lines to use original DEPRECATED functions
-- AS 'MODULE_PATHNAME','dblink' LANGUAGE 'c' --
-- WITH (isstrict); --CREATE OR REPLACE FUNCTION dblink (text,text)
--CREATE OR REPLACE FUNCTION dblink_tok (int,int) RETURNS text --RETURNS setof int
-- AS 'MODULE_PATHNAME','dblink_tok' LANGUAGE 'c' --AS 'MODULE_PATHNAME','dblink'
-- WITH (isstrict); --LANGUAGE 'C' WITH (isstrict);
--CREATE OR REPLACE FUNCTION dblink_last_oid (int) RETURNS oid --CREATE OR REPLACE FUNCTION dblink_tok (int,int)
-- AS 'MODULE_PATHNAME','dblink_last_oid' LANGUAGE 'c' --RETURNS text
-- WITH (isstrict); --AS 'MODULE_PATHNAME','dblink_tok'
--LANGUAGE 'C' WITH (isstrict);
CREATE OR REPLACE FUNCTION dblink_connect (text) RETURNS text --CREATE OR REPLACE FUNCTION dblink_last_oid (int)
AS 'MODULE_PATHNAME','dblink_connect' LANGUAGE 'c' --RETURNS oid
WITH (isstrict); --AS 'MODULE_PATHNAME','dblink_last_oid'
--LANGUAGE 'C' WITH (isstrict);
CREATE OR REPLACE FUNCTION dblink_disconnect () RETURNS text
AS 'MODULE_PATHNAME','dblink_disconnect' LANGUAGE 'c' CREATE OR REPLACE FUNCTION dblink_connect (text)
WITH (isstrict); RETURNS text
AS 'MODULE_PATHNAME','dblink_connect'
CREATE OR REPLACE FUNCTION dblink_open (text,text) RETURNS text LANGUAGE 'C' WITH (isstrict);
AS 'MODULE_PATHNAME','dblink_open' LANGUAGE 'c'
WITH (isstrict); CREATE OR REPLACE FUNCTION dblink_disconnect ()
RETURNS text
CREATE OR REPLACE FUNCTION dblink_fetch (text,int) RETURNS setof record AS 'MODULE_PATHNAME','dblink_disconnect'
AS 'MODULE_PATHNAME','dblink_fetch' LANGUAGE 'c' LANGUAGE 'C' WITH (isstrict);
WITH (isstrict);
CREATE OR REPLACE FUNCTION dblink_open (text,text)
CREATE OR REPLACE FUNCTION dblink_close (text) RETURNS text RETURNS text
AS 'MODULE_PATHNAME','dblink_close' LANGUAGE 'c' AS 'MODULE_PATHNAME','dblink_open'
WITH (isstrict); LANGUAGE 'C' WITH (isstrict);
CREATE OR REPLACE FUNCTION dblink_fetch (text,int)
RETURNS setof record
AS 'MODULE_PATHNAME','dblink_fetch'
LANGUAGE 'C' WITH (isstrict);
CREATE OR REPLACE FUNCTION dblink_close (text)
RETURNS text
AS 'MODULE_PATHNAME','dblink_close'
LANGUAGE 'C' WITH (isstrict);
-- Note: if this is not a first time install of dblink, uncomment the -- Note: if this is not a first time install of dblink, uncomment the
-- following DROP which prepares the database for the new, non-deprecated -- following DROP which prepares the database for the new, non-deprecated
...@@ -35,55 +45,49 @@ CREATE OR REPLACE FUNCTION dblink_close (text) RETURNS text ...@@ -35,55 +45,49 @@ CREATE OR REPLACE FUNCTION dblink_close (text) RETURNS text
--DROP FUNCTION dblink (text,text); --DROP FUNCTION dblink (text,text);
-- Comment out the following 3 lines if the DEPRECATED functions are used. -- Comment out the following 3 lines if the DEPRECATED functions are used.
CREATE OR REPLACE FUNCTION dblink (text,text) RETURNS setof record CREATE OR REPLACE FUNCTION dblink (text,text)
AS 'MODULE_PATHNAME','dblink_record' LANGUAGE 'c' RETURNS setof record
WITH (isstrict); AS 'MODULE_PATHNAME','dblink_record'
LANGUAGE 'C' WITH (isstrict);
CREATE OR REPLACE FUNCTION dblink (text) RETURNS setof record
AS 'MODULE_PATHNAME','dblink_record' LANGUAGE 'c' CREATE OR REPLACE FUNCTION dblink (text)
WITH (isstrict); RETURNS setof record
AS 'MODULE_PATHNAME','dblink_record'
CREATE OR REPLACE FUNCTION dblink_exec (text,text) RETURNS text LANGUAGE 'C' WITH (isstrict);
AS 'MODULE_PATHNAME','dblink_exec' LANGUAGE 'c'
WITH (isstrict); CREATE OR REPLACE FUNCTION dblink_exec (text,text)
RETURNS text
CREATE OR REPLACE FUNCTION dblink_exec (text) RETURNS text AS 'MODULE_PATHNAME','dblink_exec'
AS 'MODULE_PATHNAME','dblink_exec' LANGUAGE 'c' LANGUAGE 'C' WITH (isstrict);
WITH (isstrict);
CREATE OR REPLACE FUNCTION dblink_exec (text)
RETURNS text
AS 'MODULE_PATHNAME','dblink_exec'
LANGUAGE 'c' WITH (isstrict);
CREATE TYPE dblink_pkey_results AS (position int4, colname text); CREATE TYPE dblink_pkey_results AS (position int4, colname text);
CREATE OR REPLACE FUNCTION dblink_get_pkey (text) RETURNS setof dblink_pkey_results CREATE OR REPLACE FUNCTION dblink_get_pkey (text)
AS 'MODULE_PATHNAME','dblink_get_pkey' LANGUAGE 'c' RETURNS setof dblink_pkey_results
WITH (isstrict); AS 'MODULE_PATHNAME','dblink_get_pkey'
LANGUAGE 'c' WITH (isstrict);
CREATE OR REPLACE FUNCTION dblink_build_sql_insert (text, int2vector, int4, _text, _text) RETURNS text
AS 'MODULE_PATHNAME','dblink_build_sql_insert' LANGUAGE 'c' CREATE OR REPLACE FUNCTION dblink_build_sql_insert (text, int2vector, int4, _text, _text)
WITH (isstrict); RETURNS text
AS 'MODULE_PATHNAME','dblink_build_sql_insert'
CREATE OR REPLACE FUNCTION dblink_build_sql_delete (text, int2vector, int4, _text) RETURNS text LANGUAGE 'C' WITH (isstrict);
AS 'MODULE_PATHNAME','dblink_build_sql_delete' LANGUAGE 'c'
WITH (isstrict); CREATE OR REPLACE FUNCTION dblink_build_sql_delete (text, int2vector, int4, _text)
RETURNS text
CREATE OR REPLACE FUNCTION dblink_build_sql_update (text, int2vector, int4, _text, _text) RETURNS text AS 'MODULE_PATHNAME','dblink_build_sql_delete'
AS 'MODULE_PATHNAME','dblink_build_sql_update' LANGUAGE 'c' LANGUAGE 'C' WITH (isstrict);
WITH (isstrict);
CREATE OR REPLACE FUNCTION dblink_build_sql_update (text, int2vector, int4, _text, _text)
CREATE OR REPLACE FUNCTION dblink_current_query () RETURNS text RETURNS text
AS 'MODULE_PATHNAME','dblink_current_query' LANGUAGE 'c'; AS 'MODULE_PATHNAME','dblink_build_sql_update'
LANGUAGE 'C' WITH (isstrict);
GRANT EXECUTE ON FUNCTION dblink_connect (text) TO PUBLIC;
GRANT EXECUTE ON FUNCTION dblink_disconnect () TO PUBLIC; CREATE OR REPLACE FUNCTION dblink_current_query ()
GRANT EXECUTE ON FUNCTION dblink_open (text,text) TO PUBLIC; RETURNS text
GRANT EXECUTE ON FUNCTION dblink_fetch (text,int) TO PUBLIC; AS 'MODULE_PATHNAME','dblink_current_query'
GRANT EXECUTE ON FUNCTION dblink_close (text) TO PUBLIC; LANGUAGE 'C';
GRANT EXECUTE ON FUNCTION dblink (text,text) TO PUBLIC;
GRANT EXECUTE ON FUNCTION dblink (text) TO PUBLIC;
GRANT EXECUTE ON FUNCTION dblink_exec (text,text) TO PUBLIC;
GRANT EXECUTE ON FUNCTION dblink_exec (text) TO PUBLIC;
GRANT EXECUTE ON FUNCTION dblink_get_pkey (text) TO PUBLIC;
GRANT EXECUTE ON FUNCTION dblink_build_sql_insert (text, int2vector, int4, _text, _text) TO PUBLIC;
GRANT EXECUTE ON FUNCTION dblink_build_sql_delete (text, int2vector, int4, _text) TO PUBLIC;
GRANT EXECUTE ON FUNCTION dblink_build_sql_update (text, int2vector, int4, _text, _text) TO PUBLIC;
GRANT EXECUTE ON FUNCTION dblink_current_query () TO PUBLIC;
...@@ -4,7 +4,11 @@ ...@@ -4,7 +4,11 @@
-- --
-- This initial hackery is to allow successive runs without failures. -- This initial hackery is to allow successive runs without failures.
-- --
CREATE OR REPLACE FUNCTION conditional_drop() RETURNS text AS ' -- Adjust this setting to control where the objects get created.
SET search_path = public;
SET autocommit TO 'on';
CREATE OR REPLACE FUNCTION conditional_drop()
RETURNS text AS '
DECLARE DECLARE
dbname text; dbname text;
BEGIN BEGIN
...@@ -26,28 +30,29 @@ CREATE DATABASE regression_slave; ...@@ -26,28 +30,29 @@ CREATE DATABASE regression_slave;
-- Turn off echoing so that expected file does not depend on -- Turn off echoing so that expected file does not depend on
-- contents of dblink.sql. -- contents of dblink.sql.
\set ECHO none \set ECHO none
create table foo(f1 int, f2 text, f3 text[], primary key (f1,f2)); CREATE TABLE foo(f1 int, f2 text, f3 text[], primary key (f1,f2));
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'foo_pkey' for table 'foo' NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'foo_pkey' for table 'foo'
insert into foo values(0,'a','{"a0","b0","c0"}'); INSERT INTO foo VALUES (0,'a','{"a0","b0","c0"}');
insert into foo values(1,'b','{"a1","b1","c1"}'); INSERT INTO foo VALUES (1,'b','{"a1","b1","c1"}');
insert into foo values(2,'c','{"a2","b2","c2"}'); INSERT INTO foo VALUES (2,'c','{"a2","b2","c2"}');
insert into foo values(3,'d','{"a3","b3","c3"}'); INSERT INTO foo VALUES (3,'d','{"a3","b3","c3"}');
insert into foo values(4,'e','{"a4","b4","c4"}'); INSERT INTO foo VALUES (4,'e','{"a4","b4","c4"}');
insert into foo values(5,'f','{"a5","b5","c5"}'); INSERT INTO foo VALUES (5,'f','{"a5","b5","c5"}');
insert into foo values(6,'g','{"a6","b6","c6"}'); INSERT INTO foo VALUES (6,'g','{"a6","b6","c6"}');
insert into foo values(7,'h','{"a7","b7","c7"}'); INSERT INTO foo VALUES (7,'h','{"a7","b7","c7"}');
insert into foo values(8,'i','{"a8","b8","c8"}'); INSERT INTO foo VALUES (8,'i','{"a8","b8","c8"}');
insert into foo values(9,'j','{"a9","b9","c9"}'); INSERT INTO foo VALUES (9,'j','{"a9","b9","c9"}');
-- misc utilities -- misc utilities
-- show the currently executing query -- show the currently executing query
select 'hello' as hello, dblink_current_query() as query; SELECT 'hello' AS hello, dblink_current_query() AS query;
hello | query hello | query
-------+----------------------------------------------------------- -------+-----------------------------------------------------------
hello | select 'hello' as hello, dblink_current_query() as query; hello | SELECT 'hello' AS hello, dblink_current_query() AS query;
(1 row) (1 row)
-- list the primary key fields -- list the primary key fields
select * from dblink_get_pkey('foo'); SELECT *
FROM dblink_get_pkey('foo');
position | colname position | colname
----------+--------- ----------+---------
1 | f1 1 | f1
...@@ -56,7 +61,7 @@ select * from dblink_get_pkey('foo'); ...@@ -56,7 +61,7 @@ select * from dblink_get_pkey('foo');
-- build an insert statement based on a local tuple, -- build an insert statement based on a local tuple,
-- replacing the primary key values with new ones -- replacing the primary key values with new ones
select dblink_build_sql_insert('foo','1 2',2,'{"0", "a"}','{"99", "xyz"}'); SELECT dblink_build_sql_insert('foo','1 2',2,'{"0", "a"}','{"99", "xyz"}');
dblink_build_sql_insert dblink_build_sql_insert
----------------------------------------------------------- -----------------------------------------------------------
INSERT INTO foo(f1,f2,f3) VALUES('99','xyz','{a0,b0,c0}') INSERT INTO foo(f1,f2,f3) VALUES('99','xyz','{a0,b0,c0}')
...@@ -64,14 +69,14 @@ select dblink_build_sql_insert('foo','1 2',2,'{"0", "a"}','{"99", "xyz"}'); ...@@ -64,14 +69,14 @@ select dblink_build_sql_insert('foo','1 2',2,'{"0", "a"}','{"99", "xyz"}');
-- build an update statement based on a local tuple, -- build an update statement based on a local tuple,
-- replacing the primary key values with new ones -- replacing the primary key values with new ones
select dblink_build_sql_update('foo','1 2',2,'{"0", "a"}','{"99", "xyz"}'); SELECT dblink_build_sql_update('foo','1 2',2,'{"0", "a"}','{"99", "xyz"}');
dblink_build_sql_update dblink_build_sql_update
---------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------
UPDATE foo SET f1 = '99', f2 = 'xyz', f3 = '{a0,b0,c0}' WHERE f1 = '99' AND f2 = 'xyz' UPDATE foo SET f1 = '99', f2 = 'xyz', f3 = '{a0,b0,c0}' WHERE f1 = '99' AND f2 = 'xyz'
(1 row) (1 row)
-- build a delete statement based on a local tuple, -- build a delete statement based on a local tuple,
select dblink_build_sql_delete('foo','1 2',2,'{"0", "a"}'); SELECT dblink_build_sql_delete('foo','1 2',2,'{"0", "a"}');
dblink_build_sql_delete dblink_build_sql_delete
--------------------------------------------- ---------------------------------------------
DELETE FROM foo WHERE f1 = '0' AND f2 = 'a' DELETE FROM foo WHERE f1 = '0' AND f2 = 'a'
...@@ -85,7 +90,9 @@ select dblink_build_sql_delete('foo','1 2',2,'{"0", "a"}'); ...@@ -85,7 +90,9 @@ select dblink_build_sql_delete('foo','1 2',2,'{"0", "a"}');
\connect regression \connect regression
\set ECHO none \set ECHO none
-- regular old dblink -- regular old dblink
select * from dblink('dbname=regression_slave','select * from foo') as t(a int, b text, c text[]) where t.a > 7; SELECT *
FROM dblink('dbname=regression_slave','SELECT * FROM foo') AS t(a int, b text, c text[])
WHERE t.a > 7;
a | b | c a | b | c
---+---+------------ ---+---+------------
8 | i | {a8,b8,c8} 8 | i | {a8,b8,c8}
...@@ -93,17 +100,21 @@ select * from dblink('dbname=regression_slave','select * from foo') as t(a int, ...@@ -93,17 +100,21 @@ select * from dblink('dbname=regression_slave','select * from foo') as t(a int,
(2 rows) (2 rows)
-- should generate "no connection available" error -- should generate "no connection available" error
select * from dblink('select * from foo') as t(a int, b text, c text[]) where t.a > 7; SELECT *
FROM dblink('SELECT * FROM foo') AS t(a int, b text, c text[])
WHERE t.a > 7;
ERROR: dblink: no connection available ERROR: dblink: no connection available
-- create a persistent connection -- create a persistent connection
select dblink_connect('dbname=regression_slave'); SELECT dblink_connect('dbname=regression_slave');
dblink_connect dblink_connect
---------------- ----------------
OK OK
(1 row) (1 row)
-- use the persistent connection -- use the persistent connection
select * from dblink('select * from foo') as t(a int, b text, c text[]) where t.a > 7; SELECT *
FROM dblink('SELECT * FROM foo') AS t(a int, b text, c text[])
WHERE t.a > 7;
a | b | c a | b | c
---+---+------------ ---+---+------------
8 | i | {a8,b8,c8} 8 | i | {a8,b8,c8}
...@@ -111,14 +122,15 @@ select * from dblink('select * from foo') as t(a int, b text, c text[]) where t. ...@@ -111,14 +122,15 @@ select * from dblink('select * from foo') as t(a int, b text, c text[]) where t.
(2 rows) (2 rows)
-- open a cursor -- open a cursor
select dblink_open('rmt_foo_cursor','select * from foo'); SELECT dblink_open('rmt_foo_cursor','SELECT * FROM foo');
dblink_open dblink_open
------------- -------------
OK OK
(1 row) (1 row)
-- fetch some data -- fetch some data
select * from dblink_fetch('rmt_foo_cursor',4) as t(a int, b text, c text[]); SELECT *
FROM dblink_fetch('rmt_foo_cursor',4) AS t(a int, b text, c text[]);
a | b | c a | b | c
---+---+------------ ---+---+------------
0 | a | {a0,b0,c0} 0 | a | {a0,b0,c0}
...@@ -127,7 +139,8 @@ select * from dblink_fetch('rmt_foo_cursor',4) as t(a int, b text, c text[]); ...@@ -127,7 +139,8 @@ select * from dblink_fetch('rmt_foo_cursor',4) as t(a int, b text, c text[]);
3 | d | {a3,b3,c3} 3 | d | {a3,b3,c3}
(4 rows) (4 rows)
select * from dblink_fetch('rmt_foo_cursor',4) as t(a int, b text, c text[]); SELECT *
FROM dblink_fetch('rmt_foo_cursor',4) AS t(a int, b text, c text[]);
a | b | c a | b | c
---+---+------------ ---+---+------------
4 | e | {a4,b4,c4} 4 | e | {a4,b4,c4}
...@@ -137,7 +150,8 @@ select * from dblink_fetch('rmt_foo_cursor',4) as t(a int, b text, c text[]); ...@@ -137,7 +150,8 @@ select * from dblink_fetch('rmt_foo_cursor',4) as t(a int, b text, c text[]);
(4 rows) (4 rows)
-- this one only finds two rows left -- this one only finds two rows left
select * from dblink_fetch('rmt_foo_cursor',4) as t(a int, b text, c text[]); SELECT *
FROM dblink_fetch('rmt_foo_cursor',4) AS t(a int, b text, c text[]);
a | b | c a | b | c
---+---+------------ ---+---+------------
8 | i | {a8,b8,c8} 8 | i | {a8,b8,c8}
...@@ -145,35 +159,38 @@ select * from dblink_fetch('rmt_foo_cursor',4) as t(a int, b text, c text[]); ...@@ -145,35 +159,38 @@ select * from dblink_fetch('rmt_foo_cursor',4) as t(a int, b text, c text[]);
(2 rows) (2 rows)
-- close the cursor -- close the cursor
select dblink_close('rmt_foo_cursor'); SELECT dblink_close('rmt_foo_cursor');
dblink_close dblink_close
-------------- --------------
OK OK
(1 row) (1 row)
-- should generate "cursor rmt_foo_cursor does not exist" error -- should generate "cursor rmt_foo_cursor does not exist" error
select * from dblink_fetch('rmt_foo_cursor',4) as t(a int, b text, c text[]); SELECT *
FROM dblink_fetch('rmt_foo_cursor',4) AS t(a int, b text, c text[]);
ERROR: dblink_fetch: cursor rmt_foo_cursor does not exist ERROR: dblink_fetch: cursor rmt_foo_cursor does not exist
-- close the persistent connection -- close the persistent connection
select dblink_disconnect(); SELECT dblink_disconnect();
dblink_disconnect dblink_disconnect
------------------- -------------------
OK OK
(1 row) (1 row)
-- should generate "no connection available" error -- should generate "no connection available" error
select * from dblink('select * from foo') as t(a int, b text, c text[]) where t.a > 7; SELECT *
FROM dblink('SELECT * FROM foo') AS t(a int, b text, c text[])
WHERE t.a > 7;
ERROR: dblink: no connection available ERROR: dblink: no connection available
-- put more data into our slave table, first using arbitrary connection syntax -- put more data into our slave table, first using arbitrary connection syntax
-- but truncate the actual return value so we can use diff to check for success -- but truncate the actual return value so we can use diff to check for success
select substr(dblink_exec('dbname=regression_slave','insert into foo values(10,''k'',''{"a10","b10","c10"}'')'),1,6); SELECT substr(dblink_exec('dbname=regression_slave','INSERT INTO foo VALUES (10,''k'',''{"a10","b10","c10"}'')'),1,6);
substr substr
-------- --------
INSERT INSERT
(1 row) (1 row)
-- create a persistent connection -- create a persistent connection
select dblink_connect('dbname=regression_slave'); SELECT dblink_connect('dbname=regression_slave');
dblink_connect dblink_connect
---------------- ----------------
OK OK
...@@ -181,14 +198,15 @@ select dblink_connect('dbname=regression_slave'); ...@@ -181,14 +198,15 @@ select dblink_connect('dbname=regression_slave');
-- put more data into our slave table, using persistent connection syntax -- put more data into our slave table, using persistent connection syntax
-- but truncate the actual return value so we can use diff to check for success -- but truncate the actual return value so we can use diff to check for success
select substr(dblink_exec('insert into foo values(11,''l'',''{"a11","b11","c11"}'')'),1,6); SELECT substr(dblink_exec('INSERT INTO foo VALUES (11,''l'',''{"a11","b11","c11"}'')'),1,6);
substr substr
-------- --------
INSERT INSERT
(1 row) (1 row)
-- let's see it -- let's see it
select * from dblink('select * from foo') as t(a int, b text, c text[]); SELECT *
FROM dblink('SELECT * FROM foo') AS t(a int, b text, c text[]);
a | b | c a | b | c
----+---+--------------- ----+---+---------------
0 | a | {a0,b0,c0} 0 | a | {a0,b0,c0}
...@@ -206,34 +224,38 @@ select * from dblink('select * from foo') as t(a int, b text, c text[]); ...@@ -206,34 +224,38 @@ select * from dblink('select * from foo') as t(a int, b text, c text[]);
(12 rows) (12 rows)
-- change some data -- change some data
select dblink_exec('update foo set f3[2] = ''b99'' where f1 = 11'); SELECT dblink_exec('UPDATE foo SET f3[2] = ''b99'' WHERE f1 = 11');
dblink_exec dblink_exec
------------- -------------
UPDATE 1 UPDATE 1
(1 row) (1 row)
-- let's see it -- let's see it
select * from dblink('select * from foo') as t(a int, b text, c text[]) where a = 11; SELECT *
FROM dblink('SELECT * FROM foo') AS t(a int, b text, c text[])
WHERE a = 11;
a | b | c a | b | c
----+---+--------------- ----+---+---------------
11 | l | {a11,b99,c11} 11 | l | {a11,b99,c11}
(1 row) (1 row)
-- delete some data -- delete some data
select dblink_exec('delete from foo where f1 = 11'); SELECT dblink_exec('DELETE FROM foo WHERE f1 = 11');
dblink_exec dblink_exec
------------- -------------
DELETE 1 DELETE 1
(1 row) (1 row)
-- let's see it -- let's see it
select * from dblink('select * from foo') as t(a int, b text, c text[]) where a = 11; SELECT *
FROM dblink('SELECT * FROM foo') AS t(a int, b text, c text[])
WHERE a = 11;
a | b | c a | b | c
---+---+--- ---+---+---
(0 rows) (0 rows)
-- close the persistent connection -- close the persistent connection
select dblink_disconnect(); SELECT dblink_disconnect();
dblink_disconnect dblink_disconnect
------------------- -------------------
OK OK
......
...@@ -4,7 +4,14 @@ ...@@ -4,7 +4,14 @@
-- --
-- This initial hackery is to allow successive runs without failures. -- This initial hackery is to allow successive runs without failures.
-- --
CREATE OR REPLACE FUNCTION conditional_drop() RETURNS text AS '
-- Adjust this setting to control where the objects get created.
SET search_path = public;
SET autocommit TO 'on';
CREATE OR REPLACE FUNCTION conditional_drop()
RETURNS text AS '
DECLARE DECLARE
dbname text; dbname text;
BEGIN BEGIN
...@@ -26,36 +33,37 @@ CREATE DATABASE regression_slave; ...@@ -26,36 +33,37 @@ CREATE DATABASE regression_slave;
\i dblink.sql \i dblink.sql
\set ECHO all \set ECHO all
create table foo(f1 int, f2 text, f3 text[], primary key (f1,f2)); CREATE TABLE foo(f1 int, f2 text, f3 text[], primary key (f1,f2));
insert into foo values(0,'a','{"a0","b0","c0"}'); INSERT INTO foo VALUES (0,'a','{"a0","b0","c0"}');
insert into foo values(1,'b','{"a1","b1","c1"}'); INSERT INTO foo VALUES (1,'b','{"a1","b1","c1"}');
insert into foo values(2,'c','{"a2","b2","c2"}'); INSERT INTO foo VALUES (2,'c','{"a2","b2","c2"}');
insert into foo values(3,'d','{"a3","b3","c3"}'); INSERT INTO foo VALUES (3,'d','{"a3","b3","c3"}');
insert into foo values(4,'e','{"a4","b4","c4"}'); INSERT INTO foo VALUES (4,'e','{"a4","b4","c4"}');
insert into foo values(5,'f','{"a5","b5","c5"}'); INSERT INTO foo VALUES (5,'f','{"a5","b5","c5"}');
insert into foo values(6,'g','{"a6","b6","c6"}'); INSERT INTO foo VALUES (6,'g','{"a6","b6","c6"}');
insert into foo values(7,'h','{"a7","b7","c7"}'); INSERT INTO foo VALUES (7,'h','{"a7","b7","c7"}');
insert into foo values(8,'i','{"a8","b8","c8"}'); INSERT INTO foo VALUES (8,'i','{"a8","b8","c8"}');
insert into foo values(9,'j','{"a9","b9","c9"}'); INSERT INTO foo VALUES (9,'j','{"a9","b9","c9"}');
-- misc utilities -- misc utilities
-- show the currently executing query -- show the currently executing query
select 'hello' as hello, dblink_current_query() as query; SELECT 'hello' AS hello, dblink_current_query() AS query;
-- list the primary key fields -- list the primary key fields
select * from dblink_get_pkey('foo'); SELECT *
FROM dblink_get_pkey('foo');
-- build an insert statement based on a local tuple, -- build an insert statement based on a local tuple,
-- replacing the primary key values with new ones -- replacing the primary key values with new ones
select dblink_build_sql_insert('foo','1 2',2,'{"0", "a"}','{"99", "xyz"}'); SELECT dblink_build_sql_insert('foo','1 2',2,'{"0", "a"}','{"99", "xyz"}');
-- build an update statement based on a local tuple, -- build an update statement based on a local tuple,
-- replacing the primary key values with new ones -- replacing the primary key values with new ones
select dblink_build_sql_update('foo','1 2',2,'{"0", "a"}','{"99", "xyz"}'); SELECT dblink_build_sql_update('foo','1 2',2,'{"0", "a"}','{"99", "xyz"}');
-- build a delete statement based on a local tuple, -- build a delete statement based on a local tuple,
select dblink_build_sql_delete('foo','1 2',2,'{"0", "a"}'); SELECT dblink_build_sql_delete('foo','1 2',2,'{"0", "a"}');
-- --
-- Connect back to the regression database and define the functions. -- Connect back to the regression database and define the functions.
...@@ -68,64 +76,82 @@ select dblink_build_sql_delete('foo','1 2',2,'{"0", "a"}'); ...@@ -68,64 +76,82 @@ select dblink_build_sql_delete('foo','1 2',2,'{"0", "a"}');
\set ECHO all \set ECHO all
-- regular old dblink -- regular old dblink
select * from dblink('dbname=regression_slave','select * from foo') as t(a int, b text, c text[]) where t.a > 7; SELECT *
FROM dblink('dbname=regression_slave','SELECT * FROM foo') AS t(a int, b text, c text[])
WHERE t.a > 7;
-- should generate "no connection available" error -- should generate "no connection available" error
select * from dblink('select * from foo') as t(a int, b text, c text[]) where t.a > 7; SELECT *
FROM dblink('SELECT * FROM foo') AS t(a int, b text, c text[])
WHERE t.a > 7;
-- create a persistent connection -- create a persistent connection
select dblink_connect('dbname=regression_slave'); SELECT dblink_connect('dbname=regression_slave');
-- use the persistent connection -- use the persistent connection
select * from dblink('select * from foo') as t(a int, b text, c text[]) where t.a > 7; SELECT *
FROM dblink('SELECT * FROM foo') AS t(a int, b text, c text[])
WHERE t.a > 7;
-- open a cursor -- open a cursor
select dblink_open('rmt_foo_cursor','select * from foo'); SELECT dblink_open('rmt_foo_cursor','SELECT * FROM foo');
-- fetch some data -- fetch some data
select * from dblink_fetch('rmt_foo_cursor',4) as t(a int, b text, c text[]); SELECT *
select * from dblink_fetch('rmt_foo_cursor',4) as t(a int, b text, c text[]); FROM dblink_fetch('rmt_foo_cursor',4) AS t(a int, b text, c text[]);
SELECT *
FROM dblink_fetch('rmt_foo_cursor',4) AS t(a int, b text, c text[]);
-- this one only finds two rows left -- this one only finds two rows left
select * from dblink_fetch('rmt_foo_cursor',4) as t(a int, b text, c text[]); SELECT *
FROM dblink_fetch('rmt_foo_cursor',4) AS t(a int, b text, c text[]);
-- close the cursor -- close the cursor
select dblink_close('rmt_foo_cursor'); SELECT dblink_close('rmt_foo_cursor');
-- should generate "cursor rmt_foo_cursor does not exist" error -- should generate "cursor rmt_foo_cursor does not exist" error
select * from dblink_fetch('rmt_foo_cursor',4) as t(a int, b text, c text[]); SELECT *
FROM dblink_fetch('rmt_foo_cursor',4) AS t(a int, b text, c text[]);
-- close the persistent connection -- close the persistent connection
select dblink_disconnect(); SELECT dblink_disconnect();
-- should generate "no connection available" error -- should generate "no connection available" error
select * from dblink('select * from foo') as t(a int, b text, c text[]) where t.a > 7; SELECT *
FROM dblink('SELECT * FROM foo') AS t(a int, b text, c text[])
WHERE t.a > 7;
-- put more data into our slave table, first using arbitrary connection syntax -- put more data into our slave table, first using arbitrary connection syntax
-- but truncate the actual return value so we can use diff to check for success -- but truncate the actual return value so we can use diff to check for success
select substr(dblink_exec('dbname=regression_slave','insert into foo values(10,''k'',''{"a10","b10","c10"}'')'),1,6); SELECT substr(dblink_exec('dbname=regression_slave','INSERT INTO foo VALUES(10,''k'',''{"a10","b10","c10"}'')'),1,6);
-- create a persistent connection -- create a persistent connection
select dblink_connect('dbname=regression_slave'); SELECT dblink_connect('dbname=regression_slave');
-- put more data into our slave table, using persistent connection syntax -- put more data into our slave table, using persistent connection syntax
-- but truncate the actual return value so we can use diff to check for success -- but truncate the actual return value so we can use diff to check for success
select substr(dblink_exec('insert into foo values(11,''l'',''{"a11","b11","c11"}'')'),1,6); SELECT substr(dblink_exec('INSERT INTO foo VALUES(11,''l'',''{"a11","b11","c11"}'')'),1,6);
-- let's see it -- let's see it
select * from dblink('select * from foo') as t(a int, b text, c text[]); SELECT *
FROM dblink('SELECT * FROM foo') AS t(a int, b text, c text[]);
-- change some data -- change some data
select dblink_exec('update foo set f3[2] = ''b99'' where f1 = 11'); SELECT dblink_exec('UPDATE foo SET f3[2] = ''b99'' WHERE f1 = 11');
-- let's see it -- let's see it
select * from dblink('select * from foo') as t(a int, b text, c text[]) where a = 11; SELECT *
FROM dblink('SELECT * FROM foo') AS t(a int, b text, c text[])
WHERE a = 11;
-- delete some data -- delete some data
select dblink_exec('delete from foo where f1 = 11'); SELECT dblink_exec('DELETE FROM foo WHERE f1 = 11');
-- let's see it -- let's see it
select * from dblink('select * from foo') as t(a int, b text, c text[]) where a = 11; SELECT *
FROM dblink('SELECT * FROM foo') AS t(a int, b text, c text[])
WHERE a = 11;
-- close the persistent connection -- close the persistent connection
select dblink_disconnect(); SELECT dblink_disconnect();
-- Adjust this setting to control where the objects get created.
SET search_path = public;
CREATE TRIGGER "MyTableName_Trig" AFTER INSERT OR DELETE OR UPDATE SET autocommit TO 'on';
ON "MyTableName" FOR EACH ROW EXECUTE PROCEDURE
"recordchange" (); CREATE TRIGGER "MyTableName_Trig"
AFTER INSERT OR DELETE OR UPDATE ON "MyTableName"
FOR EACH ROW EXECUTE PROCEDURE "recordchange" ();
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
# GNU General Public License for more details. # GNU General Public License for more details.
# #
############################################################################## ##############################################################################
# $Id: DBMirror.pl,v 1.1 2002/06/23 21:58:07 momjian Exp $ # $Id: DBMirror.pl,v 1.2 2002/10/18 18:41:19 momjian Exp $
# #
############################################################################## ##############################################################################
...@@ -112,6 +112,23 @@ sub Main() { ...@@ -112,6 +112,23 @@ sub Main() {
die; die;
} }
my $setQuery;
$setQuery = "SET search_path = public";
$setResult = $masterConn->exec($setQuery);
if($setResult->resultStatus!=PGRES_COMMAND_OK) {
logErrorMessage($masterConn->errorMessage . "\n" .
$setQuery);
die;
}
my $setQuery2;
$setQuery2 = "SET autocommit TO 'on'";
$setResult2 = $masterConn->exec($setQuery2);
if($setResult2->resultStatus!=PGRES_COMMAND_OK) {
logErrorMessage($masterConn->errorMessage . "\n" .
$setQuery2);
die;
}
my $firstTime = 1; my $firstTime = 1;
while(1) { while(1) {
...@@ -127,6 +144,7 @@ sub Main() { ...@@ -127,6 +144,7 @@ sub Main() {
sendQueryToSlaves(undef,"SET autocommit TO 'on'");
sendQueryToSlaves(undef,"SET TRANSACTION ISOLATION LEVEL SERIALIZABLE"); sendQueryToSlaves(undef,"SET TRANSACTION ISOLATION LEVEL SERIALIZABLE");
sendQueryToSlaves(undef,"SET CONSTRAINTS ALL DEFERRED"); sendQueryToSlaves(undef,"SET CONSTRAINTS ALL DEFERRED");
...@@ -703,7 +721,7 @@ sub openSlaveConnection($) { ...@@ -703,7 +721,7 @@ sub openSlaveConnection($) {
$slaveConn = Pg::connectdb($slaveConnString); $slaveConn = Pg::connectdb($slaveConnString);
if($slaveConn->status !=PGRES_CONNECTION_OK) { if($slaveConn->status != PGRES_CONNECTION_OK) {
my $errorMessage = "Can't connect to slave database " ; my $errorMessage = "Can't connect to slave database " ;
$errorMessage .= $slavePtr->{"slaveHost"} . "\n"; $errorMessage .= $slavePtr->{"slaveHost"} . "\n";
$errorMessage .= $slaveConn->errorMessage; $errorMessage .= $slaveConn->errorMessage;
......
SET autocommit TO 'on';
CREATE FUNCTION "recordchange" () RETURNS trigger AS CREATE FUNCTION "recordchange" () RETURNS trigger AS
'/usr/local/pgsql/lib/pending.so', 'recordchange' LANGUAGE 'C'; '/usr/local/pgsql/lib/pending.so', 'recordchange' LANGUAGE 'C';
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
# GNU General Public License for more details. # GNU General Public License for more details.
# #
############################################################################## ##############################################################################
# $Id: clean_pending.pl,v 1.1 2002/06/23 21:58:08 momjian Exp $ # $Id: clean_pending.pl,v 1.2 2002/10/18 18:41:19 momjian Exp $
############################################################################## ##############################################################################
...@@ -69,6 +69,10 @@ unless($dbConn->status == PGRES_CONNECTION_OK) { ...@@ -69,6 +69,10 @@ unless($dbConn->status == PGRES_CONNECTION_OK) {
printf("Can't connect to database\n"); printf("Can't connect to database\n");
die; die;
} }
my $setresult = $dbConn->exec("SET autocommit TO 'on'");
unless($setresult->resultStatus == PGRES_COMMAND_OK) {
die $dbConn->errorMessage;
}
my $result = $dbConn->exec("BEGIN"); my $result = $dbConn->exec("BEGIN");
unless($result->resultStatus == PGRES_COMMAND_OK) { unless($result->resultStatus == PGRES_COMMAND_OK) {
die $dbConn->errorMessage; die $dbConn->errorMessage;
......
begin; -- Adjust this setting to control where the objects get created.
SET search_path = public;
SET autocommit TO 'on';
--------------- geo_distance --------------- geo_distance
CREATE OR REPLACE FUNCTION geo_distance (point, point) RETURNS float8 CREATE OR REPLACE FUNCTION geo_distance (point, point)
LANGUAGE 'c' IMMUTABLE STRICT AS 'MODULE_PATHNAME'; RETURNS float8
LANGUAGE 'C' IMMUTABLE STRICT AS 'MODULE_PATHNAME';
--------------- geo_distance as operator <@> --------------- geo_distance as operator <@>
CREATE OPERATOR <@> ( CREATE OPERATOR <@> (
leftarg = point, LEFTARG = point,
rightarg = point, RIGHTARG = point,
procedure = geo_distance, PROCEDURE = geo_distance,
commutator = <@> COMMUTATOR = <@>
); );
--
-- By default this function is made executable by anyone. To restrict
-- access by default, comment out the following grant command.
--
grant execute on function geo_distance(point, point) to public;
commit;
...@@ -9,73 +9,73 @@ ...@@ -9,73 +9,73 @@
-- --
-- Test getting the distance between two points using geo_distance. -- Test getting the distance between two points using geo_distance.
-- --
select geo_distance('(0,0)'::point,'(0,0)'::point)::numeric(20,5); SELECT geo_distance('(0,0)'::point,'(0,0)'::point)::numeric(20,5);
geo_distance geo_distance
-------------- --------------
0.00000 0.00000
(1 row) (1 row)
select geo_distance('(0,0)'::point,'(180,0)'::point)::numeric(20,5); SELECT geo_distance('(0,0)'::point,'(180,0)'::point)::numeric(20,5);
geo_distance geo_distance
-------------- --------------
12436.77274 12436.77274
(1 row) (1 row)
select geo_distance('(0,0)'::point,'(0,90)'::point)::numeric(20,5); SELECT geo_distance('(0,0)'::point,'(0,90)'::point)::numeric(20,5);
geo_distance geo_distance
-------------- --------------
6218.38637 6218.38637
(1 row) (1 row)
select geo_distance('(0,0)'::point,'(90,0)'::point)::numeric(20,5); SELECT geo_distance('(0,0)'::point,'(90,0)'::point)::numeric(20,5);
geo_distance geo_distance
-------------- --------------
6218.38637 6218.38637
(1 row) (1 row)
select geo_distance('(0,0)'::point,'(1,0)'::point)::numeric(20,5); SELECT geo_distance('(0,0)'::point,'(1,0)'::point)::numeric(20,5);
geo_distance geo_distance
-------------- --------------
69.09318 69.09318
(1 row) (1 row)
select geo_distance('(0,0)'::point,'(0,1)'::point)::numeric(20,5); SELECT geo_distance('(0,0)'::point,'(0,1)'::point)::numeric(20,5);
geo_distance geo_distance
-------------- --------------
69.09318 69.09318
(1 row) (1 row)
select geo_distance('(0,30)'::point,'(1,30)'::point)::numeric(20,5); SELECT geo_distance('(0,30)'::point,'(1,30)'::point)::numeric(20,5);
geo_distance geo_distance
-------------- --------------
59.83626 59.83626
(1 row) (1 row)
select geo_distance('(0,30)'::point,'(0,31)'::point)::numeric(20,5); SELECT geo_distance('(0,30)'::point,'(0,31)'::point)::numeric(20,5);
geo_distance geo_distance
-------------- --------------
69.09318 69.09318
(1 row) (1 row)
select geo_distance('(0,60)'::point,'(1,60)'::point)::numeric(20,5); SELECT geo_distance('(0,60)'::point,'(1,60)'::point)::numeric(20,5);
geo_distance geo_distance
-------------- --------------
34.54626 34.54626
(1 row) (1 row)
select geo_distance('(0,60)'::point,'(0,61)'::point)::numeric(20,5); SELECT geo_distance('(0,60)'::point,'(0,61)'::point)::numeric(20,5);
geo_distance geo_distance
-------------- --------------
69.09318 69.09318
(1 row) (1 row)
select geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)::numeric(20,5); SELECT geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)::numeric(20,5);
geo_distance geo_distance
-------------- --------------
1129.18983 1129.18983
(1 row) (1 row)
select (geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5); SELECT (geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5);
numeric numeric
--------------- ---------------
1817254.87730 1817254.87730
...@@ -84,73 +84,73 @@ select (geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)*5280.*12.*2.54/ ...@@ -84,73 +84,73 @@ select (geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)*5280.*12.*2.54/
-- --
-- Test getting the distance between two points using the <@> operator. -- Test getting the distance between two points using the <@> operator.
-- --
select ('(0,0)'::point <@> '(0,0)'::point)::numeric(20,5); SELECT ('(0,0)'::point <@> '(0,0)'::point)::numeric(20,5);
numeric numeric
--------- ---------
0.00000 0.00000
(1 row) (1 row)
select ('(0,0)'::point <@> '(180,0)'::point)::numeric(20,5); SELECT ('(0,0)'::point <@> '(180,0)'::point)::numeric(20,5);
numeric numeric
------------- -------------
12436.77274 12436.77274
(1 row) (1 row)
select ('(0,0)'::point <@> '(0,90)'::point)::numeric(20,5); SELECT ('(0,0)'::point <@> '(0,90)'::point)::numeric(20,5);
numeric numeric
------------ ------------
6218.38637 6218.38637
(1 row) (1 row)
select ('(0,0)'::point <@> '(90,0)'::point)::numeric(20,5); SELECT ('(0,0)'::point <@> '(90,0)'::point)::numeric(20,5);
numeric numeric
------------ ------------
6218.38637 6218.38637
(1 row) (1 row)
select ('(0,0)'::point <@> '(1,0)'::point)::numeric(20,5); SELECT ('(0,0)'::point <@> '(1,0)'::point)::numeric(20,5);
numeric numeric
---------- ----------
69.09318 69.09318
(1 row) (1 row)
select ('(0,0)'::point <@> '(0,1)'::point)::numeric(20,5); SELECT ('(0,0)'::point <@> '(0,1)'::point)::numeric(20,5);
numeric numeric
---------- ----------
69.09318 69.09318
(1 row) (1 row)
select ('(0,30)'::point <@> '(1,30)'::point)::numeric(20,5); SELECT ('(0,30)'::point <@> '(1,30)'::point)::numeric(20,5);
numeric numeric
---------- ----------
59.83626 59.83626
(1 row) (1 row)
select ('(0,30)'::point <@> '(0,31)'::point)::numeric(20,5); SELECT ('(0,30)'::point <@> '(0,31)'::point)::numeric(20,5);
numeric numeric
---------- ----------
69.09318 69.09318
(1 row) (1 row)
select ('(0,60)'::point <@> '(1,60)'::point)::numeric(20,5); SELECT ('(0,60)'::point <@> '(1,60)'::point)::numeric(20,5);
numeric numeric
---------- ----------
34.54626 34.54626
(1 row) (1 row)
select ('(0,60)'::point <@> '(0,61)'::point)::numeric(20,5); SELECT ('(0,60)'::point <@> '(0,61)'::point)::numeric(20,5);
numeric numeric
---------- ----------
69.09318 69.09318
(1 row) (1 row)
select ('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)::numeric(20,5); SELECT ('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)::numeric(20,5);
numeric numeric
------------ ------------
1129.18983 1129.18983
(1 row) (1 row)
select (('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5); SELECT (('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5);
numeric numeric
--------------- ---------------
1817254.87730 1817254.87730
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
-- does not depend on contents of earthdistance.sql or cube.sql. -- does not depend on contents of earthdistance.sql or cube.sql.
-- --
\set ECHO none \set ECHO none
SET autocommit TO 'on';
\i earthdistance.sql \i earthdistance.sql
\set ECHO all \set ECHO all
...@@ -14,32 +15,32 @@ ...@@ -14,32 +15,32 @@
-- Test getting the distance between two points using geo_distance. -- Test getting the distance between two points using geo_distance.
-- --
select geo_distance('(0,0)'::point,'(0,0)'::point)::numeric(20,5); SELECT geo_distance('(0,0)'::point,'(0,0)'::point)::numeric(20,5);
select geo_distance('(0,0)'::point,'(180,0)'::point)::numeric(20,5); SELECT geo_distance('(0,0)'::point,'(180,0)'::point)::numeric(20,5);
select geo_distance('(0,0)'::point,'(0,90)'::point)::numeric(20,5); SELECT geo_distance('(0,0)'::point,'(0,90)'::point)::numeric(20,5);
select geo_distance('(0,0)'::point,'(90,0)'::point)::numeric(20,5); SELECT geo_distance('(0,0)'::point,'(90,0)'::point)::numeric(20,5);
select geo_distance('(0,0)'::point,'(1,0)'::point)::numeric(20,5); SELECT geo_distance('(0,0)'::point,'(1,0)'::point)::numeric(20,5);
select geo_distance('(0,0)'::point,'(0,1)'::point)::numeric(20,5); SELECT geo_distance('(0,0)'::point,'(0,1)'::point)::numeric(20,5);
select geo_distance('(0,30)'::point,'(1,30)'::point)::numeric(20,5); SELECT geo_distance('(0,30)'::point,'(1,30)'::point)::numeric(20,5);
select geo_distance('(0,30)'::point,'(0,31)'::point)::numeric(20,5); SELECT geo_distance('(0,30)'::point,'(0,31)'::point)::numeric(20,5);
select geo_distance('(0,60)'::point,'(1,60)'::point)::numeric(20,5); SELECT geo_distance('(0,60)'::point,'(1,60)'::point)::numeric(20,5);
select geo_distance('(0,60)'::point,'(0,61)'::point)::numeric(20,5); SELECT geo_distance('(0,60)'::point,'(0,61)'::point)::numeric(20,5);
select geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)::numeric(20,5); SELECT geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)::numeric(20,5);
select (geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5); SELECT (geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5);
-- --
-- Test getting the distance between two points using the <@> operator. -- Test getting the distance between two points using the <@> operator.
-- --
select ('(0,0)'::point <@> '(0,0)'::point)::numeric(20,5); SELECT ('(0,0)'::point <@> '(0,0)'::point)::numeric(20,5);
select ('(0,0)'::point <@> '(180,0)'::point)::numeric(20,5); SELECT ('(0,0)'::point <@> '(180,0)'::point)::numeric(20,5);
select ('(0,0)'::point <@> '(0,90)'::point)::numeric(20,5); SELECT ('(0,0)'::point <@> '(0,90)'::point)::numeric(20,5);
select ('(0,0)'::point <@> '(90,0)'::point)::numeric(20,5); SELECT ('(0,0)'::point <@> '(90,0)'::point)::numeric(20,5);
select ('(0,0)'::point <@> '(1,0)'::point)::numeric(20,5); SELECT ('(0,0)'::point <@> '(1,0)'::point)::numeric(20,5);
select ('(0,0)'::point <@> '(0,1)'::point)::numeric(20,5); SELECT ('(0,0)'::point <@> '(0,1)'::point)::numeric(20,5);
select ('(0,30)'::point <@> '(1,30)'::point)::numeric(20,5); SELECT ('(0,30)'::point <@> '(1,30)'::point)::numeric(20,5);
select ('(0,30)'::point <@> '(0,31)'::point)::numeric(20,5); SELECT ('(0,30)'::point <@> '(0,31)'::point)::numeric(20,5);
select ('(0,60)'::point <@> '(1,60)'::point)::numeric(20,5); SELECT ('(0,60)'::point <@> '(1,60)'::point)::numeric(20,5);
select ('(0,60)'::point <@> '(0,61)'::point)::numeric(20,5); SELECT ('(0,60)'::point <@> '(0,61)'::point)::numeric(20,5);
select ('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)::numeric(20,5); SELECT ('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)::numeric(20,5);
select (('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5); SELECT (('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5);
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2002 by PostgreSQL Global Development Group * Copyright 2002 by PostgreSQL Global Development Group
* *
* $Header: /cvsroot/pgsql/contrib/findoidjoins/Attic/findoidjoins.c,v 1.18 2002/09/05 19:57:32 tgl Exp $ * $Header: /cvsroot/pgsql/contrib/findoidjoins/Attic/findoidjoins.c,v 1.19 2002/10/18 18:41:20 momjian Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -48,6 +48,8 @@ main(int argc, char **argv) ...@@ -48,6 +48,8 @@ main(int argc, char **argv)
resetPQExpBuffer(&sql); resetPQExpBuffer(&sql);
appendPQExpBuffer(&sql, "%s", appendPQExpBuffer(&sql, "%s",
"SET search_path = public;"
"SET autocommit TO 'on';"
"SELECT c.relname, (SELECT nspname FROM " "SELECT c.relname, (SELECT nspname FROM "
"pg_catalog.pg_namespace n WHERE n.oid = c.relnamespace) AS nspname " "pg_catalog.pg_namespace n WHERE n.oid = c.relnamespace) AS nspname "
"FROM pg_catalog.pg_class c " "FROM pg_catalog.pg_class c "
......
...@@ -166,6 +166,8 @@ sub main { ...@@ -166,6 +166,8 @@ sub main {
return 1; return 1;
} }
PQexec($PG_CONN, "SET search_path = public");
PQexec($PG_CONN, "SET autocommit TO 'on'");
PQexec($PG_CONN, "begin"); PQexec($PG_CONN, "begin");
$query = "declare C cursor for select (\""; $query = "declare C cursor for select (\"";
......
-- Adjust this setting to control where the objects get created.
SET search_path = public;
SET autocommit TO 'on';
CREATE OR REPLACE FUNCTION fti() RETURNS trigger AS CREATE OR REPLACE FUNCTION fti() RETURNS trigger AS
'MODULE_PATHNAME', 'fti' 'MODULE_PATHNAME', 'fti'
LANGUAGE 'C' VOLATILE CALLED ON NULL INPUT; LANGUAGE 'C' VOLATILE CALLED ON NULL INPUT;
GRANT EXECUTE ON FUNCTION fti() TO PUBLIC;
-- Adjust this setting to control where the objects get created.
SET search_path = public;
SET autocommit TO 'on';
DROP FUNCTION fti() CASCADE; DROP FUNCTION fti() CASCADE;
CREATE FUNCTION levenshtein (text,text) RETURNS int -- Adjust this setting to control where the objects get created.
AS 'MODULE_PATHNAME','levenshtein' LANGUAGE 'c' with (iscachable, isstrict); SET search_path = public;
CREATE FUNCTION metaphone (text,int) RETURNS text SET autocommit TO 'on';
AS 'MODULE_PATHNAME','metaphone' LANGUAGE 'c' with (iscachable, isstrict);
CREATE FUNCTION levenshtein (text,text)
RETURNS int
AS 'MODULE_PATHNAME','levenshtein'
LANGUAGE 'C' WITH (iscachable, isstrict);
CREATE FUNCTION metaphone (text,int)
RETURNS text
AS 'MODULE_PATHNAME','metaphone'
LANGUAGE 'C' WITH (iscachable, isstrict);
CREATE FUNCTION soundex(text) RETURNS text CREATE FUNCTION soundex(text) RETURNS text
AS 'MODULE_PATHNAME', 'soundex' LANGUAGE 'c' with (iscachable, isstrict); AS 'MODULE_PATHNAME', 'soundex'
LANGUAGE 'C' WITH (iscachable, isstrict);
CREATE FUNCTION text_soundex(text) RETURNS text CREATE FUNCTION text_soundex(text) RETURNS text
AS 'MODULE_PATHNAME', 'soundex' LANGUAGE 'c'; AS 'MODULE_PATHNAME', 'soundex'
LANGUAGE 'C';
GRANT EXECUTE ON FUNCTION levenshtein (text,text) TO PUBLIC;
GRANT EXECUTE ON FUNCTION metaphone (text,int) TO PUBLIC;
GRANT EXECUTE ON FUNCTION soundex(text) TO PUBLIC;
GRANT EXECUTE ON FUNCTION text_soundex(text) TO PUBLIC;
-- Drop functions -- Adjust this setting to control where the objects get created.
drop aggregate int_array_aggregate(int4); SET search_path = public;
drop function int_agg_state (int4, int4);
drop function int_agg_final_array (int4);
drop function int_array_enum (int4[]);
SET autocommit TO 'on';
-- Internal function for the aggregate -- Internal function for the aggregate
-- Is called for each item in an aggregation -- Is called for each item in an aggregation
create function int_agg_state (int4, int4) CREATE OR REPLACE FUNCTION int_agg_state (int4, int4)
returns int4 RETURNS int4
as 'MODULE_PATHNAME','int_agg_state' AS 'MODULE_PATHNAME','int_agg_state'
language 'c'; LANGUAGE 'C';
-- Internal function for the aggregate -- Internal function for the aggregate
-- Is called at the end of the aggregation, and returns an array. -- Is called at the end of the aggregation, and returns an array.
create function int_agg_final_array (int4) CREATE OR REPLACE FUNCTION int_agg_final_array (int4)
returns int4[] RETURNS int4[]
as 'MODULE_PATHNAME','int_agg_final_array' AS 'MODULE_PATHNAME','int_agg_final_array'
language 'c'; LANGUAGE 'C';
-- The aggration funcion. -- The aggration funcion.
-- uses the above functions to create an array of integers from an aggregation. -- uses the above functions to create an array of integers from an aggregation.
create aggregate int_array_aggregate CREATE OR REPLACE AGGREGATE int_array_aggregate (
(
BASETYPE = int4, BASETYPE = int4,
SFUNC = int_agg_state, SFUNC = int_agg_state,
STYPE = int4, STYPE = int4,
...@@ -33,8 +30,7 @@ create aggregate int_array_aggregate ...@@ -33,8 +30,7 @@ create aggregate int_array_aggregate
-- The enumeration function -- The enumeration function
-- returns each element in a one dimentional integer array -- returns each element in a one dimentional integer array
-- as a row. -- as a row.
create function int_array_enum(int4[]) CREATE OR REPLACE FUNCTION int_array_enum(int4[])
returns setof integer RETURNS setof integer
as 'MODULE_PATHNAME','int_enum' AS 'MODULE_PATHNAME','int_enum'
language 'c'; LANGUAGE 'C';
--
-- Create the user-defined type for the 1-D integer arrays (_int4) -- Create the user-defined type for the 1-D integer arrays (_int4)
-- --
BEGIN TRANSACTION;
-- Adjust this setting to control where the operators, functions, and -- Adjust this setting to control where the operators, functions, and
-- opclasses get created. -- opclasses get created.
SET search_path = public; SET search_path = public;
SET autocommit TO 'on';
-- Query type -- Query type
CREATE FUNCTION bqarr_in(cstring) CREATE FUNCTION bqarr_in(cstring)
RETURNS query_int RETURNS query_int
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' WITH (isstrict);
CREATE FUNCTION bqarr_out(query_int) CREATE FUNCTION bqarr_out(query_int)
RETURNS cstring RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' WITH (isstrict);
CREATE TYPE query_int ( CREATE TYPE query_int (
internallength = -1, INTERNALLENGTH = -1,
input = bqarr_in, INPUT = bqarr_in,
output = bqarr_out OUTPUT = bqarr_out
); );
--only for debug --only for debug
CREATE FUNCTION querytree(query_int) CREATE FUNCTION querytree(query_int)
RETURNS text RETURNS text
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' WITH (isstrict);
CREATE FUNCTION boolop(_int4, query_int) RETURNS bool CREATE FUNCTION boolop(_int4, query_int)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isstrict);
COMMENT ON FUNCTION boolop(_int4, query_int) IS 'boolean operation with array'; COMMENT ON FUNCTION boolop(_int4, query_int) IS 'boolean operation with array';
CREATE FUNCTION rboolop(query_int, _int4) RETURNS bool CREATE FUNCTION rboolop(query_int, _int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isstrict);
COMMENT ON FUNCTION rboolop(query_int, _int4) IS 'boolean operation with array'; COMMENT ON FUNCTION rboolop(query_int, _int4) IS 'boolean operation with array';
CREATE OPERATOR @@ ( CREATE OPERATOR @@ (
LEFTARG = _int4, RIGHTARG = query_int, PROCEDURE = boolop, LEFTARG = _int4,
COMMUTATOR = '~~', RESTRICT = contsel, JOIN = contjoinsel RIGHTARG = query_int,
PROCEDURE = boolop,
COMMUTATOR = '~~',
RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR ~~ ( CREATE OPERATOR ~~ (
LEFTARG = query_int, RIGHTARG = _int4, PROCEDURE = rboolop, LEFTARG = query_int,
COMMUTATOR = '@@', RESTRICT = contsel, JOIN = contjoinsel RIGHTARG = _int4,
PROCEDURE = rboolop,
COMMUTATOR = '@@',
RESTRICT = contsel,
JOIN = contjoinsel
); );
...@@ -57,175 +71,279 @@ CREATE OPERATOR ~~ ( ...@@ -57,175 +71,279 @@ CREATE OPERATOR ~~ (
-- Comparison methods -- Comparison methods
CREATE FUNCTION _int_contains(_int4, _int4) RETURNS bool CREATE FUNCTION _int_contains(_int4, _int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isstrict);
COMMENT ON FUNCTION _int_contains(_int4, _int4) IS 'contains'; COMMENT ON FUNCTION _int_contains(_int4, _int4) IS 'contains';
CREATE FUNCTION _int_contained(_int4, _int4) RETURNS bool CREATE FUNCTION _int_contained(_int4, _int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isstrict);
COMMENT ON FUNCTION _int_contained(_int4, _int4) IS 'contained in'; COMMENT ON FUNCTION _int_contained(_int4, _int4) IS 'contained in';
CREATE FUNCTION _int_overlap(_int4, _int4) RETURNS bool CREATE FUNCTION _int_overlap(_int4, _int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isstrict);
COMMENT ON FUNCTION _int_overlap(_int4, _int4) IS 'overlaps'; COMMENT ON FUNCTION _int_overlap(_int4, _int4) IS 'overlaps';
CREATE FUNCTION _int_same(_int4, _int4) RETURNS bool CREATE FUNCTION _int_same(_int4, _int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isstrict);
COMMENT ON FUNCTION _int_same(_int4, _int4) IS 'same as'; COMMENT ON FUNCTION _int_same(_int4, _int4) IS 'same as';
CREATE FUNCTION _int_different(_int4, _int4) RETURNS bool CREATE FUNCTION _int_different(_int4, _int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isstrict);
COMMENT ON FUNCTION _int_different(_int4, _int4) IS 'different'; COMMENT ON FUNCTION _int_different(_int4, _int4) IS 'different';
-- support routines for indexing -- support routines for indexing
CREATE FUNCTION _int_union(_int4, _int4) RETURNS _int4 CREATE FUNCTION _int_union(_int4, _int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS _int4
AS 'MODULE_PATHNAME' LANGUAGE 'C' WITH (isstrict);
CREATE FUNCTION _int_inter(_int4, _int4) RETURNS _int4 CREATE FUNCTION _int_inter(_int4, _int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS _int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isstrict);
-- --
-- OPERATORS -- OPERATORS
-- --
CREATE OPERATOR && ( CREATE OPERATOR && (
LEFTARG = _int4, RIGHTARG = _int4, PROCEDURE = _int_overlap, LEFTARG = _int4,
RIGHTARG = _int4,
PROCEDURE = _int_overlap,
COMMUTATOR = '&&', COMMUTATOR = '&&',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
--CREATE OPERATOR = ( --CREATE OPERATOR = (
-- LEFTARG = _int4, RIGHTARG = _int4, PROCEDURE = _int_same, -- LEFTARG = _int4,
-- COMMUTATOR = '=', NEGATOR = '<>', -- RIGHTARG = _int4,
-- RESTRICT = eqsel, JOIN = eqjoinsel, -- PROCEDURE = _int_same,
-- SORT1 = '<', SORT2 = '<' -- COMMUTATOR = '=',
-- NEGATOR = '<>',
-- RESTRICT = eqsel,
-- JOIN = eqjoinsel,
-- SORT1 = '<',
-- SORT2 = '<'
--); --);
CREATE OPERATOR <> ( CREATE OPERATOR <> (
LEFTARG = _int4, RIGHTARG = _int4, PROCEDURE = _int_different, LEFTARG = _int4,
COMMUTATOR = '<>', NEGATOR = '=', RIGHTARG = _int4,
RESTRICT = neqsel, JOIN = neqjoinsel PROCEDURE = _int_different,
COMMUTATOR = '<>',
NEGATOR = '=',
RESTRICT = neqsel,
JOIN = neqjoinsel
); );
CREATE OPERATOR @ ( CREATE OPERATOR @ (
LEFTARG = _int4, RIGHTARG = _int4, PROCEDURE = _int_contains, LEFTARG = _int4,
COMMUTATOR = '~', RESTRICT = contsel, JOIN = contjoinsel RIGHTARG = _int4,
PROCEDURE = _int_contains,
COMMUTATOR = '~',
RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR ~ ( CREATE OPERATOR ~ (
LEFTARG = _int4, RIGHTARG = _int4, PROCEDURE = _int_contained, LEFTARG = _int4,
COMMUTATOR = '@', RESTRICT = contsel, JOIN = contjoinsel RIGHTARG = _int4,
PROCEDURE = _int_contained,
COMMUTATOR = '@',
RESTRICT = contsel,
JOIN = contjoinsel
); );
-------------- --------------
CREATE FUNCTION intset(int4) RETURNS _int4 CREATE FUNCTION intset(int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable); RETURNS _int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict, isCachable);
CREATE FUNCTION icount(_int4)
RETURNS int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict, isCachable);
CREATE FUNCTION icount(_int4) RETURNS int4
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable);
CREATE OPERATOR # ( CREATE OPERATOR # (
RIGHTARG = _int4, PROCEDURE = icount RIGHTARG = _int4,
PROCEDURE = icount
); );
CREATE FUNCTION sort(_int4, text) RETURNS _int4 CREATE FUNCTION sort(_int4, text)
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable); RETURNS _int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict, isCachable);
CREATE FUNCTION sort(_int4)
RETURNS _int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict, isCachable);
CREATE FUNCTION sort(_int4) RETURNS _int4 CREATE FUNCTION sort_asc(_int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable); RETURNS _int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict, isCachable);
CREATE FUNCTION sort_asc(_int4) RETURNS _int4 CREATE FUNCTION sort_desc(_int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable); RETURNS _int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict, isCachable);
CREATE FUNCTION sort_desc(_int4) RETURNS _int4 CREATE FUNCTION uniq(_int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable); RETURNS _int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict, isCachable);
CREATE FUNCTION uniq(_int4) RETURNS _int4 CREATE FUNCTION idx(_int4, int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable); RETURNS int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict, isCachable);
CREATE FUNCTION idx(_int4, int4) RETURNS int4
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable);
CREATE OPERATOR # ( CREATE OPERATOR # (
LEFTARG = _int4, RIGHTARG = int4, PROCEDURE = idx LEFTARG = _int4,
RIGHTARG = int4,
PROCEDURE = idx
); );
CREATE FUNCTION subarray(_int4, int4, int4) RETURNS _int4 CREATE FUNCTION subarray(_int4, int4, int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable); RETURNS _int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict, isCachable);
CREATE FUNCTION subarray(_int4, int4)
RETURNS _int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict, isCachable);
CREATE FUNCTION subarray(_int4, int4) RETURNS _int4 CREATE FUNCTION intarray_push_elem(_int4, int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable); RETURNS _int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict, isCachable);
CREATE FUNCTION intarray_push_elem(_int4, int4) RETURNS _int4
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable);
CREATE OPERATOR + ( CREATE OPERATOR + (
LEFTARG = _int4, RIGHTARG = int4, PROCEDURE = intarray_push_elem LEFTARG = _int4,
RIGHTARG = int4,
PROCEDURE = intarray_push_elem
); );
CREATE FUNCTION intarray_push_array(_int4, _int4) RETURNS _int4 CREATE FUNCTION intarray_push_array(_int4, _int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable); RETURNS _int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict, isCachable);
CREATE OPERATOR + ( CREATE OPERATOR + (
LEFTARG = _int4, RIGHTARG = _int4, COMMUTATOR = +, PROCEDURE = intarray_push_array LEFTARG = _int4,
RIGHTARG = _int4,
COMMUTATOR = +,
PROCEDURE = intarray_push_array
); );
CREATE FUNCTION intarray_del_elem(_int4, int4) RETURNS _int4 CREATE FUNCTION intarray_del_elem(_int4, int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable); RETURNS _int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict, isCachable);
CREATE OPERATOR - ( CREATE OPERATOR - (
LEFTARG = _int4, RIGHTARG = int4, PROCEDURE = intarray_del_elem LEFTARG = _int4,
RIGHTARG = int4,
PROCEDURE = intarray_del_elem
); );
CREATE FUNCTION intset_union_elem(_int4, int4) RETURNS _int4 CREATE FUNCTION intset_union_elem(_int4, int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable); RETURNS _int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict, isCachable);
CREATE OPERATOR | ( CREATE OPERATOR | (
LEFTARG = _int4, RIGHTARG = int4, PROCEDURE = intset_union_elem LEFTARG = _int4,
RIGHTARG = int4,
PROCEDURE = intset_union_elem
); );
CREATE OPERATOR | ( CREATE OPERATOR | (
LEFTARG = _int4, RIGHTARG = _int4, COMMUTATOR = |, PROCEDURE = _int_union LEFTARG = _int4,
RIGHTARG = _int4,
COMMUTATOR = |,
PROCEDURE = _int_union
); );
CREATE FUNCTION intset_subtract(_int4, _int4) RETURNS _int4 CREATE FUNCTION intset_subtract(_int4, _int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable); RETURNS _int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict, isCachable);
CREATE OPERATOR - ( CREATE OPERATOR - (
LEFTARG = _int4, RIGHTARG = _int4, PROCEDURE = intset_subtract LEFTARG = _int4,
RIGHTARG = _int4,
PROCEDURE = intset_subtract
); );
CREATE OPERATOR & ( CREATE OPERATOR & (
LEFTARG = _int4, RIGHTARG = _int4, COMMUTATOR = &, PROCEDURE = _int_inter LEFTARG = _int4,
RIGHTARG = _int4,
COMMUTATOR = &,
PROCEDURE = _int_inter
); );
-------------- --------------
-- define the GiST support methods -- define the GiST support methods
CREATE FUNCTION g_int_consistent(internal,_int4,int4) RETURNS bool CREATE FUNCTION g_int_consistent(internal,_int4,int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION g_int_compress(internal) RETURNS internal CREATE FUNCTION g_int_compress(internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION g_int_decompress(internal) RETURNS internal CREATE FUNCTION g_int_decompress(internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION g_int_penalty(internal,internal,internal) RETURNS internal CREATE FUNCTION g_int_penalty(internal,internal,internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isstrict);
CREATE FUNCTION g_int_picksplit(internal, internal) RETURNS internal CREATE FUNCTION g_int_picksplit(internal, internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION g_int_union(bytea, internal) RETURNS _int4 CREATE FUNCTION g_int_union(bytea, internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS _int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION g_int_same(_int4, _int4, internal) RETURNS internal CREATE FUNCTION g_int_same(_int4, _int4, internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- Create the operator class for indexing -- Create the operator class for indexing
CREATE OPERATOR CLASS gist__int_ops CREATE OPERATOR CLASS gist__int_ops
DEFAULT FOR TYPE _int4 USING gist AS DEFAULT FOR TYPE _int4 USING gist AS
OPERATOR 3 &&, OPERATOR 3 &&,
OPERATOR 6 = RECHECK, OPERATOR 6 = RECHECK,
OPERATOR 7 @, OPERATOR 7 @,
...@@ -244,31 +362,46 @@ CREATE OPERATOR CLASS gist__int_ops ...@@ -244,31 +362,46 @@ CREATE OPERATOR CLASS gist__int_ops
-- intbig -- intbig
--------------------------------------------- ---------------------------------------------
-- define the GiST support methods -- define the GiST support methods
CREATE FUNCTION g_intbig_consistent(internal,_int4,int4) RETURNS bool CREATE FUNCTION g_intbig_consistent(internal,_int4,int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION g_intbig_compress(internal) RETURNS internal CREATE FUNCTION g_intbig_compress(internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION g_intbig_decompress(internal) RETURNS internal CREATE FUNCTION g_intbig_decompress(internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION g_intbig_penalty(internal,internal,internal) RETURNS internal CREATE FUNCTION g_intbig_penalty(internal,internal,internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isstrict);
CREATE FUNCTION g_intbig_picksplit(internal, internal) RETURNS internal CREATE FUNCTION g_intbig_picksplit(internal, internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION g_intbig_union(bytea, internal) RETURNS _int4 CREATE FUNCTION g_intbig_union(bytea, internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS _int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION g_intbig_same(_int4, _int4, internal) RETURNS internal CREATE FUNCTION g_intbig_same(_int4, _int4, internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- register the opclass for indexing (not as default) -- register the opclass for indexing (not as default)
CREATE OPERATOR CLASS gist__intbig_ops CREATE OPERATOR CLASS gist__intbig_ops
FOR TYPE _int4 USING gist AS FOR TYPE _int4 USING gist
AS
OPERATOR 3 && RECHECK, OPERATOR 3 && RECHECK,
OPERATOR 6 = RECHECK, OPERATOR 6 = RECHECK,
OPERATOR 7 @ RECHECK, OPERATOR 7 @ RECHECK,
...@@ -281,5 +414,3 @@ CREATE OPERATOR CLASS gist__intbig_ops ...@@ -281,5 +414,3 @@ CREATE OPERATOR CLASS gist__intbig_ops
FUNCTION 5 g_intbig_penalty (internal, internal, internal), FUNCTION 5 g_intbig_penalty (internal, internal, internal),
FUNCTION 6 g_intbig_picksplit (internal, internal), FUNCTION 6 g_intbig_picksplit (internal, internal),
FUNCTION 7 g_intbig_same (_int4, _int4, internal); FUNCTION 7 g_intbig_same (_int4, _int4, internal);
END TRANSACTION;
...@@ -3,364 +3,364 @@ ...@@ -3,364 +3,364 @@
-- does not depend on contents of seg.sql. -- does not depend on contents of seg.sql.
-- --
\set ECHO none \set ECHO none
psql:_int.sql:13: WARNING: ProcedureCreate: type query_int is not yet defined psql:_int.sql:15: WARNING: ProcedureCreate: type query_int is not yet defined
psql:_int.sql:18: WARNING: Argument type "query_int" is only a shell psql:_int.sql:20: WARNING: Argument type "query_int" is only a shell
select intset(1234); SELECT intset(1234);
intset intset
-------- --------
{1234} {1234}
(1 row) (1 row)
select icount('{1234234,234234}'); SELECT icount('{1234234,234234}');
icount icount
-------- --------
2 2
(1 row) (1 row)
select sort('{1234234,-30,234234}'); SELECT sort('{1234234,-30,234234}');
sort sort
---------------------- ----------------------
{-30,234234,1234234} {-30,234234,1234234}
(1 row) (1 row)
select sort('{1234234,-30,234234}','asc'); SELECT sort('{1234234,-30,234234}','asc');
sort sort
---------------------- ----------------------
{-30,234234,1234234} {-30,234234,1234234}
(1 row) (1 row)
select sort('{1234234,-30,234234}','desc'); SELECT sort('{1234234,-30,234234}','desc');
sort sort
---------------------- ----------------------
{1234234,234234,-30} {1234234,234234,-30}
(1 row) (1 row)
select sort_asc('{1234234,-30,234234}'); SELECT sort_asc('{1234234,-30,234234}');
sort_asc sort_asc
---------------------- ----------------------
{-30,234234,1234234} {-30,234234,1234234}
(1 row) (1 row)
select sort_desc('{1234234,-30,234234}'); SELECT sort_desc('{1234234,-30,234234}');
sort_desc sort_desc
---------------------- ----------------------
{1234234,234234,-30} {1234234,234234,-30}
(1 row) (1 row)
select uniq('{1234234,-30,-30,234234,-30}'); SELECT uniq('{1234234,-30,-30,234234,-30}');
uniq uniq
-------------------------- --------------------------
{1234234,-30,234234,-30} {1234234,-30,234234,-30}
(1 row) (1 row)
select uniq(sort_asc('{1234234,-30,-30,234234,-30}')); SELECT uniq(sort_asc('{1234234,-30,-30,234234,-30}'));
uniq uniq
---------------------- ----------------------
{-30,234234,1234234} {-30,234234,1234234}
(1 row) (1 row)
select idx('{1234234,-30,-30,234234,-30}',-30); SELECT idx('{1234234,-30,-30,234234,-30}',-30);
idx idx
----- -----
2 2
(1 row) (1 row)
select subarray('{1234234,-30,-30,234234,-30}',2,3); SELECT subarray('{1234234,-30,-30,234234,-30}',2,3);
subarray subarray
------------------ ------------------
{-30,-30,234234} {-30,-30,234234}
(1 row) (1 row)
select subarray('{1234234,-30,-30,234234,-30}',-1,1); SELECT subarray('{1234234,-30,-30,234234,-30}',-1,1);
subarray subarray
---------- ----------
{-30} {-30}
(1 row) (1 row)
select subarray('{1234234,-30,-30,234234,-30}',0,-1); SELECT subarray('{1234234,-30,-30,234234,-30}',0,-1);
subarray subarray
-------------------------- --------------------------
{1234234,-30,-30,234234} {1234234,-30,-30,234234}
(1 row) (1 row)
select #'{1234234,234234}'::int[]; SELECT #'{1234234,234234}'::int[];
?column? ?column?
---------- ----------
2 2
(1 row) (1 row)
select '{123,623,445}'::int[] + 1245; SELECT '{123,623,445}'::int[] + 1245;
?column? ?column?
-------------------- --------------------
{123,623,445,1245} {123,623,445,1245}
(1 row) (1 row)
select '{123,623,445}'::int[] + 445; SELECT '{123,623,445}'::int[] + 445;
?column? ?column?
------------------- -------------------
{123,623,445,445} {123,623,445,445}
(1 row) (1 row)
select '{123,623,445}'::int[] + '{1245,87,445}'; SELECT '{123,623,445}'::int[] + '{1245,87,445}';
?column? ?column?
--------------------------- ---------------------------
{123,623,445,1245,87,445} {123,623,445,1245,87,445}
(1 row) (1 row)
select '{123,623,445}'::int[] - 623; SELECT '{123,623,445}'::int[] - 623;
?column? ?column?
----------- -----------
{123,445} {123,445}
(1 row) (1 row)
select '{123,623,445}'::int[] - '{1623,623}'; SELECT '{123,623,445}'::int[] - '{1623,623}';
?column? ?column?
----------- -----------
{123,445} {123,445}
(1 row) (1 row)
select '{123,623,445}'::int[] | 623; SELECT '{123,623,445}'::int[] | 623;
?column? ?column?
--------------- ---------------
{123,445,623} {123,445,623}
(1 row) (1 row)
select '{123,623,445}'::int[] | 1623; SELECT '{123,623,445}'::int[] | 1623;
?column? ?column?
-------------------- --------------------
{123,445,623,1623} {123,445,623,1623}
(1 row) (1 row)
select '{123,623,445}'::int[] | '{1623,623}'; SELECT '{123,623,445}'::int[] | '{1623,623}';
?column? ?column?
-------------------- --------------------
{123,445,623,1623} {123,445,623,1623}
(1 row) (1 row)
select '{123,623,445}'::int[] & '{1623,623}'; SELECT '{123,623,445}'::int[] & '{1623,623}';
?column? ?column?
---------- ----------
{623} {623}
(1 row) (1 row)
--test query_int --test query_int
select '1'::query_int; SELECT '1'::query_int;
query_int query_int
----------- -----------
1 1
(1 row) (1 row)
select ' 1'::query_int; SELECT ' 1'::query_int;
query_int query_int
----------- -----------
1 1
(1 row) (1 row)
select '1 '::query_int; SELECT '1 '::query_int;
query_int query_int
----------- -----------
1 1
(1 row) (1 row)
select ' 1 '::query_int; SELECT ' 1 '::query_int;
query_int query_int
----------- -----------
1 1
(1 row) (1 row)
select ' ! 1 '::query_int; SELECT ' ! 1 '::query_int;
query_int query_int
----------- -----------
!1 !1
(1 row) (1 row)
select '!1'::query_int; SELECT '!1'::query_int;
query_int query_int
----------- -----------
!1 !1
(1 row) (1 row)
select '1|2'::query_int; SELECT '1|2'::query_int;
query_int query_int
----------- -----------
1 | 2 1 | 2
(1 row) (1 row)
select '1|!2'::query_int; SELECT '1|!2'::query_int;
query_int query_int
----------- -----------
1 | !2 1 | !2
(1 row) (1 row)
select '!1|2'::query_int; SELECT '!1|2'::query_int;
query_int query_int
----------- -----------
!1 | 2 !1 | 2
(1 row) (1 row)
select '!1|!2'::query_int; SELECT '!1|!2'::query_int;
query_int query_int
----------- -----------
!1 | !2 !1 | !2
(1 row) (1 row)
select '!(!1|!2)'::query_int; SELECT '!(!1|!2)'::query_int;
query_int query_int
-------------- --------------
!( !1 | !2 ) !( !1 | !2 )
(1 row) (1 row)
select '!(!1|2)'::query_int; SELECT '!(!1|2)'::query_int;
query_int query_int
------------- -------------
!( !1 | 2 ) !( !1 | 2 )
(1 row) (1 row)
select '!(1|!2)'::query_int; SELECT '!(1|!2)'::query_int;
query_int query_int
------------- -------------
!( 1 | !2 ) !( 1 | !2 )
(1 row) (1 row)
select '!(1|2)'::query_int; SELECT '!(1|2)'::query_int;
query_int query_int
------------ ------------
!( 1 | 2 ) !( 1 | 2 )
(1 row) (1 row)
select '1&2'::query_int; SELECT '1&2'::query_int;
query_int query_int
----------- -----------
1 & 2 1 & 2
(1 row) (1 row)
select '!1&2'::query_int; SELECT '!1&2'::query_int;
query_int query_int
----------- -----------
!1 & 2 !1 & 2
(1 row) (1 row)
select '1&!2'::query_int; SELECT '1&!2'::query_int;
query_int query_int
----------- -----------
1 & !2 1 & !2
(1 row) (1 row)
select '!1&!2'::query_int; SELECT '!1&!2'::query_int;
query_int query_int
----------- -----------
!1 & !2 !1 & !2
(1 row) (1 row)
select '(1&2)'::query_int; SELECT '(1&2)'::query_int;
query_int query_int
----------- -----------
1 & 2 1 & 2
(1 row) (1 row)
select '1&(2)'::query_int; SELECT '1&(2)'::query_int;
query_int query_int
----------- -----------
1 & 2 1 & 2
(1 row) (1 row)
select '!(1)&2'::query_int; SELECT '!(1)&2'::query_int;
query_int query_int
----------- -----------
!1 & 2 !1 & 2
(1 row) (1 row)
select '!(1&2)'::query_int; SELECT '!(1&2)'::query_int;
query_int query_int
------------ ------------
!( 1 & 2 ) !( 1 & 2 )
(1 row) (1 row)
select '1|2&3'::query_int; SELECT '1|2&3'::query_int;
query_int query_int
----------- -----------
1 | 2 & 3 1 | 2 & 3
(1 row) (1 row)
select '1|(2&3)'::query_int; SELECT '1|(2&3)'::query_int;
query_int query_int
----------- -----------
1 | 2 & 3 1 | 2 & 3
(1 row) (1 row)
select '(1|2)&3'::query_int; SELECT '(1|2)&3'::query_int;
query_int query_int
--------------- ---------------
( 1 | 2 ) & 3 ( 1 | 2 ) & 3
(1 row) (1 row)
select '1|2&!3'::query_int; SELECT '1|2&!3'::query_int;
query_int query_int
------------ ------------
1 | 2 & !3 1 | 2 & !3
(1 row) (1 row)
select '1|!2&3'::query_int; SELECT '1|!2&3'::query_int;
query_int query_int
------------ ------------
1 | !2 & 3 1 | !2 & 3
(1 row) (1 row)
select '!1|2&3'::query_int; SELECT '!1|2&3'::query_int;
query_int query_int
------------ ------------
!1 | 2 & 3 !1 | 2 & 3
(1 row) (1 row)
select '!1|(2&3)'::query_int; SELECT '!1|(2&3)'::query_int;
query_int query_int
------------ ------------
!1 | 2 & 3 !1 | 2 & 3
(1 row) (1 row)
select '!(1|2)&3'::query_int; SELECT '!(1|2)&3'::query_int;
query_int query_int
---------------- ----------------
!( 1 | 2 ) & 3 !( 1 | 2 ) & 3
(1 row) (1 row)
select '(!1|2)&3'::query_int; SELECT '(!1|2)&3'::query_int;
query_int query_int
---------------- ----------------
( !1 | 2 ) & 3 ( !1 | 2 ) & 3
(1 row) (1 row)
select '1|(2|(4|(5|6)))'::query_int; SELECT '1|(2|(4|(5|6)))'::query_int;
query_int query_int
------------------------------- -------------------------------
1 | ( 2 | ( 4 | ( 5 | 6 ) ) ) 1 | ( 2 | ( 4 | ( 5 | 6 ) ) )
(1 row) (1 row)
select '1|2|4|5|6'::query_int; SELECT '1|2|4|5|6'::query_int;
query_int query_int
------------------------------- -------------------------------
( ( ( 1 | 2 ) | 4 ) | 5 ) | 6 ( ( ( 1 | 2 ) | 4 ) | 5 ) | 6
(1 row) (1 row)
select '1&(2&(4&(5&6)))'::query_int; SELECT '1&(2&(4&(5&6)))'::query_int;
query_int query_int
------------------- -------------------
1 & 2 & 4 & 5 & 6 1 & 2 & 4 & 5 & 6
(1 row) (1 row)
select '1&2&4&5&6'::query_int; SELECT '1&2&4&5&6'::query_int;
query_int query_int
------------------- -------------------
1 & 2 & 4 & 5 & 6 1 & 2 & 4 & 5 & 6
(1 row) (1 row)
select '1&(2&(4&(5|6)))'::query_int; SELECT '1&(2&(4&(5|6)))'::query_int;
query_int query_int
----------------------- -----------------------
1 & 2 & 4 & ( 5 | 6 ) 1 & 2 & 4 & ( 5 | 6 )
(1 row) (1 row)
select '1&(2&(4&(5|!6)))'::query_int; SELECT '1&(2&(4&(5|!6)))'::query_int;
query_int query_int
------------------------ ------------------------
1 & 2 & 4 & ( 5 | !6 ) 1 & 2 & 4 & ( 5 | !6 )
...@@ -465,7 +465,7 @@ SELECT count(*) from test__int WHERE a @@ '(20&23)|(50&68)'; ...@@ -465,7 +465,7 @@ SELECT count(*) from test__int WHERE a @@ '(20&23)|(50&68)';
21 21
(1 row) (1 row)
drop index text_idx; DROP INDEX text_idx;
CREATE INDEX text_idx on test__int using gist ( a gist__intbig_ops ); CREATE INDEX text_idx on test__int using gist ( a gist__intbig_ops );
SELECT count(*) from test__int WHERE a && '{23,50}'; SELECT count(*) from test__int WHERE a && '{23,50}';
count count
......
...@@ -3,73 +3,74 @@ ...@@ -3,73 +3,74 @@
-- does not depend on contents of seg.sql. -- does not depend on contents of seg.sql.
-- --
\set ECHO none \set ECHO none
SET autocommit TO 'on';
\i _int.sql \i _int.sql
\set ECHO all \set ECHO all
select intset(1234); SELECT intset(1234);
select icount('{1234234,234234}'); SELECT icount('{1234234,234234}');
select sort('{1234234,-30,234234}'); SELECT sort('{1234234,-30,234234}');
select sort('{1234234,-30,234234}','asc'); SELECT sort('{1234234,-30,234234}','asc');
select sort('{1234234,-30,234234}','desc'); SELECT sort('{1234234,-30,234234}','desc');
select sort_asc('{1234234,-30,234234}'); SELECT sort_asc('{1234234,-30,234234}');
select sort_desc('{1234234,-30,234234}'); SELECT sort_desc('{1234234,-30,234234}');
select uniq('{1234234,-30,-30,234234,-30}'); SELECT uniq('{1234234,-30,-30,234234,-30}');
select uniq(sort_asc('{1234234,-30,-30,234234,-30}')); SELECT uniq(sort_asc('{1234234,-30,-30,234234,-30}'));
select idx('{1234234,-30,-30,234234,-30}',-30); SELECT idx('{1234234,-30,-30,234234,-30}',-30);
select subarray('{1234234,-30,-30,234234,-30}',2,3); SELECT subarray('{1234234,-30,-30,234234,-30}',2,3);
select subarray('{1234234,-30,-30,234234,-30}',-1,1); SELECT subarray('{1234234,-30,-30,234234,-30}',-1,1);
select subarray('{1234234,-30,-30,234234,-30}',0,-1); SELECT subarray('{1234234,-30,-30,234234,-30}',0,-1);
select #'{1234234,234234}'::int[]; SELECT #'{1234234,234234}'::int[];
select '{123,623,445}'::int[] + 1245; SELECT '{123,623,445}'::int[] + 1245;
select '{123,623,445}'::int[] + 445; SELECT '{123,623,445}'::int[] + 445;
select '{123,623,445}'::int[] + '{1245,87,445}'; SELECT '{123,623,445}'::int[] + '{1245,87,445}';
select '{123,623,445}'::int[] - 623; SELECT '{123,623,445}'::int[] - 623;
select '{123,623,445}'::int[] - '{1623,623}'; SELECT '{123,623,445}'::int[] - '{1623,623}';
select '{123,623,445}'::int[] | 623; SELECT '{123,623,445}'::int[] | 623;
select '{123,623,445}'::int[] | 1623; SELECT '{123,623,445}'::int[] | 1623;
select '{123,623,445}'::int[] | '{1623,623}'; SELECT '{123,623,445}'::int[] | '{1623,623}';
select '{123,623,445}'::int[] & '{1623,623}'; SELECT '{123,623,445}'::int[] & '{1623,623}';
--test query_int --test query_int
select '1'::query_int; SELECT '1'::query_int;
select ' 1'::query_int; SELECT ' 1'::query_int;
select '1 '::query_int; SELECT '1 '::query_int;
select ' 1 '::query_int; SELECT ' 1 '::query_int;
select ' ! 1 '::query_int; SELECT ' ! 1 '::query_int;
select '!1'::query_int; SELECT '!1'::query_int;
select '1|2'::query_int; SELECT '1|2'::query_int;
select '1|!2'::query_int; SELECT '1|!2'::query_int;
select '!1|2'::query_int; SELECT '!1|2'::query_int;
select '!1|!2'::query_int; SELECT '!1|!2'::query_int;
select '!(!1|!2)'::query_int; SELECT '!(!1|!2)'::query_int;
select '!(!1|2)'::query_int; SELECT '!(!1|2)'::query_int;
select '!(1|!2)'::query_int; SELECT '!(1|!2)'::query_int;
select '!(1|2)'::query_int; SELECT '!(1|2)'::query_int;
select '1&2'::query_int; SELECT '1&2'::query_int;
select '!1&2'::query_int; SELECT '!1&2'::query_int;
select '1&!2'::query_int; SELECT '1&!2'::query_int;
select '!1&!2'::query_int; SELECT '!1&!2'::query_int;
select '(1&2)'::query_int; SELECT '(1&2)'::query_int;
select '1&(2)'::query_int; SELECT '1&(2)'::query_int;
select '!(1)&2'::query_int; SELECT '!(1)&2'::query_int;
select '!(1&2)'::query_int; SELECT '!(1&2)'::query_int;
select '1|2&3'::query_int; SELECT '1|2&3'::query_int;
select '1|(2&3)'::query_int; SELECT '1|(2&3)'::query_int;
select '(1|2)&3'::query_int; SELECT '(1|2)&3'::query_int;
select '1|2&!3'::query_int; SELECT '1|2&!3'::query_int;
select '1|!2&3'::query_int; SELECT '1|!2&3'::query_int;
select '!1|2&3'::query_int; SELECT '!1|2&3'::query_int;
select '!1|(2&3)'::query_int; SELECT '!1|(2&3)'::query_int;
select '!(1|2)&3'::query_int; SELECT '!(1|2)&3'::query_int;
select '(!1|2)&3'::query_int; SELECT '(!1|2)&3'::query_int;
select '1|(2|(4|(5|6)))'::query_int; SELECT '1|(2|(4|(5|6)))'::query_int;
select '1|2|4|5|6'::query_int; SELECT '1|2|4|5|6'::query_int;
select '1&(2&(4&(5&6)))'::query_int; SELECT '1&(2&(4&(5&6)))'::query_int;
select '1&2&4&5&6'::query_int; SELECT '1&2&4&5&6'::query_int;
select '1&(2&(4&(5|6)))'::query_int; SELECT '1&(2&(4&(5|6)))'::query_int;
select '1&(2&(4&(5|!6)))'::query_int; SELECT '1&(2&(4&(5|!6)))'::query_int;
CREATE TABLE test__int( a int[] ); CREATE TABLE test__int( a int[] );
...@@ -96,7 +97,7 @@ SELECT count(*) from test__int WHERE a @@ '50&68'; ...@@ -96,7 +97,7 @@ SELECT count(*) from test__int WHERE a @@ '50&68';
SELECT count(*) from test__int WHERE a @ '{20,23}' or a @ '{50,68}'; SELECT count(*) from test__int WHERE a @ '{20,23}' or a @ '{50,68}';
SELECT count(*) from test__int WHERE a @@ '(20&23)|(50&68)'; SELECT count(*) from test__int WHERE a @@ '(20&23)|(50&68)';
drop index text_idx; DROP INDEX text_idx;
CREATE INDEX text_idx on test__int using gist ( a gist__intbig_ops ); CREATE INDEX text_idx on test__int using gist ( a gist__intbig_ops );
SELECT count(*) from test__int WHERE a && '{23,50}'; SELECT count(*) from test__int WHERE a && '{23,50}';
...@@ -107,4 +108,3 @@ SELECT count(*) from test__int WHERE a @ '{20,23}'; ...@@ -107,4 +108,3 @@ SELECT count(*) from test__int WHERE a @ '{20,23}';
SELECT count(*) from test__int WHERE a @@ '50&68'; SELECT count(*) from test__int WHERE a @@ '50&68';
SELECT count(*) from test__int WHERE a @ '{20,23}' or a @ '{50,68}'; SELECT count(*) from test__int WHERE a @ '{20,23}' or a @ '{50,68}';
SELECT count(*) from test__int WHERE a @@ '(20&23)|(50&68)'; SELECT count(*) from test__int WHERE a @@ '(20&23)|(50&68)';
-- --
-- PostgreSQL code for ISSNs. -- PostgreSQL code for ISSNs.
-- --
-- $Id: isbn_issn.sql.in,v 1.6 2002/08/22 00:01:39 tgl Exp $ -- $Id: isbn_issn.sql.in,v 1.7 2002/10/18 18:41:20 momjian Exp $
-- --
-- Adjust this setting to control where the objects get created. -- Adjust this setting to control where the objects get created.
SET search_path = public; SET search_path = public;
SET autocommit TO 'on';
-- --
-- Input and output functions and the type itself: -- Input and output functions and the type itself:
-- --
create function issn_in(cstring) CREATE FUNCTION issn_in(cstring)
returns issn RETURNS issn
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language 'c'; LANGUAGE 'C';
create function issn_out(issn) CREATE FUNCTION issn_out(issn)
returns cstring RETURNS cstring
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language 'c'; LANGUAGE 'C';
create type issn ( CREATE TYPE issn (
internallength = 16, INTERNALLENGTH = 16,
externallength = 9, EXTERNALLENGTH = 9,
input = issn_in, INPUT = issn_in,
output = issn_out OUTPUT = issn_out
); );
comment on type issn COMMENT ON TYPE issn
is 'International Standard Serial Number'; is 'International Standard Serial Number';
...@@ -37,35 +38,35 @@ comment on type issn ...@@ -37,35 +38,35 @@ comment on type issn
-- The various boolean tests: -- The various boolean tests:
-- --
create function issn_lt(issn, issn) CREATE FUNCTION issn_lt(issn, issn)
returns bool RETURNS bool
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language 'c'; LANGUAGE 'C';
create function issn_le(issn, issn) CREATE FUNCTION issn_le(issn, issn)
returns bool RETURNS bool
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language 'c'; LANGUAGE 'C';
create function issn_eq(issn, issn) CREATE FUNCTION issn_eq(issn, issn)
returns bool RETURNS bool
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language 'c'; LANGUAGE 'C';
create function issn_ge(issn, issn) CREATE FUNCTION issn_ge(issn, issn)
returns bool RETURNS bool
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language 'c'; LANGUAGE 'C';
create function issn_gt(issn, issn) CREATE FUNCTION issn_gt(issn, issn)
returns bool RETURNS bool
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language 'c'; LANGUAGE 'C';
create function issn_ne(issn, issn) CREATE FUNCTION issn_ne(issn, issn)
returns bool RETURNS bool
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language 'c'; LANGUAGE 'C';
-- --
-- Now the operators. Note how some of the parameters to some -- Now the operators. Note how some of the parameters to some
...@@ -74,47 +75,47 @@ create function issn_ne(issn, issn) ...@@ -74,47 +75,47 @@ create function issn_ne(issn, issn)
-- will be implicitly defined when those are, further down. -- will be implicitly defined when those are, further down.
-- --
create operator < ( CREATE OPERATOR < (
leftarg = issn, LEFTARG = issn,
rightarg = issn, RIGHTARG = issn,
-- negator = >=, -- NEGATOR = >=,
procedure = issn_lt PROCEDURE = issn_lt
); );
create operator <= ( CREATE OPERATOR <= (
leftarg = issn, LEFTARG = issn,
rightarg = issn, RIGHTARG = issn,
-- negator = >, -- NEGATOR = >,
procedure = issn_le PROCEDURE = issn_le
); );
create operator = ( CREATE OPERATOR = (
leftarg = issn, LEFTARG = issn,
rightarg = issn, RIGHTARG = issn,
commutator = =, COMMUTATOR = =,
-- negator = <>, -- NEGATOR = <>,
procedure = issn_eq PROCEDURE = issn_eq
); );
create operator >= ( CREATE OPERATOR >= (
leftarg = issn, LEFTARG = issn,
rightarg = issn, RIGHTARG = issn,
negator = <, NEGATOR = <,
procedure = issn_ge PROCEDURE = issn_ge
); );
create operator > ( CREATE OPERATOR > (
leftarg = issn, LEFTARG = issn,
rightarg = issn, RIGHTARG = issn,
negator = <=, NEGATOR = <=,
procedure = issn_gt PROCEDURE = issn_gt
); );
create operator <> ( CREATE OPERATOR <> (
leftarg = issn, LEFTARG = issn,
rightarg = issn, RIGHTARG = issn,
negator = =, NEGATOR = =,
procedure = issn_ne PROCEDURE = issn_ne
); );
-- --
...@@ -123,66 +124,65 @@ create operator <> ( ...@@ -123,66 +124,65 @@ create operator <> (
-- --
-- PostgreSQL code for ISBNs. -- PostgreSQL code for ISBNs.
-- --
-- $Id: isbn_issn.sql.in,v 1.6 2002/08/22 00:01:39 tgl Exp $ -- $Id: isbn_issn.sql.in,v 1.7 2002/10/18 18:41:20 momjian Exp $
-- --
-- --
-- Input and output functions and the type itself: -- Input and output functions and the type itself:
-- --
create function isbn_in(cstring) CREATE FUNCTION isbn_in(cstring)
returns isbn RETURNS isbn
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language 'c'; LANGUAGE 'C';
create function isbn_out(isbn) CREATE FUNCTION isbn_out(isbn)
returns cstring RETURNS cstring
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language 'c'; LANGUAGE 'C';
create type isbn ( CREATE TYPE isbn (
internallength = 16, INTERNALLENGTH = 16,
externallength = 13, EXTERNALLENGTH = 13,
input = isbn_in, INPUT = isbn_in,
output = isbn_out OUTPUT = isbn_out
); );
comment on type isbn COMMENT ON TYPE isbn IS 'International Standard Book Number';
is 'International Standard Book Number';
-- --
-- The various boolean tests: -- The various boolean tests:
-- --
create function isbn_lt(isbn, isbn) CREATE FUNCTION isbn_lt(isbn, isbn)
returns bool RETURNS bool
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language 'c'; LANGUAGE 'C';
create function isbn_le(isbn, isbn) CREATE FUNCTION isbn_le(isbn, isbn)
returns bool RETURNS bool
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language 'c'; LANGUAGE 'C';
create function isbn_eq(isbn, isbn) CREATE FUNCTION isbn_eq(isbn, isbn)
returns bool RETURNS bool
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language 'c'; LANGUAGE 'C';
create function isbn_ge(isbn, isbn) CREATE FUNCTION isbn_ge(isbn, isbn)
returns bool RETURNS bool
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language 'c'; LANGUAGE 'C';
create function isbn_gt(isbn, isbn) CREATE FUNCTION isbn_gt(isbn, isbn)
returns bool RETURNS bool
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language 'c'; LANGUAGE 'C';
create function isbn_ne(isbn, isbn) CREATE FUNCTION isbn_ne(isbn, isbn)
returns bool RETURNS bool
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language 'c'; LANGUAGE 'C';
-- --
-- Now the operators. Note how some of the parameters to some -- Now the operators. Note how some of the parameters to some
...@@ -191,61 +191,61 @@ create function isbn_ne(isbn, isbn) ...@@ -191,61 +191,61 @@ create function isbn_ne(isbn, isbn)
-- will be implicitly defined when those are, further down. -- will be implicitly defined when those are, further down.
-- --
create operator < ( CREATE OPERATOR < (
leftarg = isbn, LEFTARG = isbn,
rightarg = isbn, RIGHTARG = isbn,
-- negator = >=, -- NEGATOR = >=,
procedure = isbn_lt PROCEDURE = isbn_lt
); );
create operator <= ( CREATE OPERATOR <= (
leftarg = isbn, LEFTARG = isbn,
rightarg = isbn, RIGHTARG = isbn,
-- negator = >, -- NEGATOR = >,
procedure = isbn_le PROCEDURE = isbn_le
); );
create operator = ( CREATE OPERATOR = (
leftarg = isbn, LEFTARG = isbn,
rightarg = isbn, RIGHTARG = isbn,
commutator = =, COMMUTATOR = =,
-- negator = <>, -- NEGATOR = <>,
procedure = isbn_eq PROCEDURE = isbn_eq
); );
create operator >= ( CREATE OPERATOR >= (
leftarg = isbn, LEFTARG = isbn,
rightarg = isbn, RIGHTARG = isbn,
negator = <, NEGATOR = <,
procedure = isbn_ge PROCEDURE = isbn_ge
); );
create operator > ( CREATE OPERATOR > (
leftarg = isbn, LEFTARG = isbn,
rightarg = isbn, RIGHTARG = isbn,
negator = <=, NEGATOR = <=,
procedure = isbn_gt PROCEDURE = isbn_gt
); );
create operator <> ( CREATE OPERATOR <> (
leftarg = isbn, LEFTARG = isbn,
rightarg = isbn, RIGHTARG = isbn,
negator = =, NEGATOR = =,
procedure = isbn_ne PROCEDURE = isbn_ne
); );
-- Register 'isbn' comparison function -- Register 'isbn' comparison function
create function isbn_cmp(isbn, isbn) CREATE FUNCTION isbn_cmp(isbn, isbn)
returns integer RETURNS integer
as '$libdir/isbn_issn' AS '$libdir/isbn_issn'
language c; LANGUAGE c;
-- Register 'issn' comparison function -- Register 'issn' comparison function
create function issn_cmp(issn, issn) CREATE FUNCTION issn_cmp(issn, issn)
returns integer RETURNS integer
as '$libdir/isbn_issn' AS '$libdir/isbn_issn'
language c; LANGUAGE c;
------------------------------------------------- -------------------------------------------------
-- Create default operator class for 'isbn' -- -- Create default operator class for 'isbn' --
...@@ -253,7 +253,8 @@ create function issn_cmp(issn, issn) ...@@ -253,7 +253,8 @@ create function issn_cmp(issn, issn)
------------------------------------------------- -------------------------------------------------
CREATE OPERATOR CLASS isbn_ops CREATE OPERATOR CLASS isbn_ops
DEFAULT FOR TYPE isbn USING btree AS DEFAULT FOR TYPE isbn USING btree
AS
OPERATOR 1 < , OPERATOR 1 < ,
OPERATOR 2 <= , OPERATOR 2 <= ,
OPERATOR 3 = , OPERATOR 3 = ,
...@@ -267,7 +268,8 @@ CREATE OPERATOR CLASS isbn_ops ...@@ -267,7 +268,8 @@ CREATE OPERATOR CLASS isbn_ops
------------------------------------------------- -------------------------------------------------
CREATE OPERATOR CLASS issn_ops CREATE OPERATOR CLASS issn_ops
DEFAULT FOR TYPE issn USING btree AS DEFAULT FOR TYPE issn USING btree
AS
OPERATOR 1 < , OPERATOR 1 < ,
OPERATOR 2 <= , OPERATOR 2 <= ,
OPERATOR 3 = , OPERATOR 3 = ,
......
-- --
-- PostgreSQL code for LargeObjects -- PostgreSQL code for LargeObjects
-- --
-- $Id: lo.sql.in,v 1.7 2002/08/22 00:01:39 tgl Exp $ -- $Id: lo.sql.in,v 1.8 2002/10/18 18:41:20 momjian Exp $
-- --
-- --
-- Create the data type -- Create the data type
-- --
-- used by the lo type, it takes an oid and returns an lo object -- used by the lo type, it takes an oid and returns an lo object
create function lo_in(cstring)
returns lo -- Adjust this setting to control where the objects get created.
as 'MODULE_PATHNAME' SET search_path = public;
language 'c';
SET autocommit TO 'on';
CREATE FUNCTION lo_in(cstring)
RETURNS lo
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- used by the lo type, it returns the oid of the object -- used by the lo type, it returns the oid of the object
create function lo_out(lo) CREATE FUNCTION lo_out(lo)
returns cstring RETURNS cstring
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language 'c'; LANGUAGE 'C';
-- finally the type itself -- finally the type itself
create type lo ( CREATE TYPE lo (
internallength = 4, INTERNALLENGTH = 4,
externallength = variable, EXTERNALLENGTH = variable,
input = lo_in, INPUT = lo_in,
output = lo_out OUTPUT = lo_out
); );
-- this returns the oid associated with a lo object -- this returns the oid associated with a lo object
create function lo_oid(lo) CREATE FUNCTION lo_oid(lo)
returns oid RETURNS oid
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language 'c'; LANGUAGE 'C';
-- same function, named to allow it to be used as a type coercion, eg: -- same function, named to allow it to be used as a type coercion, eg:
-- create table a (image lo); -- CREATE TABLE a (image lo);
-- select image::oid from a; -- SELECT image::oid FROM a;
-- --
create function oid(lo) CREATE FUNCTION oid(lo)
returns oid RETURNS oid
as 'MODULE_PATHNAME', 'lo_oid' AS 'MODULE_PATHNAME', 'lo_oid'
language 'c'; LANGUAGE 'C';
-- this allows us to convert an oid to a managed lo object -- this allows us to convert an oid to a managed lo object
-- ie: insert into test values (lo_import('/fullpath/file')::lo); -- ie: insert into test values (lo_import('/fullpath/file')::lo);
create function lo(oid) CREATE FUNCTION lo(oid)
returns lo RETURNS lo
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language 'c'; LANGUAGE 'C';
-- This is used in triggers -- This is used in triggers
create function lo_manage() CREATE FUNCTION lo_manage()
returns trigger RETURNS trigger
as 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
language 'c'; LANGUAGE 'C';
...@@ -3,13 +3,18 @@ ...@@ -3,13 +3,18 @@
-- It's used just for development -- It's used just for development
-- --
-- Adjust this setting to control where the objects get created.
SET search_path = public;
SET autocommit TO 'on';
-- remove our test table -- remove our test table
drop table a; DROP TABLE a;
-- now drop the type and associated C functions -- now drop the type and associated C functions
drop type lo CASCADE; DROP TYPE lo CASCADE;
-- the trigger function has no dependency on the type, so drop separately -- the trigger function has no dependency on the type, so drop separately
drop function lo_manage(); DROP FUNCTION lo_manage();
-- the lo stuff is now removed from the system -- the lo stuff is now removed from the system
...@@ -5,53 +5,65 @@ ...@@ -5,53 +5,65 @@
-- --
-- ignore any errors here - simply drop the table if it already exists -- ignore any errors here - simply drop the table if it already exists
drop table a; DROP TABLE a;
-- create the test table -- create the test table
create table a (fname name,image lo); CREATE TABLE a (fname name,image lo);
-- insert a null object -- insert a null object
insert into a values ('null'); INSERT INTO a VALUES ('null');
-- insert an empty large object -- insert an empty large object
insert into a values ('empty',''); INSERT INTO a VALUES ('empty','');
-- insert a large object based on a file -- insert a large object based on a file
insert into a values ('/etc/group',lo_import('/etc/group')::lo); INSERT INTO a VALUES ('/etc/group',lo_import('/etc/group')::lo);
-- now select the table -- now select the table
select * from a; SELECT * FROM a;
-- this select also returns an oid based on the lo column -- this select also returns an oid based on the lo column
select *,image::oid from a; SELECT *,image::oid from a;
-- now test the trigger -- now test the trigger
create trigger t_a before update or delete on a for each row execute procedure lo_manage(image); CREATE TRIGGER t_a
BEFORE UPDATE OR DELETE ON a
FOR EACH ROW
EXECUTE PROCEDURE lo_manage(image);
-- insert -- insert
insert into a values ('aa',''); INSERT INTO a VALUES ('aa','');
select * from a where fname like 'aa%'; SELECT * FROM a
WHERE fname LIKE 'aa%';
-- update -- update
update a set image=lo_import('/etc/group')::lo where fname='aa'; UPDATE a SET image=lo_import('/etc/group')::lo
select * from a where fname like 'aa%'; WHERE fname='aa';
SELECT * FROM a
WHERE fname LIKE 'aa%';
-- update the 'empty' row which should be null -- update the 'empty' row which should be null
update a set image=lo_import('/etc/hosts')::lo where fname='empty'; UPDATE a SET image=lo_import('/etc/hosts')::lo
select * from a where fname like 'empty%'; WHERE fname='empty';
update a set image=null where fname='empty'; SELECT * FROM a
select * from a where fname like 'empty%'; WHERE fname LIKE 'empty%';
UPDATE a SET image=null
WHERE fname='empty';
SELECT * FROM a
WHERE fname LIKE 'empty%';
-- delete the entry -- delete the entry
delete from a where fname='aa'; DELETE FROM a
select * from a where fname like 'aa%'; WHERE fname='aa';
SELECT * FROM a
WHERE fname LIKE 'aa%';
-- This deletes the table contents. Note, if you comment this out, and -- This deletes the table contents. Note, if you comment this out, and
-- expect the drop table to remove the objects, think again. The trigger -- expect the drop table to remove the objects, think again. The trigger
-- doesn't get thrown by drop table. -- doesn't get thrown by drop table.
delete from a; DELETE FROM a;
-- finally drop the table -- finally drop the table
drop table a; DROP TABLE a;
-- end of tests -- end of tests
\set ECHO none \set ECHO none
psql:ltree.sql:9: WARNING: ProcedureCreate: type ltree is not yet defined psql:ltree.sql:9: WARNING: ProcedureCreate: type ltree is not yet defined
psql:ltree.sql:14: WARNING: Argument type "ltree" is only a shell psql:ltree.sql:14: WARNING: Argument type "ltree" is only a shell
psql:ltree.sql:238: WARNING: ProcedureCreate: type lquery is not yet defined psql:ltree.sql:281: WARNING: ProcedureCreate: type lquery is not yet defined
psql:ltree.sql:243: WARNING: Argument type "lquery" is only a shell psql:ltree.sql:286: WARNING: Argument type "lquery" is only a shell
psql:ltree.sql:290: WARNING: ProcedureCreate: type ltxtquery is not yet defined psql:ltree.sql:345: WARNING: ProcedureCreate: type ltxtquery is not yet defined
psql:ltree.sql:295: WARNING: Argument type "ltxtquery" is only a shell psql:ltree.sql:350: WARNING: Argument type "ltxtquery" is only a shell
psql:ltree.sql:345: WARNING: ProcedureCreate: type ltree_gist is not yet defined psql:ltree.sql:412: WARNING: ProcedureCreate: type ltree_gist is not yet defined
psql:ltree.sql:350: WARNING: Argument type "ltree_gist" is only a shell psql:ltree.sql:417: WARNING: Argument type "ltree_gist" is only a shell
select ''::ltree; SELECT ''::ltree;
ltree ltree
------- -------
(1 row) (1 row)
select '1'::ltree; SELECT '1'::ltree;
ltree ltree
------- -------
1 1
(1 row) (1 row)
select '1.2'::ltree; SELECT '1.2'::ltree;
ltree ltree
------- -------
1.2 1.2
(1 row) (1 row)
select '1.2._3'::ltree; SELECT '1.2._3'::ltree;
ltree ltree
-------- --------
1.2._3 1.2._3
(1 row) (1 row)
select subltree('Top.Child1.Child2',1,2); SELECT subltree('Top.Child1.Child2',1,2);
subltree subltree
---------- ----------
Child1 Child1
(1 row) (1 row)
select subpath('Top.Child1.Child2',1,2); SELECT subpath('Top.Child1.Child2',1,2);
subpath subpath
--------------- ---------------
Child1.Child2 Child1.Child2
(1 row) (1 row)
select subpath('Top.Child1.Child2',-1,1); SELECT subpath('Top.Child1.Child2',-1,1);
subpath subpath
--------- ---------
Child2 Child2
(1 row) (1 row)
select subpath('Top.Child1.Child2',0,-2); SELECT subpath('Top.Child1.Child2',0,-2);
subpath subpath
--------- ---------
Top Top
(1 row) (1 row)
select subpath('Top.Child1.Child2',0,-1); SELECT subpath('Top.Child1.Child2',0,-1);
subpath subpath
------------ ------------
Top.Child1 Top.Child1
(1 row) (1 row)
select subpath('Top.Child1.Child2',0,0); SELECT subpath('Top.Child1.Child2',0,0);
subpath subpath
------------------- -------------------
Top.Child1.Child2 Top.Child1.Child2
(1 row) (1 row)
select subpath('Top.Child1.Child2',1,0); SELECT subpath('Top.Child1.Child2',1,0);
subpath subpath
--------------- ---------------
Child1.Child2 Child1.Child2
(1 row) (1 row)
select subpath('Top.Child1.Child2',0); SELECT subpath('Top.Child1.Child2',0);
subpath subpath
------------------- -------------------
Top.Child1.Child2 Top.Child1.Child2
(1 row) (1 row)
select subpath('Top.Child1.Child2',1); SELECT subpath('Top.Child1.Child2',1);
subpath subpath
--------------- ---------------
Child1.Child2 Child1.Child2
(1 row) (1 row)
select 'Top.Child1.Child2'::ltree || 'Child3'::text; SELECT 'Top.Child1.Child2'::ltree || 'Child3'::text;
?column? ?column?
-------------------------- --------------------------
Top.Child1.Child2.Child3 Top.Child1.Child2.Child3
(1 row) (1 row)
select 'Top.Child1.Child2'::ltree || 'Child3'::ltree; SELECT 'Top.Child1.Child2'::ltree || 'Child3'::ltree;
?column? ?column?
-------------------------- --------------------------
Top.Child1.Child2.Child3 Top.Child1.Child2.Child3
(1 row) (1 row)
select 'Top_0'::ltree || 'Top.Child1.Child2'::ltree; SELECT 'Top_0'::ltree || 'Top.Child1.Child2'::ltree;
?column? ?column?
------------------------- -------------------------
Top_0.Top.Child1.Child2 Top_0.Top.Child1.Child2
(1 row) (1 row)
select 'Top.Child1.Child2'::ltree || ''::ltree; SELECT 'Top.Child1.Child2'::ltree || ''::ltree;
?column? ?column?
------------------- -------------------
Top.Child1.Child2 Top.Child1.Child2
(1 row) (1 row)
select ''::ltree || 'Top.Child1.Child2'::ltree; SELECT ''::ltree || 'Top.Child1.Child2'::ltree;
?column? ?column?
------------------- -------------------
Top.Child1.Child2 Top.Child1.Child2
(1 row) (1 row)
select lca('{la.2.3,1.2.3.4.5.6,}') is null; SELECT lca('{la.2.3,1.2.3.4.5.6,}') IS NULL;
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select lca('{la.2.3,1.2.3.4.5.6}') is null; SELECT lca('{la.2.3,1.2.3.4.5.6}') IS NULL;
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select lca('{1.la.2.3,1.2.3.4.5.6}'); SELECT lca('{1.la.2.3,1.2.3.4.5.6}');
lca lca
----- -----
1 1
(1 row) (1 row)
select lca('{1.2.3,1.2.3.4.5.6}'); SELECT lca('{1.2.3,1.2.3.4.5.6}');
lca lca
----- -----
1.2 1.2
(1 row) (1 row)
select lca('1.la.2.3','1.2.3.4.5.6'); SELECT lca('1.la.2.3','1.2.3.4.5.6');
lca lca
----- -----
1 1
(1 row) (1 row)
select lca('1.2.3','1.2.3.4.5.6'); SELECT lca('1.2.3','1.2.3.4.5.6');
lca lca
----- -----
1.2 1.2
(1 row) (1 row)
select lca('1.2.2.3','1.2.3.4.5.6'); SELECT lca('1.2.2.3','1.2.3.4.5.6');
lca lca
----- -----
1.2 1.2
(1 row) (1 row)
select lca('1.2.2.3','1.2.3.4.5.6',''); SELECT lca('1.2.2.3','1.2.3.4.5.6','');
lca lca
----- -----
(1 row) (1 row)
select lca('1.2.2.3','1.2.3.4.5.6','2'); SELECT lca('1.2.2.3','1.2.3.4.5.6','2');
lca lca
----- -----
(1 row) (1 row)
select lca('1.2.2.3','1.2.3.4.5.6','1'); SELECT lca('1.2.2.3','1.2.3.4.5.6','1');
lca lca
----- -----
(1 row) (1 row)
select '1'::lquery; SELECT '1'::lquery;
lquery lquery
-------- --------
1 1
(1 row) (1 row)
select '4|3|2'::lquery; SELECT '4|3|2'::lquery;
lquery lquery
-------- --------
4|3|2 4|3|2
(1 row) (1 row)
select '1.2'::lquery; SELECT '1.2'::lquery;
lquery lquery
-------- --------
1.2 1.2
(1 row) (1 row)
select '1.4|3|2'::lquery; SELECT '1.4|3|2'::lquery;
lquery lquery
--------- ---------
1.4|3|2 1.4|3|2
(1 row) (1 row)
select '1.0'::lquery; SELECT '1.0'::lquery;
lquery lquery
-------- --------
1.0 1.0
(1 row) (1 row)
select '4|3|2.0'::lquery; SELECT '4|3|2.0'::lquery;
lquery lquery
--------- ---------
4|3|2.0 4|3|2.0
(1 row) (1 row)
select '1.2.0'::lquery; SELECT '1.2.0'::lquery;
lquery lquery
-------- --------
1.2.0 1.2.0
(1 row) (1 row)
select '1.4|3|2.0'::lquery; SELECT '1.4|3|2.0'::lquery;
lquery lquery
----------- -----------
1.4|3|2.0 1.4|3|2.0
(1 row) (1 row)
select '1.*'::lquery; SELECT '1.*'::lquery;
lquery lquery
-------- --------
1.* 1.*
(1 row) (1 row)
select '4|3|2.*'::lquery; SELECT '4|3|2.*'::lquery;
lquery lquery
--------- ---------
4|3|2.* 4|3|2.*
(1 row) (1 row)
select '1.2.*'::lquery; SELECT '1.2.*'::lquery;
lquery lquery
-------- --------
1.2.* 1.2.*
(1 row) (1 row)
select '1.4|3|2.*'::lquery; SELECT '1.4|3|2.*'::lquery;
lquery lquery
----------- -----------
1.4|3|2.* 1.4|3|2.*
(1 row) (1 row)
select '*.1.*'::lquery; SELECT '*.1.*'::lquery;
lquery lquery
-------- --------
*.1.* *.1.*
(1 row) (1 row)
select '*.4|3|2.*'::lquery; SELECT '*.4|3|2.*'::lquery;
lquery lquery
----------- -----------
*.4|3|2.* *.4|3|2.*
(1 row) (1 row)
select '*.1.2.*'::lquery; SELECT '*.1.2.*'::lquery;
lquery lquery
--------- ---------
*.1.2.* *.1.2.*
(1 row) (1 row)
select '*.1.4|3|2.*'::lquery; SELECT '*.1.4|3|2.*'::lquery;
lquery lquery
------------- -------------
*.1.4|3|2.* *.1.4|3|2.*
(1 row) (1 row)
select '1.*.4|3|2'::lquery; SELECT '1.*.4|3|2'::lquery;
lquery lquery
----------- -----------
1.*.4|3|2 1.*.4|3|2
(1 row) (1 row)
select '1.*.4|3|2.0'::lquery; SELECT '1.*.4|3|2.0'::lquery;
lquery lquery
------------- -------------
1.*.4|3|2.0 1.*.4|3|2.0
(1 row) (1 row)
select '1.*.4|3|2.*{1,4}'::lquery; SELECT '1.*.4|3|2.*{1,4}'::lquery;
lquery lquery
------------------ ------------------
1.*.4|3|2.*{1,4} 1.*.4|3|2.*{1,4}
(1 row) (1 row)
select '1.*.4|3|2.*{,4}'::lquery; SELECT '1.*.4|3|2.*{,4}'::lquery;
lquery lquery
----------------- -----------------
1.*.4|3|2.*{,4} 1.*.4|3|2.*{,4}
(1 row) (1 row)
select '1.*.4|3|2.*{1,}'::lquery; SELECT '1.*.4|3|2.*{1,}'::lquery;
lquery lquery
----------------- -----------------
1.*.4|3|2.*{1,} 1.*.4|3|2.*{1,}
(1 row) (1 row)
select '1.*.4|3|2.*{1}'::lquery; SELECT '1.*.4|3|2.*{1}'::lquery;
lquery lquery
---------------- ----------------
1.*.4|3|2.*{1} 1.*.4|3|2.*{1}
(1 row) (1 row)
select 'qwerty%@*.tu'::lquery; SELECT 'qwerty%@*.tu'::lquery;
lquery lquery
-------------- --------------
qwerty%@*.tu qwerty%@*.tu
(1 row) (1 row)
select nlevel('1.2.3.4'); SELECT nlevel('1.2.3.4');
nlevel nlevel
-------- --------
4 4
(1 row) (1 row)
select '1.2'::ltree < '2.2'::ltree; SELECT '1.2'::ltree < '2.2'::ltree;
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select '1.2'::ltree <= '2.2'::ltree; SELECT '1.2'::ltree <= '2.2'::ltree;
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select '2.2'::ltree = '2.2'::ltree; SELECT '2.2'::ltree = '2.2'::ltree;
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select '3.2'::ltree >= '2.2'::ltree; SELECT '3.2'::ltree >= '2.2'::ltree;
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select '3.2'::ltree > '2.2'::ltree; SELECT '3.2'::ltree > '2.2'::ltree;
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select '1.2.3'::ltree @> '1.2.3.4'::ltree; SELECT '1.2.3'::ltree @> '1.2.3.4'::ltree;
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select '1.2.3.4'::ltree @> '1.2.3.4'::ltree; SELECT '1.2.3.4'::ltree @> '1.2.3.4'::ltree;
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select '1.2.3.4.5'::ltree @> '1.2.3.4'::ltree; SELECT '1.2.3.4.5'::ltree @> '1.2.3.4'::ltree;
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select '1.3.3'::ltree @> '1.2.3.4'::ltree; SELECT '1.3.3'::ltree @> '1.2.3.4'::ltree;
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'a.b.c.d.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.b.c.d.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'A.b.c.d.e'; SELECT 'a.b.c.d.e'::ltree ~ 'A.b.c.d.e';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'A@.b.c.d.e'; SELECT 'a.b.c.d.e'::ltree ~ 'A@.b.c.d.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'aa.b.c.d.e'::ltree ~ 'A@.b.c.d.e'; SELECT 'aa.b.c.d.e'::ltree ~ 'A@.b.c.d.e';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'aa.b.c.d.e'::ltree ~ 'A*.b.c.d.e'; SELECT 'aa.b.c.d.e'::ltree ~ 'A*.b.c.d.e';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'aa.b.c.d.e'::ltree ~ 'A*@.b.c.d.e'; SELECT 'aa.b.c.d.e'::ltree ~ 'A*@.b.c.d.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'aa.b.c.d.e'::ltree ~ 'A*@|g.b.c.d.e'; SELECT 'aa.b.c.d.e'::ltree ~ 'A*@|g.b.c.d.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'g.b.c.d.e'::ltree ~ 'A*@|g.b.c.d.e'; SELECT 'g.b.c.d.e'::ltree ~ 'A*@|g.b.c.d.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'a.b.c.d.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.b.c.d.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'a.*.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'a.*{3}.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*{3}.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'a.*{2}.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*{2}.e';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'a.*{4}.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*{4}.e';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'a.*{,4}.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*{,4}.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'a.*{2,}.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*{2,}.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'a.*{2,4}.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*{2,4}.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'a.*{2,3}.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*{2,3}.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'a.*{2,3}'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*{2,3}';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'a.*{2,4}'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*{2,4}';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'a.*{2,5}'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*{2,5}';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*{2,3}.e'; SELECT 'a.b.c.d.e'::ltree ~ '*{2,3}.e';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*{2,4}.e'; SELECT 'a.b.c.d.e'::ltree ~ '*{2,4}.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*{2,5}.e'; SELECT 'a.b.c.d.e'::ltree ~ '*{2,5}.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*.e'; SELECT 'a.b.c.d.e'::ltree ~ '*.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*.e.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.e.*';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*.d.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.d.*';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*.a.*.d.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.a.*.d.*';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*.!d.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.!d.*';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*.!d'; SELECT 'a.b.c.d.e'::ltree ~ '*.!d';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '!d.*'; SELECT 'a.b.c.d.e'::ltree ~ '!d.*';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '!a.*'; SELECT 'a.b.c.d.e'::ltree ~ '!a.*';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*.!e'; SELECT 'a.b.c.d.e'::ltree ~ '*.!e';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*.!e.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.!e.*';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'a.*.!e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*.!e';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'a.*.!d'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*.!d';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'a.*.!d.*'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*.!d.*';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'a.*.!f.*'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*.!f.*';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*.a.*.!f.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.a.*.!f.*';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*.a.*.!d.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.a.*.!d.*';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*.a.!d.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.a.!d.*';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*.a.!d'; SELECT 'a.b.c.d.e'::ltree ~ '*.a.!d';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'a.!d.*'; SELECT 'a.b.c.d.e'::ltree ~ 'a.!d.*';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*.a.*.!d.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.a.*.!d.*';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*.!b.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.!b.*';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*.!b.c.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.!b.c.*';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*.!b.*.c.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.!b.*.c.*';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '!b.*.c.*'; SELECT 'a.b.c.d.e'::ltree ~ '!b.*.c.*';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '!b.b.*'; SELECT 'a.b.c.d.e'::ltree ~ '!b.b.*';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '!b.*.e'; SELECT 'a.b.c.d.e'::ltree ~ '!b.*.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '!b.!c.*.e'; SELECT 'a.b.c.d.e'::ltree ~ '!b.!c.*.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '!b.*.!c.*.e'; SELECT 'a.b.c.d.e'::ltree ~ '!b.*.!c.*.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*{2}.!b.*.!c.*.e'; SELECT 'a.b.c.d.e'::ltree ~ '*{2}.!b.*.!c.*.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*{1}.!b.*.!c.*.e'; SELECT 'a.b.c.d.e'::ltree ~ '*{1}.!b.*.!c.*.e';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*{1}.!b.*{1}.!c.*.e'; SELECT 'a.b.c.d.e'::ltree ~ '*{1}.!b.*{1}.!c.*.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'a.!b.*{1}.!c.*.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.!b.*{1}.!c.*.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '!b.*{1}.!c.*.e'; SELECT 'a.b.c.d.e'::ltree ~ '!b.*{1}.!c.*.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*.!b.*{1}.!c.*.e'; SELECT 'a.b.c.d.e'::ltree ~ '*.!b.*{1}.!c.*.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*.!b.*.!c.*.e'; SELECT 'a.b.c.d.e'::ltree ~ '*.!b.*.!c.*.e';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '!b.!c.*'; SELECT 'a.b.c.d.e'::ltree ~ '!b.!c.*';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '!b.*.!c.*'; SELECT 'a.b.c.d.e'::ltree ~ '!b.*.!c.*';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*{2}.!b.*.!c.*'; SELECT 'a.b.c.d.e'::ltree ~ '*{2}.!b.*.!c.*';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*{1}.!b.*.!c.*'; SELECT 'a.b.c.d.e'::ltree ~ '*{1}.!b.*.!c.*';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*{1}.!b.*{1}.!c.*'; SELECT 'a.b.c.d.e'::ltree ~ '*{1}.!b.*{1}.!c.*';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ 'a.!b.*{1}.!c.*'; SELECT 'a.b.c.d.e'::ltree ~ 'a.!b.*{1}.!c.*';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '!b.*{1}.!c.*'; SELECT 'a.b.c.d.e'::ltree ~ '!b.*{1}.!c.*';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*.!b.*{1}.!c.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.!b.*{1}.!c.*';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'a.b.c.d.e'::ltree ~ '*.!b.*.!c.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.!b.*.!c.*';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'QWER_TY'::ltree ~ 'q%@*'; SELECT 'QWER_TY'::ltree ~ 'q%@*';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'QWER_TY'::ltree ~ 'Q_t%@*'; SELECT 'QWER_TY'::ltree ~ 'Q_t%@*';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'QWER_GY'::ltree ~ 'q_t%@*'; SELECT 'QWER_GY'::ltree ~ 'q_t%@*';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
--ltxtquery --ltxtquery
select '!tree & aWdf@*'::ltxtquery; SELECT '!tree & aWdf@*'::ltxtquery;
ltxtquery ltxtquery
---------------- ----------------
!tree & aWdf@* !tree & aWdf@*
(1 row) (1 row)
select 'tree & aw_qw%*'::ltxtquery; SELECT 'tree & aw_qw%*'::ltxtquery;
ltxtquery ltxtquery
---------------- ----------------
tree & aw_qw%* tree & aw_qw%*
(1 row) (1 row)
select 'ltree.awdfg'::ltree @ '!tree & aWdf@*'::ltxtquery; SELECT 'ltree.awdfg'::ltree @ '!tree & aWdf@*'::ltxtquery;
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'tree.awdfg'::ltree @ '!tree & aWdf@*'::ltxtquery; SELECT 'tree.awdfg'::ltree @ '!tree & aWdf@*'::ltxtquery;
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'tree.awdfg'::ltree @ '!tree | aWdf@*'::ltxtquery; SELECT 'tree.awdfg'::ltree @ '!tree | aWdf@*'::ltxtquery;
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'tree.awdfg'::ltree @ 'tree | aWdf@*'::ltxtquery; SELECT 'tree.awdfg'::ltree @ 'tree | aWdf@*'::ltxtquery;
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'tree.awdfg'::ltree @ 'tree & aWdf@*'::ltxtquery; SELECT 'tree.awdfg'::ltree @ 'tree & aWdf@*'::ltxtquery;
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'tree.awdfg'::ltree @ 'tree & aWdf@'::ltxtquery; SELECT 'tree.awdfg'::ltree @ 'tree & aWdf@'::ltxtquery;
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'tree.awdfg'::ltree @ 'tree & aWdf*'::ltxtquery; SELECT 'tree.awdfg'::ltree @ 'tree & aWdf*'::ltxtquery;
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'tree.awdfg'::ltree @ 'tree & aWdf'::ltxtquery; SELECT 'tree.awdfg'::ltree @ 'tree & aWdf'::ltxtquery;
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select 'tree.awdfg'::ltree @ 'tree & awdf*'::ltxtquery; SELECT 'tree.awdfg'::ltree @ 'tree & awdf*'::ltxtquery;
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'tree.awdfg'::ltree @ 'tree & aWdfg@'::ltxtquery; SELECT 'tree.awdfg'::ltree @ 'tree & aWdfg@'::ltxtquery;
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'tree.awdfg_qwerty'::ltree @ 'tree & aw_qw%*'::ltxtquery; SELECT 'tree.awdfg_qwerty'::ltree @ 'tree & aw_qw%*'::ltxtquery;
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select 'tree.awdfg_qwerty'::ltree @ 'tree & aw_rw%*'::ltxtquery; SELECT 'tree.awdfg_qwerty'::ltree @ 'tree & aw_rw%*'::ltxtquery;
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
--arrays --arrays
select '{1.2.3}'::ltree[] @> '1.2.3.4'; SELECT '{1.2.3}'::ltree[] @> '1.2.3.4';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select '{1.2.3.4}'::ltree[] @> '1.2.3.4'; SELECT '{1.2.3.4}'::ltree[] @> '1.2.3.4';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select '{1.2.3.4.5}'::ltree[] @> '1.2.3.4'; SELECT '{1.2.3.4.5}'::ltree[] @> '1.2.3.4';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select '{1.3.3}'::ltree[] @> '1.2.3.4'; SELECT '{1.3.3}'::ltree[] @> '1.2.3.4';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select '{5.67.8, 1.2.3}'::ltree[] @> '1.2.3.4'; SELECT '{5.67.8, 1.2.3}'::ltree[] @> '1.2.3.4';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select '{5.67.8, 1.2.3.4}'::ltree[] @> '1.2.3.4'; SELECT '{5.67.8, 1.2.3.4}'::ltree[] @> '1.2.3.4';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select '{5.67.8, 1.2.3.4.5}'::ltree[] @> '1.2.3.4'; SELECT '{5.67.8, 1.2.3.4.5}'::ltree[] @> '1.2.3.4';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select '{5.67.8, 1.3.3}'::ltree[] @> '1.2.3.4'; SELECT '{5.67.8, 1.3.3}'::ltree[] @> '1.2.3.4';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select '{1.2.3, 7.12.asd}'::ltree[] @> '1.2.3.4'; SELECT '{1.2.3, 7.12.asd}'::ltree[] @> '1.2.3.4';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select '{1.2.3.4, 7.12.asd}'::ltree[] @> '1.2.3.4'; SELECT '{1.2.3.4, 7.12.asd}'::ltree[] @> '1.2.3.4';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select '{1.2.3.4.5, 7.12.asd}'::ltree[] @> '1.2.3.4'; SELECT '{1.2.3.4.5, 7.12.asd}'::ltree[] @> '1.2.3.4';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select '{1.3.3, 7.12.asd}'::ltree[] @> '1.2.3.4'; SELECT '{1.3.3, 7.12.asd}'::ltree[] @> '1.2.3.4';
?column? ?column?
---------- ----------
f f
(1 row) (1 row)
select '{ltree.asd, tree.awdfg}'::ltree[] @ 'tree & aWdfg@'::ltxtquery; SELECT '{ltree.asd, tree.awdfg}'::ltree[] @ 'tree & aWdfg@'::ltxtquery;
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select '{j.k.l.m, g.b.c.d.e}'::ltree[] ~ 'A*@|g.b.c.d.e'; SELECT '{j.k.l.m, g.b.c.d.e}'::ltree[] ~ 'A*@|g.b.c.d.e';
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
--exractors --exractors
select ('{3456,1.2.3.34}'::ltree[] ?@> '1.2.3.4') is null; SELECT ('{3456,1.2.3.34}'::ltree[] ?@> '1.2.3.4') is null;
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select '{3456,1.2.3}'::ltree[] ?@> '1.2.3.4'; SELECT '{3456,1.2.3}'::ltree[] ?@> '1.2.3.4';
?column? ?column?
---------- ----------
1.2.3 1.2.3
(1 row) (1 row)
select '{3456,1.2.3.4}'::ltree[] ?<@ '1.2.3'; SELECT '{3456,1.2.3.4}'::ltree[] ?<@ '1.2.3';
?column? ?column?
---------- ----------
1.2.3.4 1.2.3.4
(1 row) (1 row)
select ('{3456,1.2.3.4}'::ltree[] ?<@ '1.2.5') is null; SELECT ('{3456,1.2.3.4}'::ltree[] ?<@ '1.2.5') is null;
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
select '{ltree.asd, tree.awdfg}'::ltree[] ?@ 'tree & aWdfg@'::ltxtquery; SELECT '{ltree.asd, tree.awdfg}'::ltree[] ?@ 'tree & aWdfg@'::ltxtquery;
?column? ?column?
------------ ------------
tree.awdfg tree.awdfg
(1 row) (1 row)
select '{j.k.l.m, g.b.c.d.e}'::ltree[] ?~ 'A*@|g.b.c.d.e'; SELECT '{j.k.l.m, g.b.c.d.e}'::ltree[] ?~ 'A*@|g.b.c.d.e';
?column? ?column?
----------- -----------
g.b.c.d.e g.b.c.d.e
(1 row) (1 row)
create table ltreetest (t ltree); CREATE TABLE ltreetest (t ltree);
\copy ltreetest from 'data/ltree.data' \copy ltreetest FROM 'data/ltree.data'
select * from ltreetest where t < '12.3' order by t asc; SELECT * FROM ltreetest WHERE t < '12.3' order by t asc;
t t
---------------------------------- ----------------------------------
...@@ -1130,7 +1130,7 @@ select * from ltreetest where t < '12.3' order by t asc; ...@@ -1130,7 +1130,7 @@ select * from ltreetest where t < '12.3' order by t asc;
12.29.26.18.4.21.28.8.13.3 12.29.26.18.4.21.28.8.13.3
(123 rows) (123 rows)
select * from ltreetest where t <= '12.3' order by t asc; SELECT * FROM ltreetest WHERE t <= '12.3' order by t asc;
t t
---------------------------------- ----------------------------------
...@@ -1259,13 +1259,13 @@ select * from ltreetest where t <= '12.3' order by t asc; ...@@ -1259,13 +1259,13 @@ select * from ltreetest where t <= '12.3' order by t asc;
12.3 12.3
(124 rows) (124 rows)
select * from ltreetest where t = '12.3' order by t asc; SELECT * FROM ltreetest WHERE t = '12.3' order by t asc;
t t
------ ------
12.3 12.3
(1 row) (1 row)
select * from ltreetest where t >= '12.3' order by t asc; SELECT * FROM ltreetest WHERE t >= '12.3' order by t asc;
t t
---------------------------------- ----------------------------------
12.3 12.3
...@@ -2153,7 +2153,7 @@ select * from ltreetest where t >= '12.3' order by t asc; ...@@ -2153,7 +2153,7 @@ select * from ltreetest where t >= '12.3' order by t asc;
9.9.13.9.14.27 9.9.13.9.14.27
(883 rows) (883 rows)
select * from ltreetest where t > '12.3' order by t asc; SELECT * FROM ltreetest WHERE t > '12.3' order by t asc;
t t
---------------------------------- ----------------------------------
12.4.10.17.4.10.23.3 12.4.10.17.4.10.23.3
...@@ -3040,7 +3040,7 @@ select * from ltreetest where t > '12.3' order by t asc; ...@@ -3040,7 +3040,7 @@ select * from ltreetest where t > '12.3' order by t asc;
9.9.13.9.14.27 9.9.13.9.14.27
(882 rows) (882 rows)
select * from ltreetest where t @> '1.1.1' order by t asc; SELECT * FROM ltreetest WHERE t @> '1.1.1' order by t asc;
t t
------- -------
...@@ -3049,7 +3049,7 @@ select * from ltreetest where t @> '1.1.1' order by t asc; ...@@ -3049,7 +3049,7 @@ select * from ltreetest where t @> '1.1.1' order by t asc;
1.1.1 1.1.1
(4 rows) (4 rows)
select * from ltreetest where t <@ '1.1.1' order by t asc; SELECT * FROM ltreetest WHERE t <@ '1.1.1' order by t asc;
t t
----------- -----------
1.1.1 1.1.1
...@@ -3058,7 +3058,7 @@ select * from ltreetest where t <@ '1.1.1' order by t asc; ...@@ -3058,7 +3058,7 @@ select * from ltreetest where t <@ '1.1.1' order by t asc;
1.1.1.2.1 1.1.1.2.1
(4 rows) (4 rows)
select * from ltreetest where t ~ '1.1.1.*' order by t asc; SELECT * FROM ltreetest WHERE t ~ '1.1.1.*' order by t asc;
t t
----------- -----------
1.1.1 1.1.1
...@@ -3067,7 +3067,7 @@ select * from ltreetest where t ~ '1.1.1.*' order by t asc; ...@@ -3067,7 +3067,7 @@ select * from ltreetest where t ~ '1.1.1.*' order by t asc;
1.1.1.2.1 1.1.1.2.1
(4 rows) (4 rows)
select * from ltreetest where t ~ '*.1' order by t asc; SELECT * FROM ltreetest WHERE t ~ '*.1' order by t asc;
t t
-------------------------------- --------------------------------
1 1
...@@ -3097,20 +3097,20 @@ select * from ltreetest where t ~ '*.1' order by t asc; ...@@ -3097,20 +3097,20 @@ select * from ltreetest where t ~ '*.1' order by t asc;
9.21.20.29.1 9.21.20.29.1
(25 rows) (25 rows)
select * from ltreetest where t ~ '23.*.1' order by t asc; SELECT * FROM ltreetest WHERE t ~ '23.*.1' order by t asc;
t t
------------------------- -------------------------
23.28.1 23.28.1
23.3.32.21.5.14.10.17.1 23.3.32.21.5.14.10.17.1
(2 rows) (2 rows)
select * from ltreetest where t ~ '23.*{1}.1' order by t asc; SELECT * FROM ltreetest WHERE t ~ '23.*{1}.1' order by t asc;
t t
--------- ---------
23.28.1 23.28.1
(1 row) (1 row)
select * from ltreetest where t @ '23 & 1' order by t asc; SELECT * FROM ltreetest WHERE t @ '23 & 1' order by t asc;
t t
-------------------------------- --------------------------------
1.10.23.25.5.11 1.10.23.25.5.11
...@@ -3156,7 +3156,7 @@ select * from ltreetest where t @ '23 & 1' order by t asc; ...@@ -3156,7 +3156,7 @@ select * from ltreetest where t @ '23 & 1' order by t asc;
create unique index tstidx on ltreetest (t); create unique index tstidx on ltreetest (t);
set enable_seqscan=off; set enable_seqscan=off;
select * from ltreetest where t < '12.3' order by t asc; SELECT * FROM ltreetest WHERE t < '12.3' order by t asc;
t t
---------------------------------- ----------------------------------
...@@ -3284,7 +3284,7 @@ select * from ltreetest where t < '12.3' order by t asc; ...@@ -3284,7 +3284,7 @@ select * from ltreetest where t < '12.3' order by t asc;
12.29.26.18.4.21.28.8.13.3 12.29.26.18.4.21.28.8.13.3
(123 rows) (123 rows)
select * from ltreetest where t <= '12.3' order by t asc; SELECT * FROM ltreetest WHERE t <= '12.3' order by t asc;
t t
---------------------------------- ----------------------------------
...@@ -3413,13 +3413,13 @@ select * from ltreetest where t <= '12.3' order by t asc; ...@@ -3413,13 +3413,13 @@ select * from ltreetest where t <= '12.3' order by t asc;
12.3 12.3
(124 rows) (124 rows)
select * from ltreetest where t = '12.3' order by t asc; SELECT * FROM ltreetest WHERE t = '12.3' order by t asc;
t t
------ ------
12.3 12.3
(1 row) (1 row)
select * from ltreetest where t >= '12.3' order by t asc; SELECT * FROM ltreetest WHERE t >= '12.3' order by t asc;
t t
---------------------------------- ----------------------------------
12.3 12.3
...@@ -4307,7 +4307,7 @@ select * from ltreetest where t >= '12.3' order by t asc; ...@@ -4307,7 +4307,7 @@ select * from ltreetest where t >= '12.3' order by t asc;
9.9.13.9.14.27 9.9.13.9.14.27
(883 rows) (883 rows)
select * from ltreetest where t > '12.3' order by t asc; SELECT * FROM ltreetest WHERE t > '12.3' order by t asc;
t t
---------------------------------- ----------------------------------
12.4.10.17.4.10.23.3 12.4.10.17.4.10.23.3
...@@ -5197,7 +5197,7 @@ select * from ltreetest where t > '12.3' order by t asc; ...@@ -5197,7 +5197,7 @@ select * from ltreetest where t > '12.3' order by t asc;
drop index tstidx; drop index tstidx;
create index tstidx on ltreetest using gist (t); create index tstidx on ltreetest using gist (t);
set enable_seqscan=off; set enable_seqscan=off;
select * from ltreetest where t < '12.3' order by t asc; SELECT * FROM ltreetest WHERE t < '12.3' order by t asc;
t t
---------------------------------- ----------------------------------
...@@ -5325,7 +5325,7 @@ select * from ltreetest where t < '12.3' order by t asc; ...@@ -5325,7 +5325,7 @@ select * from ltreetest where t < '12.3' order by t asc;
12.29.26.18.4.21.28.8.13.3 12.29.26.18.4.21.28.8.13.3
(123 rows) (123 rows)
select * from ltreetest where t <= '12.3' order by t asc; SELECT * FROM ltreetest WHERE t <= '12.3' order by t asc;
t t
---------------------------------- ----------------------------------
...@@ -5454,13 +5454,13 @@ select * from ltreetest where t <= '12.3' order by t asc; ...@@ -5454,13 +5454,13 @@ select * from ltreetest where t <= '12.3' order by t asc;
12.3 12.3
(124 rows) (124 rows)
select * from ltreetest where t = '12.3' order by t asc; SELECT * FROM ltreetest WHERE t = '12.3' order by t asc;
t t
------ ------
12.3 12.3
(1 row) (1 row)
select * from ltreetest where t >= '12.3' order by t asc; SELECT * FROM ltreetest WHERE t >= '12.3' order by t asc;
t t
---------------------------------- ----------------------------------
12.3 12.3
...@@ -6348,7 +6348,7 @@ select * from ltreetest where t >= '12.3' order by t asc; ...@@ -6348,7 +6348,7 @@ select * from ltreetest where t >= '12.3' order by t asc;
9.9.13.9.14.27 9.9.13.9.14.27
(883 rows) (883 rows)
select * from ltreetest where t > '12.3' order by t asc; SELECT * FROM ltreetest WHERE t > '12.3' order by t asc;
t t
---------------------------------- ----------------------------------
12.4.10.17.4.10.23.3 12.4.10.17.4.10.23.3
...@@ -7235,7 +7235,7 @@ select * from ltreetest where t > '12.3' order by t asc; ...@@ -7235,7 +7235,7 @@ select * from ltreetest where t > '12.3' order by t asc;
9.9.13.9.14.27 9.9.13.9.14.27
(882 rows) (882 rows)
select * from ltreetest where t @> '1.1.1' order by t asc; SELECT * FROM ltreetest WHERE t @> '1.1.1' order by t asc;
t t
------- -------
...@@ -7244,7 +7244,7 @@ select * from ltreetest where t @> '1.1.1' order by t asc; ...@@ -7244,7 +7244,7 @@ select * from ltreetest where t @> '1.1.1' order by t asc;
1.1.1 1.1.1
(4 rows) (4 rows)
select * from ltreetest where t <@ '1.1.1' order by t asc; SELECT * FROM ltreetest WHERE t <@ '1.1.1' order by t asc;
t t
----------- -----------
1.1.1 1.1.1
...@@ -7253,7 +7253,7 @@ select * from ltreetest where t <@ '1.1.1' order by t asc; ...@@ -7253,7 +7253,7 @@ select * from ltreetest where t <@ '1.1.1' order by t asc;
1.1.1.2.1 1.1.1.2.1
(4 rows) (4 rows)
select * from ltreetest where t ~ '1.1.1.*' order by t asc; SELECT * FROM ltreetest WHERE t ~ '1.1.1.*' order by t asc;
t t
----------- -----------
1.1.1 1.1.1
...@@ -7262,7 +7262,7 @@ select * from ltreetest where t ~ '1.1.1.*' order by t asc; ...@@ -7262,7 +7262,7 @@ select * from ltreetest where t ~ '1.1.1.*' order by t asc;
1.1.1.2.1 1.1.1.2.1
(4 rows) (4 rows)
select * from ltreetest where t ~ '*.1' order by t asc; SELECT * FROM ltreetest WHERE t ~ '*.1' order by t asc;
t t
-------------------------------- --------------------------------
1 1
...@@ -7292,20 +7292,20 @@ select * from ltreetest where t ~ '*.1' order by t asc; ...@@ -7292,20 +7292,20 @@ select * from ltreetest where t ~ '*.1' order by t asc;
9.21.20.29.1 9.21.20.29.1
(25 rows) (25 rows)
select * from ltreetest where t ~ '23.*.1' order by t asc; SELECT * FROM ltreetest WHERE t ~ '23.*.1' order by t asc;
t t
------------------------- -------------------------
23.28.1 23.28.1
23.3.32.21.5.14.10.17.1 23.3.32.21.5.14.10.17.1
(2 rows) (2 rows)
select * from ltreetest where t ~ '23.*{1}.1' order by t asc; SELECT * FROM ltreetest WHERE t ~ '23.*{1}.1' order by t asc;
t t
--------- ---------
23.28.1 23.28.1
(1 row) (1 row)
select * from ltreetest where t @ '23 & 1' order by t asc; SELECT * FROM ltreetest WHERE t @ '23 & 1' order by t asc;
t t
-------------------------------- --------------------------------
1.10.23.25.5.11 1.10.23.25.5.11
...@@ -7350,44 +7350,44 @@ select * from ltreetest where t @ '23 & 1' order by t asc; ...@@ -7350,44 +7350,44 @@ select * from ltreetest where t @ '23 & 1' order by t asc;
(39 rows) (39 rows)
create table _ltreetest (t ltree[]); create table _ltreetest (t ltree[]);
\copy _ltreetest from 'data/_ltree.data' \copy _ltreetest FROM 'data/_ltree.data'
select count(*) from _ltreetest where t @> '1.1.1' ; SELECT count(*) FROM _ltreetest WHERE t @> '1.1.1' ;
count count
------- -------
15 15
(1 row) (1 row)
select count(*) from _ltreetest where t <@ '1.1.1' ; SELECT count(*) FROM _ltreetest WHERE t <@ '1.1.1' ;
count count
------- -------
19 19
(1 row) (1 row)
select count(*) from _ltreetest where t ~ '1.1.1.*' ; SELECT count(*) FROM _ltreetest WHERE t ~ '1.1.1.*' ;
count count
------- -------
19 19
(1 row) (1 row)
select count(*) from _ltreetest where t ~ '*.1' ; SELECT count(*) FROM _ltreetest WHERE t ~ '*.1' ;
count count
------- -------
83 83
(1 row) (1 row)
select count(*) from _ltreetest where t ~ '23.*.1' ; SELECT count(*) FROM _ltreetest WHERE t ~ '23.*.1' ;
count count
------- -------
10 10
(1 row) (1 row)
select count(*) from _ltreetest where t ~ '23.*{1}.1' ; SELECT count(*) FROM _ltreetest WHERE t ~ '23.*{1}.1' ;
count count
------- -------
5 5
(1 row) (1 row)
select count(*) from _ltreetest where t @ '23 & 1' ; SELECT count(*) FROM _ltreetest WHERE t @ '23 & 1' ;
count count
------- -------
147 147
...@@ -7395,43 +7395,43 @@ select count(*) from _ltreetest where t @ '23 & 1' ; ...@@ -7395,43 +7395,43 @@ select count(*) from _ltreetest where t @ '23 & 1' ;
create index _tstidx on _ltreetest using gist (t); create index _tstidx on _ltreetest using gist (t);
set enable_seqscan=off; set enable_seqscan=off;
select count(*) from _ltreetest where t @> '1.1.1' ; SELECT count(*) FROM _ltreetest WHERE t @> '1.1.1' ;
count count
------- -------
15 15
(1 row) (1 row)
select count(*) from _ltreetest where t <@ '1.1.1' ; SELECT count(*) FROM _ltreetest WHERE t <@ '1.1.1' ;
count count
------- -------
19 19
(1 row) (1 row)
select count(*) from _ltreetest where t ~ '1.1.1.*' ; SELECT count(*) FROM _ltreetest WHERE t ~ '1.1.1.*' ;
count count
------- -------
19 19
(1 row) (1 row)
select count(*) from _ltreetest where t ~ '*.1' ; SELECT count(*) FROM _ltreetest WHERE t ~ '*.1' ;
count count
------- -------
83 83
(1 row) (1 row)
select count(*) from _ltreetest where t ~ '23.*.1' ; SELECT count(*) FROM _ltreetest WHERE t ~ '23.*.1' ;
count count
------- -------
10 10
(1 row) (1 row)
select count(*) from _ltreetest where t ~ '23.*{1}.1' ; SELECT count(*) FROM _ltreetest WHERE t ~ '23.*{1}.1' ;
count count
------- -------
5 5
(1 row) (1 row)
select count(*) from _ltreetest where t @ '23 & 1' ; SELECT count(*) FROM _ltreetest WHERE t @ '23 & 1' ;
count count
------- -------
147 147
......
BEGIN;
-- Adjust this setting to control where the objects get created. -- Adjust this setting to control where the objects get created.
SET search_path = public; SET search_path = public;
SET autocommit TO 'on';
CREATE FUNCTION ltree_in(cstring) CREATE FUNCTION ltree_in(cstring)
RETURNS ltree RETURNS ltree
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' WITH (isstrict);
CREATE FUNCTION ltree_out(ltree) CREATE FUNCTION ltree_out(ltree)
RETURNS cstring RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' WITH (isstrict);
CREATE TYPE ltree ( CREATE TYPE ltree (
internallength = -1, INTERNALLENGTH = -1,
input = ltree_in, INPUT = ltree_in,
output = ltree_out, OUTPUT = ltree_out,
storage = extended STORAGE = extended
); );
...@@ -25,74 +25,99 @@ storage = extended ...@@ -25,74 +25,99 @@ storage = extended
CREATE FUNCTION ltree_cmp(ltree,ltree) CREATE FUNCTION ltree_cmp(ltree,ltree)
RETURNS int4 RETURNS int4
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION ltree_lt(ltree,ltree) CREATE FUNCTION ltree_lt(ltree,ltree)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION ltree_le(ltree,ltree) CREATE FUNCTION ltree_le(ltree,ltree)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION ltree_eq(ltree,ltree) CREATE FUNCTION ltree_eq(ltree,ltree)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION ltree_ge(ltree,ltree) CREATE FUNCTION ltree_ge(ltree,ltree)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION ltree_gt(ltree,ltree) CREATE FUNCTION ltree_gt(ltree,ltree)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION ltree_ne(ltree,ltree) CREATE FUNCTION ltree_ne(ltree,ltree)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE OPERATOR < ( CREATE OPERATOR < (
LEFTARG = ltree, RIGHTARG = ltree, PROCEDURE = ltree_lt, LEFTARG = ltree,
COMMUTATOR = '>', NEGATOR = '>=', RIGHTARG = ltree,
RESTRICT = contsel, JOIN = contjoinsel PROCEDURE = ltree_lt,
COMMUTATOR = '>',
NEGATOR = '>=',
RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR <= ( CREATE OPERATOR <= (
LEFTARG = ltree, RIGHTARG = ltree, PROCEDURE = ltree_le, LEFTARG = ltree,
COMMUTATOR = '>=', NEGATOR = '>', RIGHTARG = ltree,
RESTRICT = contsel, JOIN = contjoinsel PROCEDURE = ltree_le,
COMMUTATOR = '>=',
NEGATOR = '>',
RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR >= ( CREATE OPERATOR >= (
LEFTARG = ltree, RIGHTARG = ltree, PROCEDURE = ltree_ge, LEFTARG = ltree,
COMMUTATOR = '<=', NEGATOR = '<', RIGHTARG = ltree,
RESTRICT = contsel, JOIN = contjoinsel PROCEDURE = ltree_ge,
COMMUTATOR = '<=',
NEGATOR = '<',
RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR > ( CREATE OPERATOR > (
LEFTARG = ltree, RIGHTARG = ltree, PROCEDURE = ltree_gt, LEFTARG = ltree,
COMMUTATOR = '<', NEGATOR = '<=', RIGHTARG = ltree,
RESTRICT = contsel, JOIN = contjoinsel PROCEDURE = ltree_gt,
COMMUTATOR = '<',
NEGATOR = '<=',
RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR = ( CREATE OPERATOR = (
LEFTARG = ltree, RIGHTARG = ltree, PROCEDURE = ltree_eq, LEFTARG = ltree,
COMMUTATOR = '=', NEGATOR = '<>', RIGHTARG = ltree,
RESTRICT = eqsel, JOIN = eqjoinsel, PROCEDURE = ltree_eq,
SORT1 = '<', SORT2 = '<' COMMUTATOR = '=',
NEGATOR = '<>',
RESTRICT = eqsel,
JOIN = eqjoinsel,
SORT1 = '<',
SORT2 = '<'
); );
CREATE OPERATOR <> ( CREATE OPERATOR <> (
LEFTARG = ltree, RIGHTARG = ltree, PROCEDURE = ltree_ne, LEFTARG = ltree,
COMMUTATOR = '<>', NEGATOR = '=', RIGHTARG = ltree,
RESTRICT = neqsel, JOIN = neqjoinsel PROCEDURE = ltree_ne,
COMMUTATOR = '<>',
NEGATOR = '=',
RESTRICT = neqsel,
JOIN = neqjoinsel
); );
--util functions --util functions
...@@ -100,122 +125,140 @@ CREATE OPERATOR <> ( ...@@ -100,122 +125,140 @@ CREATE OPERATOR <> (
CREATE FUNCTION subltree(ltree,int4,int4) CREATE FUNCTION subltree(ltree,int4,int4)
RETURNS ltree RETURNS ltree
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION subpath(ltree,int4,int4) CREATE FUNCTION subpath(ltree,int4,int4)
RETURNS ltree RETURNS ltree
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION subpath(ltree,int4) CREATE FUNCTION subpath(ltree,int4)
RETURNS ltree RETURNS ltree
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION nlevel(ltree) CREATE FUNCTION nlevel(ltree)
RETURNS int4 RETURNS int4
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION lca(_ltree) CREATE FUNCTION lca(_ltree)
RETURNS ltree RETURNS ltree
AS 'MODULE_PATHNAME','_lca' AS 'MODULE_PATHNAME','_lca'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION lca(ltree,ltree) CREATE FUNCTION lca(ltree,ltree)
RETURNS ltree RETURNS ltree
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION lca(ltree,ltree,ltree) CREATE FUNCTION lca(ltree,ltree,ltree)
RETURNS ltree RETURNS ltree
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION lca(ltree,ltree,ltree,ltree) CREATE FUNCTION lca(ltree,ltree,ltree,ltree)
RETURNS ltree RETURNS ltree
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION lca(ltree,ltree,ltree,ltree,ltree) CREATE FUNCTION lca(ltree,ltree,ltree,ltree,ltree)
RETURNS ltree RETURNS ltree
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION lca(ltree,ltree,ltree,ltree,ltree,ltree) CREATE FUNCTION lca(ltree,ltree,ltree,ltree,ltree,ltree)
RETURNS ltree RETURNS ltree
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION lca(ltree,ltree,ltree,ltree,ltree,ltree,ltree) CREATE FUNCTION lca(ltree,ltree,ltree,ltree,ltree,ltree,ltree)
RETURNS ltree RETURNS ltree
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION lca(ltree,ltree,ltree,ltree,ltree,ltree,ltree,ltree) CREATE FUNCTION lca(ltree,ltree,ltree,ltree,ltree,ltree,ltree,ltree)
RETURNS ltree RETURNS ltree
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION ltree_isparent(ltree,ltree) CREATE FUNCTION ltree_isparent(ltree,ltree)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION ltree_risparent(ltree,ltree) CREATE FUNCTION ltree_risparent(ltree,ltree)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION ltree_addltree(ltree,ltree) CREATE FUNCTION ltree_addltree(ltree,ltree)
RETURNS ltree RETURNS ltree
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION ltree_addtext(ltree,text) CREATE FUNCTION ltree_addtext(ltree,text)
RETURNS ltree RETURNS ltree
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION ltree_textadd(text,ltree) CREATE FUNCTION ltree_textadd(text,ltree)
RETURNS ltree RETURNS ltree
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE OPERATOR @> ( CREATE OPERATOR @> (
LEFTARG = ltree, RIGHTARG = ltree, PROCEDURE = ltree_isparent, LEFTARG = ltree,
RIGHTARG = ltree,
PROCEDURE = ltree_isparent,
COMMUTATOR = '<@', COMMUTATOR = '<@',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR ^@> ( CREATE OPERATOR ^@> (
LEFTARG = ltree, RIGHTARG = ltree, PROCEDURE = ltree_isparent, LEFTARG = ltree,
RIGHTARG = ltree,
PROCEDURE = ltree_isparent,
COMMUTATOR = '^<@', COMMUTATOR = '^<@',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR <@ ( CREATE OPERATOR <@ (
LEFTARG = ltree, RIGHTARG = ltree, PROCEDURE = ltree_risparent, LEFTARG = ltree,
RIGHTARG = ltree,
PROCEDURE = ltree_risparent,
COMMUTATOR = '@>', COMMUTATOR = '@>',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR ^<@ ( CREATE OPERATOR ^<@ (
LEFTARG = ltree, RIGHTARG = ltree, PROCEDURE = ltree_risparent, LEFTARG = ltree,
RIGHTARG = ltree,
PROCEDURE = ltree_risparent,
COMMUTATOR = '^@>', COMMUTATOR = '^@>',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR || ( CREATE OPERATOR || (
LEFTARG = ltree, RIGHTARG = ltree, PROCEDURE = ltree_addltree LEFTARG = ltree,
RIGHTARG = ltree,
PROCEDURE = ltree_addltree
); );
CREATE OPERATOR || ( CREATE OPERATOR || (
LEFTARG = ltree, RIGHTARG = text, PROCEDURE = ltree_addtext LEFTARG = ltree,
RIGHTARG = text,
PROCEDURE = ltree_addtext
); );
CREATE OPERATOR || ( CREATE OPERATOR || (
LEFTARG = text, RIGHTARG = ltree, PROCEDURE = ltree_textadd LEFTARG = text,
RIGHTARG = ltree,
PROCEDURE = ltree_textadd
); );
...@@ -235,119 +278,143 @@ CREATE OPERATOR CLASS ltree_ops ...@@ -235,119 +278,143 @@ CREATE OPERATOR CLASS ltree_ops
CREATE FUNCTION lquery_in(cstring) CREATE FUNCTION lquery_in(cstring)
RETURNS lquery RETURNS lquery
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' WITH (isstrict);
CREATE FUNCTION lquery_out(lquery) CREATE FUNCTION lquery_out(lquery)
RETURNS cstring RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' WITH (isstrict);
CREATE TYPE lquery ( CREATE TYPE lquery (
internallength = -1, INTERNALLENGTH = -1,
input = lquery_in, INPUT = lquery_in,
output = lquery_out, OUTPUT = lquery_out,
storage = extended STORAGE = extended
); );
CREATE FUNCTION ltq_regex(ltree,lquery) CREATE FUNCTION ltq_regex(ltree,lquery)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION ltq_rregex(lquery,ltree) CREATE FUNCTION ltq_rregex(lquery,ltree)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE OPERATOR ~ ( CREATE OPERATOR ~ (
LEFTARG = ltree, RIGHTARG = lquery, PROCEDURE = ltq_regex, LEFTARG = ltree,
RIGHTARG = lquery,
PROCEDURE = ltq_regex,
COMMUTATOR = '~', COMMUTATOR = '~',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR ~ ( CREATE OPERATOR ~ (
LEFTARG = lquery, RIGHTARG = ltree, PROCEDURE = ltq_rregex, LEFTARG = lquery,
RIGHTARG = ltree,
PROCEDURE = ltq_rregex,
COMMUTATOR = '~', COMMUTATOR = '~',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
--not-indexed --not-indexed
CREATE OPERATOR ^~ ( CREATE OPERATOR ^~ (
LEFTARG = ltree, RIGHTARG = lquery, PROCEDURE = ltq_regex, LEFTARG = ltree,
RIGHTARG = lquery,
PROCEDURE = ltq_regex,
COMMUTATOR = '^~', COMMUTATOR = '^~',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR ^~ ( CREATE OPERATOR ^~ (
LEFTARG = lquery, RIGHTARG = ltree, PROCEDURE = ltq_rregex, LEFTARG = lquery,
RIGHTARG = ltree,
PROCEDURE = ltq_rregex,
COMMUTATOR = '^~', COMMUTATOR = '^~',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE FUNCTION ltxtq_in(cstring) CREATE FUNCTION ltxtq_in(cstring)
RETURNS ltxtquery RETURNS ltxtquery
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' WITH (isstrict);
CREATE FUNCTION ltxtq_out(ltxtquery) CREATE FUNCTION ltxtq_out(ltxtquery)
RETURNS cstring RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' WITH (isstrict);
CREATE TYPE ltxtquery ( CREATE TYPE ltxtquery (
internallength = -1, INTERNALLENGTH = -1,
input = ltxtq_in, INPUT = ltxtq_in,
output = ltxtq_out, OUTPUT = ltxtq_out,
storage = extended STORAGE = extended
); );
-- operations with ltxtquery -- operations WITH ltxtquery
CREATE FUNCTION ltxtq_exec(ltree, ltxtquery) CREATE FUNCTION ltxtq_exec(ltree, ltxtquery)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict, iscachable); LANGUAGE 'C' WITH (isstrict, iscachable);
CREATE FUNCTION ltxtq_rexec(ltxtquery, ltree) CREATE FUNCTION ltxtq_rexec(ltxtquery, ltree)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict, iscachable); LANGUAGE 'C' WITH (isstrict, iscachable);
CREATE OPERATOR @ ( CREATE OPERATOR @ (
LEFTARG = ltree, RIGHTARG = ltxtquery, PROCEDURE = ltxtq_exec, LEFTARG = ltree,
RIGHTARG = ltxtquery,
PROCEDURE = ltxtq_exec,
COMMUTATOR = '@', COMMUTATOR = '@',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR @ ( CREATE OPERATOR @ (
LEFTARG = ltxtquery, RIGHTARG = ltree, PROCEDURE = ltxtq_rexec, LEFTARG = ltxtquery,
RIGHTARG = ltree,
PROCEDURE = ltxtq_rexec,
COMMUTATOR = '@', COMMUTATOR = '@',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
--not-indexed --not-indexed
CREATE OPERATOR ^@ ( CREATE OPERATOR ^@ (
LEFTARG = ltree, RIGHTARG = ltxtquery, PROCEDURE = ltxtq_exec, LEFTARG = ltree,
RIGHTARG = ltxtquery,
PROCEDURE = ltxtq_exec,
COMMUTATOR = '^@', COMMUTATOR = '^@',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR ^@ ( CREATE OPERATOR ^@ (
LEFTARG = ltxtquery, RIGHTARG = ltree, PROCEDURE = ltxtq_rexec, LEFTARG = ltxtquery,
RIGHTARG = ltree,
PROCEDURE = ltxtq_rexec,
COMMUTATOR = '^@', COMMUTATOR = '^@',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
--GiST support for ltree --GiST support for ltree
CREATE FUNCTION ltree_gist_in(cstring) CREATE FUNCTION ltree_gist_in(cstring)
RETURNS ltree_gist RETURNS ltree_gist
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' WITH (isstrict);
CREATE FUNCTION ltree_gist_out(ltree_gist) CREATE FUNCTION ltree_gist_out(ltree_gist)
RETURNS cstring RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' WITH (isstrict);
CREATE TYPE ltree_gist ( CREATE TYPE ltree_gist (
internallength = -1, internallength = -1,
...@@ -357,13 +424,20 @@ CREATE TYPE ltree_gist ( ...@@ -357,13 +424,20 @@ CREATE TYPE ltree_gist (
); );
create function ltree_consistent(internal,internal,int2) returns bool as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION ltree_consistent(internal,internal,int2)
create function ltree_compress(internal) returns internal as 'MODULE_PATHNAME' language 'C'; RETURNS bool as 'MODULE_PATHNAME' language 'C';
create function ltree_decompress(internal) returns internal as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION ltree_compress(internal)
create function ltree_penalty(internal,internal,internal) returns internal as 'MODULE_PATHNAME' language 'C' with(isstrict); RETURNS internal as 'MODULE_PATHNAME' language 'C';
create function ltree_picksplit(internal, internal) returns internal as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION ltree_decompress(internal)
create function ltree_union(bytea, internal) returns int4 as 'MODULE_PATHNAME' language 'C'; RETURNS internal as 'MODULE_PATHNAME' language 'C';
create function ltree_same(internal, internal, internal) returns internal as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION ltree_penalty(internal,internal,internal)
RETURNS internal as 'MODULE_PATHNAME' language 'C' with(isstrict);
CREATE FUNCTION ltree_picksplit(internal, internal)
RETURNS internal as 'MODULE_PATHNAME' language 'C';
CREATE FUNCTION ltree_union(bytea, internal)
RETURNS int4 as 'MODULE_PATHNAME' language 'C';
CREATE FUNCTION ltree_same(internal, internal, internal)
RETURNS internal as 'MODULE_PATHNAME' language 'C';
CREATE OPERATOR CLASS gist_ltree_ops CREATE OPERATOR CLASS gist_ltree_ops
DEFAULT FOR TYPE ltree USING gist AS DEFAULT FOR TYPE ltree USING gist AS
...@@ -393,185 +467,259 @@ CREATE OPERATOR CLASS gist_ltree_ops ...@@ -393,185 +467,259 @@ CREATE OPERATOR CLASS gist_ltree_ops
CREATE FUNCTION _ltree_isparent(_ltree,ltree) CREATE FUNCTION _ltree_isparent(_ltree,ltree)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION _ltree_r_isparent(ltree,_ltree) CREATE FUNCTION _ltree_r_isparent(ltree,_ltree)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION _ltree_risparent(_ltree,ltree) CREATE FUNCTION _ltree_risparent(_ltree,ltree)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION _ltree_r_risparent(ltree,_ltree) CREATE FUNCTION _ltree_r_risparent(ltree,_ltree)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION _ltq_regex(_ltree,lquery) CREATE FUNCTION _ltq_regex(_ltree,lquery)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION _ltq_rregex(lquery,_ltree) CREATE FUNCTION _ltq_rregex(lquery,_ltree)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE FUNCTION _ltxtq_exec(_ltree, ltxtquery) CREATE FUNCTION _ltxtq_exec(_ltree, ltxtquery)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict, iscachable); LANGUAGE 'C' WITH (isstrict, iscachable);
CREATE FUNCTION _ltxtq_rexec(ltxtquery, _ltree) CREATE FUNCTION _ltxtq_rexec(ltxtquery, _ltree)
RETURNS bool RETURNS bool
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict, iscachable); LANGUAGE 'C' WITH (isstrict, iscachable);
CREATE OPERATOR @> ( CREATE OPERATOR @> (
LEFTARG = _ltree, RIGHTARG = ltree, PROCEDURE = _ltree_isparent, LEFTARG = _ltree,
RIGHTARG = ltree,
PROCEDURE = _ltree_isparent,
COMMUTATOR = '<@', COMMUTATOR = '<@',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR <@ ( CREATE OPERATOR <@ (
LEFTARG = ltree, RIGHTARG = _ltree, PROCEDURE = _ltree_r_isparent, LEFTARG = ltree,
RIGHTARG = _ltree,
PROCEDURE = _ltree_r_isparent,
COMMUTATOR = '@>', COMMUTATOR = '@>',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR <@ ( CREATE OPERATOR <@ (
LEFTARG = _ltree, RIGHTARG = ltree, PROCEDURE = _ltree_risparent, LEFTARG = _ltree,
RIGHTARG = ltree,
PROCEDURE = _ltree_risparent,
COMMUTATOR = '@>', COMMUTATOR = '@>',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR @> ( CREATE OPERATOR @> (
LEFTARG = ltree, RIGHTARG = _ltree, PROCEDURE = _ltree_r_risparent, LEFTARG = ltree,
RIGHTARG = _ltree,
PROCEDURE = _ltree_r_risparent,
COMMUTATOR = '<@', COMMUTATOR = '<@',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR ~ ( CREATE OPERATOR ~ (
LEFTARG = _ltree, RIGHTARG = lquery, PROCEDURE = _ltq_regex, LEFTARG = _ltree,
RIGHTARG = lquery,
PROCEDURE = _ltq_regex,
COMMUTATOR = '~', COMMUTATOR = '~',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR ~ ( CREATE OPERATOR ~ (
LEFTARG = lquery, RIGHTARG = _ltree, PROCEDURE = _ltq_rregex, LEFTARG = lquery,
RIGHTARG = _ltree,
PROCEDURE = _ltq_rregex,
COMMUTATOR = '~', COMMUTATOR = '~',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR @ ( CREATE OPERATOR @ (
LEFTARG = _ltree, RIGHTARG = ltxtquery, PROCEDURE = _ltxtq_exec, LEFTARG = _ltree,
RIGHTARG = ltxtquery,
PROCEDURE = _ltxtq_exec,
COMMUTATOR = '@', COMMUTATOR = '@',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR @ ( CREATE OPERATOR @ (
LEFTARG = ltxtquery, RIGHTARG = _ltree, PROCEDURE = _ltxtq_rexec, LEFTARG = ltxtquery,
RIGHTARG = _ltree,
PROCEDURE = _ltxtq_rexec,
COMMUTATOR = '@', COMMUTATOR = '@',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
--not indexed --not indexed
CREATE OPERATOR ^@> ( CREATE OPERATOR ^@> (
LEFTARG = _ltree, RIGHTARG = ltree, PROCEDURE = _ltree_isparent, LEFTARG = _ltree,
RIGHTARG = ltree,
PROCEDURE = _ltree_isparent,
COMMUTATOR = '^<@', COMMUTATOR = '^<@',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR ^<@ ( CREATE OPERATOR ^<@ (
LEFTARG = ltree, RIGHTARG = _ltree, PROCEDURE = _ltree_r_isparent, LEFTARG = ltree,
RIGHTARG = _ltree,
PROCEDURE = _ltree_r_isparent,
COMMUTATOR = '^@>', COMMUTATOR = '^@>',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR ^<@ ( CREATE OPERATOR ^<@ (
LEFTARG = _ltree, RIGHTARG = ltree, PROCEDURE = _ltree_risparent, LEFTARG = _ltree,
RIGHTARG = ltree,
PROCEDURE = _ltree_risparent,
COMMUTATOR = '^@>', COMMUTATOR = '^@>',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR ^@> ( CREATE OPERATOR ^@> (
LEFTARG = ltree, RIGHTARG = _ltree, PROCEDURE = _ltree_r_risparent, LEFTARG = ltree,
RIGHTARG = _ltree,
PROCEDURE = _ltree_r_risparent,
COMMUTATOR = '^<@', COMMUTATOR = '^<@',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR ^~ ( CREATE OPERATOR ^~ (
LEFTARG = _ltree, RIGHTARG = lquery, PROCEDURE = _ltq_regex, LEFTARG = _ltree,
RIGHTARG = lquery,
PROCEDURE = _ltq_regex,
COMMUTATOR = '^~', COMMUTATOR = '^~',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR ^~ ( CREATE OPERATOR ^~ (
LEFTARG = lquery, RIGHTARG = _ltree, PROCEDURE = _ltq_rregex, LEFTARG = lquery,
RIGHTARG = _ltree,
PROCEDURE = _ltq_rregex,
COMMUTATOR = '^~', COMMUTATOR = '^~',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR ^@ ( CREATE OPERATOR ^@ (
LEFTARG = _ltree, RIGHTARG = ltxtquery, PROCEDURE = _ltxtq_exec, LEFTARG = _ltree,
RIGHTARG = ltxtquery,
PROCEDURE = _ltxtq_exec,
COMMUTATOR = '^@', COMMUTATOR = '^@',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR ^@ ( CREATE OPERATOR ^@ (
LEFTARG = ltxtquery, RIGHTARG = _ltree, PROCEDURE = _ltxtq_rexec, LEFTARG = ltxtquery,
RIGHTARG = _ltree,
PROCEDURE = _ltxtq_rexec,
COMMUTATOR = '^@', COMMUTATOR = '^@',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
--extractors --extractors
CREATE FUNCTION _ltree_extract_isparent(_ltree,ltree) CREATE FUNCTION _ltree_extract_isparent(_ltree,ltree)
RETURNS ltree RETURNS ltree
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE OPERATOR ?@> ( CREATE OPERATOR ?@> (
LEFTARG = _ltree, RIGHTARG = ltree, PROCEDURE = _ltree_extract_isparent LEFTARG = _ltree,
RIGHTARG = ltree,
PROCEDURE = _ltree_extract_isparent
); );
CREATE FUNCTION _ltree_extract_risparent(_ltree,ltree) CREATE FUNCTION _ltree_extract_risparent(_ltree,ltree)
RETURNS ltree RETURNS ltree
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE OPERATOR ?<@ ( CREATE OPERATOR ?<@ (
LEFTARG = _ltree, RIGHTARG = ltree, PROCEDURE = _ltree_extract_risparent LEFTARG = _ltree,
RIGHTARG = ltree,
PROCEDURE = _ltree_extract_risparent
); );
CREATE FUNCTION _ltq_extract_regex(_ltree,lquery) CREATE FUNCTION _ltq_extract_regex(_ltree,lquery)
RETURNS ltree RETURNS ltree
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE OPERATOR ?~ ( CREATE OPERATOR ?~ (
LEFTARG = _ltree, RIGHTARG = lquery, PROCEDURE = _ltq_extract_regex LEFTARG = _ltree,
RIGHTARG = lquery,
PROCEDURE = _ltq_extract_regex
); );
CREATE FUNCTION _ltxtq_extract_exec(_ltree,ltxtquery) CREATE FUNCTION _ltxtq_extract_exec(_ltree,ltxtquery)
RETURNS ltree RETURNS ltree
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict,iscachable); LANGUAGE 'C' WITH (isstrict,iscachable);
CREATE OPERATOR ?@ ( CREATE OPERATOR ?@ (
LEFTARG = _ltree, RIGHTARG = ltxtquery, PROCEDURE = _ltxtq_extract_exec LEFTARG = _ltree,
RIGHTARG = ltxtquery,
PROCEDURE = _ltxtq_extract_exec
); );
--GiST support for ltree[] --GiST support for ltree[]
create function _ltree_consistent(internal,internal,int2) returns bool as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION _ltree_consistent(internal,internal,int2)
create function _ltree_compress(internal) returns internal as 'MODULE_PATHNAME' language 'C'; RETURNS bool
create function _ltree_penalty(internal,internal,internal) returns internal as 'MODULE_PATHNAME' language 'C' with(isstrict); AS 'MODULE_PATHNAME'
create function _ltree_picksplit(internal, internal) returns internal as 'MODULE_PATHNAME' language 'C'; LANGUAGE 'C';
create function _ltree_union(bytea, internal) returns int4 as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION _ltree_compress(internal)
create function _ltree_same(internal, internal, internal) returns internal as 'MODULE_PATHNAME' language 'C'; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION _ltree_penalty(internal,internal,internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH(isstrict);
CREATE FUNCTION _ltree_picksplit(internal, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION _ltree_union(bytea, internal)
RETURNS int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION _ltree_same(internal, internal, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE OPERATOR CLASS gist__ltree_ops CREATE OPERATOR CLASS gist__ltree_ops
DEFAULT FOR TYPE _ltree USING gist AS DEFAULT FOR TYPE _ltree USING gist AS
...@@ -589,6 +737,3 @@ CREATE OPERATOR CLASS gist__ltree_ops ...@@ -589,6 +737,3 @@ CREATE OPERATOR CLASS gist__ltree_ops
FUNCTION 6 _ltree_picksplit (internal, internal), FUNCTION 6 _ltree_picksplit (internal, internal),
FUNCTION 7 _ltree_same (internal, internal, internal), FUNCTION 7 _ltree_same (internal, internal, internal),
STORAGE ltree_gist; STORAGE ltree_gist;
END;
create table test ( path ltree); CREATE TABLE test ( path ltree);
insert into test values ('Top'); INSERT INTO test VALUES ('Top');
insert into test values ('Top.Science'); INSERT INTO test VALUES ('Top.Science');
insert into test values ('Top.Science.Astronomy'); INSERT INTO test VALUES ('Top.Science.Astronomy');
insert into test values ('Top.Science.Astronomy.Astrophysics'); INSERT INTO test VALUES ('Top.Science.Astronomy.Astrophysics');
insert into test values ('Top.Science.Astronomy.Cosmology'); INSERT INTO test VALUES ('Top.Science.Astronomy.Cosmology');
insert into test values ('Top.Hobbies'); INSERT INTO test VALUES ('Top.Hobbies');
insert into test values ('Top.Hobbies.Amateurs_Astronomy'); INSERT INTO test VALUES ('Top.Hobbies.Amateurs_Astronomy');
insert into test values ('Top.Collections'); INSERT INTO test VALUES ('Top.Collections');
insert into test values ('Top.Collections.Pictures'); INSERT INTO test VALUES ('Top.Collections.Pictures');
insert into test values ('Top.Collections.Pictures.Astronomy'); INSERT INTO test VALUES ('Top.Collections.Pictures.Astronomy');
insert into test values ('Top.Collections.Pictures.Astronomy.Stars'); INSERT INTO test VALUES ('Top.Collections.Pictures.Astronomy.Stars');
insert into test values ('Top.Collections.Pictures.Astronomy.Galaxies'); INSERT INTO test VALUES ('Top.Collections.Pictures.Astronomy.Galaxies');
insert into test values ('Top.Collections.Pictures.Astronomy.Astronauts'); INSERT INTO test VALUES ('Top.Collections.Pictures.Astronomy.Astronauts');
create index path_gist_idx on test using gist(path); CREATE INDEX path_gist_idx ON test USING gist(path);
create index path_idx on test using btree(path); CREATE INDEX path_idx ON test USING btree(path);
\set ECHO none \set ECHO none
SET autocommit TO 'on';
\i ltree.sql \i ltree.sql
\set ECHO all \set ECHO all
select ''::ltree; SELECT ''::ltree;
select '1'::ltree; SELECT '1'::ltree;
select '1.2'::ltree; SELECT '1.2'::ltree;
select '1.2._3'::ltree; SELECT '1.2._3'::ltree;
select subltree('Top.Child1.Child2',1,2); SELECT subltree('Top.Child1.Child2',1,2);
select subpath('Top.Child1.Child2',1,2); SELECT subpath('Top.Child1.Child2',1,2);
select subpath('Top.Child1.Child2',-1,1); SELECT subpath('Top.Child1.Child2',-1,1);
select subpath('Top.Child1.Child2',0,-2); SELECT subpath('Top.Child1.Child2',0,-2);
select subpath('Top.Child1.Child2',0,-1); SELECT subpath('Top.Child1.Child2',0,-1);
select subpath('Top.Child1.Child2',0,0); SELECT subpath('Top.Child1.Child2',0,0);
select subpath('Top.Child1.Child2',1,0); SELECT subpath('Top.Child1.Child2',1,0);
select subpath('Top.Child1.Child2',0); SELECT subpath('Top.Child1.Child2',0);
select subpath('Top.Child1.Child2',1); SELECT subpath('Top.Child1.Child2',1);
select 'Top.Child1.Child2'::ltree || 'Child3'::text; SELECT 'Top.Child1.Child2'::ltree || 'Child3'::text;
select 'Top.Child1.Child2'::ltree || 'Child3'::ltree; SELECT 'Top.Child1.Child2'::ltree || 'Child3'::ltree;
select 'Top_0'::ltree || 'Top.Child1.Child2'::ltree; SELECT 'Top_0'::ltree || 'Top.Child1.Child2'::ltree;
select 'Top.Child1.Child2'::ltree || ''::ltree; SELECT 'Top.Child1.Child2'::ltree || ''::ltree;
select ''::ltree || 'Top.Child1.Child2'::ltree; SELECT ''::ltree || 'Top.Child1.Child2'::ltree;
select lca('{la.2.3,1.2.3.4.5.6,}') is null; SELECT lca('{la.2.3,1.2.3.4.5.6,}') IS NULL;
select lca('{la.2.3,1.2.3.4.5.6}') is null; SELECT lca('{la.2.3,1.2.3.4.5.6}') IS NULL;
select lca('{1.la.2.3,1.2.3.4.5.6}'); SELECT lca('{1.la.2.3,1.2.3.4.5.6}');
select lca('{1.2.3,1.2.3.4.5.6}'); SELECT lca('{1.2.3,1.2.3.4.5.6}');
select lca('1.la.2.3','1.2.3.4.5.6'); SELECT lca('1.la.2.3','1.2.3.4.5.6');
select lca('1.2.3','1.2.3.4.5.6'); SELECT lca('1.2.3','1.2.3.4.5.6');
select lca('1.2.2.3','1.2.3.4.5.6'); SELECT lca('1.2.2.3','1.2.3.4.5.6');
select lca('1.2.2.3','1.2.3.4.5.6',''); SELECT lca('1.2.2.3','1.2.3.4.5.6','');
select lca('1.2.2.3','1.2.3.4.5.6','2'); SELECT lca('1.2.2.3','1.2.3.4.5.6','2');
select lca('1.2.2.3','1.2.3.4.5.6','1'); SELECT lca('1.2.2.3','1.2.3.4.5.6','1');
select '1'::lquery; SELECT '1'::lquery;
select '4|3|2'::lquery; SELECT '4|3|2'::lquery;
select '1.2'::lquery; SELECT '1.2'::lquery;
select '1.4|3|2'::lquery; SELECT '1.4|3|2'::lquery;
select '1.0'::lquery; SELECT '1.0'::lquery;
select '4|3|2.0'::lquery; SELECT '4|3|2.0'::lquery;
select '1.2.0'::lquery; SELECT '1.2.0'::lquery;
select '1.4|3|2.0'::lquery; SELECT '1.4|3|2.0'::lquery;
select '1.*'::lquery; SELECT '1.*'::lquery;
select '4|3|2.*'::lquery; SELECT '4|3|2.*'::lquery;
select '1.2.*'::lquery; SELECT '1.2.*'::lquery;
select '1.4|3|2.*'::lquery; SELECT '1.4|3|2.*'::lquery;
select '*.1.*'::lquery; SELECT '*.1.*'::lquery;
select '*.4|3|2.*'::lquery; SELECT '*.4|3|2.*'::lquery;
select '*.1.2.*'::lquery; SELECT '*.1.2.*'::lquery;
select '*.1.4|3|2.*'::lquery; SELECT '*.1.4|3|2.*'::lquery;
select '1.*.4|3|2'::lquery; SELECT '1.*.4|3|2'::lquery;
select '1.*.4|3|2.0'::lquery; SELECT '1.*.4|3|2.0'::lquery;
select '1.*.4|3|2.*{1,4}'::lquery; SELECT '1.*.4|3|2.*{1,4}'::lquery;
select '1.*.4|3|2.*{,4}'::lquery; SELECT '1.*.4|3|2.*{,4}'::lquery;
select '1.*.4|3|2.*{1,}'::lquery; SELECT '1.*.4|3|2.*{1,}'::lquery;
select '1.*.4|3|2.*{1}'::lquery; SELECT '1.*.4|3|2.*{1}'::lquery;
select 'qwerty%@*.tu'::lquery; SELECT 'qwerty%@*.tu'::lquery;
select nlevel('1.2.3.4'); SELECT nlevel('1.2.3.4');
select '1.2'::ltree < '2.2'::ltree; SELECT '1.2'::ltree < '2.2'::ltree;
select '1.2'::ltree <= '2.2'::ltree; SELECT '1.2'::ltree <= '2.2'::ltree;
select '2.2'::ltree = '2.2'::ltree; SELECT '2.2'::ltree = '2.2'::ltree;
select '3.2'::ltree >= '2.2'::ltree; SELECT '3.2'::ltree >= '2.2'::ltree;
select '3.2'::ltree > '2.2'::ltree; SELECT '3.2'::ltree > '2.2'::ltree;
select '1.2.3'::ltree @> '1.2.3.4'::ltree; SELECT '1.2.3'::ltree @> '1.2.3.4'::ltree;
select '1.2.3.4'::ltree @> '1.2.3.4'::ltree; SELECT '1.2.3.4'::ltree @> '1.2.3.4'::ltree;
select '1.2.3.4.5'::ltree @> '1.2.3.4'::ltree; SELECT '1.2.3.4.5'::ltree @> '1.2.3.4'::ltree;
select '1.3.3'::ltree @> '1.2.3.4'::ltree; SELECT '1.3.3'::ltree @> '1.2.3.4'::ltree;
select 'a.b.c.d.e'::ltree ~ 'a.b.c.d.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.b.c.d.e';
select 'a.b.c.d.e'::ltree ~ 'A.b.c.d.e'; SELECT 'a.b.c.d.e'::ltree ~ 'A.b.c.d.e';
select 'a.b.c.d.e'::ltree ~ 'A@.b.c.d.e'; SELECT 'a.b.c.d.e'::ltree ~ 'A@.b.c.d.e';
select 'aa.b.c.d.e'::ltree ~ 'A@.b.c.d.e'; SELECT 'aa.b.c.d.e'::ltree ~ 'A@.b.c.d.e';
select 'aa.b.c.d.e'::ltree ~ 'A*.b.c.d.e'; SELECT 'aa.b.c.d.e'::ltree ~ 'A*.b.c.d.e';
select 'aa.b.c.d.e'::ltree ~ 'A*@.b.c.d.e'; SELECT 'aa.b.c.d.e'::ltree ~ 'A*@.b.c.d.e';
select 'aa.b.c.d.e'::ltree ~ 'A*@|g.b.c.d.e'; SELECT 'aa.b.c.d.e'::ltree ~ 'A*@|g.b.c.d.e';
select 'g.b.c.d.e'::ltree ~ 'A*@|g.b.c.d.e'; SELECT 'g.b.c.d.e'::ltree ~ 'A*@|g.b.c.d.e';
select 'a.b.c.d.e'::ltree ~ 'a.b.c.d.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.b.c.d.e';
select 'a.b.c.d.e'::ltree ~ 'a.*.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*.e';
select 'a.b.c.d.e'::ltree ~ 'a.*{3}.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*{3}.e';
select 'a.b.c.d.e'::ltree ~ 'a.*{2}.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*{2}.e';
select 'a.b.c.d.e'::ltree ~ 'a.*{4}.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*{4}.e';
select 'a.b.c.d.e'::ltree ~ 'a.*{,4}.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*{,4}.e';
select 'a.b.c.d.e'::ltree ~ 'a.*{2,}.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*{2,}.e';
select 'a.b.c.d.e'::ltree ~ 'a.*{2,4}.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*{2,4}.e';
select 'a.b.c.d.e'::ltree ~ 'a.*{2,3}.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*{2,3}.e';
select 'a.b.c.d.e'::ltree ~ 'a.*{2,3}'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*{2,3}';
select 'a.b.c.d.e'::ltree ~ 'a.*{2,4}'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*{2,4}';
select 'a.b.c.d.e'::ltree ~ 'a.*{2,5}'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*{2,5}';
select 'a.b.c.d.e'::ltree ~ '*{2,3}.e'; SELECT 'a.b.c.d.e'::ltree ~ '*{2,3}.e';
select 'a.b.c.d.e'::ltree ~ '*{2,4}.e'; SELECT 'a.b.c.d.e'::ltree ~ '*{2,4}.e';
select 'a.b.c.d.e'::ltree ~ '*{2,5}.e'; SELECT 'a.b.c.d.e'::ltree ~ '*{2,5}.e';
select 'a.b.c.d.e'::ltree ~ '*.e'; SELECT 'a.b.c.d.e'::ltree ~ '*.e';
select 'a.b.c.d.e'::ltree ~ '*.e.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.e.*';
select 'a.b.c.d.e'::ltree ~ '*.d.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.d.*';
select 'a.b.c.d.e'::ltree ~ '*.a.*.d.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.a.*.d.*';
select 'a.b.c.d.e'::ltree ~ '*.!d.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.!d.*';
select 'a.b.c.d.e'::ltree ~ '*.!d'; SELECT 'a.b.c.d.e'::ltree ~ '*.!d';
select 'a.b.c.d.e'::ltree ~ '!d.*'; SELECT 'a.b.c.d.e'::ltree ~ '!d.*';
select 'a.b.c.d.e'::ltree ~ '!a.*'; SELECT 'a.b.c.d.e'::ltree ~ '!a.*';
select 'a.b.c.d.e'::ltree ~ '*.!e'; SELECT 'a.b.c.d.e'::ltree ~ '*.!e';
select 'a.b.c.d.e'::ltree ~ '*.!e.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.!e.*';
select 'a.b.c.d.e'::ltree ~ 'a.*.!e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*.!e';
select 'a.b.c.d.e'::ltree ~ 'a.*.!d'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*.!d';
select 'a.b.c.d.e'::ltree ~ 'a.*.!d.*'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*.!d.*';
select 'a.b.c.d.e'::ltree ~ 'a.*.!f.*'; SELECT 'a.b.c.d.e'::ltree ~ 'a.*.!f.*';
select 'a.b.c.d.e'::ltree ~ '*.a.*.!f.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.a.*.!f.*';
select 'a.b.c.d.e'::ltree ~ '*.a.*.!d.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.a.*.!d.*';
select 'a.b.c.d.e'::ltree ~ '*.a.!d.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.a.!d.*';
select 'a.b.c.d.e'::ltree ~ '*.a.!d'; SELECT 'a.b.c.d.e'::ltree ~ '*.a.!d';
select 'a.b.c.d.e'::ltree ~ 'a.!d.*'; SELECT 'a.b.c.d.e'::ltree ~ 'a.!d.*';
select 'a.b.c.d.e'::ltree ~ '*.a.*.!d.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.a.*.!d.*';
select 'a.b.c.d.e'::ltree ~ '*.!b.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.!b.*';
select 'a.b.c.d.e'::ltree ~ '*.!b.c.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.!b.c.*';
select 'a.b.c.d.e'::ltree ~ '*.!b.*.c.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.!b.*.c.*';
select 'a.b.c.d.e'::ltree ~ '!b.*.c.*'; SELECT 'a.b.c.d.e'::ltree ~ '!b.*.c.*';
select 'a.b.c.d.e'::ltree ~ '!b.b.*'; SELECT 'a.b.c.d.e'::ltree ~ '!b.b.*';
select 'a.b.c.d.e'::ltree ~ '!b.*.e'; SELECT 'a.b.c.d.e'::ltree ~ '!b.*.e';
select 'a.b.c.d.e'::ltree ~ '!b.!c.*.e'; SELECT 'a.b.c.d.e'::ltree ~ '!b.!c.*.e';
select 'a.b.c.d.e'::ltree ~ '!b.*.!c.*.e'; SELECT 'a.b.c.d.e'::ltree ~ '!b.*.!c.*.e';
select 'a.b.c.d.e'::ltree ~ '*{2}.!b.*.!c.*.e'; SELECT 'a.b.c.d.e'::ltree ~ '*{2}.!b.*.!c.*.e';
select 'a.b.c.d.e'::ltree ~ '*{1}.!b.*.!c.*.e'; SELECT 'a.b.c.d.e'::ltree ~ '*{1}.!b.*.!c.*.e';
select 'a.b.c.d.e'::ltree ~ '*{1}.!b.*{1}.!c.*.e'; SELECT 'a.b.c.d.e'::ltree ~ '*{1}.!b.*{1}.!c.*.e';
select 'a.b.c.d.e'::ltree ~ 'a.!b.*{1}.!c.*.e'; SELECT 'a.b.c.d.e'::ltree ~ 'a.!b.*{1}.!c.*.e';
select 'a.b.c.d.e'::ltree ~ '!b.*{1}.!c.*.e'; SELECT 'a.b.c.d.e'::ltree ~ '!b.*{1}.!c.*.e';
select 'a.b.c.d.e'::ltree ~ '*.!b.*{1}.!c.*.e'; SELECT 'a.b.c.d.e'::ltree ~ '*.!b.*{1}.!c.*.e';
select 'a.b.c.d.e'::ltree ~ '*.!b.*.!c.*.e'; SELECT 'a.b.c.d.e'::ltree ~ '*.!b.*.!c.*.e';
select 'a.b.c.d.e'::ltree ~ '!b.!c.*'; SELECT 'a.b.c.d.e'::ltree ~ '!b.!c.*';
select 'a.b.c.d.e'::ltree ~ '!b.*.!c.*'; SELECT 'a.b.c.d.e'::ltree ~ '!b.*.!c.*';
select 'a.b.c.d.e'::ltree ~ '*{2}.!b.*.!c.*'; SELECT 'a.b.c.d.e'::ltree ~ '*{2}.!b.*.!c.*';
select 'a.b.c.d.e'::ltree ~ '*{1}.!b.*.!c.*'; SELECT 'a.b.c.d.e'::ltree ~ '*{1}.!b.*.!c.*';
select 'a.b.c.d.e'::ltree ~ '*{1}.!b.*{1}.!c.*'; SELECT 'a.b.c.d.e'::ltree ~ '*{1}.!b.*{1}.!c.*';
select 'a.b.c.d.e'::ltree ~ 'a.!b.*{1}.!c.*'; SELECT 'a.b.c.d.e'::ltree ~ 'a.!b.*{1}.!c.*';
select 'a.b.c.d.e'::ltree ~ '!b.*{1}.!c.*'; SELECT 'a.b.c.d.e'::ltree ~ '!b.*{1}.!c.*';
select 'a.b.c.d.e'::ltree ~ '*.!b.*{1}.!c.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.!b.*{1}.!c.*';
select 'a.b.c.d.e'::ltree ~ '*.!b.*.!c.*'; SELECT 'a.b.c.d.e'::ltree ~ '*.!b.*.!c.*';
select 'QWER_TY'::ltree ~ 'q%@*'; SELECT 'QWER_TY'::ltree ~ 'q%@*';
select 'QWER_TY'::ltree ~ 'Q_t%@*'; SELECT 'QWER_TY'::ltree ~ 'Q_t%@*';
select 'QWER_GY'::ltree ~ 'q_t%@*'; SELECT 'QWER_GY'::ltree ~ 'q_t%@*';
--ltxtquery --ltxtquery
select '!tree & aWdf@*'::ltxtquery; SELECT '!tree & aWdf@*'::ltxtquery;
select 'tree & aw_qw%*'::ltxtquery; SELECT 'tree & aw_qw%*'::ltxtquery;
select 'ltree.awdfg'::ltree @ '!tree & aWdf@*'::ltxtquery; SELECT 'ltree.awdfg'::ltree @ '!tree & aWdf@*'::ltxtquery;
select 'tree.awdfg'::ltree @ '!tree & aWdf@*'::ltxtquery; SELECT 'tree.awdfg'::ltree @ '!tree & aWdf@*'::ltxtquery;
select 'tree.awdfg'::ltree @ '!tree | aWdf@*'::ltxtquery; SELECT 'tree.awdfg'::ltree @ '!tree | aWdf@*'::ltxtquery;
select 'tree.awdfg'::ltree @ 'tree | aWdf@*'::ltxtquery; SELECT 'tree.awdfg'::ltree @ 'tree | aWdf@*'::ltxtquery;
select 'tree.awdfg'::ltree @ 'tree & aWdf@*'::ltxtquery; SELECT 'tree.awdfg'::ltree @ 'tree & aWdf@*'::ltxtquery;
select 'tree.awdfg'::ltree @ 'tree & aWdf@'::ltxtquery; SELECT 'tree.awdfg'::ltree @ 'tree & aWdf@'::ltxtquery;
select 'tree.awdfg'::ltree @ 'tree & aWdf*'::ltxtquery; SELECT 'tree.awdfg'::ltree @ 'tree & aWdf*'::ltxtquery;
select 'tree.awdfg'::ltree @ 'tree & aWdf'::ltxtquery; SELECT 'tree.awdfg'::ltree @ 'tree & aWdf'::ltxtquery;
select 'tree.awdfg'::ltree @ 'tree & awdf*'::ltxtquery; SELECT 'tree.awdfg'::ltree @ 'tree & awdf*'::ltxtquery;
select 'tree.awdfg'::ltree @ 'tree & aWdfg@'::ltxtquery; SELECT 'tree.awdfg'::ltree @ 'tree & aWdfg@'::ltxtquery;
select 'tree.awdfg_qwerty'::ltree @ 'tree & aw_qw%*'::ltxtquery; SELECT 'tree.awdfg_qwerty'::ltree @ 'tree & aw_qw%*'::ltxtquery;
select 'tree.awdfg_qwerty'::ltree @ 'tree & aw_rw%*'::ltxtquery; SELECT 'tree.awdfg_qwerty'::ltree @ 'tree & aw_rw%*'::ltxtquery;
--arrays --arrays
select '{1.2.3}'::ltree[] @> '1.2.3.4'; SELECT '{1.2.3}'::ltree[] @> '1.2.3.4';
select '{1.2.3.4}'::ltree[] @> '1.2.3.4'; SELECT '{1.2.3.4}'::ltree[] @> '1.2.3.4';
select '{1.2.3.4.5}'::ltree[] @> '1.2.3.4'; SELECT '{1.2.3.4.5}'::ltree[] @> '1.2.3.4';
select '{1.3.3}'::ltree[] @> '1.2.3.4'; SELECT '{1.3.3}'::ltree[] @> '1.2.3.4';
select '{5.67.8, 1.2.3}'::ltree[] @> '1.2.3.4'; SELECT '{5.67.8, 1.2.3}'::ltree[] @> '1.2.3.4';
select '{5.67.8, 1.2.3.4}'::ltree[] @> '1.2.3.4'; SELECT '{5.67.8, 1.2.3.4}'::ltree[] @> '1.2.3.4';
select '{5.67.8, 1.2.3.4.5}'::ltree[] @> '1.2.3.4'; SELECT '{5.67.8, 1.2.3.4.5}'::ltree[] @> '1.2.3.4';
select '{5.67.8, 1.3.3}'::ltree[] @> '1.2.3.4'; SELECT '{5.67.8, 1.3.3}'::ltree[] @> '1.2.3.4';
select '{1.2.3, 7.12.asd}'::ltree[] @> '1.2.3.4'; SELECT '{1.2.3, 7.12.asd}'::ltree[] @> '1.2.3.4';
select '{1.2.3.4, 7.12.asd}'::ltree[] @> '1.2.3.4'; SELECT '{1.2.3.4, 7.12.asd}'::ltree[] @> '1.2.3.4';
select '{1.2.3.4.5, 7.12.asd}'::ltree[] @> '1.2.3.4'; SELECT '{1.2.3.4.5, 7.12.asd}'::ltree[] @> '1.2.3.4';
select '{1.3.3, 7.12.asd}'::ltree[] @> '1.2.3.4'; SELECT '{1.3.3, 7.12.asd}'::ltree[] @> '1.2.3.4';
select '{ltree.asd, tree.awdfg}'::ltree[] @ 'tree & aWdfg@'::ltxtquery; SELECT '{ltree.asd, tree.awdfg}'::ltree[] @ 'tree & aWdfg@'::ltxtquery;
select '{j.k.l.m, g.b.c.d.e}'::ltree[] ~ 'A*@|g.b.c.d.e'; SELECT '{j.k.l.m, g.b.c.d.e}'::ltree[] ~ 'A*@|g.b.c.d.e';
--exractors --exractors
select ('{3456,1.2.3.34}'::ltree[] ?@> '1.2.3.4') is null; SELECT ('{3456,1.2.3.34}'::ltree[] ?@> '1.2.3.4') is null;
select '{3456,1.2.3}'::ltree[] ?@> '1.2.3.4'; SELECT '{3456,1.2.3}'::ltree[] ?@> '1.2.3.4';
select '{3456,1.2.3.4}'::ltree[] ?<@ '1.2.3'; SELECT '{3456,1.2.3.4}'::ltree[] ?<@ '1.2.3';
select ('{3456,1.2.3.4}'::ltree[] ?<@ '1.2.5') is null; SELECT ('{3456,1.2.3.4}'::ltree[] ?<@ '1.2.5') is null;
select '{ltree.asd, tree.awdfg}'::ltree[] ?@ 'tree & aWdfg@'::ltxtquery; SELECT '{ltree.asd, tree.awdfg}'::ltree[] ?@ 'tree & aWdfg@'::ltxtquery;
select '{j.k.l.m, g.b.c.d.e}'::ltree[] ?~ 'A*@|g.b.c.d.e'; SELECT '{j.k.l.m, g.b.c.d.e}'::ltree[] ?~ 'A*@|g.b.c.d.e';
create table ltreetest (t ltree); CREATE TABLE ltreetest (t ltree);
\copy ltreetest from 'data/ltree.data' \copy ltreetest FROM 'data/ltree.data'
select * from ltreetest where t < '12.3' order by t asc; SELECT * FROM ltreetest WHERE t < '12.3' order by t asc;
select * from ltreetest where t <= '12.3' order by t asc; SELECT * FROM ltreetest WHERE t <= '12.3' order by t asc;
select * from ltreetest where t = '12.3' order by t asc; SELECT * FROM ltreetest WHERE t = '12.3' order by t asc;
select * from ltreetest where t >= '12.3' order by t asc; SELECT * FROM ltreetest WHERE t >= '12.3' order by t asc;
select * from ltreetest where t > '12.3' order by t asc; SELECT * FROM ltreetest WHERE t > '12.3' order by t asc;
select * from ltreetest where t @> '1.1.1' order by t asc; SELECT * FROM ltreetest WHERE t @> '1.1.1' order by t asc;
select * from ltreetest where t <@ '1.1.1' order by t asc; SELECT * FROM ltreetest WHERE t <@ '1.1.1' order by t asc;
select * from ltreetest where t ~ '1.1.1.*' order by t asc; SELECT * FROM ltreetest WHERE t ~ '1.1.1.*' order by t asc;
select * from ltreetest where t ~ '*.1' order by t asc; SELECT * FROM ltreetest WHERE t ~ '*.1' order by t asc;
select * from ltreetest where t ~ '23.*.1' order by t asc; SELECT * FROM ltreetest WHERE t ~ '23.*.1' order by t asc;
select * from ltreetest where t ~ '23.*{1}.1' order by t asc; SELECT * FROM ltreetest WHERE t ~ '23.*{1}.1' order by t asc;
select * from ltreetest where t @ '23 & 1' order by t asc; SELECT * FROM ltreetest WHERE t @ '23 & 1' order by t asc;
create unique index tstidx on ltreetest (t); create unique index tstidx on ltreetest (t);
set enable_seqscan=off; set enable_seqscan=off;
select * from ltreetest where t < '12.3' order by t asc; SELECT * FROM ltreetest WHERE t < '12.3' order by t asc;
select * from ltreetest where t <= '12.3' order by t asc; SELECT * FROM ltreetest WHERE t <= '12.3' order by t asc;
select * from ltreetest where t = '12.3' order by t asc; SELECT * FROM ltreetest WHERE t = '12.3' order by t asc;
select * from ltreetest where t >= '12.3' order by t asc; SELECT * FROM ltreetest WHERE t >= '12.3' order by t asc;
select * from ltreetest where t > '12.3' order by t asc; SELECT * FROM ltreetest WHERE t > '12.3' order by t asc;
drop index tstidx; drop index tstidx;
create index tstidx on ltreetest using gist (t); create index tstidx on ltreetest using gist (t);
set enable_seqscan=off; set enable_seqscan=off;
select * from ltreetest where t < '12.3' order by t asc; SELECT * FROM ltreetest WHERE t < '12.3' order by t asc;
select * from ltreetest where t <= '12.3' order by t asc; SELECT * FROM ltreetest WHERE t <= '12.3' order by t asc;
select * from ltreetest where t = '12.3' order by t asc; SELECT * FROM ltreetest WHERE t = '12.3' order by t asc;
select * from ltreetest where t >= '12.3' order by t asc; SELECT * FROM ltreetest WHERE t >= '12.3' order by t asc;
select * from ltreetest where t > '12.3' order by t asc; SELECT * FROM ltreetest WHERE t > '12.3' order by t asc;
select * from ltreetest where t @> '1.1.1' order by t asc; SELECT * FROM ltreetest WHERE t @> '1.1.1' order by t asc;
select * from ltreetest where t <@ '1.1.1' order by t asc; SELECT * FROM ltreetest WHERE t <@ '1.1.1' order by t asc;
select * from ltreetest where t ~ '1.1.1.*' order by t asc; SELECT * FROM ltreetest WHERE t ~ '1.1.1.*' order by t asc;
select * from ltreetest where t ~ '*.1' order by t asc; SELECT * FROM ltreetest WHERE t ~ '*.1' order by t asc;
select * from ltreetest where t ~ '23.*.1' order by t asc; SELECT * FROM ltreetest WHERE t ~ '23.*.1' order by t asc;
select * from ltreetest where t ~ '23.*{1}.1' order by t asc; SELECT * FROM ltreetest WHERE t ~ '23.*{1}.1' order by t asc;
select * from ltreetest where t @ '23 & 1' order by t asc; SELECT * FROM ltreetest WHERE t @ '23 & 1' order by t asc;
create table _ltreetest (t ltree[]); create table _ltreetest (t ltree[]);
\copy _ltreetest from 'data/_ltree.data' \copy _ltreetest FROM 'data/_ltree.data'
select count(*) from _ltreetest where t @> '1.1.1' ; SELECT count(*) FROM _ltreetest WHERE t @> '1.1.1' ;
select count(*) from _ltreetest where t <@ '1.1.1' ; SELECT count(*) FROM _ltreetest WHERE t <@ '1.1.1' ;
select count(*) from _ltreetest where t ~ '1.1.1.*' ; SELECT count(*) FROM _ltreetest WHERE t ~ '1.1.1.*' ;
select count(*) from _ltreetest where t ~ '*.1' ; SELECT count(*) FROM _ltreetest WHERE t ~ '*.1' ;
select count(*) from _ltreetest where t ~ '23.*.1' ; SELECT count(*) FROM _ltreetest WHERE t ~ '23.*.1' ;
select count(*) from _ltreetest where t ~ '23.*{1}.1' ; SELECT count(*) FROM _ltreetest WHERE t ~ '23.*{1}.1' ;
select count(*) from _ltreetest where t @ '23 & 1' ; SELECT count(*) FROM _ltreetest WHERE t @ '23 & 1' ;
create index _tstidx on _ltreetest using gist (t); create index _tstidx on _ltreetest using gist (t);
set enable_seqscan=off; set enable_seqscan=off;
select count(*) from _ltreetest where t @> '1.1.1' ; SELECT count(*) FROM _ltreetest WHERE t @> '1.1.1' ;
select count(*) from _ltreetest where t <@ '1.1.1' ; SELECT count(*) FROM _ltreetest WHERE t <@ '1.1.1' ;
select count(*) from _ltreetest where t ~ '1.1.1.*' ; SELECT count(*) FROM _ltreetest WHERE t ~ '1.1.1.*' ;
select count(*) from _ltreetest where t ~ '*.1' ; SELECT count(*) FROM _ltreetest WHERE t ~ '*.1' ;
select count(*) from _ltreetest where t ~ '23.*.1' ; SELECT count(*) FROM _ltreetest WHERE t ~ '23.*.1' ;
select count(*) from _ltreetest where t ~ '23.*{1}.1' ; SELECT count(*) FROM _ltreetest WHERE t ~ '23.*{1}.1' ;
select count(*) from _ltreetest where t @ '23 & 1' ; SELECT count(*) FROM _ltreetest WHERE t @ '23 & 1' ;
...@@ -9,38 +9,48 @@ ...@@ -9,38 +9,48 @@
-- Return the pid of the backend. -- Return the pid of the backend.
-- --
create function backend_pid() returns int4
as 'MODULE_PATHNAME' -- Adjust this setting to control where the objects get created.
language 'C'; SET search_path = public;
SET autocommit TO 'on';
CREATE OR REPLACE FUNCTION backend_pid()
RETURNS int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- Unlisten from a relation. -- Unlisten from a relation.
-- --
create function "unlisten"(name) returns int4 CREATE OR REPLACE FUNCTION "unlisten"(name)
as 'MODULE_PATHNAME' RETURNS int4
language 'C'; AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- Unlisten from all relations for this backend. -- Unlisten from all relations for this backend.
-- --
create function "unlisten"() returns int4 CREATE OR REPLACE FUNCTION "unlisten"()
as 'select "unlisten"(''*'')' RETURNS int4
language 'sql'; AS 'SELECT "unlisten"(''*'')'
LANGUAGE 'SQL';
-- min(x,y) -- min(x,y)
-- --
create function min(int4,int4) returns int4 CREATE OR REPLACE FUNCTION min(int4,int4)
as 'MODULE_PATHNAME' RETURNS int4
language 'C'; AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- max(x,y) -- max(x,y)
-- --
create function max(int4,int4) returns int4 CREATE OR REPLACE FUNCTION max(int4,int4)
as 'MODULE_PATHNAME' RETURNS int4
language 'C'; AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- Return the number of active listeners on a relation -- Return the number of active listeners on a relation
-- --
create function active_listeners(text) returns int4 CREATE OR REPLACE FUNCTION active_listeners(text)
as 'MODULE_PATHNAME' RETURNS int4
language 'C'; AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- end of file
DROP FUNCTION noup (); -- Adjust this setting to control where the objects get created.
SET search_path = public;
CREATE FUNCTION noup () SET autocommit TO 'on';
RETURNS trigger
AS 'MODULE_PATHNAME' CREATE OR REPLACE FUNCTION noup ()
LANGUAGE 'C'; RETURNS trigger
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
...@@ -245,6 +245,10 @@ sql_conn(const char *dbName, struct options * my_opts) ...@@ -245,6 +245,10 @@ sql_conn(const char *dbName, struct options * my_opts)
if (pgpass != NULL) if (pgpass != NULL)
free(pgpass); free(pgpass);
sql_exec(conn, "SET search_path = public;", 0);
sql_exec(conn, "SET autocommit TO 'on';", 0);
/* return the conn if good */ /* return the conn if good */
return conn; return conn;
} }
......
/* ------------------------------------------------------------------------- /* -------------------------------------------------------------------------
* pg_dumplo * pg_dumplo
* *
* $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/main.c,v 1.12 2002/09/05 21:01:16 tgl Exp $ * $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/main.c,v 1.13 2002/10/18 18:41:20 momjian Exp $
* *
* Karel Zak 1999-2000 * Karel Zak 1999-2000
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
...@@ -191,6 +191,10 @@ main(int argc, char **argv) ...@@ -191,6 +191,10 @@ main(int argc, char **argv)
if (pgLO->action != ACTION_SHOW) if (pgLO->action != ACTION_SHOW)
index_file(pgLO); index_file(pgLO);
PQexec(pgLO->conn, "SET search_path = public");
PQexec(pgLO->conn, "SET autocommit TO 'on'");
PQexec(pgLO->conn, "BEGIN"); PQexec(pgLO->conn, "BEGIN");
switch (pgLO->action) switch (pgLO->action)
......
/* /*
* $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.20 2002/10/07 05:10:02 ishii Exp $ * $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.21 2002/10/18 18:41:20 momjian Exp $
* *
* pgbench: a simple TPC-B like benchmark program for PostgreSQL * pgbench: a simple TPC-B like benchmark program for PostgreSQL
* written by Tatsuo Ishii * written by Tatsuo Ishii
...@@ -117,6 +117,7 @@ static PGconn * ...@@ -117,6 +117,7 @@ static PGconn *
doConnect() doConnect()
{ {
PGconn *con; PGconn *con;
PGresult *res;
con = PQsetdbLogin(pghost, pgport, pgoptions, pgtty, dbName, con = PQsetdbLogin(pghost, pgport, pgoptions, pgtty, dbName,
login, pwd); login, pwd);
...@@ -138,6 +139,22 @@ doConnect() ...@@ -138,6 +139,22 @@ doConnect()
return (NULL); return (NULL);
} }
res = PQexec(con, "SET search_path = public");
if (PQresultStatus(res) != PGRES_COMMAND_OK)
{
fprintf(stderr, "%s", PQerrorMessage(con));
exit(1);
}
PQclear(res);
res = PQexec(con, "SET autocommit TO 'on'");
if (PQresultStatus(res) != PGRES_COMMAND_OK)
{
fprintf(stderr, "%s", PQerrorMessage(con));
exit(1);
}
PQclear(res);
return (con); return (con);
} }
...@@ -499,6 +516,7 @@ init(void) ...@@ -499,6 +516,7 @@ init(void)
fprintf(stderr, "%s", PQerrorMessage(con)); fprintf(stderr, "%s", PQerrorMessage(con));
exit(1); exit(1);
} }
PQclear(res);
for (i = 0; i < nbranches * tps; i++) for (i = 0; i < nbranches * tps; i++)
{ {
...@@ -589,6 +607,7 @@ init(void) ...@@ -589,6 +607,7 @@ init(void)
fprintf(stderr, "%s", PQerrorMessage(con)); fprintf(stderr, "%s", PQerrorMessage(con));
exit(1); exit(1);
} }
PQclear(res);
#endif /* NOT_USED */ #endif /* NOT_USED */
} }
} }
...@@ -601,6 +620,7 @@ init(void) ...@@ -601,6 +620,7 @@ init(void)
fprintf(stderr, "%s", PQerrorMessage(con)); fprintf(stderr, "%s", PQerrorMessage(con));
exit(1); exit(1);
} }
PQclear(res);
fprintf(stderr, "done.\n"); fprintf(stderr, "done.\n");
PQfinish(con); PQfinish(con);
...@@ -833,6 +853,7 @@ main(int argc, char **argv) ...@@ -833,6 +853,7 @@ main(int argc, char **argv)
fprintf(stderr, "%s", PQerrorMessage(con)); fprintf(stderr, "%s", PQerrorMessage(con));
exit(1); exit(1);
} }
PQclear(res);
tps = atoi(PQgetvalue(res, 0, 0)); tps = atoi(PQgetvalue(res, 0, 0));
if (tps < 0) if (tps < 0)
{ {
......
-- --
-- Blowfish cipher -- Blowfish cipher
-- --
SET autocommit TO 'on';
-- some standard Blowfish testvalues -- some standard Blowfish testvalues
select encode(encrypt( SELECT encode(encrypt(
decode('0000000000000000', 'hex'), decode('0000000000000000', 'hex'),
decode('0000000000000000', 'hex'), decode('0000000000000000', 'hex'),
'bf-ecb/pad:none'), 'hex'); 'bf-ecb/pad:none'), 'hex');
...@@ -11,7 +12,7 @@ decode('0000000000000000', 'hex'), ...@@ -11,7 +12,7 @@ decode('0000000000000000', 'hex'),
4ef997456198dd78 4ef997456198dd78
(1 row) (1 row)
select encode(encrypt( SELECT encode(encrypt(
decode('ffffffffffffffff', 'hex'), decode('ffffffffffffffff', 'hex'),
decode('ffffffffffffffff', 'hex'), decode('ffffffffffffffff', 'hex'),
'bf-ecb/pad:none'), 'hex'); 'bf-ecb/pad:none'), 'hex');
...@@ -20,7 +21,7 @@ decode('ffffffffffffffff', 'hex'), ...@@ -20,7 +21,7 @@ decode('ffffffffffffffff', 'hex'),
51866fd5b85ecb8a 51866fd5b85ecb8a
(1 row) (1 row)
select encode(encrypt( SELECT encode(encrypt(
decode('1000000000000001', 'hex'), decode('1000000000000001', 'hex'),
decode('3000000000000000', 'hex'), decode('3000000000000000', 'hex'),
'bf-ecb/pad:none'), 'hex'); 'bf-ecb/pad:none'), 'hex');
...@@ -29,7 +30,7 @@ decode('3000000000000000', 'hex'), ...@@ -29,7 +30,7 @@ decode('3000000000000000', 'hex'),
7d856f9a613063f2 7d856f9a613063f2
(1 row) (1 row)
select encode(encrypt( SELECT encode(encrypt(
decode('1111111111111111', 'hex'), decode('1111111111111111', 'hex'),
decode('1111111111111111', 'hex'), decode('1111111111111111', 'hex'),
'bf-ecb/pad:none'), 'hex'); 'bf-ecb/pad:none'), 'hex');
...@@ -38,7 +39,7 @@ decode('1111111111111111', 'hex'), ...@@ -38,7 +39,7 @@ decode('1111111111111111', 'hex'),
2466dd878b963c9d 2466dd878b963c9d
(1 row) (1 row)
select encode(encrypt( SELECT encode(encrypt(
decode('0123456789abcdef', 'hex'), decode('0123456789abcdef', 'hex'),
decode('fedcba9876543210', 'hex'), decode('fedcba9876543210', 'hex'),
'bf-ecb/pad:none'), 'hex'); 'bf-ecb/pad:none'), 'hex');
...@@ -47,7 +48,7 @@ decode('fedcba9876543210', 'hex'), ...@@ -47,7 +48,7 @@ decode('fedcba9876543210', 'hex'),
0aceab0fc6a0a28d 0aceab0fc6a0a28d
(1 row) (1 row)
select encode(encrypt( SELECT encode(encrypt(
decode('01a1d6d039776742', 'hex'), decode('01a1d6d039776742', 'hex'),
decode('fedcba9876543210', 'hex'), decode('fedcba9876543210', 'hex'),
'bf-ecb/pad:none'), 'hex'); 'bf-ecb/pad:none'), 'hex');
...@@ -56,7 +57,7 @@ decode('fedcba9876543210', 'hex'), ...@@ -56,7 +57,7 @@ decode('fedcba9876543210', 'hex'),
3273b8badc9e9e15 3273b8badc9e9e15
(1 row) (1 row)
select encode(encrypt( SELECT encode(encrypt(
decode('ffffffffffffffff', 'hex'), decode('ffffffffffffffff', 'hex'),
decode('0000000000000000', 'hex'), decode('0000000000000000', 'hex'),
'bf-ecb/pad:none'), 'hex'); 'bf-ecb/pad:none'), 'hex');
...@@ -66,7 +67,7 @@ decode('0000000000000000', 'hex'), ...@@ -66,7 +67,7 @@ decode('0000000000000000', 'hex'),
(1 row) (1 row)
-- setkey -- setkey
select encode(encrypt( SELECT encode(encrypt(
decode('fedcba9876543210', 'hex'), decode('fedcba9876543210', 'hex'),
decode('f0e1d2c3b4a5968778695a4b3c2d1e0f', 'hex'), decode('f0e1d2c3b4a5968778695a4b3c2d1e0f', 'hex'),
'bf-ecb/pad:none'), 'hex'); 'bf-ecb/pad:none'), 'hex');
...@@ -76,7 +77,7 @@ decode('f0e1d2c3b4a5968778695a4b3c2d1e0f', 'hex'), ...@@ -76,7 +77,7 @@ decode('f0e1d2c3b4a5968778695a4b3c2d1e0f', 'hex'),
(1 row) (1 row)
-- with padding -- with padding
select encode(encrypt( SELECT encode(encrypt(
decode('01234567890123456789', 'hex'), decode('01234567890123456789', 'hex'),
decode('33443344334433443344334433443344', 'hex'), decode('33443344334433443344334433443344', 'hex'),
'bf-ecb'), 'hex'); 'bf-ecb'), 'hex');
...@@ -87,7 +88,7 @@ decode('33443344334433443344334433443344', 'hex'), ...@@ -87,7 +88,7 @@ decode('33443344334433443344334433443344', 'hex'),
-- cbc -- cbc
-- 28 bytes key -- 28 bytes key
select encode(encrypt( SELECT encode(encrypt(
decode('6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5', 'hex'), decode('6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5', 'hex'),
decode('37363534333231204e6f77206973207468652074696d6520666f7220', 'hex'), decode('37363534333231204e6f77206973207468652074696d6520666f7220', 'hex'),
'bf-cbc'), 'hex'); 'bf-cbc'), 'hex');
...@@ -97,7 +98,7 @@ decode('37363534333231204e6f77206973207468652074696d6520666f7220', 'hex'), ...@@ -97,7 +98,7 @@ decode('37363534333231204e6f77206973207468652074696d6520666f7220', 'hex'),
(1 row) (1 row)
-- 29 bytes key -- 29 bytes key
select encode(encrypt( SELECT encode(encrypt(
decode('6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5ff92cc', 'hex'), decode('6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5ff92cc', 'hex'),
decode('37363534333231204e6f77206973207468652074696d6520666f722000', 'hex'), decode('37363534333231204e6f77206973207468652074696d6520666f722000', 'hex'),
'bf-cbc'), 'hex'); 'bf-cbc'), 'hex');
......
-- --
-- crypt() and gen_salt(): bcrypt -- crypt() and gen_salt(): bcrypt
-- --
select crypt('', '$2a$06$RQiOJ.3ELirrXwxIZY8q0O'); SET autocommit TO 'on';
SELECT crypt('', '$2a$06$RQiOJ.3ELirrXwxIZY8q0O');
crypt crypt
-------------------------------------------------------------- --------------------------------------------------------------
$2a$06$RQiOJ.3ELirrXwxIZY8q0OlGbBEpDmx7IRZlNYvGJ1SHXwNi2cEKK $2a$06$RQiOJ.3ELirrXwxIZY8q0OlGbBEpDmx7IRZlNYvGJ1SHXwNi2cEKK
(1 row) (1 row)
select crypt('foox', '$2a$06$RQiOJ.3ELirrXwxIZY8q0O'); SELECT crypt('foox', '$2a$06$RQiOJ.3ELirrXwxIZY8q0O');
crypt crypt
-------------------------------------------------------------- --------------------------------------------------------------
$2a$06$RQiOJ.3ELirrXwxIZY8q0OR3CVJrAfda1z26CCHPnB6mmVZD8p0/C $2a$06$RQiOJ.3ELirrXwxIZY8q0OR3CVJrAfda1z26CCHPnB6mmVZD8p0/C
(1 row) (1 row)
create table ctest (data text, res text, salt text); CREATE TABLE ctest (data text, res text, salt text);
insert into ctest values ('password', '', ''); INSERT INTO ctest VALUES ('password', '', '');
update ctest set salt = gen_salt('bf', 8); UPDATE ctest SET salt = gen_salt('bf', 8);
update ctest set res = crypt(data, salt); UPDATE ctest SET res = crypt(data, salt);
select res = crypt(data, res) as "worked" from ctest; SELECT res = crypt(data, res) AS "worked"
FROM ctest;
worked worked
-------- --------
t t
(1 row) (1 row)
drop table ctest; DROP TABLE ctest;
-- --
-- crypt() and gen_salt(): crypt-des -- crypt() and gen_salt(): crypt-des
-- --
select crypt('', 'NB'); SET autocommit TO 'on';
SELECT crypt('', 'NB');
crypt crypt
--------------- ---------------
NBPx/38Y48kHg NBPx/38Y48kHg
(1 row) (1 row)
select crypt('foox', 'NB'); SELECT crypt('foox', 'NB');
crypt crypt
--------------- ---------------
NB53EGGqrrb5E NB53EGGqrrb5E
(1 row) (1 row)
create table ctest (data text, res text, salt text); CREATE TABLE ctest (data text, res text, salt text);
insert into ctest values ('password', '', ''); INSERT INTO ctest VALUES ('password', '', '');
update ctest set salt = gen_salt('des'); UPDATE ctest SET salt = gen_salt('des');
update ctest set res = crypt(data, salt); UPDATE ctest SET res = crypt(data, salt);
select res = crypt(data, res) as "worked" from ctest; SELECT res = crypt(data, res) AS "worked"
FROM ctest;
worked worked
-------- --------
t t
(1 row) (1 row)
drop table ctest; DROP TABLE ctest;
-- --
-- crypt() and gen_salt(): md5 -- crypt() and gen_salt(): md5
-- --
select crypt('', '$1$Szzz0yzz'); SET autocommit TO 'on';
SELECT crypt('', '$1$Szzz0yzz');
crypt crypt
------------------------------------ ------------------------------------
$1$Szzz0yzz$To38XrR3BsbXQW2ZpfKjF1 $1$Szzz0yzz$To38XrR3BsbXQW2ZpfKjF1
(1 row) (1 row)
select crypt('foox', '$1$Szzz0yzz'); SELECT crypt('foox', '$1$Szzz0yzz');
crypt crypt
------------------------------------ ------------------------------------
$1$Szzz0yzz$IYL49cd3t9bllsA7Jmz1M1 $1$Szzz0yzz$IYL49cd3t9bllsA7Jmz1M1
(1 row) (1 row)
create table ctest (data text, res text, salt text); CREATE TABLE ctest (data text, res text, salt text);
insert into ctest values ('password', '', ''); INSERT INTO ctest VALUES ('password', '', '');
update ctest set salt = gen_salt('md5'); UPDATE ctest SET salt = gen_salt('md5');
update ctest set res = crypt(data, salt); UPDATE ctest SET res = crypt(data, salt);
select res = crypt(data, res) as "worked" from ctest; SELECT res = crypt(data, res) AS "worked"
FROM ctest;
worked worked
-------- --------
t t
(1 row) (1 row)
drop table ctest; DROP TABLE ctest;
-- --
-- crypt() and gen_salt(): extended des -- crypt() and gen_salt(): extended des
-- --
select crypt('', '_J9..j2zz'); SET autocommit TO 'on';
SELECT crypt('', '_J9..j2zz');
crypt crypt
---------------------- ----------------------
_J9..j2zzR/nIRDK3pPc _J9..j2zzR/nIRDK3pPc
(1 row) (1 row)
select crypt('foox', '_J9..j2zz'); SELECT crypt('foox', '_J9..j2zz');
crypt crypt
---------------------- ----------------------
_J9..j2zzAYKMvO2BYRY _J9..j2zzAYKMvO2BYRY
(1 row) (1 row)
create table ctest (data text, res text, salt text); CREATE TABLE ctest (data text, res text, salt text);
insert into ctest values ('password', '', ''); INSERT INTO ctest VALUES ('password', '', '');
update ctest set salt = gen_salt('xdes', 1001); UPDATE ctest SET salt = gen_salt('xdes', 1001);
update ctest set res = crypt(data, salt); UPDATE ctest SET res = crypt(data, salt);
select res = crypt(data, res) as "worked" from ctest; SELECT res = crypt(data, res) AS "worked"
FROM ctest;
worked worked
-------- --------
t t
(1 row) (1 row)
drop table ctest; DROP TABLE ctest;
-- --
-- HMAC-MD5 -- HMAC-MD5
-- --
select encode(hmac( SET autocommit TO 'on';
SELECT encode(hmac(
'Hi There', 'Hi There',
decode('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'), decode('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'),
'md5'), 'hex'); 'md5'), 'hex');
...@@ -11,7 +12,7 @@ decode('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'), ...@@ -11,7 +12,7 @@ decode('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'),
(1 row) (1 row)
-- 2 -- 2
select encode(hmac( SELECT encode(hmac(
'Jefe', 'Jefe',
'what do ya want for nothing?', 'what do ya want for nothing?',
'md5'), 'hex'); 'md5'), 'hex');
...@@ -21,7 +22,7 @@ select encode(hmac( ...@@ -21,7 +22,7 @@ select encode(hmac(
(1 row) (1 row)
-- 3 -- 3
select encode(hmac( SELECT encode(hmac(
decode('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd', 'hex'), decode('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd', 'hex'),
decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'), decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
'md5'), 'hex'); 'md5'), 'hex');
...@@ -31,7 +32,7 @@ decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'), ...@@ -31,7 +32,7 @@ decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
(1 row) (1 row)
-- 4 -- 4
select encode(hmac( SELECT encode(hmac(
decode('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd', 'hex'), decode('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd', 'hex'),
decode('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'), decode('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'),
'md5'), 'hex'); 'md5'), 'hex');
...@@ -41,7 +42,7 @@ decode('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'), ...@@ -41,7 +42,7 @@ decode('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'),
(1 row) (1 row)
-- 5 -- 5
select encode(hmac( SELECT encode(hmac(
'Test With Truncation', 'Test With Truncation',
decode('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'), decode('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'),
'md5'), 'hex'); 'md5'), 'hex');
...@@ -51,7 +52,7 @@ decode('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'), ...@@ -51,7 +52,7 @@ decode('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'),
(1 row) (1 row)
-- 6 -- 6
select encode(hmac( SELECT encode(hmac(
'Test Using Larger Than Block-Size Key - Hash Key First', 'Test Using Larger Than Block-Size Key - Hash Key First',
decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'), decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
'md5'), 'hex'); 'md5'), 'hex');
...@@ -61,7 +62,7 @@ decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ...@@ -61,7 +62,7 @@ decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
(1 row) (1 row)
-- 7 -- 7
select encode(hmac( SELECT encode(hmac(
'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data', 'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data',
decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'), decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
'md5'), 'hex'); 'md5'), 'hex');
......
-- --
-- HMAC-MD5 -- HMAC-MD5
-- --
select encode(hmac( SET autocommit TO 'on';
SELECT encode(hmac(
'Hi There', 'Hi There',
decode('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'), decode('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'),
'sha1'), 'hex'); 'sha1'), 'hex');
...@@ -11,7 +12,7 @@ decode('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'), ...@@ -11,7 +12,7 @@ decode('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'),
(1 row) (1 row)
-- 2 -- 2
select encode(hmac( SELECT encode(hmac(
'Jefe', 'Jefe',
'what do ya want for nothing?', 'what do ya want for nothing?',
'sha1'), 'hex'); 'sha1'), 'hex');
...@@ -21,7 +22,7 @@ select encode(hmac( ...@@ -21,7 +22,7 @@ select encode(hmac(
(1 row) (1 row)
-- 3 -- 3
select encode(hmac( SELECT encode(hmac(
decode('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd', 'hex'), decode('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd', 'hex'),
decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'), decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
'sha1'), 'hex'); 'sha1'), 'hex');
...@@ -31,7 +32,7 @@ decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'), ...@@ -31,7 +32,7 @@ decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
(1 row) (1 row)
-- 4 -- 4
select encode(hmac( SELECT encode(hmac(
decode('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd', 'hex'), decode('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd', 'hex'),
decode('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'), decode('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'),
'sha1'), 'hex'); 'sha1'), 'hex');
...@@ -41,7 +42,7 @@ decode('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'), ...@@ -41,7 +42,7 @@ decode('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'),
(1 row) (1 row)
-- 5 -- 5
select encode(hmac( SELECT encode(hmac(
'Test With Truncation', 'Test With Truncation',
decode('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'), decode('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'),
'sha1'), 'hex'); 'sha1'), 'hex');
...@@ -51,7 +52,7 @@ decode('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'), ...@@ -51,7 +52,7 @@ decode('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'),
(1 row) (1 row)
-- 6 -- 6
select encode(hmac( SELECT encode(hmac(
'Test Using Larger Than Block-Size Key - Hash Key First', 'Test Using Larger Than Block-Size Key - Hash Key First',
decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'), decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
'sha1'), 'hex'); 'sha1'), 'hex');
...@@ -61,7 +62,7 @@ decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ...@@ -61,7 +62,7 @@ decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
(1 row) (1 row)
-- 7 -- 7
select encode(hmac( SELECT encode(hmac(
'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data', 'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data',
decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'), decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
'sha1'), 'hex'); 'sha1'), 'hex');
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
-- --
\set ECHO none \set ECHO none
-- check for encoding fn's -- check for encoding fn's
select encode('foo', 'hex'); SELECT encode('foo', 'hex');
encode encode
-------- --------
666f6f 666f6f
(1 row) (1 row)
select decode('666f6f', 'hex'); SELECT decode('666f6f', 'hex');
decode decode
-------- --------
foo foo
......
-- --
-- MD5 message digest -- MD5 message digest
-- --
select encode(digest('', 'md5'), 'hex'); SET autocommit TO 'on';
SELECT encode(digest('', 'md5'), 'hex');
encode encode
---------------------------------- ----------------------------------
d41d8cd98f00b204e9800998ecf8427e d41d8cd98f00b204e9800998ecf8427e
(1 row) (1 row)
select encode(digest('a', 'md5'), 'hex'); SELECT encode(digest('a', 'md5'), 'hex');
encode encode
---------------------------------- ----------------------------------
0cc175b9c0f1b6a831c399e269772661 0cc175b9c0f1b6a831c399e269772661
(1 row) (1 row)
select encode(digest('abc', 'md5'), 'hex'); SELECT encode(digest('abc', 'md5'), 'hex');
encode encode
---------------------------------- ----------------------------------
900150983cd24fb0d6963f7d28e17f72 900150983cd24fb0d6963f7d28e17f72
(1 row) (1 row)
select encode(digest('message digest', 'md5'), 'hex'); SELECT encode(digest('message digest', 'md5'), 'hex');
encode encode
---------------------------------- ----------------------------------
f96b697d7cb7938d525a2f31aaf161d0 f96b697d7cb7938d525a2f31aaf161d0
(1 row) (1 row)
select encode(digest('abcdefghijklmnopqrstuvwxyz', 'md5'), 'hex'); SELECT encode(digest('abcdefghijklmnopqrstuvwxyz', 'md5'), 'hex');
encode encode
---------------------------------- ----------------------------------
c3fcd3d76192e4007dfb496cca67e13b c3fcd3d76192e4007dfb496cca67e13b
(1 row) (1 row)
select encode(digest('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', 'md5'), 'hex'); SELECT encode(digest('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', 'md5'), 'hex');
encode encode
---------------------------------- ----------------------------------
d174ab98d277d9f5a5611c2c9f419d9f d174ab98d277d9f5a5611c2c9f419d9f
(1 row) (1 row)
select encode(digest('12345678901234567890123456789012345678901234567890123456789012345678901234567890', 'md5'), 'hex'); SELECT encode(digest('12345678901234567890123456789012345678901234567890123456789012345678901234567890', 'md5'), 'hex');
encode encode
---------------------------------- ----------------------------------
57edf4a22be3c955ac49da2e2107b67a 57edf4a22be3c955ac49da2e2107b67a
......
-- --
-- AES / Rijndael-128 cipher -- AES / Rijndael-128 cipher
-- --
SET autocommit TO 'on';
-- some standard Rijndael testvalues -- some standard Rijndael testvalues
select encode(encrypt( SELECT encode(encrypt(
decode('00112233445566778899aabbccddeeff', 'hex'), decode('00112233445566778899aabbccddeeff', 'hex'),
decode('000102030405060708090a0b0c0d0e0f', 'hex'), decode('000102030405060708090a0b0c0d0e0f', 'hex'),
'aes-ecb/pad:none'), 'hex'); 'aes-ecb/pad:none'), 'hex');
...@@ -11,7 +12,7 @@ decode('000102030405060708090a0b0c0d0e0f', 'hex'), ...@@ -11,7 +12,7 @@ decode('000102030405060708090a0b0c0d0e0f', 'hex'),
69c4e0d86a7b0430d8cdb78070b4c55a 69c4e0d86a7b0430d8cdb78070b4c55a
(1 row) (1 row)
select encode(encrypt( SELECT encode(encrypt(
decode('00112233445566778899aabbccddeeff', 'hex'), decode('00112233445566778899aabbccddeeff', 'hex'),
decode('000102030405060708090a0b0c0d0e0f1011121314151617', 'hex'), decode('000102030405060708090a0b0c0d0e0f1011121314151617', 'hex'),
'aes-ecb/pad:none'), 'hex'); 'aes-ecb/pad:none'), 'hex');
...@@ -20,7 +21,7 @@ decode('000102030405060708090a0b0c0d0e0f1011121314151617', 'hex'), ...@@ -20,7 +21,7 @@ decode('000102030405060708090a0b0c0d0e0f1011121314151617', 'hex'),
dda97ca4864cdfe06eaf70a0ec0d7191 dda97ca4864cdfe06eaf70a0ec0d7191
(1 row) (1 row)
select encode(encrypt( SELECT encode(encrypt(
decode('00112233445566778899aabbccddeeff', 'hex'), decode('00112233445566778899aabbccddeeff', 'hex'),
decode('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', 'hex'), decode('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', 'hex'),
'aes-ecb/pad:none'), 'hex'); 'aes-ecb/pad:none'), 'hex');
...@@ -30,7 +31,7 @@ decode('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', 'hex' ...@@ -30,7 +31,7 @@ decode('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', 'hex'
(1 row) (1 row)
-- cbc -- cbc
select encode(encrypt( SELECT encode(encrypt(
decode('00112233445566778899aabbccddeeff', 'hex'), decode('00112233445566778899aabbccddeeff', 'hex'),
decode('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', 'hex'), decode('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', 'hex'),
'aes-cbc/pad:none'), 'hex'); 'aes-cbc/pad:none'), 'hex');
...@@ -40,7 +41,7 @@ decode('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', 'hex' ...@@ -40,7 +41,7 @@ decode('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', 'hex'
(1 row) (1 row)
-- key padding -- key padding
select encode(encrypt( SELECT encode(encrypt(
decode('0011223344', 'hex'), decode('0011223344', 'hex'),
decode('000102030405', 'hex'), decode('000102030405', 'hex'),
'aes-cbc'), 'hex'); 'aes-cbc'), 'hex');
...@@ -49,7 +50,7 @@ decode('000102030405', 'hex'), ...@@ -49,7 +50,7 @@ decode('000102030405', 'hex'),
189a28932213f017b246678dbc28655f 189a28932213f017b246678dbc28655f
(1 row) (1 row)
select encode(encrypt( SELECT encode(encrypt(
decode('0011223344', 'hex'), decode('0011223344', 'hex'),
decode('000102030405060708090a0b0c0d0e0f10111213', 'hex'), decode('000102030405060708090a0b0c0d0e0f10111213', 'hex'),
'aes-cbc'), 'hex'); 'aes-cbc'), 'hex');
...@@ -58,7 +59,7 @@ decode('000102030405060708090a0b0c0d0e0f10111213', 'hex'), ...@@ -58,7 +59,7 @@ decode('000102030405060708090a0b0c0d0e0f10111213', 'hex'),
3b02279162d15580e069d3a71407a556 3b02279162d15580e069d3a71407a556
(1 row) (1 row)
select encode(encrypt( SELECT encode(encrypt(
decode('0011223344', 'hex'), decode('0011223344', 'hex'),
decode('000102030405060708090a0b0c0d0e0f101112131415161718191a1b', 'hex'), decode('000102030405060708090a0b0c0d0e0f101112131415161718191a1b', 'hex'),
'aes-cbc'), 'hex'); 'aes-cbc'), 'hex');
......
-- --
-- SHA1 message digest -- SHA1 message digest
-- --
select encode(digest('', 'sha1'), 'hex'); SET autocommit TO 'on';
SELECT encode(digest('', 'sha1'), 'hex');
encode encode
------------------------------------------ ------------------------------------------
da39a3ee5e6b4b0d3255bfef95601890afd80709 da39a3ee5e6b4b0d3255bfef95601890afd80709
(1 row) (1 row)
select encode(digest('a', 'sha1'), 'hex'); SELECT encode(digest('a', 'sha1'), 'hex');
encode encode
------------------------------------------ ------------------------------------------
86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 86f7e437faa5a7fce15d1ddcb9eaeaea377667b8
(1 row) (1 row)
select encode(digest('abc', 'sha1'), 'hex'); SELECT encode(digest('abc', 'sha1'), 'hex');
encode encode
------------------------------------------ ------------------------------------------
a9993e364706816aba3e25717850c26c9cd0d89d a9993e364706816aba3e25717850c26c9cd0d89d
(1 row) (1 row)
select encode(digest('message digest', 'sha1'), 'hex'); SELECT encode(digest('message digest', 'sha1'), 'hex');
encode encode
------------------------------------------ ------------------------------------------
c12252ceda8be8994d5fa0290a47231c1d16aae3 c12252ceda8be8994d5fa0290a47231c1d16aae3
(1 row) (1 row)
select encode(digest('abcdefghijklmnopqrstuvwxyz', 'sha1'), 'hex'); SELECT encode(digest('abcdefghijklmnopqrstuvwxyz', 'sha1'), 'hex');
encode encode
------------------------------------------ ------------------------------------------
32d10c7b8cf96570ca04ce37f2a19d84240d3a89 32d10c7b8cf96570ca04ce37f2a19d84240d3a89
(1 row) (1 row)
select encode(digest('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', 'sha1'), 'hex'); SELECT encode(digest('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', 'sha1'), 'hex');
encode encode
------------------------------------------ ------------------------------------------
761c457bf73b14d27e9e9265c46f4b4dda11f940 761c457bf73b14d27e9e9265c46f4b4dda11f940
(1 row) (1 row)
select encode(digest('12345678901234567890123456789012345678901234567890123456789012345678901234567890', 'sha1'), 'hex'); SELECT encode(digest('12345678901234567890123456789012345678901234567890123456789012345678901234567890', 'sha1'), 'hex');
encode encode
------------------------------------------ ------------------------------------------
50abf5706a150990a08b2c5ea40fa0e585554732 50abf5706a150990a08b2c5ea40fa0e585554732
......
-- Adjust this setting to control where the objects get created.
-- drop function digest(text, text); SET search_path = public;
-- drop function digest(bytea, text);
-- drop function digest_exists(text); SET autocommit TO 'on';
-- drop function hmac(text, text, text);
-- drop function hmac(bytea, bytea, text); CREATE OR REPLACE FUNCTION digest(text, text)
-- drop function hmac_exists(text); RETURNS bytea
-- drop function crypt(text, text); AS 'MODULE_PATHNAME', 'pg_digest'
-- drop function gen_salt(text); LANGUAGE 'C';
-- drop function gen_salt(text, int4);
-- drop function encrypt(bytea, bytea, text); CREATE OR REPLACE FUNCTION digest(bytea, text)
-- drop function decrypt(bytea, bytea, text); RETURNS bytea
-- drop function encrypt_iv(bytea, bytea, bytea, text); AS 'MODULE_PATHNAME', 'pg_digest'
-- drop function decrypt_iv(bytea, bytea, bytea, text); LANGUAGE 'C';
-- drop function cipher_exists(text);
CREATE OR REPLACE FUNCTION digest_exists(text)
RETURNS bool
AS 'MODULE_PATHNAME', 'pg_digest_exists'
CREATE FUNCTION digest(text, text) RETURNS bytea LANGUAGE 'C';
AS 'MODULE_PATHNAME',
'pg_digest' LANGUAGE 'C'; CREATE OR REPLACE FUNCTION hmac(text, text, text)
RETURNS bytea
CREATE FUNCTION digest(bytea, text) RETURNS bytea AS 'MODULE_PATHNAME', 'pg_hmac'
AS 'MODULE_PATHNAME', LANGUAGE 'C';
'pg_digest' LANGUAGE 'C';
CREATE OR REPLACE FUNCTION hmac(bytea, bytea, text)
CREATE FUNCTION digest_exists(text) RETURNS bool RETURNS bytea
AS 'MODULE_PATHNAME', AS 'MODULE_PATHNAME', 'pg_hmac'
'pg_digest_exists' LANGUAGE 'C'; LANGUAGE 'C';
CREATE FUNCTION hmac(text, text, text) RETURNS bytea CREATE OR REPLACE FUNCTION hmac_exists(text)
AS 'MODULE_PATHNAME', RETURNS bool
'pg_hmac' LANGUAGE 'C'; AS 'MODULE_PATHNAME', 'pg_hmac_exists'
LANGUAGE 'C';
CREATE FUNCTION hmac(bytea, bytea, text) RETURNS bytea
AS 'MODULE_PATHNAME', CREATE OR REPLACE FUNCTION crypt(text, text)
'pg_hmac' LANGUAGE 'C'; RETURNS text
AS 'MODULE_PATHNAME', 'pg_crypt'
CREATE FUNCTION hmac_exists(text) RETURNS bool LANGUAGE 'C';
AS 'MODULE_PATHNAME',
'pg_hmac_exists' LANGUAGE 'C'; CREATE OR REPLACE FUNCTION gen_salt(text)
RETURNS text
CREATE FUNCTION crypt(text, text) RETURNS text AS 'MODULE_PATHNAME', 'pg_gen_salt'
AS 'MODULE_PATHNAME', LANGUAGE 'C';
'pg_crypt' LANGUAGE 'C';
CREATE OR REPLACE FUNCTION gen_salt(text, int4)
CREATE FUNCTION gen_salt(text) RETURNS text RETURNS text
AS 'MODULE_PATHNAME', AS 'MODULE_PATHNAME', 'pg_gen_salt_rounds'
'pg_gen_salt' LANGUAGE 'C'; LANGUAGE 'C';
CREATE FUNCTION gen_salt(text, int4) RETURNS text CREATE OR REPLACE FUNCTION encrypt(bytea, bytea, text)
AS 'MODULE_PATHNAME', RETURNS bytea
'pg_gen_salt_rounds' LANGUAGE 'C'; AS 'MODULE_PATHNAME', 'pg_encrypt'
LANGUAGE 'C';
CREATE FUNCTION encrypt(bytea, bytea, text) RETURNS bytea
AS 'MODULE_PATHNAME', CREATE OR REPLACE FUNCTION decrypt(bytea, bytea, text)
'pg_encrypt' LANGUAGE 'C'; RETURNS bytea
AS 'MODULE_PATHNAME', 'pg_decrypt'
CREATE FUNCTION decrypt(bytea, bytea, text) RETURNS bytea LANGUAGE 'C';
AS 'MODULE_PATHNAME',
'pg_decrypt' LANGUAGE 'C'; CREATE OR REPLACE FUNCTION encrypt_iv(bytea, bytea, bytea, text)
RETURNS bytea
CREATE FUNCTION encrypt_iv(bytea, bytea, bytea, text) RETURNS bytea AS 'MODULE_PATHNAME', 'pg_encrypt_iv'
AS 'MODULE_PATHNAME', LANGUAGE 'C';
'pg_encrypt_iv' LANGUAGE 'C';
CREATE OR REPLACE FUNCTION decrypt_iv(bytea, bytea, bytea, text)
CREATE FUNCTION decrypt_iv(bytea, bytea, bytea, text) RETURNS bytea RETURNS bytea
AS 'MODULE_PATHNAME', AS 'MODULE_PATHNAME', 'pg_decrypt_iv'
'pg_decrypt_iv' LANGUAGE 'C'; LANGUAGE 'C';
CREATE FUNCTION cipher_exists(text) RETURNS bool CREATE OR REPLACE FUNCTION cipher_exists(text)
AS 'MODULE_PATHNAME', RETURNS bool
'pg_cipher_exists' LANGUAGE 'C'; AS 'MODULE_PATHNAME', 'pg_cipher_exists'
LANGUAGE 'C';
...@@ -2,50 +2,52 @@ ...@@ -2,50 +2,52 @@
-- Blowfish cipher -- Blowfish cipher
-- --
SET autocommit TO 'on';
-- some standard Blowfish testvalues -- some standard Blowfish testvalues
select encode(encrypt( SELECT encode(encrypt(
decode('0000000000000000', 'hex'), decode('0000000000000000', 'hex'),
decode('0000000000000000', 'hex'), decode('0000000000000000', 'hex'),
'bf-ecb/pad:none'), 'hex'); 'bf-ecb/pad:none'), 'hex');
select encode(encrypt( SELECT encode(encrypt(
decode('ffffffffffffffff', 'hex'), decode('ffffffffffffffff', 'hex'),
decode('ffffffffffffffff', 'hex'), decode('ffffffffffffffff', 'hex'),
'bf-ecb/pad:none'), 'hex'); 'bf-ecb/pad:none'), 'hex');
select encode(encrypt( SELECT encode(encrypt(
decode('1000000000000001', 'hex'), decode('1000000000000001', 'hex'),
decode('3000000000000000', 'hex'), decode('3000000000000000', 'hex'),
'bf-ecb/pad:none'), 'hex'); 'bf-ecb/pad:none'), 'hex');
select encode(encrypt( SELECT encode(encrypt(
decode('1111111111111111', 'hex'), decode('1111111111111111', 'hex'),
decode('1111111111111111', 'hex'), decode('1111111111111111', 'hex'),
'bf-ecb/pad:none'), 'hex'); 'bf-ecb/pad:none'), 'hex');
select encode(encrypt( SELECT encode(encrypt(
decode('0123456789abcdef', 'hex'), decode('0123456789abcdef', 'hex'),
decode('fedcba9876543210', 'hex'), decode('fedcba9876543210', 'hex'),
'bf-ecb/pad:none'), 'hex'); 'bf-ecb/pad:none'), 'hex');
select encode(encrypt( SELECT encode(encrypt(
decode('01a1d6d039776742', 'hex'), decode('01a1d6d039776742', 'hex'),
decode('fedcba9876543210', 'hex'), decode('fedcba9876543210', 'hex'),
'bf-ecb/pad:none'), 'hex'); 'bf-ecb/pad:none'), 'hex');
select encode(encrypt( SELECT encode(encrypt(
decode('ffffffffffffffff', 'hex'), decode('ffffffffffffffff', 'hex'),
decode('0000000000000000', 'hex'), decode('0000000000000000', 'hex'),
'bf-ecb/pad:none'), 'hex'); 'bf-ecb/pad:none'), 'hex');
-- setkey -- setkey
select encode(encrypt( SELECT encode(encrypt(
decode('fedcba9876543210', 'hex'), decode('fedcba9876543210', 'hex'),
decode('f0e1d2c3b4a5968778695a4b3c2d1e0f', 'hex'), decode('f0e1d2c3b4a5968778695a4b3c2d1e0f', 'hex'),
'bf-ecb/pad:none'), 'hex'); 'bf-ecb/pad:none'), 'hex');
-- with padding -- with padding
select encode(encrypt( SELECT encode(encrypt(
decode('01234567890123456789', 'hex'), decode('01234567890123456789', 'hex'),
decode('33443344334433443344334433443344', 'hex'), decode('33443344334433443344334433443344', 'hex'),
'bf-ecb'), 'hex'); 'bf-ecb'), 'hex');
...@@ -53,13 +55,13 @@ decode('33443344334433443344334433443344', 'hex'), ...@@ -53,13 +55,13 @@ decode('33443344334433443344334433443344', 'hex'),
-- cbc -- cbc
-- 28 bytes key -- 28 bytes key
select encode(encrypt( SELECT encode(encrypt(
decode('6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5', 'hex'), decode('6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5', 'hex'),
decode('37363534333231204e6f77206973207468652074696d6520666f7220', 'hex'), decode('37363534333231204e6f77206973207468652074696d6520666f7220', 'hex'),
'bf-cbc'), 'hex'); 'bf-cbc'), 'hex');
-- 29 bytes key -- 29 bytes key
select encode(encrypt( SELECT encode(encrypt(
decode('6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5ff92cc', 'hex'), decode('6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5ff92cc', 'hex'),
decode('37363534333231204e6f77206973207468652074696d6520666f722000', 'hex'), decode('37363534333231204e6f77206973207468652074696d6520666f722000', 'hex'),
'bf-cbc'), 'hex'); 'bf-cbc'), 'hex');
......
...@@ -2,16 +2,19 @@ ...@@ -2,16 +2,19 @@
-- crypt() and gen_salt(): bcrypt -- crypt() and gen_salt(): bcrypt
-- --
select crypt('', '$2a$06$RQiOJ.3ELirrXwxIZY8q0O'); SET autocommit TO 'on';
select crypt('foox', '$2a$06$RQiOJ.3ELirrXwxIZY8q0O'); SELECT crypt('', '$2a$06$RQiOJ.3ELirrXwxIZY8q0O');
create table ctest (data text, res text, salt text); SELECT crypt('foox', '$2a$06$RQiOJ.3ELirrXwxIZY8q0O');
insert into ctest values ('password', '', '');
update ctest set salt = gen_salt('bf', 8); CREATE TABLE ctest (data text, res text, salt text);
update ctest set res = crypt(data, salt); INSERT INTO ctest VALUES ('password', '', '');
select res = crypt(data, res) as "worked" from ctest;
drop table ctest; UPDATE ctest SET salt = gen_salt('bf', 8);
UPDATE ctest SET res = crypt(data, salt);
SELECT res = crypt(data, res) AS "worked"
FROM ctest;
DROP TABLE ctest;
...@@ -2,16 +2,19 @@ ...@@ -2,16 +2,19 @@
-- crypt() and gen_salt(): crypt-des -- crypt() and gen_salt(): crypt-des
-- --
select crypt('', 'NB'); SET autocommit TO 'on';
select crypt('foox', 'NB'); SELECT crypt('', 'NB');
create table ctest (data text, res text, salt text); SELECT crypt('foox', 'NB');
insert into ctest values ('password', '', '');
update ctest set salt = gen_salt('des'); CREATE TABLE ctest (data text, res text, salt text);
update ctest set res = crypt(data, salt); INSERT INTO ctest VALUES ('password', '', '');
select res = crypt(data, res) as "worked" from ctest;
drop table ctest; UPDATE ctest SET salt = gen_salt('des');
UPDATE ctest SET res = crypt(data, salt);
SELECT res = crypt(data, res) AS "worked"
FROM ctest;
DROP TABLE ctest;
...@@ -2,16 +2,19 @@ ...@@ -2,16 +2,19 @@
-- crypt() and gen_salt(): md5 -- crypt() and gen_salt(): md5
-- --
select crypt('', '$1$Szzz0yzz'); SET autocommit TO 'on';
select crypt('foox', '$1$Szzz0yzz'); SELECT crypt('', '$1$Szzz0yzz');
create table ctest (data text, res text, salt text); SELECT crypt('foox', '$1$Szzz0yzz');
insert into ctest values ('password', '', '');
update ctest set salt = gen_salt('md5'); CREATE TABLE ctest (data text, res text, salt text);
update ctest set res = crypt(data, salt); INSERT INTO ctest VALUES ('password', '', '');
select res = crypt(data, res) as "worked" from ctest;
drop table ctest; UPDATE ctest SET salt = gen_salt('md5');
UPDATE ctest SET res = crypt(data, salt);
SELECT res = crypt(data, res) AS "worked"
FROM ctest;
DROP TABLE ctest;
...@@ -2,16 +2,19 @@ ...@@ -2,16 +2,19 @@
-- crypt() and gen_salt(): extended des -- crypt() and gen_salt(): extended des
-- --
select crypt('', '_J9..j2zz'); SET autocommit TO 'on';
select crypt('foox', '_J9..j2zz'); SELECT crypt('', '_J9..j2zz');
create table ctest (data text, res text, salt text); SELECT crypt('foox', '_J9..j2zz');
insert into ctest values ('password', '', '');
update ctest set salt = gen_salt('xdes', 1001); CREATE TABLE ctest (data text, res text, salt text);
update ctest set res = crypt(data, salt); INSERT INTO ctest VALUES ('password', '', '');
select res = crypt(data, res) as "worked" from ctest;
drop table ctest; UPDATE ctest SET salt = gen_salt('xdes', 1001);
UPDATE ctest SET res = crypt(data, salt);
SELECT res = crypt(data, res) AS "worked"
FROM ctest;
DROP TABLE ctest;
...@@ -2,43 +2,45 @@ ...@@ -2,43 +2,45 @@
-- HMAC-MD5 -- HMAC-MD5
-- --
select encode(hmac( SET autocommit TO 'on';
SELECT encode(hmac(
'Hi There', 'Hi There',
decode('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'), decode('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'),
'md5'), 'hex'); 'md5'), 'hex');
-- 2 -- 2
select encode(hmac( SELECT encode(hmac(
'Jefe', 'Jefe',
'what do ya want for nothing?', 'what do ya want for nothing?',
'md5'), 'hex'); 'md5'), 'hex');
-- 3 -- 3
select encode(hmac( SELECT encode(hmac(
decode('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd', 'hex'), decode('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd', 'hex'),
decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'), decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
'md5'), 'hex'); 'md5'), 'hex');
-- 4 -- 4
select encode(hmac( SELECT encode(hmac(
decode('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd', 'hex'), decode('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd', 'hex'),
decode('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'), decode('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'),
'md5'), 'hex'); 'md5'), 'hex');
-- 5 -- 5
select encode(hmac( SELECT encode(hmac(
'Test With Truncation', 'Test With Truncation',
decode('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'), decode('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'),
'md5'), 'hex'); 'md5'), 'hex');
-- 6 -- 6
select encode(hmac( SELECT encode(hmac(
'Test Using Larger Than Block-Size Key - Hash Key First', 'Test Using Larger Than Block-Size Key - Hash Key First',
decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'), decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
'md5'), 'hex'); 'md5'), 'hex');
-- 7 -- 7
select encode(hmac( SELECT encode(hmac(
'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data', 'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data',
decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'), decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
'md5'), 'hex'); 'md5'), 'hex');
......
...@@ -2,43 +2,45 @@ ...@@ -2,43 +2,45 @@
-- HMAC-MD5 -- HMAC-MD5
-- --
select encode(hmac( SET autocommit TO 'on';
SELECT encode(hmac(
'Hi There', 'Hi There',
decode('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'), decode('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'),
'sha1'), 'hex'); 'sha1'), 'hex');
-- 2 -- 2
select encode(hmac( SELECT encode(hmac(
'Jefe', 'Jefe',
'what do ya want for nothing?', 'what do ya want for nothing?',
'sha1'), 'hex'); 'sha1'), 'hex');
-- 3 -- 3
select encode(hmac( SELECT encode(hmac(
decode('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd', 'hex'), decode('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd', 'hex'),
decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'), decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
'sha1'), 'hex'); 'sha1'), 'hex');
-- 4 -- 4
select encode(hmac( SELECT encode(hmac(
decode('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd', 'hex'), decode('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd', 'hex'),
decode('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'), decode('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'),
'sha1'), 'hex'); 'sha1'), 'hex');
-- 5 -- 5
select encode(hmac( SELECT encode(hmac(
'Test With Truncation', 'Test With Truncation',
decode('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'), decode('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'),
'sha1'), 'hex'); 'sha1'), 'hex');
-- 6 -- 6
select encode(hmac( SELECT encode(hmac(
'Test Using Larger Than Block-Size Key - Hash Key First', 'Test Using Larger Than Block-Size Key - Hash Key First',
decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'), decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
'sha1'), 'hex'); 'sha1'), 'hex');
-- 7 -- 7
select encode(hmac( SELECT encode(hmac(
'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data', 'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data',
decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'), decode('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
'sha1'), 'hex'); 'sha1'), 'hex');
......
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
-- --
\set ECHO none \set ECHO none
SET autocommit TO 'on';
\i pgcrypto.sql \i pgcrypto.sql
\set ECHO all \set ECHO all
-- check for encoding fn's -- check for encoding fn's
select encode('foo', 'hex'); SELECT encode('foo', 'hex');
select decode('666f6f', 'hex'); SELECT decode('666f6f', 'hex');
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
-- MD5 message digest -- MD5 message digest
-- --
select encode(digest('', 'md5'), 'hex'); SET autocommit TO 'on';
select encode(digest('a', 'md5'), 'hex');
select encode(digest('abc', 'md5'), 'hex'); SELECT encode(digest('', 'md5'), 'hex');
select encode(digest('message digest', 'md5'), 'hex'); SELECT encode(digest('a', 'md5'), 'hex');
select encode(digest('abcdefghijklmnopqrstuvwxyz', 'md5'), 'hex'); SELECT encode(digest('abc', 'md5'), 'hex');
select encode(digest('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', 'md5'), 'hex'); SELECT encode(digest('message digest', 'md5'), 'hex');
select encode(digest('12345678901234567890123456789012345678901234567890123456789012345678901234567890', 'md5'), 'hex'); SELECT encode(digest('abcdefghijklmnopqrstuvwxyz', 'md5'), 'hex');
SELECT encode(digest('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', 'md5'), 'hex');
SELECT encode(digest('12345678901234567890123456789012345678901234567890123456789012345678901234567890', 'md5'), 'hex');
...@@ -2,41 +2,43 @@ ...@@ -2,41 +2,43 @@
-- AES / Rijndael-128 cipher -- AES / Rijndael-128 cipher
-- --
SET autocommit TO 'on';
-- some standard Rijndael testvalues -- some standard Rijndael testvalues
select encode(encrypt( SELECT encode(encrypt(
decode('00112233445566778899aabbccddeeff', 'hex'), decode('00112233445566778899aabbccddeeff', 'hex'),
decode('000102030405060708090a0b0c0d0e0f', 'hex'), decode('000102030405060708090a0b0c0d0e0f', 'hex'),
'aes-ecb/pad:none'), 'hex'); 'aes-ecb/pad:none'), 'hex');
select encode(encrypt( SELECT encode(encrypt(
decode('00112233445566778899aabbccddeeff', 'hex'), decode('00112233445566778899aabbccddeeff', 'hex'),
decode('000102030405060708090a0b0c0d0e0f1011121314151617', 'hex'), decode('000102030405060708090a0b0c0d0e0f1011121314151617', 'hex'),
'aes-ecb/pad:none'), 'hex'); 'aes-ecb/pad:none'), 'hex');
select encode(encrypt( SELECT encode(encrypt(
decode('00112233445566778899aabbccddeeff', 'hex'), decode('00112233445566778899aabbccddeeff', 'hex'),
decode('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', 'hex'), decode('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', 'hex'),
'aes-ecb/pad:none'), 'hex'); 'aes-ecb/pad:none'), 'hex');
-- cbc -- cbc
select encode(encrypt( SELECT encode(encrypt(
decode('00112233445566778899aabbccddeeff', 'hex'), decode('00112233445566778899aabbccddeeff', 'hex'),
decode('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', 'hex'), decode('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', 'hex'),
'aes-cbc/pad:none'), 'hex'); 'aes-cbc/pad:none'), 'hex');
-- key padding -- key padding
select encode(encrypt( SELECT encode(encrypt(
decode('0011223344', 'hex'), decode('0011223344', 'hex'),
decode('000102030405', 'hex'), decode('000102030405', 'hex'),
'aes-cbc'), 'hex'); 'aes-cbc'), 'hex');
select encode(encrypt( SELECT encode(encrypt(
decode('0011223344', 'hex'), decode('0011223344', 'hex'),
decode('000102030405060708090a0b0c0d0e0f10111213', 'hex'), decode('000102030405060708090a0b0c0d0e0f10111213', 'hex'),
'aes-cbc'), 'hex'); 'aes-cbc'), 'hex');
select encode(encrypt( SELECT encode(encrypt(
decode('0011223344', 'hex'), decode('0011223344', 'hex'),
decode('000102030405060708090a0b0c0d0e0f101112131415161718191a1b', 'hex'), decode('000102030405060708090a0b0c0d0e0f101112131415161718191a1b', 'hex'),
'aes-cbc'), 'hex'); 'aes-cbc'), 'hex');
......
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
-- SHA1 message digest -- SHA1 message digest
-- --
select encode(digest('', 'sha1'), 'hex'); SET autocommit TO 'on';
select encode(digest('a', 'sha1'), 'hex');
select encode(digest('abc', 'sha1'), 'hex'); SELECT encode(digest('', 'sha1'), 'hex');
select encode(digest('message digest', 'sha1'), 'hex'); SELECT encode(digest('a', 'sha1'), 'hex');
select encode(digest('abcdefghijklmnopqrstuvwxyz', 'sha1'), 'hex'); SELECT encode(digest('abc', 'sha1'), 'hex');
select encode(digest('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', 'sha1'), 'hex'); SELECT encode(digest('message digest', 'sha1'), 'hex');
select encode(digest('12345678901234567890123456789012345678901234567890123456789012345678901234567890', 'sha1'), 'hex'); SELECT encode(digest('abcdefghijklmnopqrstuvwxyz', 'sha1'), 'hex');
SELECT encode(digest('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', 'sha1'), 'hex');
SELECT encode(digest('12345678901234567890123456789012345678901234567890123456789012345678901234567890', 'sha1'), 'hex');
-- Adjust this setting to control where the objects get created.
SET search_path = public;
SET autocommit TO 'on';
DROP TYPE pgstattuple_type CASCADE; DROP TYPE pgstattuple_type CASCADE;
CREATE TYPE pgstattuple_type AS ( CREATE TYPE pgstattuple_type AS (
table_len BIGINT, -- physical table length in bytes table_len BIGINT, -- physical table length in bytes
...@@ -11,7 +16,7 @@ CREATE TYPE pgstattuple_type AS ( ...@@ -11,7 +16,7 @@ CREATE TYPE pgstattuple_type AS (
free_percent FLOAT -- free space in % free_percent FLOAT -- free space in %
); );
CREATE OR REPLACE FUNCTION pgstattuple(text) RETURNS pgstattuple_type CREATE OR REPLACE FUNCTION pgstattuple(text)
AS 'MODULE_PATHNAME', 'pgstattuple' RETURNS pgstattuple_type
LANGUAGE 'c' WITH (isstrict); AS 'MODULE_PATHNAME', 'pgstattuple'
GRANT EXECUTE ON FUNCTION pgstattuple(text) TO PUBLIC; LANGUAGE 'C' WITH (isstrict);
#!/bin/sh #!/bin/sh
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #
# Package : reindexdb Version : $Revision: 1.1 $ # Package : reindexdb Version : $Revision: 1.2 $
# Date : 05/08/2002 Author : Shaun Thomas # Date : 05/08/2002 Author : Shaun Thomas
# Req : psql, sh, perl, sed Type : Utility # Req : psql, sh, perl, sed Type : Utility
# #
...@@ -184,11 +184,11 @@ fi ...@@ -184,11 +184,11 @@ fi
# If index was set, reindex that index. # If index was set, reindex that index.
if [ "$index" ]; then if [ "$index" ]; then
$PSQL $PSQLOPT $ECHOOPT -c "REINDEX INDEX $index" -d $dbname $PSQL $PSQLOPT $ECHOOPT -c "SET autocommit TO 'on';REINDEX INDEX $index" -d $dbname
# Ok, no index. Is there a specific table to reindex? # Ok, no index. Is there a specific table to reindex?
elif [ "$table" ]; then elif [ "$table" ]; then
$PSQL $PSQLOPT $ECHOOPT -c "REINDEX TABLE \"$table\"" -d $dbname $PSQL $PSQLOPT $ECHOOPT -c "SET autocommit TO 'on';REINDEX TABLE \"$table\"" -d $dbname
# No specific table, no specific index, either we have a specific database, # No specific table, no specific index, either we have a specific database,
# or were told to do all databases. Do it! # or were told to do all databases. Do it!
...@@ -204,9 +204,9 @@ else ...@@ -204,9 +204,9 @@ else
# Ok, reindex every table in the database. Use the same method # Ok, reindex every table in the database. Use the same method
# we used to get a list of databases, and get a list of tables in this # we used to get a list of databases, and get a list of tables in this
# database that we may reindex. # database that we may reindex.
tables=`$PSQL $PSQLOPT -q -t -A -d $db -c "$sql"` tables=`$PSQL $PSQLOPT -q -t -A -d $db -c "SET autocommit TO 'on';$sql"`
for tab in $tables; do for tab in $tables; do
$PSQL $PSQLOPT $ECHOOPT -c "REINDEX TABLE \"$tab\"" -d $db $PSQL $PSQLOPT $ECHOOPT -c "SET autocommit TO 'on';REINDEX TABLE \"$tab\"" -d $db
done done
done done
......
...@@ -25,6 +25,20 @@ EOT ...@@ -25,6 +25,20 @@ EOT
$opt{d} ||= 'TEST'; $opt{d} ||= 'TEST';
my $dbi=DBI->connect('DBI:Pg:dbname='.$opt{d}) || die "Couldn't connect DB: $opt{d} !\n"; my $dbi=DBI->connect('DBI:Pg:dbname='.$opt{d}) || die "Couldn't connect DB: $opt{d} !\n";
my $setsql = qq{
SET search_path = public;
};
my $sth = $dbi->prepare($setsql);
$sth->execute();
my $setsql2 = qq{
SET autocommit TO 'on';
};
my $sth2 = $dbi->prepare($setsql2);
$sth2->execute();
my $sql; my $sql;
my $notice; my $notice;
my $sss = '(3000,3000,2990,2990)'; my $sss = '(3000,3000,2990,2990)';
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
use strict; use strict;
my $NUM = 20000; my $NUM = 20000;
print "drop table boxtmp;\n"; print "DROP TABLE boxtmp;\n";
print "drop table boxtmp2;\n"; print "DROP TABLE boxtmp2;\n";
print "create table boxtmp (b box);\n"; print "CREATE TABLE boxtmp (b box);\n";
print "create table boxtmp2 (b box);\n"; print "CREATE TABLE boxtmp2 (b box);\n";
srand(1); srand(1);
open(DAT,">bbb.dat") || die; open(DAT,">bbb.dat") || die;
...@@ -26,20 +26,20 @@ foreach ( 1..$NUM ) { ...@@ -26,20 +26,20 @@ foreach ( 1..$NUM ) {
} }
close DAT; close DAT;
print "copy boxtmp from stdin;\n"; print "COPY boxtmp FROM stdin;\n";
open(DAT,"bbb.dat") || die; open(DAT,"bbb.dat") || die;
while(<DAT>) { print; } while(<DAT>) { print; }
close DAT; close DAT;
print "\\.\n"; print "\\.\n";
print "copy boxtmp2 from stdin;\n"; print "COPY boxtmp2 FROM stdin;\n";
open(DAT,"bbb.dat") || die; open(DAT,"bbb.dat") || die;
while(<DAT>) { print; } while(<DAT>) { print; }
close DAT; close DAT;
print "\\.\n"; print "\\.\n";
print "create index bix on boxtmp using gist (b gist_box_ops);\n"; print "CREATE INDEX bix ON boxtmp USING gist (b gist_box_ops);\n";
print "create index bix2 on boxtmp2 using rtree (b box_ops);\n"; print "CREATE INDEX bix2 ON boxtmp2 USING rtree (b box_ops);\n";
sub min { sub min {
......
...@@ -3,41 +3,51 @@ ...@@ -3,41 +3,51 @@
-- does not depend on contents of seg.sql. -- does not depend on contents of seg.sql.
-- --
\set ECHO none \set ECHO none
create table boxtmp (b box); CREATE TABLE boxtmp (b box);
\copy boxtmp from 'data/test_box.data' \copy boxtmp from 'data/test_box.data'
select count(*) from boxtmp where b && '(1000,1000,0,0)'::box; SELECT count(*)
FROM boxtmp
WHERE b && '(1000,1000,0,0)'::box;
count count
------- -------
2 2
(1 row) (1 row)
create index bix on boxtmp using rtree (b); CREATE INDEX bix ON boxtmp USING rtree (b);
select count(*) from boxtmp where b && '(1000,1000,0,0)'::box; SELECT count(*)
FROM boxtmp
WHERE b && '(1000,1000,0,0)'::box;
count count
------- -------
2 2
(1 row) (1 row)
drop index bix; DROP INDEX bix;
create index bix on boxtmp using gist (b); CREATE INDEX bix ON boxtmp USING gist (b);
select count(*) from boxtmp where b && '(1000,1000,0,0)'::box; SELECT count(*)
FROM boxtmp
WHERE b && '(1000,1000,0,0)'::box;
count count
------- -------
2 2
(1 row) (1 row)
create table polytmp (p polygon); CREATE TABLE polytmp (p polygon);
\copy polytmp from 'data/test_box.data' \copy polytmp from 'data/test_box.data'
create index pix on polytmp using rtree (p); CREATE INDEX pix ON polytmp USING rtree (p);
select count(*) from polytmp where p && '(1000,1000),(0,0)'::polygon; SELECT count(*)
FROM polytmp
WHERE p && '(1000,1000),(0,0)'::polygon;
count count
------- -------
2 2
(1 row) (1 row)
drop index pix; DROP INDEX pix;
create index pix on polytmp using gist (p); CREATE INDEX pix ON polytmp USING gist (p);
select count(*) from polytmp where p && '(1000,1000),(0,0)'::polygon; SELECT count(*)
FROM polytmp
WHERE p && '(1000,1000),(0,0)'::polygon;
count count
------- -------
2 2
......
begin transaction;
-- Adjust this setting to control where the objects get created. -- Adjust this setting to control where the objects get created.
SET search_path = public; SET search_path = public;
SET autocommit TO 'on';
-- --
-- --
-- --
...@@ -11,23 +11,45 @@ SET search_path = public; ...@@ -11,23 +11,45 @@ SET search_path = public;
-- --
-- --
-- define the GiST support methods -- define the GiST support methods
create function gbox_consistent(internal,box,int4) returns bool as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION gbox_consistent(internal,box,int4)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
create function gbox_compress(internal) returns internal as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION gbox_compress(internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
create function rtree_decompress(internal) returns internal as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION rtree_decompress(internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
create function gbox_penalty(internal,internal,internal) returns internal as 'MODULE_PATHNAME' language 'C' with (isstrict); CREATE FUNCTION gbox_penalty(internal,internal,internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
create function gbox_picksplit(internal, internal) returns internal as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION gbox_picksplit(internal, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
create function gbox_union(bytea, internal) returns box as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION gbox_union(bytea, internal)
RETURNS box
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
create function gbox_same(box, box, internal) returns internal as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION gbox_same(box, box, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- create the operator class -- create the operator class
CREATE OPERATOR CLASS gist_box_ops CREATE OPERATOR CLASS gist_box_ops
DEFAULT FOR TYPE box USING gist AS DEFAULT FOR TYPE box USING gist
AS
OPERATOR 1 << , OPERATOR 1 << ,
OPERATOR 2 &< , OPERATOR 2 &< ,
OPERATOR 3 && , OPERATOR 3 && ,
...@@ -53,21 +75,28 @@ CREATE OPERATOR CLASS gist_box_ops ...@@ -53,21 +75,28 @@ CREATE OPERATOR CLASS gist_box_ops
-- --
-- --
-- define the GiST support methods -- define the GiST support methods
create function gpoly_consistent(internal,polygon,int4) returns bool as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION gpoly_consistent(internal,polygon,int4)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
create function gpoly_compress(internal) returns internal as 'MODULE_PATHNAME' language 'C'; CREATE FUNCTION gpoly_compress(internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- create the operator class -- create the operator class
CREATE OPERATOR CLASS gist_poly_ops CREATE OPERATOR CLASS gist_poly_ops
DEFAULT FOR TYPE polygon USING gist AS DEFAULT FOR TYPE polygon USING gist
OPERATOR 1 << RECHECK , AS
OPERATOR 2 &< RECHECK , OPERATOR 1 << RECHECK,
OPERATOR 3 && RECHECK , OPERATOR 2 &< RECHECK,
OPERATOR 4 &> RECHECK , OPERATOR 3 && RECHECK,
OPERATOR 5 >> RECHECK , OPERATOR 4 &> RECHECK,
OPERATOR 6 ~= RECHECK , OPERATOR 5 >> RECHECK,
OPERATOR 7 ~ RECHECK , OPERATOR 6 ~= RECHECK,
OPERATOR 8 @ RECHECK , OPERATOR 7 ~ RECHECK,
OPERATOR 8 @ RECHECK,
FUNCTION 1 gpoly_consistent (internal, polygon, int4), FUNCTION 1 gpoly_consistent (internal, polygon, int4),
FUNCTION 2 gbox_union (bytea, internal), FUNCTION 2 gbox_union (bytea, internal),
FUNCTION 3 gpoly_compress (internal), FUNCTION 3 gpoly_compress (internal),
...@@ -76,6 +105,3 @@ CREATE OPERATOR CLASS gist_poly_ops ...@@ -76,6 +105,3 @@ CREATE OPERATOR CLASS gist_poly_ops
FUNCTION 6 gbox_picksplit (internal, internal), FUNCTION 6 gbox_picksplit (internal, internal),
FUNCTION 7 gbox_same (box, box, internal), FUNCTION 7 gbox_same (box, box, internal),
STORAGE box; STORAGE box;
end transaction;
...@@ -3,36 +3,46 @@ ...@@ -3,36 +3,46 @@
-- does not depend on contents of seg.sql. -- does not depend on contents of seg.sql.
-- --
\set ECHO none \set ECHO none
SET autocommit TO 'on';
\i rtree_gist.sql \i rtree_gist.sql
\set ECHO all \set ECHO all
create table boxtmp (b box); CREATE TABLE boxtmp (b box);
\copy boxtmp from 'data/test_box.data' \copy boxtmp from 'data/test_box.data'
select count(*) from boxtmp where b && '(1000,1000,0,0)'::box; SELECT count(*)
FROM boxtmp
WHERE b && '(1000,1000,0,0)'::box;
create index bix on boxtmp using rtree (b); CREATE INDEX bix ON boxtmp USING rtree (b);
select count(*) from boxtmp where b && '(1000,1000,0,0)'::box; SELECT count(*)
FROM boxtmp
WHERE b && '(1000,1000,0,0)'::box;
drop index bix; DROP INDEX bix;
create index bix on boxtmp using gist (b); CREATE INDEX bix ON boxtmp USING gist (b);
select count(*) from boxtmp where b && '(1000,1000,0,0)'::box; SELECT count(*)
FROM boxtmp
WHERE b && '(1000,1000,0,0)'::box;
create table polytmp (p polygon); CREATE TABLE polytmp (p polygon);
\copy polytmp from 'data/test_box.data' \copy polytmp from 'data/test_box.data'
create index pix on polytmp using rtree (p); CREATE INDEX pix ON polytmp USING rtree (p);
select count(*) from polytmp where p && '(1000,1000),(0,0)'::polygon; SELECT count(*)
FROM polytmp
WHERE p && '(1000,1000),(0,0)'::polygon;
drop index pix; DROP INDEX pix;
create index pix on polytmp using gist (p); CREATE INDEX pix ON polytmp USING gist (p);
select count(*) from polytmp where p && '(1000,1000),(0,0)'::polygon;
SELECT count(*)
FROM polytmp
WHERE p && '(1000,1000),(0,0)'::polygon;
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
-- does not depend on contents of seg.sql. -- does not depend on contents of seg.sql.
-- --
\set ECHO none \set ECHO none
psql:seg.sql:11: WARNING: ProcedureCreate: type seg is not yet defined psql:seg.sql:12: WARNING: ProcedureCreate: type seg is not yet defined
psql:seg.sql:16: WARNING: Argument type "seg" is only a shell psql:seg.sql:17: WARNING: Argument type "seg" is only a shell
-- --
-- testing the input and output functions -- testing the input and output functions
-- --
......
-- Create the user-defined type for 1-D floating point intervals (seg) -- Create the user-defined type for 1-D floating point intervals (seg)
-- --
BEGIN TRANSACTION;
-- Adjust this setting to control where the objects get created. -- Adjust this setting to control where the objects get created.
SET search_path = public; SET search_path = public;
SET autocommit TO 'on';
CREATE FUNCTION seg_in(cstring) CREATE FUNCTION seg_in(cstring)
RETURNS seg RETURNS seg
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c'; LANGUAGE 'C';
CREATE FUNCTION seg_out(seg) CREATE FUNCTION seg_out(seg)
RETURNS cstring RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c'; LANGUAGE 'C';
CREATE TYPE seg ( CREATE TYPE seg (
internallength = 12, INTERNALLENGTH = 12,
input = seg_in, INPUT = seg_in,
output = seg_out OUTPUT = seg_out
); );
COMMENT ON TYPE seg IS COMMENT ON TYPE seg IS
...@@ -30,26 +31,34 @@ COMMENT ON TYPE seg IS ...@@ -30,26 +31,34 @@ COMMENT ON TYPE seg IS
-- Left/Right methods -- Left/Right methods
CREATE FUNCTION seg_over_left(seg, seg) RETURNS bool CREATE FUNCTION seg_over_left(seg, seg)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
COMMENT ON FUNCTION seg_over_left(seg, seg) IS COMMENT ON FUNCTION seg_over_left(seg, seg) IS
'is over and left of'; 'is over and left of';
CREATE FUNCTION seg_over_right(seg, seg) RETURNS bool CREATE FUNCTION seg_over_right(seg, seg)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
COMMENT ON FUNCTION seg_over_right(seg, seg) IS COMMENT ON FUNCTION seg_over_right(seg, seg) IS
'is over and right of'; 'is over and right of';
CREATE FUNCTION seg_left(seg, seg) RETURNS bool CREATE FUNCTION seg_left(seg, seg)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
COMMENT ON FUNCTION seg_left(seg, seg) IS COMMENT ON FUNCTION seg_left(seg, seg) IS
'is left of'; 'is left of';
CREATE FUNCTION seg_right(seg, seg) RETURNS bool CREATE FUNCTION seg_right(seg, seg)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
COMMENT ON FUNCTION seg_right(seg, seg) IS COMMENT ON FUNCTION seg_right(seg, seg) IS
'is right of'; 'is right of';
...@@ -57,78 +66,106 @@ COMMENT ON FUNCTION seg_right(seg, seg) IS ...@@ -57,78 +66,106 @@ COMMENT ON FUNCTION seg_right(seg, seg) IS
-- Comparison methods -- Comparison methods
CREATE FUNCTION seg_lt(seg, seg) RETURNS bool CREATE FUNCTION seg_lt(seg, seg)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
COMMENT ON FUNCTION seg_lt(seg, seg) IS COMMENT ON FUNCTION seg_lt(seg, seg) IS
'less than'; 'less than';
CREATE FUNCTION seg_le(seg, seg) RETURNS bool CREATE FUNCTION seg_le(seg, seg)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
COMMENT ON FUNCTION seg_le(seg, seg) IS COMMENT ON FUNCTION seg_le(seg, seg) IS
'less than or equal'; 'less than or equal';
CREATE FUNCTION seg_gt(seg, seg) RETURNS bool CREATE FUNCTION seg_gt(seg, seg)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
COMMENT ON FUNCTION seg_gt(seg, seg) IS COMMENT ON FUNCTION seg_gt(seg, seg) IS
'greater than'; 'greater than';
CREATE FUNCTION seg_ge(seg, seg) RETURNS bool CREATE FUNCTION seg_ge(seg, seg)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
COMMENT ON FUNCTION seg_ge(seg, seg) IS COMMENT ON FUNCTION seg_ge(seg, seg) IS
'greater than or equal'; 'greater than or equal';
CREATE FUNCTION seg_contains(seg, seg) RETURNS bool CREATE FUNCTION seg_contains(seg, seg)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
COMMENT ON FUNCTION seg_contains(seg, seg) IS COMMENT ON FUNCTION seg_contains(seg, seg) IS
'contains'; 'contains';
CREATE FUNCTION seg_contained(seg, seg) RETURNS bool CREATE FUNCTION seg_contained(seg, seg)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
COMMENT ON FUNCTION seg_contained(seg, seg) IS COMMENT ON FUNCTION seg_contained(seg, seg) IS
'contained in'; 'contained in';
CREATE FUNCTION seg_overlap(seg, seg) RETURNS bool CREATE FUNCTION seg_overlap(seg, seg)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
COMMENT ON FUNCTION seg_overlap(seg, seg) IS COMMENT ON FUNCTION seg_overlap(seg, seg) IS
'overlaps'; 'overlaps';
CREATE FUNCTION seg_same(seg, seg) RETURNS bool CREATE FUNCTION seg_same(seg, seg)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
COMMENT ON FUNCTION seg_same(seg, seg) IS COMMENT ON FUNCTION seg_same(seg, seg) IS
'same as'; 'same as';
CREATE FUNCTION seg_different(seg, seg) RETURNS bool CREATE FUNCTION seg_different(seg, seg)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
COMMENT ON FUNCTION seg_different(seg, seg) IS COMMENT ON FUNCTION seg_different(seg, seg) IS
'different'; 'different';
-- support routines for indexing -- support routines for indexing
CREATE FUNCTION seg_union(seg, seg) RETURNS seg CREATE FUNCTION seg_union(seg, seg)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS seg
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
CREATE FUNCTION seg_inter(seg, seg) RETURNS seg CREATE FUNCTION seg_inter(seg, seg)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS seg
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
CREATE FUNCTION seg_size(seg) RETURNS float4 CREATE FUNCTION seg_size(seg)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS float4
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
-- miscellaneous -- miscellaneous
CREATE FUNCTION seg_upper(seg) RETURNS float4 CREATE FUNCTION seg_upper(seg)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS float4
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
CREATE FUNCTION seg_lower(seg) RETURNS float4 CREATE FUNCTION seg_lower(seg)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS float4
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
-- --
...@@ -136,112 +173,173 @@ CREATE FUNCTION seg_lower(seg) RETURNS float4 ...@@ -136,112 +173,173 @@ CREATE FUNCTION seg_lower(seg) RETURNS float4
-- --
CREATE OPERATOR < ( CREATE OPERATOR < (
LEFTARG = seg, RIGHTARG = seg, PROCEDURE = seg_lt, LEFTARG = seg,
COMMUTATOR = '>', NEGATOR = '>=', RIGHTARG = seg,
RESTRICT = scalarltsel, JOIN = scalarltjoinsel PROCEDURE = seg_lt,
COMMUTATOR = '>',
NEGATOR = '>=',
RESTRICT = scalarltsel,
JOIN = scalarltjoinsel
); );
CREATE OPERATOR <= ( CREATE OPERATOR <= (
LEFTARG = seg, RIGHTARG = seg, PROCEDURE = seg_le, LEFTARG = seg,
COMMUTATOR = '>=', NEGATOR = '>', RIGHTARG = seg,
RESTRICT = scalarltsel, JOIN = scalarltjoinsel PROCEDURE = seg_le,
COMMUTATOR = '>=',
NEGATOR = '>',
RESTRICT = scalarltsel,
JOIN = scalarltjoinsel
); );
CREATE OPERATOR > ( CREATE OPERATOR > (
LEFTARG = seg, RIGHTARG = seg, PROCEDURE = seg_gt, LEFTARG = seg,
COMMUTATOR = '<', NEGATOR = '<=', RIGHTARG = seg,
RESTRICT = scalargtsel, JOIN = scalargtjoinsel PROCEDURE = seg_gt,
COMMUTATOR = '<',
NEGATOR = '<=',
RESTRICT = scalargtsel,
JOIN = scalargtjoinsel
); );
CREATE OPERATOR >= ( CREATE OPERATOR >= (
LEFTARG = seg, RIGHTARG = seg, PROCEDURE = seg_ge, LEFTARG = seg,
COMMUTATOR = '<=', NEGATOR = '<', RIGHTARG = seg,
RESTRICT = scalargtsel, JOIN = scalargtjoinsel PROCEDURE = seg_ge,
COMMUTATOR = '<=',
NEGATOR = '<',
RESTRICT = scalargtsel,
JOIN = scalargtjoinsel
); );
CREATE OPERATOR << ( CREATE OPERATOR << (
LEFTARG = seg, RIGHTARG = seg, PROCEDURE = seg_left, LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_left,
COMMUTATOR = '>>', COMMUTATOR = '>>',
RESTRICT = positionsel, JOIN = positionjoinsel RESTRICT = positionsel,
JOIN = positionjoinsel
); );
CREATE OPERATOR &< ( CREATE OPERATOR &< (
LEFTARG = seg, RIGHTARG = seg, PROCEDURE = seg_over_left, LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_over_left,
COMMUTATOR = '&>', COMMUTATOR = '&>',
RESTRICT = positionsel, JOIN = positionjoinsel RESTRICT = positionsel,
JOIN = positionjoinsel
); );
CREATE OPERATOR && ( CREATE OPERATOR && (
LEFTARG = seg, RIGHTARG = seg, PROCEDURE = seg_overlap, LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_overlap,
COMMUTATOR = '&&', COMMUTATOR = '&&',
RESTRICT = positionsel, JOIN = positionjoinsel RESTRICT = positionsel,
JOIN = positionjoinsel
); );
CREATE OPERATOR &> ( CREATE OPERATOR &> (
LEFTARG = seg, RIGHTARG = seg, PROCEDURE = seg_over_right, LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_over_right,
COMMUTATOR = '&<', COMMUTATOR = '&<',
RESTRICT = positionsel, JOIN = positionjoinsel RESTRICT = positionsel,
JOIN = positionjoinsel
); );
CREATE OPERATOR >> ( CREATE OPERATOR >> (
LEFTARG = seg, RIGHTARG = seg, PROCEDURE = seg_right, LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_right,
COMMUTATOR = '<<', COMMUTATOR = '<<',
RESTRICT = positionsel, JOIN = positionjoinsel RESTRICT = positionsel,
JOIN = positionjoinsel
); );
CREATE OPERATOR = ( CREATE OPERATOR = (
LEFTARG = seg, RIGHTARG = seg, PROCEDURE = seg_same, LEFTARG = seg,
COMMUTATOR = '=', NEGATOR = '<>', RIGHTARG = seg,
RESTRICT = eqsel, JOIN = eqjoinsel, PROCEDURE = seg_same,
SORT1 = '<', SORT2 = '<' COMMUTATOR = '=',
NEGATOR = '<>',
RESTRICT = eqsel,
JOIN = eqjoinsel,
SORT1 = '<',
SORT2 = '<'
); );
CREATE OPERATOR <> ( CREATE OPERATOR <> (
LEFTARG = seg, RIGHTARG = seg, PROCEDURE = seg_different, LEFTARG = seg,
COMMUTATOR = '<>', NEGATOR = '=', RIGHTARG = seg,
RESTRICT = neqsel, JOIN = neqjoinsel PROCEDURE = seg_different,
COMMUTATOR = '<>',
NEGATOR = '=',
RESTRICT = neqsel,
JOIN = neqjoinsel
); );
CREATE OPERATOR @ ( CREATE OPERATOR @ (
LEFTARG = seg, RIGHTARG = seg, PROCEDURE = seg_contains, LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_contains,
COMMUTATOR = '~', COMMUTATOR = '~',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR ~ ( CREATE OPERATOR ~ (
LEFTARG = seg, RIGHTARG = seg, PROCEDURE = seg_contained, LEFTARG = seg,
RIGHTARG = seg,
PROCEDURE = seg_contained,
COMMUTATOR = '@', COMMUTATOR = '@',
RESTRICT = contsel, JOIN = contjoinsel RESTRICT = contsel,
JOIN = contjoinsel
); );
-- define the GiST support methods -- define the GiST support methods
CREATE FUNCTION gseg_consistent(internal,seg,int4) RETURNS bool CREATE FUNCTION gseg_consistent(internal,seg,int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION gseg_compress(internal) RETURNS internal CREATE FUNCTION gseg_compress(internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION gseg_decompress(internal) RETURNS internal CREATE FUNCTION gseg_decompress(internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION gseg_penalty(internal,internal,internal) RETURNS internal CREATE FUNCTION gseg_penalty(internal,internal,internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
CREATE FUNCTION gseg_picksplit(internal, internal) RETURNS internal CREATE FUNCTION gseg_picksplit(internal, internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION gseg_union(bytea, internal) RETURNS seg CREATE FUNCTION gseg_union(bytea, internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS seg
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION gseg_same(seg, seg, internal) RETURNS internal CREATE FUNCTION gseg_same(seg, seg, internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- Create the operator class for indexing -- Create the operator class for indexing
CREATE OPERATOR CLASS gist_seg_ops CREATE OPERATOR CLASS gist_seg_ops
DEFAULT FOR TYPE seg USING gist AS DEFAULT FOR TYPE seg USING gist
AS
OPERATOR 1 << , OPERATOR 1 << ,
OPERATOR 2 &< , OPERATOR 2 &< ,
OPERATOR 3 && , OPERATOR 3 && ,
...@@ -257,6 +355,3 @@ CREATE OPERATOR CLASS gist_seg_ops ...@@ -257,6 +355,3 @@ CREATE OPERATOR CLASS gist_seg_ops
FUNCTION 5 gseg_penalty (internal, internal, internal), FUNCTION 5 gseg_penalty (internal, internal, internal),
FUNCTION 6 gseg_picksplit (internal, internal), FUNCTION 6 gseg_picksplit (internal, internal),
FUNCTION 7 gseg_same (seg, seg, internal); FUNCTION 7 gseg_same (seg, seg, internal);
END TRANSACTION;
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
-- does not depend on contents of seg.sql. -- does not depend on contents of seg.sql.
-- --
\set ECHO none \set ECHO none
SET autocommit TO 'on';
\i seg.sql \i seg.sql
\set ECHO all \set ECHO all
......
DROP FUNCTION autoinc(); -- Adjust this setting to control where the objects get created.
SET search_path = public;
CREATE FUNCTION autoinc() SET autocommit TO 'on';
RETURNS trigger
AS 'MODULE_PATHNAME' CREATE OR REPLACE FUNCTION autoinc()
LANGUAGE 'C'; RETURNS trigger
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
DROP FUNCTION insert_username(); -- Adjust this setting to control where the objects get created.
SET search_path = public;
CREATE FUNCTION insert_username() SET autocommit TO 'on';
RETURNS trigger
AS 'MODULE_PATHNAME' CREATE OR REPLACE FUNCTION insert_username()
LANGUAGE 'C'; RETURNS trigger
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
DROP FUNCTION moddatetime(); -- Adjust this setting to control where the objects get created.
SET search_path = public;
CREATE FUNCTION moddatetime() SET autocommit TO 'on';
RETURNS trigger
AS 'MODULE_PATHNAME' CREATE OR REPLACE FUNCTION moddatetime()
LANGUAGE 'C'; RETURNS trigger
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
DROP FUNCTION check_primary_key (); -- Adjust this setting to control where the objects get created.
DROP FUNCTION check_foreign_key (); SET search_path = public;
CREATE FUNCTION check_primary_key () SET autocommit TO 'on';
RETURNS trigger
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION check_foreign_key () CREATE OR REPLACE FUNCTION check_primary_key()
RETURNS trigger RETURNS trigger
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C'; LANGUAGE 'C';
CREATE OR REPLACE FUNCTION check_foreign_key()
RETURNS trigger
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
DROP FUNCTION timetravel(); -- Adjust this setting to control where the objects get created.
DROP FUNCTION set_timetravel(name, int4); SET search_path = public;
CREATE FUNCTION timetravel() SET autocommit TO 'on';
RETURNS trigger
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION set_timetravel(name, int4) CREATE OR REPLACE FUNCTION timetravel()
RETURNS int4 RETURNS trigger
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict); LANGUAGE 'C';
CREATE OR REPLACE FUNCTION set_timetravel(name, int4)
RETURNS int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C' WITH (isStrict);
...@@ -9,71 +9,76 @@ ...@@ -9,71 +9,76 @@
-- Define the new output functions. -- Define the new output functions.
-- --
create function c_charout(bpchar) returns cstring CREATE FUNCTION c_charout(bpchar)
as 'MODULE_PATHNAME' RETURNS cstring
language 'c'; AS 'MODULE_PATHNAME'
LANGUAGE 'C';
create function c_textout(text) returns cstring CREATE FUNCTION c_textout(text)
as 'MODULE_PATHNAME' RETURNS cstring
language 'c'; AS 'MODULE_PATHNAME'
LANGUAGE 'C';
create function c_varcharout(varchar) returns cstring CREATE FUNCTION c_varcharout(varchar)
as 'MODULE_PATHNAME' RETURNS cstring
language 'c'; AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- This is not needed because escapes are handled by the parser -- This is not needed because escapes are handled by the parser
-- --
-- create function c_textin(cstring) -- CREATE FUNCTION c_textin(cstring)
-- returns text -- RETURNS text
-- as 'MODULE_PATHNAME' -- AS 'MODULE_PATHNAME'
-- language 'c'; -- LANGUAGE 'c';
-- Define a function which sets the new output routines for char types. -- Define a function which sets the new output routines for char types.
-- --
-- select c_mode(); -- SELECT c_mode();
-- --
create function c_mode() returns text CREATE FUNCTION c_mode()
as 'update pg_type set typoutput=''c_textout'' where typname=''SET''; RETURNS text
update pg_type set typoutput=''c_varcharout'' where typname=''bpchar''; AS ' UPDATE pg_type SET typoutput=''c_textout'' WHERE typname=''SET'';
update pg_type set typoutput=''c_textout'' where typname=''bytea''; UPDATE pg_type SET typoutput=''c_varcharout'' WHERE typname=''bpchar'';
update pg_type set typoutput=''c_charout'' where typname=''char''; UPDATE pg_type SET typoutput=''c_textout'' WHERE typname=''bytea'';
update pg_type set typoutput=''c_textout'' where typname=''text''; UPDATE pg_type SET typoutput=''c_charout'' WHERE typname=''char'';
update pg_type set typoutput=''c_textout'' where typname=''unknown''; UPDATE pg_type SET typoutput=''c_textout'' WHERE typname=''text'';
update pg_type set typoutput=''c_varcharout'' where typname=''varchar''; UPDATE pg_type SET typoutput=''c_textout'' WHERE typname=''unknown'';
UPDATE pg_type SET typoutput=''c_varcharout'' WHERE typname=''varchar'';
select ''c_mode''::text;' select ''c_mode''::text;'
language 'sql'; LANGUAGE 'SQL';
-- Define a function which restores the standard routines for char types. -- Define a function which restores the standard routines for char types.
-- --
-- select pg_mode(); -- SELECT pg_mode();
-- --
create function pg_mode() returns text CREATE FUNCTION pg_mode()
as 'update pg_type set typoutput=''textout'' where typname=''SET''; RETURNS text
update pg_type set typoutput=''varcharout'' where typname=''bpchar''; AS ' UPDATE pg_type SET typoutput=''textout'' WHERE typname=''SET'';
update pg_type set typoutput=''textout'' where typname=''bytea''; UPDATE pg_type SET typoutput=''varcharout'' WHERE typname=''bpchar'';
update pg_type set typoutput=''charout'' where typname=''char''; UPDATE pg_type SET typoutput=''textout'' WHERE typname=''bytea'';
update pg_type set typoutput=''textout'' where typname=''text''; UPDATE pg_type SET typoutput=''charout'' WHERE typname=''char'';
update pg_type set typoutput=''textout'' where typname=''unknown''; UPDATE pg_type SET typoutput=''textout'' WHERE typname=''text'';
update pg_type set typoutput=''varcharout'' where typname=''varchar''; UPDATE pg_type SET typoutput=''textout'' WHERE typname=''unknown'';
UPDATE pg_type SET typoutput=''varcharout'' WHERE typname=''varchar'';
select ''pg_mode''::text;' select ''pg_mode''::text;'
language 'sql'; LANGUAGE 'SQL';
-- Use these to do the changes manually. -- Use these to do the changes manually.
-- --
-- update pg_type set typoutput='textout' where typname='SET'; -- UPDATE pg_type SET typoutput='textout' WHERE typname='SET';
-- update pg_type set typoutput='varcharout' where typname='bpchar'; -- UPDATE pg_type SET typoutput='varcharout' WHERE typname='bpchar';
-- update pg_type set typoutput='textout' where typname='bytea'; -- UPDATE pg_type SET typoutput='textout' WHERE typname='bytea';
-- update pg_type set typoutput='charout' where typname='char'; -- UPDATE pg_type SET typoutput='charout' WHERE typname='char';
-- update pg_type set typoutput='textout' where typname='text'; -- UPDATE pg_type SET typoutput='textout' WHERE typname='text';
-- update pg_type set typoutput='textout' where typname='unknown'; -- UPDATE pg_type SET typoutput='textout' WHERE typname='unknown';
-- update pg_type set typoutput='varcharout' where typname='varchar'; -- UPDATE pg_type SET typoutput='varcharout' WHERE typname='varchar';
-- --
-- update pg_type set typoutput='c_textout' where typname='SET'; -- UPDATE pg_type SET typoutput='c_textout' WHERE typname='SET';
-- update pg_type set typoutput='c_varcharout' where typname='bpchar'; -- UPDATE pg_type SET typoutput='c_varcharout' WHERE typname='bpchar';
-- update pg_type set typoutput='c_textout' where typname='bytea'; -- UPDATE pg_type SET typoutput='c_textout' WHERE typname='bytea';
-- update pg_type set typoutput='c_charout' where typname='char'; -- UPDATE pg_type SET typoutput='c_charout' WHERE typname='char';
-- update pg_type set typoutput='c_textout' where typname='text'; -- UPDATE pg_type SET typoutput='c_textout' WHERE typname='text';
-- update pg_type set typoutput='c_textout' where typname='unknown'; -- UPDATE pg_type SET typoutput='c_textout' WHERE typname='unknown';
-- update pg_type set typoutput='c_varcharout' where typname='varchar'; -- UPDATE pg_type SET typoutput='c_varcharout' WHERE typname='varchar';
-- end of file -- end of file
...@@ -16,107 +16,107 @@ SELECT avg(normal_rand)::int FROM normal_rand(100, 250, 0.2, EXTRACT(SECONDS FRO ...@@ -16,107 +16,107 @@ SELECT avg(normal_rand)::int FROM normal_rand(100, 250, 0.2, EXTRACT(SECONDS FRO
-- --
-- crosstab() -- crosstab()
-- --
create table ct(id int, rowclass text, rowid text, attribute text, value text); CREATE TABLE ct(id int, rowclass text, rowid text, attribute text, value text);
\copy ct from 'data/ct.data' \copy ct from 'data/ct.data'
select * from crosstab2('select rowid, attribute, value from ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') order by 1,2;'); SELECT * FROM crosstab2('SELECT rowid, attribute, value FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;');
row_name | category_1 | category_2 row_name | category_1 | category_2
----------+------------+------------ ----------+------------+------------
test1 | val2 | val3 test1 | val2 | val3
test2 | val6 | val7 test2 | val6 | val7
(2 rows) (2 rows)
select * from crosstab3('select rowid, attribute, value from ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') order by 1,2;'); SELECT * FROM crosstab3('SELECT rowid, attribute, value FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;');
row_name | category_1 | category_2 | category_3 row_name | category_1 | category_2 | category_3
----------+------------+------------+------------ ----------+------------+------------+------------
test1 | val2 | val3 | test1 | val2 | val3 |
test2 | val6 | val7 | test2 | val6 | val7 |
(2 rows) (2 rows)
select * from crosstab4('select rowid, attribute, value from ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') order by 1,2;'); SELECT * FROM crosstab4('SELECT rowid, attribute, value FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;');
row_name | category_1 | category_2 | category_3 | category_4 row_name | category_1 | category_2 | category_3 | category_4
----------+------------+------------+------------+------------ ----------+------------+------------+------------+------------
test1 | val2 | val3 | | test1 | val2 | val3 | |
test2 | val6 | val7 | | test2 | val6 | val7 | |
(2 rows) (2 rows)
select * from crosstab2('select rowid, attribute, value from ct where rowclass = ''group1'' order by 1,2;'); SELECT * FROM crosstab2('SELECT rowid, attribute, value FROM ct where rowclass = ''group1'' ORDER BY 1,2;');
row_name | category_1 | category_2 row_name | category_1 | category_2
----------+------------+------------ ----------+------------+------------
test1 | val1 | val2 test1 | val1 | val2
test2 | val5 | val6 test2 | val5 | val6
(2 rows) (2 rows)
select * from crosstab3('select rowid, attribute, value from ct where rowclass = ''group1'' order by 1,2;'); SELECT * FROM crosstab3('SELECT rowid, attribute, value FROM ct where rowclass = ''group1'' ORDER BY 1,2;');
row_name | category_1 | category_2 | category_3 row_name | category_1 | category_2 | category_3
----------+------------+------------+------------ ----------+------------+------------+------------
test1 | val1 | val2 | val3 test1 | val1 | val2 | val3
test2 | val5 | val6 | val7 test2 | val5 | val6 | val7
(2 rows) (2 rows)
select * from crosstab4('select rowid, attribute, value from ct where rowclass = ''group1'' order by 1,2;'); SELECT * FROM crosstab4('SELECT rowid, attribute, value FROM ct where rowclass = ''group1'' ORDER BY 1,2;');
row_name | category_1 | category_2 | category_3 | category_4 row_name | category_1 | category_2 | category_3 | category_4
----------+------------+------------+------------+------------ ----------+------------+------------+------------+------------
test1 | val1 | val2 | val3 | val4 test1 | val1 | val2 | val3 | val4
test2 | val5 | val6 | val7 | val8 test2 | val5 | val6 | val7 | val8
(2 rows) (2 rows)
select * from crosstab2('select rowid, attribute, value from ct where rowclass = ''group2'' and (attribute = ''att1'' or attribute = ''att2'') order by 1,2;'); SELECT * FROM crosstab2('SELECT rowid, attribute, value FROM ct where rowclass = ''group2'' and (attribute = ''att1'' or attribute = ''att2'') ORDER BY 1,2;');
row_name | category_1 | category_2 row_name | category_1 | category_2
----------+------------+------------ ----------+------------+------------
test3 | val1 | val2 test3 | val1 | val2
test4 | val4 | val5 test4 | val4 | val5
(2 rows) (2 rows)
select * from crosstab3('select rowid, attribute, value from ct where rowclass = ''group2'' and (attribute = ''att1'' or attribute = ''att2'') order by 1,2;'); SELECT * FROM crosstab3('SELECT rowid, attribute, value FROM ct where rowclass = ''group2'' and (attribute = ''att1'' or attribute = ''att2'') ORDER BY 1,2;');
row_name | category_1 | category_2 | category_3 row_name | category_1 | category_2 | category_3
----------+------------+------------+------------ ----------+------------+------------+------------
test3 | val1 | val2 | test3 | val1 | val2 |
test4 | val4 | val5 | test4 | val4 | val5 |
(2 rows) (2 rows)
select * from crosstab4('select rowid, attribute, value from ct where rowclass = ''group2'' and (attribute = ''att1'' or attribute = ''att2'') order by 1,2;'); SELECT * FROM crosstab4('SELECT rowid, attribute, value FROM ct where rowclass = ''group2'' and (attribute = ''att1'' or attribute = ''att2'') ORDER BY 1,2;');
row_name | category_1 | category_2 | category_3 | category_4 row_name | category_1 | category_2 | category_3 | category_4
----------+------------+------------+------------+------------ ----------+------------+------------+------------+------------
test3 | val1 | val2 | | test3 | val1 | val2 | |
test4 | val4 | val5 | | test4 | val4 | val5 | |
(2 rows) (2 rows)
select * from crosstab2('select rowid, attribute, value from ct where rowclass = ''group2'' order by 1,2;'); SELECT * FROM crosstab2('SELECT rowid, attribute, value FROM ct where rowclass = ''group2'' ORDER BY 1,2;');
row_name | category_1 | category_2 row_name | category_1 | category_2
----------+------------+------------ ----------+------------+------------
test3 | val1 | val2 test3 | val1 | val2
test4 | val4 | val5 test4 | val4 | val5
(2 rows) (2 rows)
select * from crosstab3('select rowid, attribute, value from ct where rowclass = ''group2'' order by 1,2;'); SELECT * FROM crosstab3('SELECT rowid, attribute, value FROM ct where rowclass = ''group2'' ORDER BY 1,2;');
row_name | category_1 | category_2 | category_3 row_name | category_1 | category_2 | category_3
----------+------------+------------+------------ ----------+------------+------------+------------
test3 | val1 | val2 | val3 test3 | val1 | val2 | val3
test4 | val4 | val5 | val6 test4 | val4 | val5 | val6
(2 rows) (2 rows)
select * from crosstab4('select rowid, attribute, value from ct where rowclass = ''group2'' order by 1,2;'); SELECT * FROM crosstab4('SELECT rowid, attribute, value FROM ct where rowclass = ''group2'' ORDER BY 1,2;');
row_name | category_1 | category_2 | category_3 | category_4 row_name | category_1 | category_2 | category_3 | category_4
----------+------------+------------+------------+------------ ----------+------------+------------+------------+------------
test3 | val1 | val2 | val3 | test3 | val1 | val2 | val3 |
test4 | val4 | val5 | val6 | test4 | val4 | val5 | val6 |
(2 rows) (2 rows)
select * from crosstab('select rowid, attribute, value from ct where rowclass = ''group1'' order by 1,2;', 2) as c(rowid text, att1 text, att2 text); SELECT * FROM crosstab('SELECT rowid, attribute, value FROM ct where rowclass = ''group1'' ORDER BY 1,2;', 2) AS c(rowid text, att1 text, att2 text);
rowid | att1 | att2 rowid | att1 | att2
-------+------+------ -------+------+------
test1 | val1 | val2 test1 | val1 | val2
test2 | val5 | val6 test2 | val5 | val6
(2 rows) (2 rows)
select * from crosstab('select rowid, attribute, value from ct where rowclass = ''group1'' order by 1,2;', 3) as c(rowid text, att1 text, att2 text, att3 text); SELECT * FROM crosstab('SELECT rowid, attribute, value FROM ct where rowclass = ''group1'' ORDER BY 1,2;', 3) AS c(rowid text, att1 text, att2 text, att3 text);
rowid | att1 | att2 | att3 rowid | att1 | att2 | att3
-------+------+------+------ -------+------+------+------
test1 | val1 | val2 | val3 test1 | val1 | val2 | val3
test2 | val5 | val6 | val7 test2 | val5 | val6 | val7
(2 rows) (2 rows)
select * from crosstab('select rowid, attribute, value from ct where rowclass = ''group1'' order by 1,2;', 4) as c(rowid text, att1 text, att2 text, att3 text, att4 text); SELECT * FROM crosstab('SELECT rowid, attribute, value FROM ct where rowclass = ''group1'' ORDER BY 1,2;', 4) AS c(rowid text, att1 text, att2 text, att3 text, att4 text);
rowid | att1 | att2 | att3 | att4 rowid | att1 | att2 | att3 | att4
-------+------+------+------+------ -------+------+------+------+------
test1 | val1 | val2 | val3 | val4 test1 | val1 | val2 | val3 | val4
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
-- does not depend on contents of tablefunc.sql. -- does not depend on contents of tablefunc.sql.
-- --
\set ECHO none \set ECHO none
SET autocommit TO 'on';
\i tablefunc.sql \i tablefunc.sql
\set ECHO all \set ECHO all
...@@ -15,28 +16,28 @@ SELECT avg(normal_rand)::int FROM normal_rand(100, 250, 0.2, EXTRACT(SECONDS FRO ...@@ -15,28 +16,28 @@ SELECT avg(normal_rand)::int FROM normal_rand(100, 250, 0.2, EXTRACT(SECONDS FRO
-- --
-- crosstab() -- crosstab()
-- --
create table ct(id int, rowclass text, rowid text, attribute text, value text); CREATE TABLE ct(id int, rowclass text, rowid text, attribute text, value text);
\copy ct from 'data/ct.data' \copy ct from 'data/ct.data'
select * from crosstab2('select rowid, attribute, value from ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') order by 1,2;'); SELECT * FROM crosstab2('SELECT rowid, attribute, value FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;');
select * from crosstab3('select rowid, attribute, value from ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') order by 1,2;'); SELECT * FROM crosstab3('SELECT rowid, attribute, value FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;');
select * from crosstab4('select rowid, attribute, value from ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') order by 1,2;'); SELECT * FROM crosstab4('SELECT rowid, attribute, value FROM ct where rowclass = ''group1'' and (attribute = ''att2'' or attribute = ''att3'') ORDER BY 1,2;');
select * from crosstab2('select rowid, attribute, value from ct where rowclass = ''group1'' order by 1,2;'); SELECT * FROM crosstab2('SELECT rowid, attribute, value FROM ct where rowclass = ''group1'' ORDER BY 1,2;');
select * from crosstab3('select rowid, attribute, value from ct where rowclass = ''group1'' order by 1,2;'); SELECT * FROM crosstab3('SELECT rowid, attribute, value FROM ct where rowclass = ''group1'' ORDER BY 1,2;');
select * from crosstab4('select rowid, attribute, value from ct where rowclass = ''group1'' order by 1,2;'); SELECT * FROM crosstab4('SELECT rowid, attribute, value FROM ct where rowclass = ''group1'' ORDER BY 1,2;');
select * from crosstab2('select rowid, attribute, value from ct where rowclass = ''group2'' and (attribute = ''att1'' or attribute = ''att2'') order by 1,2;'); SELECT * FROM crosstab2('SELECT rowid, attribute, value FROM ct where rowclass = ''group2'' and (attribute = ''att1'' or attribute = ''att2'') ORDER BY 1,2;');
select * from crosstab3('select rowid, attribute, value from ct where rowclass = ''group2'' and (attribute = ''att1'' or attribute = ''att2'') order by 1,2;'); SELECT * FROM crosstab3('SELECT rowid, attribute, value FROM ct where rowclass = ''group2'' and (attribute = ''att1'' or attribute = ''att2'') ORDER BY 1,2;');
select * from crosstab4('select rowid, attribute, value from ct where rowclass = ''group2'' and (attribute = ''att1'' or attribute = ''att2'') order by 1,2;'); SELECT * FROM crosstab4('SELECT rowid, attribute, value FROM ct where rowclass = ''group2'' and (attribute = ''att1'' or attribute = ''att2'') ORDER BY 1,2;');
select * from crosstab2('select rowid, attribute, value from ct where rowclass = ''group2'' order by 1,2;'); SELECT * FROM crosstab2('SELECT rowid, attribute, value FROM ct where rowclass = ''group2'' ORDER BY 1,2;');
select * from crosstab3('select rowid, attribute, value from ct where rowclass = ''group2'' order by 1,2;'); SELECT * FROM crosstab3('SELECT rowid, attribute, value FROM ct where rowclass = ''group2'' ORDER BY 1,2;');
select * from crosstab4('select rowid, attribute, value from ct where rowclass = ''group2'' order by 1,2;'); SELECT * FROM crosstab4('SELECT rowid, attribute, value FROM ct where rowclass = ''group2'' ORDER BY 1,2;');
select * from crosstab('select rowid, attribute, value from ct where rowclass = ''group1'' order by 1,2;', 2) as c(rowid text, att1 text, att2 text); SELECT * FROM crosstab('SELECT rowid, attribute, value FROM ct where rowclass = ''group1'' ORDER BY 1,2;', 2) AS c(rowid text, att1 text, att2 text);
select * from crosstab('select rowid, attribute, value from ct where rowclass = ''group1'' order by 1,2;', 3) as c(rowid text, att1 text, att2 text, att3 text); SELECT * FROM crosstab('SELECT rowid, attribute, value FROM ct where rowclass = ''group1'' ORDER BY 1,2;', 3) AS c(rowid text, att1 text, att2 text, att3 text);
select * from crosstab('select rowid, attribute, value from ct where rowclass = ''group1'' order by 1,2;', 4) as c(rowid text, att1 text, att2 text, att3 text, att4 text); SELECT * FROM crosstab('SELECT rowid, attribute, value FROM ct where rowclass = ''group1'' ORDER BY 1,2;', 4) AS c(rowid text, att1 text, att2 text, att3 text, att4 text);
-- test connectby with text based hierarchy -- test connectby with text based hierarchy
CREATE TABLE connectby_text(keyid text, parent_keyid text); CREATE TABLE connectby_text(keyid text, parent_keyid text);
......
-- Adjust this setting to control where the objects get created.
SET search_path = public;
SET autocommit TO 'on';
CREATE OR REPLACE FUNCTION normal_rand(int4, float8, float8, int4) CREATE OR REPLACE FUNCTION normal_rand(int4, float8, float8, int4)
RETURNS setof float8 RETURNS setof float8
AS 'MODULE_PATHNAME','normal_rand' LANGUAGE 'c' VOLATILE STRICT; AS 'MODULE_PATHNAME','normal_rand'
LANGUAGE 'C' VOLATILE STRICT;
CREATE TYPE tablefunc_crosstab_2 AS CREATE TYPE tablefunc_crosstab_2 AS
( (
...@@ -27,33 +33,31 @@ CREATE TYPE tablefunc_crosstab_4 AS ...@@ -27,33 +33,31 @@ CREATE TYPE tablefunc_crosstab_4 AS
); );
CREATE OR REPLACE FUNCTION crosstab2(text) CREATE OR REPLACE FUNCTION crosstab2(text)
RETURNS setof tablefunc_crosstab_2 RETURNS setof tablefunc_crosstab_2
AS 'MODULE_PATHNAME','crosstab' LANGUAGE 'c' STABLE STRICT; AS 'MODULE_PATHNAME','crosstab'
LANGUAGE 'C' STABLE STRICT;
CREATE OR REPLACE FUNCTION crosstab3(text) CREATE OR REPLACE FUNCTION crosstab3(text)
RETURNS setof tablefunc_crosstab_3 RETURNS setof tablefunc_crosstab_3
AS 'MODULE_PATHNAME','crosstab' LANGUAGE 'c' STABLE STRICT; AS 'MODULE_PATHNAME','crosstab'
LANGUAGE 'C' STABLE STRICT;
CREATE OR REPLACE FUNCTION crosstab4(text) CREATE OR REPLACE FUNCTION crosstab4(text)
RETURNS setof tablefunc_crosstab_4 RETURNS setof tablefunc_crosstab_4
AS 'MODULE_PATHNAME','crosstab' LANGUAGE 'c' STABLE STRICT; AS 'MODULE_PATHNAME','crosstab'
LANGUAGE 'C' STABLE STRICT;
CREATE OR REPLACE FUNCTION crosstab(text,int) CREATE OR REPLACE FUNCTION crosstab(text,int)
RETURNS setof record RETURNS setof record
AS 'MODULE_PATHNAME','crosstab' LANGUAGE 'c' STABLE STRICT; AS 'MODULE_PATHNAME','crosstab'
LANGUAGE 'C' STABLE STRICT;
CREATE OR REPLACE FUNCTION connectby(text,text,text,text,int,text) CREATE OR REPLACE FUNCTION connectby(text,text,text,text,int,text)
RETURNS setof record RETURNS setof record
AS 'MODULE_PATHNAME','connectby_text' LANGUAGE 'c' STABLE STRICT; AS 'MODULE_PATHNAME','connectby_text'
LANGUAGE 'C' STABLE STRICT;
CREATE OR REPLACE FUNCTION connectby(text,text,text,text,int) CREATE OR REPLACE FUNCTION connectby(text,text,text,text,int)
RETURNS setof record RETURNS setof record
AS 'MODULE_PATHNAME','connectby_text' LANGUAGE 'c' STABLE STRICT; AS 'MODULE_PATHNAME','connectby_text'
LANGUAGE 'C' STABLE STRICT;
GRANT EXECUTE ON FUNCTION normal_rand(int4, float8, float8, int4) TO PUBLIC;
GRANT EXECUTE ON FUNCTION crosstab2(text) TO PUBLIC;
GRANT EXECUTE ON FUNCTION crosstab3(text) TO PUBLIC;
GRANT EXECUTE ON FUNCTION crosstab4(text) TO PUBLIC;
GRANT EXECUTE ON FUNCTION crosstab(text,int) TO PUBLIC;
GRANT EXECUTE ON FUNCTION connectby(text,text,text,text,int,text) TO PUBLIC;
GRANT EXECUTE ON FUNCTION connectby(text,text,text,text,int) TO PUBLIC;
...@@ -9,539 +9,539 @@ psql:tsearch.sql:40: WARNING: ProcedureCreate: type query_txt is not yet define ...@@ -9,539 +9,539 @@ psql:tsearch.sql:40: WARNING: ProcedureCreate: type query_txt is not yet define
psql:tsearch.sql:45: WARNING: Argument type "query_txt" is only a shell psql:tsearch.sql:45: WARNING: Argument type "query_txt" is only a shell
psql:tsearch.sql:57: WARNING: ProcedureCreate: type mquery_txt is not yet defined psql:tsearch.sql:57: WARNING: ProcedureCreate: type mquery_txt is not yet defined
psql:tsearch.sql:63: WARNING: Argument type "mquery_txt" is only a shell psql:tsearch.sql:63: WARNING: Argument type "mquery_txt" is only a shell
psql:tsearch.sql:133: WARNING: ProcedureCreate: type gtxtidx is not yet defined psql:tsearch.sql:158: WARNING: ProcedureCreate: type gtxtidx is not yet defined
psql:tsearch.sql:138: WARNING: Argument type "gtxtidx" is only a shell psql:tsearch.sql:163: WARNING: Argument type "gtxtidx" is only a shell
--txtidx --txtidx
select '1'::txtidx; SELECT '1'::txtidx;
txtidx txtidx
-------- --------
'1' '1'
(1 row) (1 row)
select '1 '::txtidx; SELECT '1 '::txtidx;
txtidx txtidx
-------- --------
'1' '1'
(1 row) (1 row)
select ' 1'::txtidx; SELECT ' 1'::txtidx;
txtidx txtidx
-------- --------
'1' '1'
(1 row) (1 row)
select ' 1 '::txtidx; SELECT ' 1 '::txtidx;
txtidx txtidx
-------- --------
'1' '1'
(1 row) (1 row)
select '1 2'::txtidx; SELECT '1 2'::txtidx;
txtidx txtidx
--------- ---------
'1' '2' '1' '2'
(1 row) (1 row)
select '\'1 2\''::txtidx; SELECT '\'1 2\''::txtidx;
txtidx txtidx
-------- --------
'1 2' '1 2'
(1 row) (1 row)
select '\'1 \\\'2\''::txtidx; SELECT '\'1 \\\'2\''::txtidx;
txtidx txtidx
--------- ---------
'1 \'2' '1 \'2'
(1 row) (1 row)
select '\'1 \\\'2\'3'::txtidx; SELECT '\'1 \\\'2\'3'::txtidx;
txtidx txtidx
------------- -------------
'3' '1 \'2' '3' '1 \'2'
(1 row) (1 row)
select '\'1 \\\'2\' 3'::txtidx; SELECT '\'1 \\\'2\' 3'::txtidx;
txtidx txtidx
------------- -------------
'3' '1 \'2' '3' '1 \'2'
(1 row) (1 row)
select '\'1 \\\'2\' \' 3\' 4 '::txtidx; SELECT '\'1 \\\'2\' \' 3\' 4 '::txtidx;
txtidx txtidx
------------------ ------------------
'4' ' 3' '1 \'2' '4' ' 3' '1 \'2'
(1 row) (1 row)
--query_txt --query_txt
select '1'::query_txt; SELECT '1'::query_txt;
query_txt query_txt
----------- -----------
'1' '1'
(1 row) (1 row)
select '1 '::query_txt; SELECT '1 '::query_txt;
query_txt query_txt
----------- -----------
'1' '1'
(1 row) (1 row)
select ' 1'::query_txt; SELECT ' 1'::query_txt;
query_txt query_txt
----------- -----------
'1' '1'
(1 row) (1 row)
select ' 1 '::query_txt; SELECT ' 1 '::query_txt;
query_txt query_txt
----------- -----------
'1' '1'
(1 row) (1 row)
select '\'1 2\''::query_txt; SELECT '\'1 2\''::query_txt;
query_txt query_txt
----------- -----------
'1 2' '1 2'
(1 row) (1 row)
select '\'1 \\\'2\''::query_txt; SELECT '\'1 \\\'2\''::query_txt;
query_txt query_txt
----------- -----------
'1 \'2' '1 \'2'
(1 row) (1 row)
select '!1'::query_txt; SELECT '!1'::query_txt;
query_txt query_txt
----------- -----------
!'1' !'1'
(1 row) (1 row)
select '1|2'::query_txt; SELECT '1|2'::query_txt;
query_txt query_txt
----------- -----------
'1' | '2' '1' | '2'
(1 row) (1 row)
select '1|!2'::query_txt; SELECT '1|!2'::query_txt;
query_txt query_txt
------------ ------------
'1' | !'2' '1' | !'2'
(1 row) (1 row)
select '!1|2'::query_txt; SELECT '!1|2'::query_txt;
query_txt query_txt
------------ ------------
!'1' | '2' !'1' | '2'
(1 row) (1 row)
select '!1|!2'::query_txt; SELECT '!1|!2'::query_txt;
query_txt query_txt
------------- -------------
!'1' | !'2' !'1' | !'2'
(1 row) (1 row)
select '!(!1|!2)'::query_txt; SELECT '!(!1|!2)'::query_txt;
query_txt query_txt
------------------ ------------------
!( !'1' | !'2' ) !( !'1' | !'2' )
(1 row) (1 row)
select '!(!1|2)'::query_txt; SELECT '!(!1|2)'::query_txt;
query_txt query_txt
----------------- -----------------
!( !'1' | '2' ) !( !'1' | '2' )
(1 row) (1 row)
select '!(1|!2)'::query_txt; SELECT '!(1|!2)'::query_txt;
query_txt query_txt
----------------- -----------------
!( '1' | !'2' ) !( '1' | !'2' )
(1 row) (1 row)
select '!(1|2)'::query_txt; SELECT '!(1|2)'::query_txt;
query_txt query_txt
---------------- ----------------
!( '1' | '2' ) !( '1' | '2' )
(1 row) (1 row)
select '1&2'::query_txt; SELECT '1&2'::query_txt;
query_txt query_txt
----------- -----------
'1' & '2' '1' & '2'
(1 row) (1 row)
select '!1&2'::query_txt; SELECT '!1&2'::query_txt;
query_txt query_txt
------------ ------------
!'1' & '2' !'1' & '2'
(1 row) (1 row)
select '1&!2'::query_txt; SELECT '1&!2'::query_txt;
query_txt query_txt
------------ ------------
'1' & !'2' '1' & !'2'
(1 row) (1 row)
select '!1&!2'::query_txt; SELECT '!1&!2'::query_txt;
query_txt query_txt
------------- -------------
!'1' & !'2' !'1' & !'2'
(1 row) (1 row)
select '(1&2)'::query_txt; SELECT '(1&2)'::query_txt;
query_txt query_txt
----------- -----------
'1' & '2' '1' & '2'
(1 row) (1 row)
select '1&(2)'::query_txt; SELECT '1&(2)'::query_txt;
query_txt query_txt
----------- -----------
'1' & '2' '1' & '2'
(1 row) (1 row)
select '!(1)&2'::query_txt; SELECT '!(1)&2'::query_txt;
query_txt query_txt
------------ ------------
!'1' & '2' !'1' & '2'
(1 row) (1 row)
select '!(1&2)'::query_txt; SELECT '!(1&2)'::query_txt;
query_txt query_txt
---------------- ----------------
!( '1' & '2' ) !( '1' & '2' )
(1 row) (1 row)
select '1|2&3'::query_txt; SELECT '1|2&3'::query_txt;
query_txt query_txt
----------------- -----------------
'1' | '2' & '3' '1' | '2' & '3'
(1 row) (1 row)
select '1|(2&3)'::query_txt; SELECT '1|(2&3)'::query_txt;
query_txt query_txt
----------------- -----------------
'1' | '2' & '3' '1' | '2' & '3'
(1 row) (1 row)
select '(1|2)&3'::query_txt; SELECT '(1|2)&3'::query_txt;
query_txt query_txt
--------------------- ---------------------
( '1' | '2' ) & '3' ( '1' | '2' ) & '3'
(1 row) (1 row)
select '1|2&!3'::query_txt; SELECT '1|2&!3'::query_txt;
query_txt query_txt
------------------ ------------------
'1' | '2' & !'3' '1' | '2' & !'3'
(1 row) (1 row)
select '1|!2&3'::query_txt; SELECT '1|!2&3'::query_txt;
query_txt query_txt
------------------ ------------------
'1' | !'2' & '3' '1' | !'2' & '3'
(1 row) (1 row)
select '!1|2&3'::query_txt; SELECT '!1|2&3'::query_txt;
query_txt query_txt
------------------ ------------------
!'1' | '2' & '3' !'1' | '2' & '3'
(1 row) (1 row)
select '!1|(2&3)'::query_txt; SELECT '!1|(2&3)'::query_txt;
query_txt query_txt
------------------ ------------------
!'1' | '2' & '3' !'1' | '2' & '3'
(1 row) (1 row)
select '!(1|2)&3'::query_txt; SELECT '!(1|2)&3'::query_txt;
query_txt query_txt
---------------------- ----------------------
!( '1' | '2' ) & '3' !( '1' | '2' ) & '3'
(1 row) (1 row)
select '(!1|2)&3'::query_txt; SELECT '(!1|2)&3'::query_txt;
query_txt query_txt
---------------------- ----------------------
( !'1' | '2' ) & '3' ( !'1' | '2' ) & '3'
(1 row) (1 row)
select '1|(2|(4|(5|6)))'::query_txt; SELECT '1|(2|(4|(5|6)))'::query_txt;
query_txt query_txt
----------------------------------------- -----------------------------------------
'1' | ( '2' | ( '4' | ( '5' | '6' ) ) ) '1' | ( '2' | ( '4' | ( '5' | '6' ) ) )
(1 row) (1 row)
select '1|2|4|5|6'::query_txt; SELECT '1|2|4|5|6'::query_txt;
query_txt query_txt
----------------------------------------- -----------------------------------------
( ( ( '1' | '2' ) | '4' ) | '5' ) | '6' ( ( ( '1' | '2' ) | '4' ) | '5' ) | '6'
(1 row) (1 row)
select '1&(2&(4&(5&6)))'::query_txt; SELECT '1&(2&(4&(5&6)))'::query_txt;
query_txt query_txt
----------------------------- -----------------------------
'1' & '2' & '4' & '5' & '6' '1' & '2' & '4' & '5' & '6'
(1 row) (1 row)
select '1&2&4&5&6'::query_txt; SELECT '1&2&4&5&6'::query_txt;
query_txt query_txt
----------------------------- -----------------------------
'1' & '2' & '4' & '5' & '6' '1' & '2' & '4' & '5' & '6'
(1 row) (1 row)
select '1&(2&(4&(5|6)))'::query_txt; SELECT '1&(2&(4&(5|6)))'::query_txt;
query_txt query_txt
--------------------------------- ---------------------------------
'1' & '2' & '4' & ( '5' | '6' ) '1' & '2' & '4' & ( '5' | '6' )
(1 row) (1 row)
select '1&(2&(4&(5|!6)))'::query_txt; SELECT '1&(2&(4&(5|!6)))'::query_txt;
query_txt query_txt
---------------------------------- ----------------------------------
'1' & '2' & '4' & ( '5' | !'6' ) '1' & '2' & '4' & ( '5' | !'6' )
(1 row) (1 row)
select '1&(\'2\'&(\' 4\'&(\\|5 | \'6 \\\' !|&\')))'::query_txt; SELECT '1&(\'2\'&(\' 4\'&(\\|5 | \'6 \\\' !|&\')))'::query_txt;
query_txt query_txt
------------------------------------------ ------------------------------------------
'1' & '2' & ' 4' & ( '|5' | '6 \' !|&' ) '1' & '2' & ' 4' & ( '|5' | '6 \' !|&' )
(1 row) (1 row)
select '1'::mquery_txt; SELECT '1'::mquery_txt;
mquery_txt mquery_txt
------------ ------------
'1' '1'
(1 row) (1 row)
select '1 '::mquery_txt; SELECT '1 '::mquery_txt;
mquery_txt mquery_txt
------------ ------------
'1' '1'
(1 row) (1 row)
select ' 1'::mquery_txt; SELECT ' 1'::mquery_txt;
mquery_txt mquery_txt
------------ ------------
'1' '1'
(1 row) (1 row)
select ' 1 '::mquery_txt; SELECT ' 1 '::mquery_txt;
mquery_txt mquery_txt
------------ ------------
'1' '1'
(1 row) (1 row)
select '\'1 2\''::mquery_txt; SELECT '\'1 2\''::mquery_txt;
mquery_txt mquery_txt
------------ ------------
'1' & '2' '1' & '2'
(1 row) (1 row)
select '\'1 \\\'2\''::mquery_txt; SELECT '\'1 \\\'2\''::mquery_txt;
mquery_txt mquery_txt
------------ ------------
'1' & '2' '1' & '2'
(1 row) (1 row)
select '!1'::mquery_txt; SELECT '!1'::mquery_txt;
mquery_txt mquery_txt
------------ ------------
!'1' !'1'
(1 row) (1 row)
select '1|2'::mquery_txt; SELECT '1|2'::mquery_txt;
mquery_txt mquery_txt
------------ ------------
'1' | '2' '1' | '2'
(1 row) (1 row)
select '1|!2'::mquery_txt; SELECT '1|!2'::mquery_txt;
mquery_txt mquery_txt
------------ ------------
'1' | !'2' '1' | !'2'
(1 row) (1 row)
select '!1|2'::mquery_txt; SELECT '!1|2'::mquery_txt;
mquery_txt mquery_txt
------------ ------------
!'1' | '2' !'1' | '2'
(1 row) (1 row)
select '!1|!2'::mquery_txt; SELECT '!1|!2'::mquery_txt;
mquery_txt mquery_txt
------------- -------------
!'1' | !'2' !'1' | !'2'
(1 row) (1 row)
select '!(!1|!2)'::mquery_txt; SELECT '!(!1|!2)'::mquery_txt;
mquery_txt mquery_txt
------------------ ------------------
!( !'1' | !'2' ) !( !'1' | !'2' )
(1 row) (1 row)
select '!(!1|2)'::mquery_txt; SELECT '!(!1|2)'::mquery_txt;
mquery_txt mquery_txt
----------------- -----------------
!( !'1' | '2' ) !( !'1' | '2' )
(1 row) (1 row)
select '!(1|!2)'::mquery_txt; SELECT '!(1|!2)'::mquery_txt;
mquery_txt mquery_txt
----------------- -----------------
!( '1' | !'2' ) !( '1' | !'2' )
(1 row) (1 row)
select '!(1|2)'::mquery_txt; SELECT '!(1|2)'::mquery_txt;
mquery_txt mquery_txt
---------------- ----------------
!( '1' | '2' ) !( '1' | '2' )
(1 row) (1 row)
select '1&2'::mquery_txt; SELECT '1&2'::mquery_txt;
mquery_txt mquery_txt
------------ ------------
'1' & '2' '1' & '2'
(1 row) (1 row)
select '!1&2'::mquery_txt; SELECT '!1&2'::mquery_txt;
mquery_txt mquery_txt
------------ ------------
!'1' & '2' !'1' & '2'
(1 row) (1 row)
select '1&!2'::mquery_txt; SELECT '1&!2'::mquery_txt;
mquery_txt mquery_txt
------------ ------------
'1' & !'2' '1' & !'2'
(1 row) (1 row)
select '!1&!2'::mquery_txt; SELECT '!1&!2'::mquery_txt;
mquery_txt mquery_txt
------------- -------------
!'1' & !'2' !'1' & !'2'
(1 row) (1 row)
select '(1&2)'::mquery_txt; SELECT '(1&2)'::mquery_txt;
mquery_txt mquery_txt
------------ ------------
'1' & '2' '1' & '2'
(1 row) (1 row)
select '1&(2)'::mquery_txt; SELECT '1&(2)'::mquery_txt;
mquery_txt mquery_txt
------------ ------------
'1' & '2' '1' & '2'
(1 row) (1 row)
select '!(1)&2'::mquery_txt; SELECT '!(1)&2'::mquery_txt;
mquery_txt mquery_txt
------------ ------------
!'1' & '2' !'1' & '2'
(1 row) (1 row)
select '!(1&2)'::mquery_txt; SELECT '!(1&2)'::mquery_txt;
mquery_txt mquery_txt
---------------- ----------------
!( '1' & '2' ) !( '1' & '2' )
(1 row) (1 row)
select '1|2&3'::mquery_txt; SELECT '1|2&3'::mquery_txt;
mquery_txt mquery_txt
----------------- -----------------
'1' | '2' & '3' '1' | '2' & '3'
(1 row) (1 row)
select '1|(2&3)'::mquery_txt; SELECT '1|(2&3)'::mquery_txt;
mquery_txt mquery_txt
----------------- -----------------
'1' | '2' & '3' '1' | '2' & '3'
(1 row) (1 row)
select '(1|2)&3'::mquery_txt; SELECT '(1|2)&3'::mquery_txt;
mquery_txt mquery_txt
--------------------- ---------------------
( '1' | '2' ) & '3' ( '1' | '2' ) & '3'
(1 row) (1 row)
select '1|2&!3'::mquery_txt; SELECT '1|2&!3'::mquery_txt;
mquery_txt mquery_txt
------------------ ------------------
'1' | '2' & !'3' '1' | '2' & !'3'
(1 row) (1 row)
select '1|!2&3'::mquery_txt; SELECT '1|!2&3'::mquery_txt;
mquery_txt mquery_txt
------------------ ------------------
'1' | !'2' & '3' '1' | !'2' & '3'
(1 row) (1 row)
select '!1|2&3'::mquery_txt; SELECT '!1|2&3'::mquery_txt;
mquery_txt mquery_txt
------------------ ------------------
!'1' | '2' & '3' !'1' | '2' & '3'
(1 row) (1 row)
select '!1|(2&3)'::mquery_txt; SELECT '!1|(2&3)'::mquery_txt;
mquery_txt mquery_txt
------------------ ------------------
!'1' | '2' & '3' !'1' | '2' & '3'
(1 row) (1 row)
select '!(1|2)&3'::mquery_txt; SELECT '!(1|2)&3'::mquery_txt;
mquery_txt mquery_txt
---------------------- ----------------------
!( '1' | '2' ) & '3' !( '1' | '2' ) & '3'
(1 row) (1 row)
select '(!1|2)&3'::mquery_txt; SELECT '(!1|2)&3'::mquery_txt;
mquery_txt mquery_txt
---------------------- ----------------------
( !'1' | '2' ) & '3' ( !'1' | '2' ) & '3'
(1 row) (1 row)
select '1|(2|(4|(5|6)))'::mquery_txt; SELECT '1|(2|(4|(5|6)))'::mquery_txt;
mquery_txt mquery_txt
----------------------------------------- -----------------------------------------
'1' | ( '2' | ( '4' | ( '5' | '6' ) ) ) '1' | ( '2' | ( '4' | ( '5' | '6' ) ) )
(1 row) (1 row)
select '1|2|4|5|6'::mquery_txt; SELECT '1|2|4|5|6'::mquery_txt;
mquery_txt mquery_txt
----------------------------------------- -----------------------------------------
( ( ( '1' | '2' ) | '4' ) | '5' ) | '6' ( ( ( '1' | '2' ) | '4' ) | '5' ) | '6'
(1 row) (1 row)
select '1&(2&(4&(5&6)))'::mquery_txt; SELECT '1&(2&(4&(5&6)))'::mquery_txt;
mquery_txt mquery_txt
----------------------------- -----------------------------
'1' & '2' & '4' & '5' & '6' '1' & '2' & '4' & '5' & '6'
(1 row) (1 row)
select '1&2&4&5&6'::mquery_txt; SELECT '1&2&4&5&6'::mquery_txt;
mquery_txt mquery_txt
----------------------------- -----------------------------
'1' & '2' & '4' & '5' & '6' '1' & '2' & '4' & '5' & '6'
(1 row) (1 row)
select '1&(2&(4&(5|6)))'::mquery_txt; SELECT '1&(2&(4&(5|6)))'::mquery_txt;
mquery_txt mquery_txt
--------------------------------- ---------------------------------
'1' & '2' & '4' & ( '5' | '6' ) '1' & '2' & '4' & ( '5' | '6' )
(1 row) (1 row)
select '1&(2&(4&(5|!6)))'::mquery_txt; SELECT '1&(2&(4&(5|!6)))'::mquery_txt;
mquery_txt mquery_txt
---------------------------------- ----------------------------------
'1' & '2' & '4' & ( '5' | !'6' ) '1' & '2' & '4' & ( '5' | !'6' )
(1 row) (1 row)
select '1&(\'2\'&(\' 4\'&(\\|5 | \'6 \\\' !|&\')))'::mquery_txt; SELECT '1&(\'2\'&(\' 4\'&(\\|5 | \'6 \\\' !|&\')))'::mquery_txt;
mquery_txt mquery_txt
--------------------------------- ---------------------------------
'1' & '2' & '4' & ( '5' | '6' ) '1' & '2' & '4' & ( '5' | '6' )
(1 row) (1 row)
select 'querty-fgries | http://www.google.com/index.html | www.rambler.ru/index.shtml'::mquery_txt; SELECT 'querty-fgries | http://www.google.com/index.html | www.rambler.ru/index.shtml'::mquery_txt;
mquery_txt mquery_txt
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
( 'querty-fgri' & 'querti' & 'fgri' | 'www.google.com/index.html' & 'www.google.com' & '/index.html' ) | 'www.rambler.ru/index.shtml' & 'www.rambler.ru' & '/index.shtml' ( 'querty-fgri' & 'querti' & 'fgri' | 'www.google.com/index.html' & 'www.google.com' & '/index.html' ) | 'www.rambler.ru/index.shtml' & 'www.rambler.ru' & '/index.shtml'
...@@ -694,7 +694,7 @@ SELECT count(*) FROM test_txtidx WHERE a ## '(eq|yt)&(wR|qh)'; ...@@ -694,7 +694,7 @@ SELECT count(*) FROM test_txtidx WHERE a ## '(eq|yt)&(wR|qh)';
11 11
(1 row) (1 row)
select txt2txtidx('345 qwe@efd.r \' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>"> SELECT txt2txtidx('345 qwe@efd.r \' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>">
/usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234 /usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234
<i <b> wow < jqw <> qwerty'); <i <b> wow < jqw <> qwerty');
txt2txtidx txt2txtidx
...@@ -702,13 +702,13 @@ select txt2txtidx('345 qwe@efd.r \' http://www.com/ http://aew.werc.ewr/?ad=qwe& ...@@ -702,13 +702,13 @@ select txt2txtidx('345 qwe@efd.r \' http://www.com/ http://aew.werc.ewr/?ad=qwe&
'ad' 'dw' 'jf' '234' '345' '4.2' '455' 'jqw' 'qwe' 'wer' 'wow' 'asdf' 'ewr1' 'qwer' 'sdjk' '5.005' 'ewri2' 'qwqwe' 'wefjn' 'gist.c' 'gist.h' 'qwerti' '234.435' ':8100/?' 'qwe-wer' 'readlin' 'www.com' '+4.0e-10' 'gist.h.c' 'rewt/ewr' 'qwe@efd.r' 'readline-4' '/?ad=qwe&dw' '/wqe-324/ewr' 'aew.werc.ewr' '1aew.werc.ewr' '2aew.werc.ewr' '3aew.werc.ewr' '4aew.werc.ewr' '5aew.werc.ewr' '6aew.werc.ewr' '7aew.werc.ewr' '/usr/local/fff' '/awdf/dwqe/4325' ':8100/?ad=qwe&dw' 'teodor@stack.net' '5aew.werc.ewr:8100/?' ':8100/?ad=qwe&dw=%20%32' 'aew.werc.ewr/?ad=qwe&dw' '1aew.werc.ewr/?ad=qwe&dw' '3aew.werc.ewr/?ad=qwe&dw' '6aew.werc.ewr:8100/?ad=qwe&dw' '7aew.werc.ewr:8100/?ad=qwe&dw=%20%32' 'ad' 'dw' 'jf' '234' '345' '4.2' '455' 'jqw' 'qwe' 'wer' 'wow' 'asdf' 'ewr1' 'qwer' 'sdjk' '5.005' 'ewri2' 'qwqwe' 'wefjn' 'gist.c' 'gist.h' 'qwerti' '234.435' ':8100/?' 'qwe-wer' 'readlin' 'www.com' '+4.0e-10' 'gist.h.c' 'rewt/ewr' 'qwe@efd.r' 'readline-4' '/?ad=qwe&dw' '/wqe-324/ewr' 'aew.werc.ewr' '1aew.werc.ewr' '2aew.werc.ewr' '3aew.werc.ewr' '4aew.werc.ewr' '5aew.werc.ewr' '6aew.werc.ewr' '7aew.werc.ewr' '/usr/local/fff' '/awdf/dwqe/4325' ':8100/?ad=qwe&dw' 'teodor@stack.net' '5aew.werc.ewr:8100/?' ':8100/?ad=qwe&dw=%20%32' 'aew.werc.ewr/?ad=qwe&dw' '1aew.werc.ewr/?ad=qwe&dw' '3aew.werc.ewr/?ad=qwe&dw' '6aew.werc.ewr:8100/?ad=qwe&dw' '7aew.werc.ewr:8100/?ad=qwe&dw=%20%32'
(1 row) (1 row)
select txtidxsize(txt2txtidx('345 qw')); SELECT txtidxsize(txt2txtidx('345 qw'));
txtidxsize txtidxsize
------------ ------------
2 2
(1 row) (1 row)
select txtidxsize(txt2txtidx('345 qwe@efd.r \' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>"> SELECT txtidxsize(txt2txtidx('345 qwe@efd.r \' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>">
/usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234 /usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234
<i <b> wow < jqw <> qwerty')); <i <b> wow < jqw <> qwerty'));
txtidxsize txtidxsize
...@@ -716,30 +716,31 @@ select txtidxsize(txt2txtidx('345 qwe@efd.r \' http://www.com/ http://aew.werc.e ...@@ -716,30 +716,31 @@ select txtidxsize(txt2txtidx('345 qwe@efd.r \' http://www.com/ http://aew.werc.e
53 53
(1 row) (1 row)
insert into test_txtidx (a) values ('345 qwerty'); INSERT INTO test_txtidx (a) VALUES ('345 qwerty');
create trigger txtidxupdate before update or insert on test_txtidx CREATE TRIGGER txtidxupdate
for each row execute procedure tsearch(a, t); BEFORE UPDATE OR INSERT ON test_txtidx
insert into test_txtidx (t) values ('345 qwerty'); FOR EACH ROW EXECUTE PROCEDURE tsearch(a, t);
select count(*) FROM test_txtidx WHERE a @@ '345&qwerty'; INSERT INTO test_txtidx (t) VALUES ('345 qwerty');
SELECT count(*) FROM test_txtidx WHERE a @@ '345&qwerty';
count count
------- -------
1 1
(1 row) (1 row)
select count(*) FROM test_txtidx WHERE a ## '345&qwerty'; SELECT count(*) FROM test_txtidx WHERE a ## '345&qwerty';
count count
------- -------
1 1
(1 row) (1 row)
update test_txtidx set t = null where t = '345 qwerty'; UPDATE test_txtidx SET t = null WHERE t = '345 qwerty';
select count(*) FROM test_txtidx WHERE a ## '345&qwerty'; SELECT count(*) FROM test_txtidx WHERE a ## '345&qwerty';
count count
------- -------
0 0
(1 row) (1 row)
select count(*) FROM test_txtidx WHERE a @@ '345&qwerty'; SELECT count(*) FROM test_txtidx WHERE a @@ '345&qwerty';
count count
------- -------
1 1
......
...@@ -3,101 +3,102 @@ ...@@ -3,101 +3,102 @@
-- does not depend on contents of seg.sql. -- does not depend on contents of seg.sql.
-- --
\set ECHO none \set ECHO none
SET autocommit TO 'on';
\i tsearch.sql \i tsearch.sql
\set ECHO all \set ECHO all
--txtidx --txtidx
select '1'::txtidx; SELECT '1'::txtidx;
select '1 '::txtidx; SELECT '1 '::txtidx;
select ' 1'::txtidx; SELECT ' 1'::txtidx;
select ' 1 '::txtidx; SELECT ' 1 '::txtidx;
select '1 2'::txtidx; SELECT '1 2'::txtidx;
select '\'1 2\''::txtidx; SELECT '\'1 2\''::txtidx;
select '\'1 \\\'2\''::txtidx; SELECT '\'1 \\\'2\''::txtidx;
select '\'1 \\\'2\'3'::txtidx; SELECT '\'1 \\\'2\'3'::txtidx;
select '\'1 \\\'2\' 3'::txtidx; SELECT '\'1 \\\'2\' 3'::txtidx;
select '\'1 \\\'2\' \' 3\' 4 '::txtidx; SELECT '\'1 \\\'2\' \' 3\' 4 '::txtidx;
--query_txt --query_txt
select '1'::query_txt; SELECT '1'::query_txt;
select '1 '::query_txt; SELECT '1 '::query_txt;
select ' 1'::query_txt; SELECT ' 1'::query_txt;
select ' 1 '::query_txt; SELECT ' 1 '::query_txt;
select '\'1 2\''::query_txt; SELECT '\'1 2\''::query_txt;
select '\'1 \\\'2\''::query_txt; SELECT '\'1 \\\'2\''::query_txt;
select '!1'::query_txt; SELECT '!1'::query_txt;
select '1|2'::query_txt; SELECT '1|2'::query_txt;
select '1|!2'::query_txt; SELECT '1|!2'::query_txt;
select '!1|2'::query_txt; SELECT '!1|2'::query_txt;
select '!1|!2'::query_txt; SELECT '!1|!2'::query_txt;
select '!(!1|!2)'::query_txt; SELECT '!(!1|!2)'::query_txt;
select '!(!1|2)'::query_txt; SELECT '!(!1|2)'::query_txt;
select '!(1|!2)'::query_txt; SELECT '!(1|!2)'::query_txt;
select '!(1|2)'::query_txt; SELECT '!(1|2)'::query_txt;
select '1&2'::query_txt; SELECT '1&2'::query_txt;
select '!1&2'::query_txt; SELECT '!1&2'::query_txt;
select '1&!2'::query_txt; SELECT '1&!2'::query_txt;
select '!1&!2'::query_txt; SELECT '!1&!2'::query_txt;
select '(1&2)'::query_txt; SELECT '(1&2)'::query_txt;
select '1&(2)'::query_txt; SELECT '1&(2)'::query_txt;
select '!(1)&2'::query_txt; SELECT '!(1)&2'::query_txt;
select '!(1&2)'::query_txt; SELECT '!(1&2)'::query_txt;
select '1|2&3'::query_txt; SELECT '1|2&3'::query_txt;
select '1|(2&3)'::query_txt; SELECT '1|(2&3)'::query_txt;
select '(1|2)&3'::query_txt; SELECT '(1|2)&3'::query_txt;
select '1|2&!3'::query_txt; SELECT '1|2&!3'::query_txt;
select '1|!2&3'::query_txt; SELECT '1|!2&3'::query_txt;
select '!1|2&3'::query_txt; SELECT '!1|2&3'::query_txt;
select '!1|(2&3)'::query_txt; SELECT '!1|(2&3)'::query_txt;
select '!(1|2)&3'::query_txt; SELECT '!(1|2)&3'::query_txt;
select '(!1|2)&3'::query_txt; SELECT '(!1|2)&3'::query_txt;
select '1|(2|(4|(5|6)))'::query_txt; SELECT '1|(2|(4|(5|6)))'::query_txt;
select '1|2|4|5|6'::query_txt; SELECT '1|2|4|5|6'::query_txt;
select '1&(2&(4&(5&6)))'::query_txt; SELECT '1&(2&(4&(5&6)))'::query_txt;
select '1&2&4&5&6'::query_txt; SELECT '1&2&4&5&6'::query_txt;
select '1&(2&(4&(5|6)))'::query_txt; SELECT '1&(2&(4&(5|6)))'::query_txt;
select '1&(2&(4&(5|!6)))'::query_txt; SELECT '1&(2&(4&(5|!6)))'::query_txt;
select '1&(\'2\'&(\' 4\'&(\\|5 | \'6 \\\' !|&\')))'::query_txt; SELECT '1&(\'2\'&(\' 4\'&(\\|5 | \'6 \\\' !|&\')))'::query_txt;
select '1'::mquery_txt; SELECT '1'::mquery_txt;
select '1 '::mquery_txt; SELECT '1 '::mquery_txt;
select ' 1'::mquery_txt; SELECT ' 1'::mquery_txt;
select ' 1 '::mquery_txt; SELECT ' 1 '::mquery_txt;
select '\'1 2\''::mquery_txt; SELECT '\'1 2\''::mquery_txt;
select '\'1 \\\'2\''::mquery_txt; SELECT '\'1 \\\'2\''::mquery_txt;
select '!1'::mquery_txt; SELECT '!1'::mquery_txt;
select '1|2'::mquery_txt; SELECT '1|2'::mquery_txt;
select '1|!2'::mquery_txt; SELECT '1|!2'::mquery_txt;
select '!1|2'::mquery_txt; SELECT '!1|2'::mquery_txt;
select '!1|!2'::mquery_txt; SELECT '!1|!2'::mquery_txt;
select '!(!1|!2)'::mquery_txt; SELECT '!(!1|!2)'::mquery_txt;
select '!(!1|2)'::mquery_txt; SELECT '!(!1|2)'::mquery_txt;
select '!(1|!2)'::mquery_txt; SELECT '!(1|!2)'::mquery_txt;
select '!(1|2)'::mquery_txt; SELECT '!(1|2)'::mquery_txt;
select '1&2'::mquery_txt; SELECT '1&2'::mquery_txt;
select '!1&2'::mquery_txt; SELECT '!1&2'::mquery_txt;
select '1&!2'::mquery_txt; SELECT '1&!2'::mquery_txt;
select '!1&!2'::mquery_txt; SELECT '!1&!2'::mquery_txt;
select '(1&2)'::mquery_txt; SELECT '(1&2)'::mquery_txt;
select '1&(2)'::mquery_txt; SELECT '1&(2)'::mquery_txt;
select '!(1)&2'::mquery_txt; SELECT '!(1)&2'::mquery_txt;
select '!(1&2)'::mquery_txt; SELECT '!(1&2)'::mquery_txt;
select '1|2&3'::mquery_txt; SELECT '1|2&3'::mquery_txt;
select '1|(2&3)'::mquery_txt; SELECT '1|(2&3)'::mquery_txt;
select '(1|2)&3'::mquery_txt; SELECT '(1|2)&3'::mquery_txt;
select '1|2&!3'::mquery_txt; SELECT '1|2&!3'::mquery_txt;
select '1|!2&3'::mquery_txt; SELECT '1|!2&3'::mquery_txt;
select '!1|2&3'::mquery_txt; SELECT '!1|2&3'::mquery_txt;
select '!1|(2&3)'::mquery_txt; SELECT '!1|(2&3)'::mquery_txt;
select '!(1|2)&3'::mquery_txt; SELECT '!(1|2)&3'::mquery_txt;
select '(!1|2)&3'::mquery_txt; SELECT '(!1|2)&3'::mquery_txt;
select '1|(2|(4|(5|6)))'::mquery_txt; SELECT '1|(2|(4|(5|6)))'::mquery_txt;
select '1|2|4|5|6'::mquery_txt; SELECT '1|2|4|5|6'::mquery_txt;
select '1&(2&(4&(5&6)))'::mquery_txt; SELECT '1&(2&(4&(5&6)))'::mquery_txt;
select '1&2&4&5&6'::mquery_txt; SELECT '1&2&4&5&6'::mquery_txt;
select '1&(2&(4&(5|6)))'::mquery_txt; SELECT '1&(2&(4&(5|6)))'::mquery_txt;
select '1&(2&(4&(5|!6)))'::mquery_txt; SELECT '1&(2&(4&(5|!6)))'::mquery_txt;
select '1&(\'2\'&(\' 4\'&(\\|5 | \'6 \\\' !|&\')))'::mquery_txt; SELECT '1&(\'2\'&(\' 4\'&(\\|5 | \'6 \\\' !|&\')))'::mquery_txt;
select 'querty-fgries | http://www.google.com/index.html | www.rambler.ru/index.shtml'::mquery_txt; SELECT 'querty-fgries | http://www.google.com/index.html | www.rambler.ru/index.shtml'::mquery_txt;
CREATE TABLE test_txtidx( t text, a txtidx ); CREATE TABLE test_txtidx( t text, a txtidx );
...@@ -133,30 +134,31 @@ SELECT count(*) FROM test_txtidx WHERE a ## 'eq|yt'; ...@@ -133,30 +134,31 @@ SELECT count(*) FROM test_txtidx WHERE a ## 'eq|yt';
SELECT count(*) FROM test_txtidx WHERE a ## '(eq&yt)|(wR&qh)'; SELECT count(*) FROM test_txtidx WHERE a ## '(eq&yt)|(wR&qh)';
SELECT count(*) FROM test_txtidx WHERE a ## '(eq|yt)&(wR|qh)'; SELECT count(*) FROM test_txtidx WHERE a ## '(eq|yt)&(wR|qh)';
select txt2txtidx('345 qwe@efd.r \' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>"> SELECT txt2txtidx('345 qwe@efd.r \' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>">
/usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234 /usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234
<i <b> wow < jqw <> qwerty'); <i <b> wow < jqw <> qwerty');
select txtidxsize(txt2txtidx('345 qw')); SELECT txtidxsize(txt2txtidx('345 qw'));
select txtidxsize(txt2txtidx('345 qwe@efd.r \' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>"> SELECT txtidxsize(txt2txtidx('345 qwe@efd.r \' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>">
/usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234 /usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234
<i <b> wow < jqw <> qwerty')); <i <b> wow < jqw <> qwerty'));
insert into test_txtidx (a) values ('345 qwerty'); INSERT INTO test_txtidx (a) VALUES ('345 qwerty');
create trigger txtidxupdate before update or insert on test_txtidx CREATE TRIGGER txtidxupdate
for each row execute procedure tsearch(a, t); BEFORE UPDATE OR INSERT ON test_txtidx
FOR EACH ROW EXECUTE PROCEDURE tsearch(a, t);
insert into test_txtidx (t) values ('345 qwerty'); INSERT INTO test_txtidx (t) VALUES ('345 qwerty');
select count(*) FROM test_txtidx WHERE a @@ '345&qwerty'; SELECT count(*) FROM test_txtidx WHERE a @@ '345&qwerty';
select count(*) FROM test_txtidx WHERE a ## '345&qwerty'; SELECT count(*) FROM test_txtidx WHERE a ## '345&qwerty';
update test_txtidx set t = null where t = '345 qwerty'; UPDATE test_txtidx SET t = null WHERE t = '345 qwerty';
select count(*) FROM test_txtidx WHERE a ## '345&qwerty'; SELECT count(*) FROM test_txtidx WHERE a ## '345&qwerty';
select count(*) FROM test_txtidx WHERE a @@ '345&qwerty'; SELECT count(*) FROM test_txtidx WHERE a @@ '345&qwerty';
BEGIN TRANSACTION;
-- Adjust this setting to control where the objects get created. -- Adjust this setting to control where the objects get created.
SET search_path = public; SET search_path = public;
SET autocommit TO 'on';
-- TXTIDX type -- TXTIDX type
CREATE FUNCTION txtidx_in(cstring) CREATE FUNCTION txtidx_in(cstring)
RETURNS txtidx RETURNS txtidx
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' with (isstrict);
CREATE FUNCTION txtidx_out(txtidx) CREATE FUNCTION txtidx_out(txtidx)
RETURNS cstring RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' with (isstrict);
CREATE TYPE txtidx ( CREATE TYPE txtidx (
internallength = -1, INTERNALLENGTH = -1,
input = txtidx_in, INPUT = txtidx_in,
output = txtidx_out, OUTPUT = txtidx_out,
storage = extended STORAGE = extended
); );
CREATE FUNCTION txt2txtidx(text) CREATE FUNCTION txt2txtidx(text)
RETURNS txtidx RETURNS txtidx
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' with (isstrict);
CREATE FUNCTION txtidxsize(txtidx) CREATE FUNCTION txtidxsize(txtidx)
RETURNS int4 RETURNS int4
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' with (isstrict);
--QUERYTYPES --QUERYTYPES
--without morphology --without morphology
CREATE FUNCTION qtxt_in(cstring) CREATE FUNCTION qtxt_in(cstring)
RETURNS query_txt RETURNS query_txt
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' with (isstrict);
CREATE FUNCTION qtxt_out(query_txt) CREATE FUNCTION qtxt_out(query_txt)
RETURNS cstring RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' with (isstrict);
CREATE TYPE query_txt ( CREATE TYPE query_txt (
internallength = -1, INTERNALLENGTH = -1,
input = qtxt_in, INPUT = qtxt_in,
output = qtxt_out OUTPUT = qtxt_out
); );
--with morphology --with morphology
CREATE FUNCTION mqtxt_in(cstring) CREATE FUNCTION mqtxt_in(cstring)
RETURNS mquery_txt RETURNS mquery_txt
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' with (isstrict);
--same C output function as for query_txt --same C output function as for query_txt
CREATE FUNCTION mqtxt_out(mquery_txt) CREATE FUNCTION mqtxt_out(mquery_txt)
RETURNS cstring RETURNS cstring
AS 'MODULE_PATHNAME', 'qtxt_out' AS 'MODULE_PATHNAME', 'qtxt_out'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' with (isstrict);
CREATE TYPE mquery_txt ( CREATE TYPE mquery_txt (
internallength = -1, INTERNALLENGTH = -1,
input = mqtxt_in, INPUT = mqtxt_in,
output = mqtxt_out OUTPUT = mqtxt_out
); );
--only for debug --only for debug
CREATE FUNCTION querytree(query_txt) CREATE FUNCTION querytree(query_txt)
RETURNS text RETURNS text
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' with (isstrict);
CREATE FUNCTION querytree(mquery_txt) CREATE FUNCTION querytree(mquery_txt)
RETURNS text RETURNS text
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' with (isstrict);
--operations --operations
CREATE FUNCTION execqtxt(txtidx, query_txt) RETURNS bool CREATE FUNCTION execqtxt(txtidx, query_txt)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
COMMENT ON FUNCTION execqtxt(txtidx, query_txt) IS 'boolean operation with text index'; COMMENT ON FUNCTION execqtxt(txtidx, query_txt) IS 'boolean operation with text index';
CREATE FUNCTION execqtxt(txtidx, mquery_txt) RETURNS bool CREATE FUNCTION execqtxt(txtidx, mquery_txt)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
COMMENT ON FUNCTION execqtxt(txtidx, mquery_txt) IS 'boolean operation with text index'; COMMENT ON FUNCTION execqtxt(txtidx, mquery_txt) IS 'boolean operation with text index';
CREATE FUNCTION rexecqtxt(query_txt, txtidx) RETURNS bool CREATE FUNCTION rexecqtxt(query_txt, txtidx)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
COMMENT ON FUNCTION rexecqtxt(query_txt, txtidx) IS 'boolean operation with text index'; COMMENT ON FUNCTION rexecqtxt(query_txt, txtidx) IS 'boolean operation with text index';
CREATE FUNCTION rexecqtxt(mquery_txt, txtidx) RETURNS bool CREATE FUNCTION rexecqtxt(mquery_txt, txtidx)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
COMMENT ON FUNCTION rexecqtxt(mquery_txt, txtidx) IS 'boolean operation with text index'; COMMENT ON FUNCTION rexecqtxt(mquery_txt, txtidx) IS 'boolean operation with text index';
CREATE OPERATOR @@ ( CREATE OPERATOR @@ (
LEFTARG = txtidx, RIGHTARG = query_txt, PROCEDURE = execqtxt, LEFTARG = txtidx,
COMMUTATOR = '~@', RESTRICT = contsel, JOIN = contjoinsel RIGHTARG = query_txt,
PROCEDURE = execqtxt,
COMMUTATOR = '~@',
RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR ~@ ( CREATE OPERATOR ~@ (
LEFTARG = query_txt, RIGHTARG = txtidx, PROCEDURE = rexecqtxt, LEFTARG = query_txt,
COMMUTATOR = '@@', RESTRICT = contsel, JOIN = contjoinsel RIGHTARG = txtidx,
PROCEDURE = rexecqtxt,
COMMUTATOR = '@@',
RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR ## ( CREATE OPERATOR ## (
LEFTARG = txtidx, RIGHTARG = mquery_txt, PROCEDURE = execqtxt, LEFTARG = txtidx,
COMMUTATOR = '~#', RESTRICT = contsel, JOIN = contjoinsel RIGHTARG = mquery_txt,
PROCEDURE = execqtxt,
COMMUTATOR = '~#',
RESTRICT = contsel,
JOIN = contjoinsel
); );
CREATE OPERATOR ~# ( CREATE OPERATOR ~# (
LEFTARG = mquery_txt, RIGHTARG = txtidx, PROCEDURE = rexecqtxt, LEFTARG = mquery_txt,
COMMUTATOR = '##', RESTRICT = contsel, JOIN = contjoinsel RIGHTARG = txtidx,
PROCEDURE = rexecqtxt,
COMMUTATOR = '##',
RESTRICT = contsel,
JOIN = contjoinsel
); );
--Trigger --Trigger
create function tsearch() returns trigger as CREATE FUNCTION tsearch()
'MODULE_PATHNAME' RETURNS trigger
language 'C'; AS 'MODULE_PATHNAME'
LANGUAGE 'C';
--GiST --GiST
--GiST key type --GiST key type
CREATE FUNCTION gtxtidx_in(cstring) CREATE FUNCTION gtxtidx_in(cstring)
RETURNS gtxtidx RETURNS gtxtidx
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' with (isstrict);
CREATE FUNCTION gtxtidx_out(gtxtidx) CREATE FUNCTION gtxtidx_out(gtxtidx)
RETURNS cstring RETURNS cstring
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
LANGUAGE 'c' with (isstrict); LANGUAGE 'C' with (isstrict);
CREATE TYPE gtxtidx ( CREATE TYPE gtxtidx (
internallength = -1, INTERNALLENGTH = -1,
input = gtxtidx_in, INPUT = gtxtidx_in,
output = gtxtidx_out OUTPUT = gtxtidx_out
); );
-- support functions -- support functions
CREATE FUNCTION gtxtidx_consistent(gtxtidx,internal,int4) RETURNS bool CREATE FUNCTION gtxtidx_consistent(gtxtidx,internal,int4)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION gtxtidx_compress(internal) RETURNS internal CREATE FUNCTION gtxtidx_compress(internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION gtxtidx_decompress(internal) RETURNS internal CREATE FUNCTION gtxtidx_decompress(internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION gtxtidx_penalty(internal,internal,internal) RETURNS internal CREATE FUNCTION gtxtidx_penalty(internal,internal,internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict); RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict);
CREATE FUNCTION gtxtidx_picksplit(internal, internal) RETURNS internal CREATE FUNCTION gtxtidx_picksplit(internal, internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION gtxtidx_union(bytea, internal) RETURNS _int4 CREATE FUNCTION gtxtidx_union(bytea, internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS _int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION gtxtidx_same(gtxtidx, gtxtidx, internal) RETURNS internal CREATE FUNCTION gtxtidx_same(gtxtidx, gtxtidx, internal)
AS 'MODULE_PATHNAME' LANGUAGE 'c'; RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- create the operator class -- create the operator class
CREATE OPERATOR CLASS gist_txtidx_ops CREATE OPERATOR CLASS gist_txtidx_ops
DEFAULT FOR TYPE txtidx USING gist AS DEFAULT FOR TYPE txtidx USING gist
AS
OPERATOR 1 @@ (txtidx, query_txt) RECHECK , OPERATOR 1 @@ (txtidx, query_txt) RECHECK ,
OPERATOR 2 ## (txtidx, mquery_txt) RECHECK , OPERATOR 2 ## (txtidx, mquery_txt) RECHECK ,
FUNCTION 1 gtxtidx_consistent (gtxtidx, internal, int4), FUNCTION 1 gtxtidx_consistent (gtxtidx, internal, int4),
...@@ -178,6 +218,3 @@ CREATE OPERATOR CLASS gist_txtidx_ops ...@@ -178,6 +218,3 @@ CREATE OPERATOR CLASS gist_txtidx_ops
FUNCTION 6 gtxtidx_picksplit (internal, internal), FUNCTION 6 gtxtidx_picksplit (internal, internal),
FUNCTION 7 gtxtidx_same (gtxtidx, gtxtidx, internal), FUNCTION 7 gtxtidx_same (gtxtidx, gtxtidx, internal),
STORAGE gtxtidx; STORAGE gtxtidx;
END TRANSACTION;
...@@ -9,68 +9,82 @@ ...@@ -9,68 +9,82 @@
-- select user_lock(group,id,mode); -- select user_lock(group,id,mode);
-- --
create function user_lock(int4,int4,int4) returns int4 -- Adjust this setting to control where the objects get created.
as 'MODULE_PATHNAME' SET search_path = public;
language 'c';
-- select user_unlock(group,id,mode); SET autocommit TO 'on';
--
create function user_unlock(int4,int4,int4) returns int4 CREATE OR REPLACE FUNCTION user_lock(int4,int4,int4)
as 'MODULE_PATHNAME' RETURNS int4
language 'c'; AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- select user_write_lock(group,id); -- SELECT user_unlock(group,id,mode);
-- --
create function user_write_lock(int4,int4) returns int4 CREATE OR REPLACE FUNCTION user_unlock(int4,int4,int4)
as 'MODULE_PATHNAME' RETURNS int4
language 'c'; AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- select user_write_unlock(group,id); -- SELECT user_write_lock(group,id);
-- --
create function user_write_unlock(int4,int4) returns int4 CREATE OR REPLACE FUNCTION user_write_lock(int4,int4)
as 'MODULE_PATHNAME' RETURNS int4
language 'c'; AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- select user_write_lock(group,oid); -- SELECT user_write_unlock(group,id);
-- --
create function user_write_lock(int4,oid) returns int4 CREATE OR REPLACE FUNCTION user_write_unlock(int4,int4)
as 'MODULE_PATHNAME' RETURNS int4
language 'c'; AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- select user_write_unlock(group,oid); -- SELECT user_write_lock(group,oid);
-- --
create function user_write_unlock(int4,oid) returns int4 CREATE OR REPLACE FUNCTION user_write_lock(int4,oid)
as 'MODULE_PATHNAME' RETURNS int4
language 'c'; AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- select user_write_lock_oid(oid); -- SELECT user_write_unlock(group,oid);
-- --
create function user_write_lock_oid(oid) returns int4 CREATE OR REPLACE FUNCTION user_write_unlock(int4,oid)
as 'MODULE_PATHNAME' RETURNS int4
language 'c'; AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- select user_write_unlock_oid(oid); -- SELECT user_write_lock_oid(oid);
-- --
create function user_write_unlock_oid(oid) returns int4 CREATE OR REPLACE FUNCTION user_write_lock_oid(oid)
as 'MODULE_PATHNAME' RETURNS int4
language 'c'; AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- select user_write_lock_oid(int4); -- SELECT user_write_unlock_oid(oid);
-- --
create function user_write_lock_oid(int4) returns int4 CREATE OR REPLACE FUNCTION user_write_unlock_oid(oid)
as 'MODULE_PATHNAME' RETURNS int4
language 'c'; AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- select user_write_unlock_oid(int4); -- SELECT user_write_lock_oid(int4);
-- --
create function user_write_unlock_oid(int4) returns int4 CREATE OR REPLACE FUNCTION user_write_lock_oid(int4)
as 'MODULE_PATHNAME' RETURNS int4
language 'c'; AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- select user_unlock_all(); -- SELECT user_write_unlock_oid(int4);
-- --
create function user_unlock_all() returns int4 CREATE OR REPLACE FUNCTION user_write_unlock_oid(int4)
as 'MODULE_PATHNAME' RETURNS int4
language 'c'; AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- end of file -- SELECT user_unlock_all();
--
CREATE OR REPLACE FUNCTION user_unlock_all()
RETURNS int4
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/contrib/vacuumlo/vacuumlo.c,v 1.16 2002/10/03 17:20:39 momjian Exp $ * $Header: /cvsroot/pgsql/contrib/vacuumlo/vacuumlo.c,v 1.17 2002/10/18 18:41:21 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -207,6 +207,28 @@ vacuumlo(char *database, struct _param * param) ...@@ -207,6 +207,28 @@ vacuumlo(char *database, struct _param * param)
fprintf(stdout, "Test run: no large objects will be removed!\n"); fprintf(stdout, "Test run: no large objects will be removed!\n");
} }
res = PQexec(conn, "SET search_path = public");
if (PQresultStatus(res) != PGRES_COMMAND_OK)
{
fprintf(stderr, "Failed to set search_path on:\n");
fprintf(stderr, "%s", PQerrorMessage(conn));
PQclear(res);
PQfinish(conn);
return -1;
}
PQclear(res);
res = PQexec(conn, "SET autocommit TO 'on'");
if (PQresultStatus(res) != PGRES_COMMAND_OK)
{
fprintf(stderr, "Failed to set autocommit on:\n");
fprintf(stderr, "%s", PQerrorMessage(conn));
PQclear(res);
PQfinish(conn);
return -1;
}
PQclear(res);
/* /*
* First we create and populate the LO temp table * First we create and populate the LO temp table
*/ */
......
--SQL for XML parser --SQL for XML parser
CREATE FUNCTION pgxml_parse(text) RETURNS bool -- Adjust this setting to control where the objects get created.
AS '_OBJWD_/pgxml_dom_DLSUFFIX_' LANGUAGE 'c' WITH (isStrict); SET search_path = public;
CREATE FUNCTION pgxml_xpath(text,text,text,text) RETURNS text SET autocommit TO 'on';
AS '_OBJWD_/pgxml_dom_DLSUFFIX_' LANGUAGE 'c' WITH (isStrict);
\ No newline at end of file CREATE OR REPLACE FUNCTION pgxml_parse(text)
RETURNS bool
AS '_OBJWD_/pgxml_dom_DLSUFFIX_'
LANGUAGE 'c' WITH (isStrict);
CREATE OR REPLACE FUNCTION pgxml_xpath(text,text,text,text)
RETURNS text
AS '_OBJWD_/pgxml_dom_DLSUFFIX_'
LANGUAGE 'c' WITH (isStrict);
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group # Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California # Portions Copyright (c) 1994, Regents of the University of California
# #
# $Header: /cvsroot/pgsql/src/bin/scripts/Makefile,v 1.16 2002/08/27 03:38:27 momjian Exp $ # $Header: /cvsroot/pgsql/src/bin/scripts/Makefile,v 1.17 2002/10/18 18:41:22 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -19,9 +19,9 @@ SCRIPTS := createdb dropdb createuser dropuser createlang droplang vacuumdb \ ...@@ -19,9 +19,9 @@ SCRIPTS := createdb dropdb createuser dropuser createlang droplang vacuumdb \
all: $(SCRIPTS) all: $(SCRIPTS)
# we don't need this now, but we may need it some day, bjm 2002-01-03 # we don't need this now, but we may need it some day, bjm 2002-01-03
createlang: createlang.sh #createlang: createlang.sh
cp $< $@ # cp $< $@
chmod a+x $@ # chmod a+x $@
install: all installdirs install: all installdirs
for i in $(filter-out createlang, $(SCRIPTS)); do \ for i in $(filter-out createlang, $(SCRIPTS)); do \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment