Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit90a391c

Browse files
committed
Regression tests for new btree_gist "not equals" support.
Jeff Davis, with minor adjustments by me.
1 parent3491520 commit90a391c

File tree

3 files changed

+74
-2
lines changed

3 files changed

+74
-2
lines changed

‎contrib/btree_gist/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $PostgreSQL: pgsql/contrib/btree_gist/Makefile,v 1.12 2007/11/10 23:59:50 momjian Exp $
1+
# $PostgreSQL: pgsql/contrib/btree_gist/Makefile,v 1.13 2010/08/03 19:53:19 rhaas Exp $
22

33
MODULE_big = btree_gist
44

@@ -11,7 +11,7 @@ DATA_built = btree_gist.sql
1111
DATA = uninstall_btree_gist.sql
1212

1313
REGRESS = init int2 int4 int8 float4 float8 cash oid timestamp timestamptz time timetz\
14-
date interval macaddr inet cidr text varchar char bytea bit varbit numeric
14+
date interval macaddr inet cidr text varchar char bytea bit varbit numeric not_equal
1515

1616
ifdefUSE_PGXS
1717
PG_CONFIG = pg_config
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
SET enable_seqscan to false;
2+
-- test search for "not equals"
3+
CREATE TABLE test_ne (
4+
a TIMESTAMP,
5+
b NUMERIC
6+
);
7+
CREATE INDEX test_ne_idx ON test_ne USING gist (a, b);
8+
INSERT INTO test_ne SELECT '2009-01-01', 10.7 FROM generate_series(1,1000);
9+
INSERT INTO test_ne VALUES('2007-02-03', -91.3);
10+
INSERT INTO test_ne VALUES('2011-09-01', 43.7);
11+
INSERT INTO test_ne SELECT '2009-01-01', 10.7 FROM generate_series(1,1000);
12+
EXPLAIN (COSTS OFF) SELECT * FROM test_ne WHERE a <> '2009-01-01' AND b <> 10.7;
13+
QUERY PLAN
14+
------------------------------------------------------------------------------------------------------
15+
Bitmap Heap Scan on test_ne
16+
Recheck Cond: ((a <> 'Thu Jan 01 00:00:00 2009'::timestamp without time zone) AND (b <> 10.7))
17+
-> Bitmap Index Scan on test_ne_idx
18+
Index Cond: ((a <> 'Thu Jan 01 00:00:00 2009'::timestamp without time zone) AND (b <> 10.7))
19+
(4 rows)
20+
21+
SELECT * FROM test_ne WHERE a <> '2009-01-01' AND b <> 10.7;
22+
a | b
23+
--------------------------+-------
24+
Sat Feb 03 00:00:00 2007 | -91.3
25+
Thu Sep 01 00:00:00 2011 | 43.7
26+
(2 rows)
27+
28+
-- test search for "not equals" using an exclusion constraint
29+
CREATE TABLE zoo (
30+
cage INTEGER,
31+
animal TEXT,
32+
EXCLUDE USING gist (cage WITH =, animal WITH <>)
33+
);
34+
NOTICE: CREATE TABLE / EXCLUDE will create implicit index "zoo_cage_animal_excl" for table "zoo"
35+
INSERT INTO zoo VALUES(123, 'zebra');
36+
INSERT INTO zoo VALUES(123, 'zebra');
37+
INSERT INTO zoo VALUES(123, 'lion');
38+
ERROR: conflicting key value violates exclusion constraint "zoo_cage_animal_excl"
39+
DETAIL: Key (cage, animal)=(123, lion) conflicts with existing key (cage, animal)=(123, zebra).
40+
INSERT INTO zoo VALUES(124, 'lion');

‎contrib/btree_gist/sql/not_equal.sql

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
SET enable_seqscan to false;
3+
4+
-- test search for "not equals"
5+
6+
CREATETABLEtest_ne (
7+
aTIMESTAMP,
8+
bNUMERIC
9+
);
10+
CREATEINDEXtest_ne_idxON test_ne USING gist (a, b);
11+
12+
INSERT INTO test_neSELECT'2009-01-01',10.7FROM generate_series(1,1000);
13+
INSERT INTO test_neVALUES('2007-02-03',-91.3);
14+
INSERT INTO test_neVALUES('2011-09-01',43.7);
15+
INSERT INTO test_neSELECT'2009-01-01',10.7FROM generate_series(1,1000);
16+
17+
EXPLAIN (COSTS OFF)SELECT*FROM test_neWHERE a<>'2009-01-01'AND b<>10.7;
18+
19+
SELECT*FROM test_neWHERE a<>'2009-01-01'AND b<>10.7;
20+
21+
-- test search for "not equals" using an exclusion constraint
22+
23+
CREATETABLEzoo (
24+
cageINTEGER,
25+
animalTEXT,
26+
EXCLUDE USING gist (cage WITH=, animal WITH<>)
27+
);
28+
29+
INSERT INTO zooVALUES(123,'zebra');
30+
INSERT INTO zooVALUES(123,'zebra');
31+
INSERT INTO zooVALUES(123,'lion');
32+
INSERT INTO zooVALUES(124,'lion');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp