mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-31 08:27:23 +02:00
Add test for CREATE INDEX CONCURRENTLY with not-so-immutable predicate
83158f7
has improved index_set_state_flags() so as it is possible to use
transactional updates when updating pg_index state flags, but there was
not really a test case which stressed directly the possibility it fixed.
This commit adds such a test, using a predicate that looks valid in
appearance but calls a stable function.
Author: Andrey Lepikhov
Discussion: https://postgr.es/m/9b905019-5297-7372-0ad2-e1a4bb66a719@postgrespro.ru
Backpatch-through: 9.6
This commit is contained in:
parent
08acba558b
commit
38ca11adeb
@ -2529,6 +2529,18 @@ BEGIN;
|
|||||||
CREATE INDEX CONCURRENTLY concur_index7 ON concur_heap(f1);
|
CREATE INDEX CONCURRENTLY concur_index7 ON concur_heap(f1);
|
||||||
ERROR: CREATE INDEX CONCURRENTLY cannot run inside a transaction block
|
ERROR: CREATE INDEX CONCURRENTLY cannot run inside a transaction block
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
-- test where predicate is able to do a transactional update during
|
||||||
|
-- a concurrent build before switching pg_index state flags.
|
||||||
|
CREATE FUNCTION predicate_stable() RETURNS bool IMMUTABLE
|
||||||
|
LANGUAGE plpgsql AS $$
|
||||||
|
BEGIN
|
||||||
|
EXECUTE 'SELECT txid_current()';
|
||||||
|
RETURN true;
|
||||||
|
END; $$;
|
||||||
|
CREATE INDEX CONCURRENTLY concur_index8 ON concur_heap (f1)
|
||||||
|
WHERE predicate_stable();
|
||||||
|
DROP INDEX concur_index8;
|
||||||
|
DROP FUNCTION predicate_stable();
|
||||||
-- But you can do a regular index build in a transaction
|
-- But you can do a regular index build in a transaction
|
||||||
BEGIN;
|
BEGIN;
|
||||||
CREATE INDEX std_index on concur_heap(f2);
|
CREATE INDEX std_index on concur_heap(f2);
|
||||||
|
@ -805,11 +805,22 @@ CREATE INDEX CONCURRENTLY concur_index4 on concur_heap(f2) WHERE f1='a';
|
|||||||
CREATE INDEX CONCURRENTLY concur_index5 on concur_heap(f2) WHERE f1='x';
|
CREATE INDEX CONCURRENTLY concur_index5 on concur_heap(f2) WHERE f1='x';
|
||||||
-- here we also check that you can default the index name
|
-- here we also check that you can default the index name
|
||||||
CREATE INDEX CONCURRENTLY on concur_heap((f2||f1));
|
CREATE INDEX CONCURRENTLY on concur_heap((f2||f1));
|
||||||
|
|
||||||
-- You can't do a concurrent index build in a transaction
|
-- You can't do a concurrent index build in a transaction
|
||||||
BEGIN;
|
BEGIN;
|
||||||
CREATE INDEX CONCURRENTLY concur_index7 ON concur_heap(f1);
|
CREATE INDEX CONCURRENTLY concur_index7 ON concur_heap(f1);
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
-- test where predicate is able to do a transactional update during
|
||||||
|
-- a concurrent build before switching pg_index state flags.
|
||||||
|
CREATE FUNCTION predicate_stable() RETURNS bool IMMUTABLE
|
||||||
|
LANGUAGE plpgsql AS $$
|
||||||
|
BEGIN
|
||||||
|
EXECUTE 'SELECT txid_current()';
|
||||||
|
RETURN true;
|
||||||
|
END; $$;
|
||||||
|
CREATE INDEX CONCURRENTLY concur_index8 ON concur_heap (f1)
|
||||||
|
WHERE predicate_stable();
|
||||||
|
DROP INDEX concur_index8;
|
||||||
|
DROP FUNCTION predicate_stable();
|
||||||
|
|
||||||
-- But you can do a regular index build in a transaction
|
-- But you can do a regular index build in a transaction
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
Loading…
Reference in New Issue
Block a user