Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit09a69f6

Browse files
committed
Add test for CREATE INDEX CONCURRENTLY with not-so-immutable predicate
83158f7 has improved index_set_state_flags() so as it is possible to usetransactional updates when updating pg_index state flags, but there wasnot really a test case which stressed directly the possibility it fixed.This commit adds such a test, using a predicate that looks valid inappearance but calls a stable function.Author: Andrey LepikhovDiscussion:https://postgr.es/m/9b905019-5297-7372-0ad2-e1a4bb66a719@postgrespro.ruBackpatch-through: 9.6
1 parent642c069 commit09a69f6

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

‎src/test/regress/expected/create_index.out

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,18 @@ BEGIN;
13971397
CREATE INDEX CONCURRENTLY concur_index7 ON concur_heap(f1);
13981398
ERROR: CREATE INDEX CONCURRENTLY cannot run inside a transaction block
13991399
COMMIT;
1400+
-- test where predicate is able to do a transactional update during
1401+
-- a concurrent build before switching pg_index state flags.
1402+
CREATE FUNCTION predicate_stable() RETURNS bool IMMUTABLE
1403+
LANGUAGE plpgsql AS $$
1404+
BEGIN
1405+
EXECUTE 'SELECT txid_current()';
1406+
RETURN true;
1407+
END; $$;
1408+
CREATE INDEX CONCURRENTLY concur_index8 ON concur_heap (f1)
1409+
WHERE predicate_stable();
1410+
DROP INDEX concur_index8;
1411+
DROP FUNCTION predicate_stable();
14001412
-- But you can do a regular index build in a transaction
14011413
BEGIN;
14021414
CREATE INDEX std_index on concur_heap(f2);

‎src/test/regress/sql/create_index.sql

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,11 +481,22 @@ CREATE INDEX CONCURRENTLY concur_index4 on concur_heap(f2) WHERE f1='a';
481481
CREATEINDEXCONCURRENTLY concur_index5on concur_heap(f2)WHERE f1='x';
482482
-- here we also check that you can default the index name
483483
CREATEINDEXCONCURRENTLYon concur_heap((f2||f1));
484-
485484
-- You can't do a concurrent index build in a transaction
486485
BEGIN;
487486
CREATEINDEXCONCURRENTLY concur_index7ON concur_heap(f1);
488487
COMMIT;
488+
-- test where predicate is able to do a transactional update during
489+
-- a concurrent build before switching pg_index state flags.
490+
CREATEFUNCTIONpredicate_stable() RETURNS bool IMMUTABLE
491+
LANGUAGE plpgsqlAS $$
492+
BEGIN
493+
EXECUTE'SELECT txid_current()';
494+
RETURN true;
495+
END; $$;
496+
CREATEINDEXCONCURRENTLY concur_index8ON concur_heap (f1)
497+
WHERE predicate_stable();
498+
DROPINDEX concur_index8;
499+
DROPFUNCTION predicate_stable();
489500

490501
-- But you can do a regular index build in a transaction
491502
BEGIN;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp