=== Applying patches on top of PostgreSQL commit ID ce146621f7860d2e19c509f1466feca3bf777678 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Thu May 14 15:05:24 UTC 2026 On branch cf/5379 nothing to commit, working tree clean === using 'git am' to apply patch ./v22-0001-Add-tests-for-cross-session-temp-table-access.patch === Applying: Add tests for cross-session temp table access Using index info to reconstruct a base tree... M src/include/utils/rel.h M src/test/modules/test_misc/meson.build Falling back to patching base and 3-way merge... CONFLICT (add/add): Merge conflict in src/test/modules/test_misc/t/013_temp_obj_multisession.pl Auto-merging src/test/modules/test_misc/t/013_temp_obj_multisession.pl Auto-merging src/include/utils/rel.h CONFLICT (content): Merge conflict in src/include/utils/rel.h error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 Add tests for cross-session temp table access When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". === using patch(1) to apply patch ./v22-0001-Add-tests-for-cross-session-temp-table-access.patch === patching file src/include/utils/rel.h Hunk #1 succeeded at 673 with fuzz 2 (offset 9 lines). patching file src/test/modules/test_misc/meson.build Hunk #1 FAILED at 21. 1 out of 1 hunk FAILED -- saving rejects to file src/test/modules/test_misc/meson.build.rej The next patch would create the file src/test/modules/test_misc/t/013_temp_obj_multisession.pl, which already exists! Skipping patch. 1 out of 1 hunk ignored Unstaged changes after reset: M src/include/utils/rel.h Removing src/test/modules/test_misc/meson.build.rej === using 'git apply' to apply patch ./v22-0001-Add-tests-for-cross-session-temp-table-access.patch === Applied patch to 'src/include/utils/rel.h' with conflicts. Applied patch to 'src/test/modules/test_misc/meson.build' cleanly. Performing three-way merge... Applied patch to 'src/test/modules/test_misc/t/013_temp_obj_multisession.pl' with conflicts. U src/include/utils/rel.h U src/test/modules/test_misc/t/013_temp_obj_multisession.pl diff --cc src/include/utils/rel.h index fa07ebf8ff7,ad50e43b801..00000000000 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@@ -664,14 -664,14 +664,25 @@@ RelationCloseSmgr(Relation relation * RELATION_IS_OTHER_TEMP * Test for a temporary relation that belongs to some other session. * ++<<<<<<< ours + * Reading another session's temp-table data through never works right: + * the owning session keeps the data in its private local buffer pool, + * which we cannot access. Existing buffer-manager entry points + * (ReadBuffer_common(), StartReadBuffersImpl(), read_stream_begin_impl(), + * and PrefetchBuffer()) already enforce this; any new buffer-access entry + * points must do the same. Command-level code (TRUNCATE, ALTER TABLE, + * VACUUM, CLUSTER, REINDEX, ...) additionally uses this macro for + * command-specific error messages. ++======= + * Any code path that reads a relation's data must reject such relations: + * the owning session keeps the data in its private local buffer pool, + * which we cannot inspect. Existing buffer-manager entry points + * (ReadBufferExtended(), ReadBuffer_common(), StartReadBuffersImpl(), + * read_stream_begin_impl(), PrefetchBuffer()) already enforce this; any + * new buffer-access entry point must do the same. Command-level code + * (TRUNCATE, ALTER TABLE, VACUUM, CLUSTER, REINDEX, ...) additionally + * uses this macro for command-specific error messages. ++>>>>>>> theirs * * Beware of multiple eval of argument */ diff --cc src/test/modules/test_misc/t/013_temp_obj_multisession.pl index 5f3cc7d2fc5,bfcba42acd0..00000000000 --- a/src/test/modules/test_misc/t/013_temp_obj_multisession.pl +++ b/src/test/modules/test_misc/t/013_temp_obj_multisession.pl @@@ -55,20 -55,25 +55,41 @@@ my ($stdout, $stderr) # DML and SELECT have to read the table's data and therefore go through # the buffer manager. With no index on the table, the planner cannot # use index access, so SELECT/UPDATE/DELETE/MERGE/COPY all run through ++<<<<<<< ours +# the read-stream path and are caught by read_stream_begin_impl(). ++======= + # the read-stream path. + # + # XXX: in current code, the read-stream path bypasses the + # RELATION_IS_OTHER_TEMP() check, so these commands silently see no + # rows / report zero affected rows -- the visible symptom of the bug + # this test suite documents. A follow-up patch will route the check + # through read_stream_begin_impl() and these assertions will be + # updated to expect "cannot access temporary tables of other sessions". ++>>>>>>> theirs $node->psql( 'postgres', "SELECT val FROM $tempschema.foo;", ++<<<<<<< ours + stderr => \$stderr); +like( + $stderr, + qr/cannot access temporary tables of other sessions/, + 'SELECT (seqscan via read_stream)'); + +# INSERT goes through hio.c which calls ReadBufferExtended() to find a +# page with free space; that hits the existing check before any data +# is written. ++======= + stdout => \$stdout, + stderr => \$stderr); + is($stderr, '', 'SELECT (currently no error -- bug to be fixed)'); + + # INSERT goes through hio.c which calls ReadBufferExtended() to find a + # page with free space; that hits the existing check before any data is + # written. This case currently errors as expected. ++>>>>>>> theirs $node->psql( 'postgres', "INSERT INTO $tempschema.foo VALUES (73);", @@@ -82,21 -87,21 +103,36 @@@ $node->psql 'postgres', "UPDATE $tempschema.foo SET val = NULL;", stderr => \$stderr); ++<<<<<<< ours +like($stderr, qr/cannot access temporary tables of other sessions/, 'UPDATE'); + +$node->psql('postgres', "DELETE FROM $tempschema.foo;", stderr => \$stderr); +like($stderr, qr/cannot access temporary tables of other sessions/, 'DELETE'); ++======= + is($stderr, '', 'UPDATE (currently no error -- bug to be fixed)'); + + $node->psql('postgres', "DELETE FROM $tempschema.foo;", stderr => \$stderr); + is($stderr, '', 'DELETE (currently no error -- bug to be fixed)'); ++>>>>>>> theirs $node->psql( 'postgres', "MERGE INTO $tempschema.foo USING (VALUES (42)) AS s(val) " . "ON foo.val = s.val WHEN MATCHED THEN DELETE;", stderr => \$stderr); ++<<<<<<< ours +like($stderr, qr/cannot access temporary tables of other sessions/, 'MERGE'); + +$node->psql('postgres', "COPY $tempschema.foo TO STDOUT;", + stderr => \$stderr); +like($stderr, qr/cannot access temporary tables of other sessions/, 'COPY'); ++======= + is($stderr, '', 'MERGE (currently no error -- bug to be fixed)'); + + $node->psql('postgres', "COPY $tempschema.foo TO STDOUT;", + stderr => \$stderr); + is($stderr, '', 'COPY (currently no error -- bug to be fixed)'); ++>>>>>>> theirs # DDL and maintenance commands have their own command-specific checks # (older than the buffer-manager check above), so they fail with