Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6ccd052

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

File tree

3 files changed

+21
-2
lines changed
Filter options

3 files changed

+21
-2
lines changed

‎expected/rum_validate.out

Copy file name to clipboardExpand all lines: expected/rum_validate.out
+11-1Lines changed: 11 additions & 1 deletion
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

Copy file name to clipboardExpand all lines: sql/rum_validate.sql
+7-1Lines changed: 7 additions & 1 deletion
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

Copy file name to clipboardExpand all lines: src/rumutil.c
+3Lines changed: 3 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.