Skip to content

Commit 6ccd052

Browse files
committed
[PGPRO-9026] Added check for attached column
1 parent 61258f4 commit 6ccd052

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

expected/rum_validate.out

+11-1
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,19 @@ SET enable_indexscan=on;
114114
SELECT a
115115
FROM test_rum
116116
WHERE a @@ to_tsquery('pg_catalog.english', 'bar')
117-
ORDER BY a <=> (to_tsquery('pg_catalog.english', 'bar'),0)
117+
ORDER BY a <=> (to_tsquery('pg_catalog.english', 'bar'),0);
118118
a
119119
------------------------------
120120
'bar':2,8 'foo':1,3,6 'qq':7
121121
(1 row)
122122

123+
-- PGPRO-9026: column and attached column cannot be the same
124+
CREATE TABLE test_array (i int2[]);
125+
CREATE INDEX idx_array ON test_array USING rum (i rum_anyarray_addon_ops) WITH (attach = 'i', to = 'i');
126+
ERROR: column "i" and attached column cannot be the same
127+
SELECT * FROM test_array WHERE i && '{1}';
128+
i
129+
---
130+
(0 rows)
131+
132+
DROP TABLE test_array;

sql/rum_validate.sql

+7-1
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,10 @@ SET enable_indexscan=on;
5858
SELECT a
5959
FROM test_rum
6060
WHERE a @@ to_tsquery('pg_catalog.english', 'bar')
61-
ORDER BY a <=> (to_tsquery('pg_catalog.english', 'bar'),0)
61+
ORDER BY a <=> (to_tsquery('pg_catalog.english', 'bar'),0);
62+
63+
-- PGPRO-9026: column and attached column cannot be the same
64+
CREATE TABLE test_array (i int2[]);
65+
CREATE INDEX idx_array ON test_array USING rum (i rum_anyarray_addon_ops) WITH (attach = 'i', to = 'i');
66+
SELECT * FROM test_array WHERE i && '{1}';
67+
DROP TABLE test_array;

src/rumutil.c

+3
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ initRumState(RumState * state, Relation index)
211211

212212
if (!AttributeNumberIsValid(state->attrnAddToColumn))
213213
elog(ERROR, "attribute \"%s\" is not found in index", colname);
214+
215+
if (state->attrnAddToColumn == state->attrnAttachColumn)
216+
elog(ERROR, "column \"%s\" and attached column cannot be the same", colname);
214217
}
215218

216219
if (!(AttributeNumberIsValid(state->attrnAttachColumn) &&

0 commit comments

Comments
 (0)