Line data Source code
1 : /*-------------------------------------------------------------------------- 2 : * 3 : * test_multixact.c 4 : * Support code for multixact testing 5 : * 6 : * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group 7 : * Portions Copyright (c) 1994, Regents of the University of California 8 : * 9 : * IDENTIFICATION 10 : * src/test/modules/test_slru/test_multixact.c 11 : * 12 : * ------------------------------------------------------------------------- 13 : */ 14 : 15 : #include "postgres.h" 16 : 17 : #include "access/multixact.h" 18 : #include "access/xact.h" 19 : #include "fmgr.h" 20 : #include "utils/injection_point.h" 21 : 22 8 : PG_FUNCTION_INFO_V1(test_create_multixact); 23 6 : PG_FUNCTION_INFO_V1(test_read_multixact); 24 : 25 : /* 26 : * Produces multixact with 2 current xids 27 : */ 28 : Datum 29 4 : test_create_multixact(PG_FUNCTION_ARGS) 30 : { 31 : MultiXactId id; 32 : 33 4 : MultiXactIdSetOldestMember(); 34 4 : id = MultiXactIdCreate(GetCurrentTransactionId(), MultiXactStatusUpdate, 35 : GetCurrentTransactionId(), MultiXactStatusForShare); 36 4 : PG_RETURN_TRANSACTIONID(id); 37 : } 38 : 39 : /* 40 : * Reads given multixact after running an injection point. Discards local cache 41 : * to make a real read. Tailored for multixact testing. 42 : */ 43 : Datum 44 2 : test_read_multixact(PG_FUNCTION_ARGS) 45 : { 46 2 : MultiXactId id = PG_GETARG_TRANSACTIONID(0); 47 : MultiXactMember *members; 48 : 49 2 : INJECTION_POINT("test-multixact-read"); 50 : /* discard caches */ 51 2 : AtEOXact_MultiXact(); 52 : 53 2 : if (GetMultiXactIdMembers(id, &members, false, false) == -1) 54 0 : elog(ERROR, "MultiXactId not found"); 55 : 56 2 : PG_RETURN_VOID(); 57 : }