1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Add btree_gin contrib module.

Teodor Sigaev and Oleg Bartunov
This commit is contained in:
Tom Lane
2009-03-25 23:20:01 +00:00
parent 87b8db3774
commit 9151e1bb06
57 changed files with 2781 additions and 3 deletions

View File

@ -0,0 +1,44 @@
set enable_seqscan=off;
CREATE TABLE test_bit (
i bit(3)
);
INSERT INTO test_bit VALUES ('001'),('010'),('011'),('100'),('101'),('110');
CREATE INDEX idx_bit ON test_bit USING gin (i);
SELECT * FROM test_bit WHERE i<'100'::bit(3) ORDER BY i;
i
-----
001
010
011
(3 rows)
SELECT * FROM test_bit WHERE i<='100'::bit(3) ORDER BY i;
i
-----
001
010
011
100
(4 rows)
SELECT * FROM test_bit WHERE i='100'::bit(3) ORDER BY i;
i
-----
100
(1 row)
SELECT * FROM test_bit WHERE i>='100'::bit(3) ORDER BY i;
i
-----
100
101
110
(3 rows)
SELECT * FROM test_bit WHERE i>'100'::bit(3) ORDER BY i;
i
-----
101
110
(2 rows)

View File

@ -0,0 +1,44 @@
set enable_seqscan=off;
CREATE TABLE test_bytea (
i bytea
);
INSERT INTO test_bytea VALUES ('aaa'),('a'),('abc'),('abb'),('axy'),('xyz');
CREATE INDEX idx_bytea ON test_bytea USING gin (i);
SELECT * FROM test_bytea WHERE i<'abc'::bytea ORDER BY i;
i
-----
a
aaa
abb
(3 rows)
SELECT * FROM test_bytea WHERE i<='abc'::bytea ORDER BY i;
i
-----
a
aaa
abb
abc
(4 rows)
SELECT * FROM test_bytea WHERE i='abc'::bytea ORDER BY i;
i
-----
abc
(1 row)
SELECT * FROM test_bytea WHERE i>='abc'::bytea ORDER BY i;
i
-----
abc
axy
xyz
(3 rows)
SELECT * FROM test_bytea WHERE i>'abc'::bytea ORDER BY i;
i
-----
axy
xyz
(2 rows)

View File

@ -0,0 +1,37 @@
set enable_seqscan=off;
CREATE TABLE test_char (
i "char"
);
INSERT INTO test_char VALUES ('a'),('b'),('c'),('d'),('e'),('f');
CREATE INDEX idx_char ON test_char USING gin (i);
SELECT * FROM test_char WHERE i<'d'::"char" ORDER BY i;
i
---
(0 rows)
SELECT * FROM test_char WHERE i<='d'::"char" ORDER BY i;
i
---
(0 rows)
SELECT * FROM test_char WHERE i='d'::"char" ORDER BY i;
i
---
d
(1 row)
SELECT * FROM test_char WHERE i>='d'::"char" ORDER BY i;
i
---
d
e
f
(3 rows)
SELECT * FROM test_char WHERE i>'d'::"char" ORDER BY i;
i
---
e
f
(2 rows)

View File

@ -0,0 +1,51 @@
set enable_seqscan=off;
CREATE TABLE test_cidr (
i cidr
);
INSERT INTO test_cidr VALUES
( '1.2.3.4' ),
( '1.2.4.4' ),
( '1.2.5.4' ),
( '1.2.6.4' ),
( '1.2.7.4' ),
( '1.2.8.4' )
;
CREATE INDEX idx_cidr ON test_cidr USING gin (i);
SELECT * FROM test_cidr WHERE i<'1.2.6.4'::cidr ORDER BY i;
i
------------
1.2.3.4/32
1.2.4.4/32
1.2.5.4/32
(3 rows)
SELECT * FROM test_cidr WHERE i<='1.2.6.4'::cidr ORDER BY i;
i
------------
1.2.3.4/32
1.2.4.4/32
1.2.5.4/32
1.2.6.4/32
(4 rows)
SELECT * FROM test_cidr WHERE i='1.2.6.4'::cidr ORDER BY i;
i
------------
1.2.6.4/32
(1 row)
SELECT * FROM test_cidr WHERE i>='1.2.6.4'::cidr ORDER BY i;
i
------------
1.2.6.4/32
1.2.7.4/32
1.2.8.4/32
(3 rows)
SELECT * FROM test_cidr WHERE i>'1.2.6.4'::cidr ORDER BY i;
i
------------
1.2.7.4/32
1.2.8.4/32
(2 rows)

