summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2001-07-16 05:07:00 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2001-07-16 05:07:00 +0000
commitf31dc0ada731d89313dbca7ef5da91d674fc640c (patch)
treea9c8343c489be6f99c5a9dff58838f72cf7d5dc4 /src/test
parent237e5dfa581503b2ab877c73eecde517d284563c (diff)
Partial indexes work again, courtesy of Martijn van Oosterhout.
Note: I didn't force an initdb, figuring that one today was enough. However, there is a new function in pg_proc.h, and pg_dump won't be able to dump partial indexes until you add that function.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/create_index.out15
-rw-r--r--src/test/regress/expected/portals_p2.out1
-rw-r--r--src/test/regress/expected/sanity_check.out3
-rw-r--r--src/test/regress/expected/select.out84
-rw-r--r--src/test/regress/sql/create_index.sql17
-rw-r--r--src/test/regress/sql/portals_p2.sql2
-rw-r--r--src/test/regress/sql/select.sql26
7 files changed, 104 insertions, 44 deletions
diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.out
index 3e727517741..06eeeecdd43 100644
--- a/src/test/regress/expected/create_index.out
+++ b/src/test/regress/expected/create_index.out
@@ -32,16 +32,13 @@ CREATE INDEX bt_txt_index ON bt_txt_heap USING btree (seqno text_ops);
CREATE INDEX bt_f8_index ON bt_f8_heap USING btree (seqno float8_ops);
--
-- BTREE partial indices
--- partial indices are not supported in PostgreSQL
--
---CREATE INDEX onek2_u1_prtl ON onek2 USING btree(unique1 int4_ops)
--- where onek2.unique1 < 20 or onek2.unique1 > 980;
---CREATE INDEX onek2_u2_prtl ON onek2 USING btree(unique2 int4_ops)
--- where onek2.stringu1 < 'B';
--- EXTEND INDEX onek2_u2_prtl where onek2.stringu1 < 'C';
--- EXTEND INDEX onek2_u2_prtl;
--- CREATE INDEX onek2_stu1_prtl ON onek2 USING btree(stringu1 name_ops)
--- where onek2.stringu1 >= 'J' and onek2.stringu1 < 'K';
+CREATE INDEX onek2_u1_prtl ON onek2 USING btree(unique1 int4_ops)
+ where unique1 < 20 or unique1 > 980;
+CREATE INDEX onek2_u2_prtl ON onek2 USING btree(unique2 int4_ops)
+ where stringu1 < 'B';
+CREATE INDEX onek2_stu1_prtl ON onek2 USING btree(stringu1 name_ops)
+ where onek2.stringu1 >= 'J' and onek2.stringu1 < 'K';
--
-- RTREE
--
diff --git a/src/test/regress/expected/portals_p2.out b/src/test/regress/expected/portals_p2.out
index 558397f5c9d..7a9cf696746 100644
--- a/src/test/regress/expected/portals_p2.out
+++ b/src/test/regress/expected/portals_p2.out
@@ -1,7 +1,6 @@
--
-- PORTALS_P2
--
--- EXTEND INDEX onek2_u1_prtl WHERE onek2.unique1 <= 60;
BEGIN;
DECLARE foo13 CURSOR FOR
SELECT * FROM onek WHERE unique1 = 50;
diff --git a/src/test/regress/expected/sanity_check.out b/src/test/regress/expected/sanity_check.out
index 5f5911c09c6..ac0e344c747 100644
--- a/src/test/regress/expected/sanity_check.out
+++ b/src/test/regress/expected/sanity_check.out
@@ -29,6 +29,7 @@ SELECT relname, relhasindex
num_exp_sqrt | t
num_exp_sub | t
onek | t
+ onek2 | t
pg_aggregate | t
pg_am | t
pg_amop | t
@@ -57,5 +58,5 @@ SELECT relname, relhasindex
shighway | t
tenk1 | t
tenk2 | t
-(47 rows)
+(48 rows)
diff --git a/src/test/regress/expected/select.out b/src/test/regress/expected/select.out
index ed6cbac1df0..7974d141c54 100644
--- a/src/test/regress/expected/select.out
+++ b/src/test/regress/expected/select.out
@@ -205,24 +205,88 @@ SELECT onek.unique1, onek.string4
(20 rows)
--
--- partial btree index
+-- test partial btree indexes
+--
+-- As of 7.2, planner probably won't pick an indexscan without stats,
+-- so ANALYZE first.
+--
+ANALYZE onek2;
+--
-- awk '{if($1<10){print $0;}else{next;}}' onek.data | sort +0n -1
--
---SELECT onek2.* WHERE onek2.unique1 < 10;
+SELECT onek2.* WHERE onek2.unique1 < 10;
+ unique1 | unique2 | two | four | ten | twenty | hundred | thousand | twothousand | fivethous | tenthous | odd | even | stringu1 | stringu2 | string4
+---------+---------+-----+------+-----+--------+---------+----------+-------------+-----------+----------+-----+------+----------+----------+---------
+ 0 | 998 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | AAAAAA | KMBAAA | OOOOxx
+ 1 | 214 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 2 | 3 | BAAAAA | GIAAAA | OOOOxx
+ 2 | 326 | 0 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 4 | 5 | CAAAAA | OMAAAA | OOOOxx
+ 3 | 431 | 1 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 6 | 7 | DAAAAA | PQAAAA | VVVVxx
+ 4 | 833 | 0 | 0 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 8 | 9 | EAAAAA | BGBAAA | HHHHxx
+ 5 | 541 | 1 | 1 | 5 | 5 | 5 | 5 | 5 | 5 | 5 | 10 | 11 | FAAAAA | VUAAAA | HHHHxx
+ 6 | 978 | 0 | 2 | 6 | 6 | 6 | 6 | 6 | 6 | 6 | 12 | 13 | GAAAAA | QLBAAA | OOOOxx
+ 7 | 647 | 1 | 3 | 7 | 7 | 7 | 7 | 7 | 7 | 7 | 14 | 15 | HAAAAA | XYAAAA | VVVVxx
+ 8 | 653 | 0 | 0 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 16 | 17 | IAAAAA | DZAAAA | HHHHxx
+ 9 | 49 | 1 | 1 | 9 | 9 | 9 | 9 | 9 | 9 | 9 | 18 | 19 | JAAAAA | XBAAAA | HHHHxx
+(10 rows)
+
--
--- partial btree index
-- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | sort +0nr -1
--
---SELECT onek2.unique1, onek2.stringu1
--- WHERE onek2.unique1 < 20
--- ORDER BY unique1 using >;
+SELECT onek2.unique1, onek2.stringu1
+ WHERE onek2.unique1 < 20
+ ORDER BY unique1 using >;
+ unique1 | stringu1
+---------+----------
+ 19 | TAAAAA
+ 18 | SAAAAA
+ 17 | RAAAAA
+ 16 | QAAAAA
+ 15 | PAAAAA
+ 14 | OAAAAA
+ 13 | NAAAAA
+ 12 | MAAAAA
+ 11 | LAAAAA
+ 10 | KAAAAA
+ 9 | JAAAAA
+ 8 | IAAAAA
+ 7 | HAAAAA
+ 6 | GAAAAA
+ 5 | FAAAAA
+ 4 | EAAAAA
+ 3 | DAAAAA
+ 2 | CAAAAA
+ 1 | BAAAAA
+ 0 | AAAAAA
+(20 rows)
+
--
-- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | sort +1d -2
--
---SELECT onek2.unique1, onek2.stringu1
--- WHERE onek2.unique1 > 980
--- ORDER BY stringu1 using <;
-
+SELECT onek2.unique1, onek2.stringu1
+ WHERE onek2.unique1 > 980;
+ unique1 | stringu1
+---------+----------
+ 981 | TLAAAA
+ 982 | ULAAAA
+ 983 | VLAAAA
+ 984 | WLAAAA
+ 985 | XLAAAA
+ 986 | YLAAAA
+ 987 | ZLAAAA
+ 988 | AMAAAA
+ 989 | BMAAAA
+ 990 | CMAAAA
+ 991 | DMAAAA
+ 992 | EMAAAA
+ 993 | FMAAAA
+ 994 | GMAAAA
+ 995 | HMAAAA
+ 996 | IMAAAA
+ 997 | JMAAAA
+ 998 | KMAAAA
+ 999 | LMAAAA
+(19 rows)
+
SELECT two, stringu1, ten, string4
INTO TABLE tmp
FROM onek;
diff --git a/src/test/regress/sql/create_index.sql b/src/test/regress/sql/create_index.sql
index 2ebc7ef3c3a..888edafe750 100644
--- a/src/test/regress/sql/create_index.sql
+++ b/src/test/regress/sql/create_index.sql
@@ -50,20 +50,15 @@ CREATE INDEX bt_f8_index ON bt_f8_heap USING btree (seqno float8_ops);
--
-- BTREE partial indices
--- partial indices are not supported in PostgreSQL
--
---CREATE INDEX onek2_u1_prtl ON onek2 USING btree(unique1 int4_ops)
--- where onek2.unique1 < 20 or onek2.unique1 > 980;
+CREATE INDEX onek2_u1_prtl ON onek2 USING btree(unique1 int4_ops)
+ where unique1 < 20 or unique1 > 980;
---CREATE INDEX onek2_u2_prtl ON onek2 USING btree(unique2 int4_ops)
--- where onek2.stringu1 < 'B';
+CREATE INDEX onek2_u2_prtl ON onek2 USING btree(unique2 int4_ops)
+ where stringu1 < 'B';
--- EXTEND INDEX onek2_u2_prtl where onek2.stringu1 < 'C';
-
--- EXTEND INDEX onek2_u2_prtl;
-
--- CREATE INDEX onek2_stu1_prtl ON onek2 USING btree(stringu1 name_ops)
--- where onek2.stringu1 >= 'J' and onek2.stringu1 < 'K';
+CREATE INDEX onek2_stu1_prtl ON onek2 USING btree(stringu1 name_ops)
+ where onek2.stringu1 >= 'J' and onek2.stringu1 < 'K';
--
-- RTREE
diff --git a/src/test/regress/sql/portals_p2.sql b/src/test/regress/sql/portals_p2.sql
index c1c92e1cf2b..12bd903e5f1 100644
--- a/src/test/regress/sql/portals_p2.sql
+++ b/src/test/regress/sql/portals_p2.sql
@@ -2,8 +2,6 @@
-- PORTALS_P2
--
--- EXTEND INDEX onek2_u1_prtl WHERE onek2.unique1 <= 60;
-
BEGIN;
DECLARE foo13 CURSOR FOR
diff --git a/src/test/regress/sql/select.sql b/src/test/regress/sql/select.sql
index 42b664eaaee..ee9389dc597 100644
--- a/src/test/regress/sql/select.sql
+++ b/src/test/regress/sql/select.sql
@@ -55,26 +55,32 @@ SELECT onek.unique1, onek.string4
ORDER BY unique1 using <, string4 using >;
--
--- partial btree index
+-- test partial btree indexes
+--
+-- As of 7.2, planner probably won't pick an indexscan without stats,
+-- so ANALYZE first.
+--
+ANALYZE onek2;
+
+--
-- awk '{if($1<10){print $0;}else{next;}}' onek.data | sort +0n -1
--
---SELECT onek2.* WHERE onek2.unique1 < 10;
+SELECT onek2.* WHERE onek2.unique1 < 10;
--
--- partial btree index
-- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | sort +0nr -1
--
---SELECT onek2.unique1, onek2.stringu1
--- WHERE onek2.unique1 < 20
--- ORDER BY unique1 using >;
+SELECT onek2.unique1, onek2.stringu1
+ WHERE onek2.unique1 < 20
+ ORDER BY unique1 using >;
--
-- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | sort +1d -2
--
---SELECT onek2.unique1, onek2.stringu1
--- WHERE onek2.unique1 > 980
--- ORDER BY stringu1 using <;
-
+SELECT onek2.unique1, onek2.stringu1
+ WHERE onek2.unique1 > 980;
+
+
SELECT two, stringu1, ten, string4
INTO TABLE tmp
FROM onek;