File tree 4 files changed +31
-2
lines changed
4 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -68,3 +68,16 @@ CREATE INDEX hash_name_index ON hash_name_heap USING hash (random name_ops);
68
68
CREATE INDEX hash_txt_index ON hash_txt_heap USING hash (random text_ops);
69
69
CREATE INDEX hash_f8_index ON hash_f8_heap USING hash (random float8_ops);
70
70
-- 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');
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ SELECT relname, relhasindex
15
15
bt_name_heap | t
16
16
bt_txt_heap | t
17
17
fast_emp4000 | t
18
+ func_index_heap | t
18
19
hash_f8_heap | t
19
20
hash_i4_heap | t
20
21
hash_name_heap | t
@@ -58,5 +59,5 @@ SELECT relname, relhasindex
58
59
shighway | t
59
60
tenk1 | t
60
61
tenk2 | t
61
- (48 rows)
62
+ (49 rows)
62
63
Original file line number Diff line number Diff line change @@ -599,6 +599,7 @@ SELECT user_relns() AS user_relns
599
599
fast_emp4000
600
600
float4_tbl
601
601
float8_tbl
602
+ func_index_heap
602
603
hash_f8_heap
603
604
hash_i4_heap
604
605
hash_name_heap
@@ -653,7 +654,7 @@ SELECT user_relns() AS user_relns
653
654
toyemp
654
655
varchar_tbl
655
656
xacttest
656
- (90 rows)
657
+ (91 rows)
657
658
658
659
--SELECT name(equipment(hobby_construct(text 'skywalking', text 'mer'))) AS equip_name;
659
660
SELECT hobbies_by_name('basketball');
Original file line number Diff line number Diff line change @@ -90,3 +90,17 @@ CREATE INDEX hash_f8_index ON hash_f8_heap USING hash (random float8_ops);
90
90
91
91
-- CREATE INDEX hash_ovfl_index ON hash_ovfl_heap USING hash (x int4_ops);
92
92
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' );
You can’t perform that action at this time.
0 commit comments