View File

@ -0,0 +1,51 @@
set enable_seqscan=off;
CREATE TABLE test_date (
i date
);
INSERT INTO test_date VALUES
( '2004-10-23' ),
( '2004-10-24' ),
( '2004-10-25' ),
( '2004-10-26' ),
( '2004-10-27' ),
( '2004-10-28' )
;
CREATE INDEX idx_date ON test_date USING gin (i);
SELECT * FROM test_date WHERE i<'2004-10-26'::date ORDER BY i;
i
------------
10-23-2004
10-24-2004
10-25-2004
(3 rows)
SELECT * FROM test_date WHERE i<='2004-10-26'::date ORDER BY i;
i
------------
10-23-2004
10-24-2004
10-25-2004
10-26-2004
(4 rows)
SELECT * FROM test_date WHERE i='2004-10-26'::date ORDER BY i;
i
------------
10-26-2004
(1 row)
SELECT * FROM test_date WHERE i>='2004-10-26'::date ORDER BY i;
i
------------
10-26-2004
10-27-2004
10-28-2004
(3 rows)
SELECT * FROM test_date WHERE i>'2004-10-26'::date ORDER BY i;
i
------------
10-27-2004
10-28-2004
(2 rows)

View File

@ -0,0 +1,44 @@
set enable_seqscan=off;
CREATE TABLE test_float4 (
i float4
);
INSERT INTO test_float4 VALUES (-2),(-1),(0),(1),(2),(3);
CREATE INDEX idx_float4 ON test_float4 USING gin (i);
SELECT * FROM test_float4 WHERE i<1::float4 ORDER BY i;
i
----
-2
-1
0
(3 rows)
SELECT * FROM test_float4 WHERE i<=1::float4 ORDER BY i;
i
----
-2
-1
0
1
(4 rows)
SELECT * FROM test_float4 WHERE i=1::float4 ORDER BY i;
i
---
1
(1 row)
SELECT * FROM test_float4 WHERE i>=1::float4 ORDER BY i;
i
---
1
2
3
(3 rows)
SELECT * FROM test_float4 WHERE i>1::float4 ORDER BY i;
i
---
2
3
(2 rows)

View File

@ -0,0 +1,44 @@
set enable_seqscan=off;
CREATE TABLE test_float8 (
i float8
);
INSERT INTO test_float8 VALUES (-2),(-1),(0),(1),(2),(3);
CREATE INDEX idx_float8 ON test_float8 USING gin (i);
SELECT * FROM test_float8 WHERE i<1::float8 ORDER BY i;
i
----
-2
-1
0
(3 rows)
SELECT * FROM test_float8 WHERE i<=1::float8 ORDER BY i;
i
----
-2
-1
0
1
(4 rows)
SELECT * FROM test_float8 WHERE i=1::float8 ORDER BY i;
i
---
1
(1 row)
SELECT * FROM test_float8 WHERE i>=1::float8 ORDER BY i;
i
---
1
2
3
(3 rows)
SELECT * FROM test_float8 WHERE i>1::float8 ORDER BY i;
i
---
2
3
(2 rows)

View File

