Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7d66bf2

Browse files
committed
Add some minimal exercising of functional-index feature to regression
tests.
1 parent c92b450 commit 7d66bf2

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

src/test/regress/expected/create_index.out

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,16 @@ CREATE INDEX hash_name_index ON hash_name_heap USING hash (random name_ops);
6868
CREATE INDEX hash_txt_index ON hash_txt_heap USING hash (random text_ops);
6969
CREATE INDEX hash_f8_index ON hash_f8_heap USING hash (random float8_ops);
7070
-- CREATE INDEX hash_ovfl_index ON hash_ovfl_heap USING hash (x int4_ops);
71+
--
72+
-- Test functional index
73+
--
74+
CREATE TABLE func_index_heap (f1 text, f2 text);
75+
CREATE UNIQUE INDEX func_index_index on func_index_heap (textcat(f1,f2));
76+
INSERT INTO func_index_heap VALUES('ABC','DEF');
77+
INSERT INTO func_index_heap VALUES('AB','CDEFG');
78+
INSERT INTO func_index_heap VALUES('QWE','RTY');
79+
-- this should fail because of unique index:
80+
INSERT INTO func_index_heap VALUES('ABCD', 'EF');
81+
ERROR: Cannot insert a duplicate key into unique index func_index_index
82+
-- but this shouldn't:
83+
INSERT INTO func_index_heap VALUES('QWERTY');

src/test/regress/expected/sanity_check.out

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ SELECT relname, relhasindex
1515
bt_name_heap | t
1616
bt_txt_heap | t
1717
fast_emp4000 | t
18+
func_index_heap | t
1819
hash_f8_heap | t
1920
hash_i4_heap | t
2021
hash_name_heap | t
@@ -58,5 +59,5 @@ SELECT relname, relhasindex
5859
shighway | t
5960
tenk1 | t
6061
tenk2 | t
61-
(48 rows)
62+
(49 rows)
6263

src/test/regress/output/misc.source

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ SELECT user_relns() AS user_relns
599599
fast_emp4000
600600
float4_tbl
601601
float8_tbl
602+
func_index_heap
602603
hash_f8_heap
603604
hash_i4_heap
604605
hash_name_heap
@@ -653,7 +654,7 @@ SELECT user_relns() AS user_relns
653654
toyemp
654655
varchar_tbl
655656
xacttest
656-
(90 rows)
657+
(91 rows)
657658

658659
--SELECT name(equipment(hobby_construct(text 'skywalking', text 'mer'))) AS equip_name;
659660
SELECT hobbies_by_name('basketball');

src/test/regress/sql/create_index.sql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,17 @@ CREATE INDEX hash_f8_index ON hash_f8_heap USING hash (random float8_ops);
9090

9191
-- CREATE INDEX hash_ovfl_index ON hash_ovfl_heap USING hash (x int4_ops);
9292

93+
94+
--
95+
-- Test functional index
96+
--
97+
CREATE TABLE func_index_heap (f1 text, f2 text);
98+
CREATE UNIQUE INDEX func_index_index on func_index_heap (textcat(f1,f2));
99+
100+
INSERT INTO func_index_heap VALUES('ABC','DEF');
101+
INSERT INTO func_index_heap VALUES('AB','CDEFG');
102+
INSERT INTO func_index_heap VALUES('QWE','RTY');
103+
-- this should fail because of unique index:
104+
INSERT INTO func_index_heap VALUES('ABCD', 'EF');
105+
-- but this shouldn't:
106+
INSERT INTO func_index_heap VALUES('QWERTY');

0 commit comments

Comments
 (0)