1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-16 16:42:29 +03:00

Disallow creation of indexes on system columns (except for OID).

Although OID acts pretty much like user data, the other system columns do
not, so an index on one would likely misbehave.  And it's pretty hard to
see a use-case for one, anyway.  Let's just forbid the case rather than
worry about whether it should be supported.

David Rowley
This commit is contained in:
Tom Lane
2016-04-16 12:11:41 -04:00
parent 99f2f3c19a
commit c34df8a003
3 changed files with 72 additions and 0 deletions

View File

@@ -824,6 +824,25 @@ DROP INDEX cwi_replaced_pkey; -- Should fail; a constraint depends on it
DROP TABLE cwi_test;
--
-- Check handling of indexes on system columns
--
CREATE TABLE oid_table (a INT) WITH OIDS;
-- An index on the OID column should be allowed
CREATE INDEX ON oid_table (oid);
-- Other system columns cannot be indexed
CREATE INDEX ON oid_table (ctid);
-- nor used in expressions
CREATE INDEX ON oid_table ((ctid >= '(1000,0)'));
-- nor used in predicates
CREATE INDEX ON oid_table (a) WHERE ctid >= '(1000,0)';
DROP TABLE oid_table;
--
-- Tests for IS NULL/IS NOT NULL with b-tree indexes
--