@ -0,0 +1,51 @@
set enable_seqscan=off;
CREATE TABLE test_inet (
i inet
);
INSERT INTO test_inet VALUES
( '1.2.3.4/16' ),
( '1.2.4.4/16' ),
( '1.2.5.4/16' ),
( '1.2.6.4/16' ),
( '1.2.7.4/16' ),
( '1.2.8.4/16' )
;
CREATE INDEX idx_inet ON test_inet USING gin (i);
SELECT * FROM test_inet WHERE i<'1.2.6.4/16'::inet ORDER BY i;
i
------------
1.2.3.4/16
1.2.4.4/16
1.2.5.4/16
(3 rows)
SELECT * FROM test_inet WHERE i<='1.2.6.4/16'::inet ORDER BY i;
i
------------
1.2.3.4/16
1.2.4.4/16
1.2.5.4/16
1.2.6.4/16
(4 rows)
SELECT * FROM test_inet WHERE i='1.2.6.4/16'::inet ORDER BY i;
i
------------
1.2.6.4/16
(1 row)
SELECT * FROM test_inet WHERE i>='1.2.6.4/16'::inet ORDER BY i;
i
------------
1.2.6.4/16
1.2.7.4/16
1.2.8.4/16
(3 rows)
SELECT * FROM test_inet WHERE i>'1.2.6.4/16'::inet ORDER BY i;
i
------------
1.2.7.4/16
1.2.8.4/16
(2 rows)

View File

@ -0,0 +1,3 @@
SET client_min_messages = warning;
\set ECHO none
RESET client_min_messages;

View File

@ -0,0 +1,44 @@
set enable_seqscan=off;
CREATE TABLE test_int2 (
i int2
);
INSERT INTO test_int2 VALUES (-2),(-1),(0),(1),(2),(3);
CREATE INDEX idx_int2 ON test_int2 USING gin (i);
SELECT * FROM test_int2 WHERE i<1::int2 ORDER BY i;
i
----
-2
-1
0
(3 rows)
SELECT * FROM test_int2 WHERE i<=1::int2 ORDER BY i;
i
----
-2
-1
0
1
(4 rows)
SELECT * FROM test_int2 WHERE i=1::int2 ORDER BY i;
i
---
1
(1 row)
SELECT * FROM test_int2 WHERE i>=1::int2 ORDER BY i;
i
---
1
2
3
(3 rows)
SELECT * FROM test_int2 WHERE i>1::int2 ORDER BY i;
i
---
2
3
(2 rows)

View File

@ -0,0 +1,44 @@
set enable_seqscan=off;
CREATE TABLE test_int4 (
i int4
);
INSERT INTO test_int4 VALUES (-2),(-1),(0),(1),(2),(3);
CREATE INDEX idx_int4 ON test_int4 USING gin (i);
SELECT * FROM test_int4 WHERE i<1::int4 ORDER BY i;
i
----
-2
-1
0
(3 rows)
SELECT * FROM test_int4 WHERE i<=1::int4 ORDER BY i;
i
----
-2
-1
0
1
(4 rows)
SELECT * FROM test_int4 WHERE i=1::int4 ORDER BY i;
i
---
1
(1 row)
SELECT * FROM test_int4 WHERE i>=1::int4 ORDER BY i;
i
---
1
2
3
(3 rows)
SELECT * FROM test_int4 WHERE i>1::int4 ORDER BY i;
i
---
2
3
(2 rows)

View File

@ -0,0 +1,44 @@
set enable_seqscan=off;
CREATE TABLE test_int8 (
i int8
);
INSERT INTO test_int8 VALUES (-2),(-1),(0),(1),(2),(3);
CREATE INDEX idx_int8 ON test_int8 USING gin (i);
SELECT * FROM test_int8 WHERE i<1::int8 ORDER BY i;
i
----
-2
-1
0
(3 rows)
SELECT * FROM test_int8 WHERE i<=1::int8 ORDER BY i;
i
----
-2
-1
0
1
(4 rows)
SELECT * FROM test_int8 WHERE i=1::int8 ORDER BY i;
i
---
1
(1 row)
SELECT * FROM test_int8 WHERE i>=1::int8 ORDER BY i;
i
---
1
2
3
(3 rows)
SELECT * FROM test_int8 WHERE i>1::int8 ORDER BY i;
i
---
2
3
(2 rows)

