Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
pageinspect: Fix memory context allocation of page in brin_revmap_data()
authorMichael Paquier <michael@paquier.xyz>
Wed, 16 Mar 2022 03:29:55 +0000 (12:29 +0900)
committerMichael Paquier <michael@paquier.xyz>
Wed, 16 Mar 2022 03:29:55 +0000 (12:29 +0900)
This caused the function to fail, as the aligned copy of the raw page
given by the function caller was not saved in the correct memory
context, which needs to be multi_call_memory_ctx in this case.

Issue introduced by 076f4d9.

Per buildfarm members sifika, mylodon and longfin.  I have reproduced
that locally with macos.

Discussion: https://postgr.es/m/YjFPOtfCW6yLXUeM@paquier.xyz
Backpatch-through: 10

contrib/pageinspect/brinfuncs.c

index 733e18566140dd5e5b24d92c17d042267e76a517..2db8d134fdc8c4bc6889d04f5ce35605be61769d 100644 (file)
@@ -372,15 +372,15 @@ brin_revmap_data(PG_FUNCTION_ARGS)
        MemoryContext mctx;
        Page        page;
 
-       /* minimally verify the page we got */
-       page = verify_brin_page(raw_page, BRIN_PAGETYPE_REVMAP, "revmap");
-
        /* create a function context for cross-call persistence */
        fctx = SRF_FIRSTCALL_INIT();
 
        /* switch to memory context appropriate for multiple function calls */
        mctx = MemoryContextSwitchTo(fctx->multi_call_memory_ctx);
 
+       /* minimally verify the page we got */
+       page = verify_brin_page(raw_page, BRIN_PAGETYPE_REVMAP, "revmap");
+
        state = palloc(sizeof(*state));
        state->tids = ((RevmapContents *) PageGetContents(page))->rm_tids;
        state->idx = 0;