diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.out index 06eeeecdd4377425cf83754cbc989e107e316ee9..243198d79f2713a0dbef91b4f859c20ab604dd75 100644 --- a/src/test/regress/expected/create_index.out +++ b/src/test/regress/expected/create_index.out @@ -68,3 +68,16 @@ CREATE INDEX hash_name_index ON hash_name_heap USING hash (random name_ops); CREATE INDEX hash_txt_index ON hash_txt_heap USING hash (random text_ops); CREATE INDEX hash_f8_index ON hash_f8_heap USING hash (random float8_ops); -- CREATE INDEX hash_ovfl_index ON hash_ovfl_heap USING hash (x int4_ops); +-- +-- Test functional index +-- +CREATE TABLE func_index_heap (f1 text, f2 text); +CREATE UNIQUE INDEX func_index_index on func_index_heap (textcat(f1,f2)); +INSERT INTO func_index_heap VALUES('ABC','DEF'); +INSERT INTO func_index_heap VALUES('AB','CDEFG'); +INSERT INTO func_index_heap VALUES('QWE','RTY'); +-- this should fail because of unique index: +INSERT INTO func_index_heap VALUES('ABCD', 'EF'); +ERROR: Cannot insert a duplicate key into unique index func_index_index +-- but this shouldn't: +INSERT INTO func_index_heap VALUES('QWERTY'); diff --git a/src/test/regress/expected/sanity_check.out b/src/test/regress/expected/sanity_check.out index ac0e344c747c68026616bff71c5e340cf40e935b..47196e559931d635daade2063ed304b2369bfb26 100644 --- a/src/test/regress/expected/sanity_check.out +++ b/src/test/regress/expected/sanity_check.out @@ -15,6 +15,7 @@ SELECT relname, relhasindex bt_name_heap | t bt_txt_heap | t fast_emp4000 | t + func_index_heap | t hash_f8_heap | t hash_i4_heap | t hash_name_heap | t @@ -58,5 +59,5 @@ SELECT relname, relhasindex shighway | t tenk1 | t tenk2 | t -(48 rows) +(49 rows) diff --git a/src/test/regress/output/misc.source b/src/test/regress/output/misc.source index a98ccd73e36cb0db1ae72995c884d26a6d3e3b55..035065b993323a284e35d5dc255c697e6a954216 100644 --- a/src/test/regress/output/misc.source +++ b/src/test/regress/output/misc.source @@ -599,6 +599,7 @@ SELECT user_relns() AS user_relns fast_emp4000 float4_tbl float8_tbl + func_index_heap hash_f8_heap hash_i4_heap hash_name_heap @@ -653,7 +654,7 @@ SELECT user_relns() AS user_relns toyemp varchar_tbl xacttest -(90 rows) +(91 rows) --SELECT name(equipment(hobby_construct(text 'skywalking', text 'mer'))) AS equip_name; SELECT hobbies_by_name('basketball'); diff --git a/src/test/regress/sql/create_index.sql b/src/test/regress/sql/create_index.sql index 888edafe7502507f973d8b4deb5c3f98705d62c4..fe49d4ec2e2220d2909492dc3aa25edd126f7aab 100644 --- a/src/test/regress/sql/create_index.sql +++ b/src/test/regress/sql/create_index.sql @@ -90,3 +90,17 @@ CREATE INDEX hash_f8_index ON hash_f8_heap USING hash (random float8_ops); -- CREATE INDEX hash_ovfl_index ON hash_ovfl_heap USING hash (x int4_ops); + +-- +-- Test functional index +-- +CREATE TABLE func_index_heap (f1 text, f2 text); +CREATE UNIQUE INDEX func_index_index on func_index_heap (textcat(f1,f2)); + +INSERT INTO func_index_heap VALUES('ABC','DEF'); +INSERT INTO func_index_heap VALUES('AB','CDEFG'); +INSERT INTO func_index_heap VALUES('QWE','RTY'); +-- this should fail because of unique index: +INSERT INTO func_index_heap VALUES('ABCD', 'EF'); +-- but this shouldn't: +INSERT INTO func_index_heap VALUES('QWERTY');