View File

@ -0,0 +1,51 @@
set enable_seqscan=off;
CREATE TABLE test_interval (
i interval
);
INSERT INTO test_interval VALUES
( '03:55:08' ),
( '04:55:08' ),
( '05:55:08' ),
( '08:55:08' ),
( '09:55:08' ),
( '10:55:08' )
;
CREATE INDEX idx_interval ON test_interval USING gin (i);
SELECT * FROM test_interval WHERE i<'08:55:08'::interval ORDER BY i;
i
--------------------------
@ 3 hours 55 mins 8 secs
@ 4 hours 55 mins 8 secs
@ 5 hours 55 mins 8 secs
(3 rows)
SELECT * FROM test_interval WHERE i<='08:55:08'::interval ORDER BY i;
i
--------------------------
@ 3 hours 55 mins 8 secs
@ 4 hours 55 mins 8 secs
@ 5 hours 55 mins 8 secs
@ 8 hours 55 mins 8 secs
(4 rows)
SELECT * FROM test_interval WHERE i='08:55:08'::interval ORDER BY i;
i
--------------------------
@ 8 hours 55 mins 8 secs
(1 row)
SELECT * FROM test_interval WHERE i>='08:55:08'::interval ORDER BY i;
i
---------------------------
@ 8 hours 55 mins 8 secs
@ 9 hours 55 mins 8 secs
@ 10 hours 55 mins 8 secs
(3 rows)
SELECT * FROM test_interval WHERE i>'08:55:08'::interval ORDER BY i;
i
---------------------------
@ 9 hours 55 mins 8 secs
@ 10 hours 55 mins 8 secs
(2 rows)

View File

@ -0,0 +1,51 @@
set enable_seqscan=off;
CREATE TABLE test_macaddr (
i macaddr
);
INSERT INTO test_macaddr VALUES
( '22:00:5c:03:55:08' ),
( '22:00:5c:04:55:08' ),
( '22:00:5c:05:55:08' ),
( '22:00:5c:08:55:08' ),
( '22:00:5c:09:55:08' ),
( '22:00:5c:10:55:08' )
;
CREATE INDEX idx_macaddr ON test_macaddr USING gin (i);
SELECT * FROM test_macaddr WHERE i<'22:00:5c:08:55:08'::macaddr ORDER BY i;
i
-------------------
22:00:5c:03:55:08
22:00:5c:04:55:08
22:00:5c:05:55:08
(3 rows)
SELECT * FROM test_macaddr WHERE i<='22:00:5c:08:55:08'::macaddr ORDER BY i;
i
-------------------
22:00:5c:03:55:08
22:00:5c:04:55:08
22:00:5c:05:55:08
22:00:5c:08:55:08
(4 rows)
SELECT * FROM test_macaddr WHERE i='22:00:5c:08:55:08'::macaddr ORDER BY i;
i
-------------------
22:00:5c:08:55:08
(1 row)
SELECT * FROM test_macaddr WHERE i>='22:00:5c:08:55:08'::macaddr ORDER BY i;
i
-------------------
22:00:5c:08:55:08
22:00:5c:09:55:08
22:00:5c:10:55:08
(3 rows)
SELECT * FROM test_macaddr WHERE i>'22:00:5c:08:55:08'::macaddr ORDER BY i;
i
-------------------
22:00:5c:09:55:08
22:00:5c:10:55:08
(2 rows)

View File

