From 7d66bf261cf9c3452d8230a527aa5dff54d46a9a Mon Sep 17 00:00:00 2001 From: Tom Lane <tgl@sss.pgh.pa.us> Date: Mon, 27 Aug 2001 23:23:35 +0000 Subject: [PATCH] Add some minimal exercising of functional-index feature to regression tests. --- src/test/regress/expected/create_index.out | 13 +++++++++++++ src/test/regress/expected/sanity_check.out | 3 ++- src/test/regress/output/misc.source | 3 ++- src/test/regress/sql/create_index.sql | 14 ++++++++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.out index 06eeeecdd43..243198d79f2 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 ac0e344c747..47196e55993 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 a98ccd73e36..035065b9933 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 888edafe750..fe49d4ec2e2 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'); -- GitLab