@ -0,0 +1,44 @@
set enable_seqscan=off;
CREATE TABLE test_money (
i money
);
INSERT INTO test_money VALUES ('-2'),('-1'),('0'),('1'),('2'),('3');
CREATE INDEX idx_money ON test_money USING gin (i);
SELECT * FROM test_money WHERE i<'1'::money ORDER BY i;
i
--------
-$2.00
-$1.00
$0.00
(3 rows)
SELECT * FROM test_money WHERE i<='1'::money ORDER BY i;
i
--------
-$2.00
-$1.00
$0.00
$1.00
(4 rows)
SELECT * FROM test_money WHERE i='1'::money ORDER BY i;
i
-------
$1.00
(1 row)
SELECT * FROM test_money WHERE i>='1'::money ORDER BY i;
i
-------
$1.00
$2.00
$3.00
(3 rows)
SELECT * FROM test_money WHERE i>'1'::money ORDER BY i;
i
-------
$2.00
$3.00
(2 rows)

View File

@ -0,0 +1,44 @@
set enable_seqscan=off;
CREATE TABLE test_numeric (
i numeric
);
INSERT INTO test_numeric VALUES (-2),(-1),(0),(1),(2),(3);
CREATE INDEX idx_numeric ON test_numeric USING gin (i);
SELECT * FROM test_numeric WHERE i<'1'::numeric ORDER BY i;
i
----
-2
-1
0
(3 rows)
SELECT * FROM test_numeric WHERE i<='1'::numeric ORDER BY i;
i
----
-2
-1
0
1
(4 rows)
SELECT * FROM test_numeric WHERE i='1'::numeric ORDER BY i;
i
---
1
(1 row)
SELECT * FROM test_numeric WHERE i>='1'::numeric ORDER BY i;
i
---
1
2
3
(3 rows)
SELECT * FROM test_numeric WHERE i>'1'::numeric ORDER BY i;
i
---
2
3
(2 rows)

View File

@ -0,0 +1,44 @@
set enable_seqscan=off;
CREATE TABLE test_oid (
i oid
);
INSERT INTO test_oid VALUES (0),(1),(2),(3),(4),(5);
CREATE INDEX idx_oid ON test_oid USING gin (i);
SELECT * FROM test_oid WHERE i<3::oid ORDER BY i;
i
---
0
1
2
(3 rows)
SELECT * FROM test_oid WHERE i<=3::oid ORDER BY i;
i
---
0
1
2
3
(4 rows)
SELECT * FROM test_oid WHERE i=3::oid ORDER BY i;
i
---
3
(1 row)
SELECT * FROM test_oid WHERE i>=3::oid ORDER BY i;
i
---
3
4
5
(3 rows)
SELECT * FROM test_oid WHERE i>3::oid ORDER BY i;
i
---
4
5
(2 rows)

View File

@ -0,0 +1,44 @@
set enable_seqscan=off;
CREATE TABLE test_text (
i text
);
INSERT INTO test_text VALUES ('aaa'),('a'),('abc'),('abb'),('axy'),('xyz');
CREATE INDEX idx_text ON test_text USING gin (i);
SELECT * FROM test_text WHERE i<'abc' ORDER BY i;
i
-----
a
aaa
abb
(3 rows)
SELECT * FROM test_text WHERE i<='abc' ORDER BY i;
i
-----
a
aaa
abb
abc
(4 rows)
SELECT * FROM test_text WHERE i='abc' ORDER BY i;
i
-----
abc
(1 row)
SELECT * FROM test_text WHERE i>='abc' ORDER BY i;
i
-----
abc
axy
xyz
(3 rows)
SELECT * FROM test_text WHERE i>'abc' ORDER BY i;
i
-----
axy
xyz
(2 rows)

View File

@ -0,0 +1,51 @@
set enable_seqscan=off;
CREATE TABLE test_time (
i time
);
INSERT INTO test_time VALUES
( '03:55:08' ),
( '04:55:08' ),
( '05:55:08' ),
( '08:55:08' ),
( '09:55:08' ),
( '10:55:08' )
;
CREATE INDEX idx_time ON test_time USING gin (i);
SELECT * FROM test_time WHERE i<'08:55:08'::time ORDER BY i;
i
----------
03:55:08
04:55:08
05:55:08
(3 rows)
SELECT * FROM test_time WHERE i<='08:55:08'::time ORDER BY i;
i
----------
03:55:08
04:55:08
05:55:08
08:55:08
(4 rows)
SELECT * FROM test_time WHERE i='08:55:08'::time ORDER BY i;
i
----------
08:55:08
(1 row)
SELECT * FROM test_time WHERE i>='08:55:08'::time ORDER BY i;
i
----------
08:55:08
09:55:08
10:55:08
(3 rows)
SELECT * FROM test_time WHERE i>'08:55:08'::time ORDER BY i;
i
----------
09:55:08
10:55:08
(2 rows)

View File

@ -0,0 +1,51 @@
set enable_seqscan=off;
CREATE TABLE test_timestamp (
i timestamp
);
INSERT INTO test_timestamp VALUES
( '2004-10-26 03:55:08' ),
( '2004-10-26 04:55:08' ),
( '2004-10-26 05:55:08' ),
( '2004-10-26 08:55:08' ),
( '2004-10-26 09:55:08' ),
( '2004-10-26 10:55:08' )
;
CREATE INDEX idx_timestamp ON test_timestamp USING gin (i);
SELECT * FROM test_timestamp WHERE i<'2004-10-26 08:55:08'::timestamp ORDER BY i;
i
--------------------------
Tue Oct 26 03:55:08 2004
Tue Oct 26 04:55:08 2004
Tue Oct 26 05:55:08 2004
(3 rows)
SELECT * FROM test_timestamp WHERE i<='2004-10-26 08:55:08'::timestamp ORDER BY i;
i
--------------------------
Tue Oct 26 03:55:08 2004
Tue Oct 26 04:55:08 2004
Tue Oct 26 05:55:08 2004
Tue Oct 26 08:55:08 2004
(4 rows)
SELECT * FROM test_timestamp WHERE i='2004-10-26 08:55:08'::timestamp ORDER BY i;
i
--------------------------
Tue Oct 26 08:55:08 2004
(1 row)
SELECT * FROM test_timestamp WHERE i>='2004-10-26 08:55:08'::timestamp ORDER BY i;
i
--------------------------
Tue Oct 26 08:55:08 2004
Tue Oct 26 09:55:08 2004
Tue Oct 26 10:55:08 2004
(3 rows)
SELECT * FROM test_timestamp WHERE i>'2004-10-26 08:55:08'::timestamp ORDER BY i;
i
--------------------------
Tue Oct 26 09:55:08 2004
Tue Oct 26 10:55:08 2004
(2 rows)

View File

@ -0,0 +1,51 @@
set enable_seqscan=off;
CREATE TABLE test_timestamptz (
i timestamptz
);
INSERT INTO test_timestamptz VALUES
( '2004-10-26 03:55:08' ),
( '2004-10-26 04:55:08' ),
( '2004-10-26 05:55:08' ),
( '2004-10-26 08:55:08' ),
( '2004-10-26 09:55:08' ),
( '2004-10-26 10:55:08' )
;
CREATE INDEX idx_timestamptz ON test_timestamptz USING gin (i);
SELECT * FROM test_timestamptz WHERE i<'2004-10-26 08:55:08'::timestamptz ORDER BY i;
i
------------------------------
Tue Oct 26 03:55:08 2004 PDT
Tue Oct 26 04:55:08 2004 PDT
Tue Oct 26 05:55:08 2004 PDT
(3 rows)
SELECT * FROM test_timestamptz WHERE i<='2004-10-26 08:55:08'::timestamptz ORDER BY i;
i
------------------------------
Tue Oct 26 03:55:08 2004 PDT
Tue Oct 26 04:55:08 2004 PDT
Tue Oct 26 05:55:08 2004 PDT
Tue Oct 26 08:55:08 2004 PDT
(4 rows)
SELECT * FROM test_timestamptz WHERE i='2004-10-26 08:55:08'::timestamptz ORDER BY i;
i
------------------------------
Tue Oct 26 08:55:08 2004 PDT
(1 row)
SELECT * FROM test_timestamptz WHERE i>='2004-10-26 08:55:08'::timestamptz ORDER BY i;
i
------------------------------
Tue Oct 26 08:55:08 2004 PDT
Tue Oct 26 09:55:08 2004 PDT
Tue Oct 26 10:55:08 2004 PDT
(3 rows)
SELECT * FROM test_timestamptz WHERE i>'2004-10-26 08:55:08'::timestamptz ORDER BY i;
i
------------------------------
Tue Oct 26 09:55:08 2004 PDT
Tue Oct 26 10:55:08 2004 PDT
(2 rows)

View File

@ -0,0 +1,51 @@
set enable_seqscan=off;
CREATE TABLE test_timetz (
i timetz
);
INSERT INTO test_timetz VALUES
( '03:55:08 GMT+2' ),
( '04:55:08 GMT+2' ),
( '05:55:08 GMT+2' ),
( '08:55:08 GMT+2' ),
( '09:55:08 GMT+2' ),
( '10:55:08 GMT+2' )
;
CREATE INDEX idx_timetz ON test_timetz USING gin (i);
SELECT * FROM test_timetz WHERE i<'08:55:08 GMT+2'::timetz ORDER BY i;
i
-------------
03:55:08-02
04:55:08-02
05:55:08-02
(3 rows)
SELECT * FROM test_timetz WHERE i<='08:55:08 GMT+2'::timetz ORDER BY i;
i
-------------
03:55:08-02
04:55:08-02
05:55:08-02
08:55:08-02
(4 rows)
SELECT * FROM test_timetz WHERE i='08:55:08 GMT+2'::timetz ORDER BY i;
i
-------------
08:55:08-02
(1 row)
SELECT * FROM test_timetz WHERE i>='08:55:08 GMT+2'::timetz ORDER BY i;
i
-------------
08:55:08-02
09:55:08-02
10:55:08-02
(3 rows)
SELECT * FROM test_timetz WHERE i>'08:55:08 GMT+2'::timetz ORDER BY i;
i
-------------
09:55:08-02
10:55:08-02
(2 rows)

View File

@ -0,0 +1,44 @@
set enable_seqscan=off;
CREATE TABLE test_varbit (
i varbit
);
INSERT INTO test_varbit VALUES ('001'),('010'),('011'),('100'),('101'),('110');
CREATE INDEX idx_varbit ON test_varbit USING gin (i);
SELECT * FROM test_varbit WHERE i<'100'::varbit ORDER BY i;
i
-----
001
010
011
(3 rows)
SELECT * FROM test_varbit WHERE i<='100'::varbit ORDER BY i;
i
-----
001
010
011
100
(4 rows)
SELECT * FROM test_varbit WHERE i='100'::varbit ORDER BY i;
i
-----
100
(1 row)
SELECT * FROM test_varbit WHERE i>='100'::varbit ORDER BY i;
i
-----
100
101
110
(3 rows)
SELECT * FROM test_varbit WHERE i>'100'::varbit ORDER BY i;
i
-----
101
110
(2 rows)

View File

@ -0,0 +1,44 @@
set enable_seqscan=off;
CREATE TABLE test_varchar (
i varchar
);
INSERT INTO test_varchar VALUES ('aaa'),('a'),('abc'),('abb'),('axy'),('xyz');
CREATE INDEX idx_varchar ON test_varchar USING gin (i);
SELECT * FROM test_varchar WHERE i<'abc'::varchar ORDER BY i;
i
-----
a
aaa
abb
(3 rows)
SELECT * FROM test_varchar WHERE i<='abc'::varchar ORDER BY i;
i
-----
a
aaa
abb
abc
(4 rows)
SELECT * FROM test_varchar WHERE i='abc'::varchar ORDER BY i;
i
-----
abc
(1 row)
SELECT * FROM test_varchar WHERE i>='abc'::varchar ORDER BY i;
i
-----
abc
axy
xyz
(3 rows)
SELECT * FROM test_varchar WHERE i>'abc'::varchar ORDER BY i;
i
-----
axy
xyz
(2 rows)