@@ -613,6 +613,24 @@ SELECT t1."C 1", t2.c1, t3.c1 FROM "S 1"."T 1" t1 full join ft1 t2 full join ft2
613613
614614RESET enable_hashjoin;
615615RESET enable_nestloop;
616+ -- Test executing assertion in estimate_path_cost_size() that makes sure that
617+ -- retrieved_rows for foreign rel re-used to cost pre-sorted foreign paths is
618+ -- a sensible value even when the rel has tuples=0
619+ CREATE TABLE loct_empty (c1 int NOT NULL, c2 text);
620+ CREATE FOREIGN TABLE ft_empty (c1 int NOT NULL, c2 text)
621+ SERVER loopback OPTIONS (table_name 'loct_empty');
622+ INSERT INTO loct_empty
623+ SELECT id, 'AAA' || to_char(id, 'FM000') FROM generate_series(1, 100) id;
624+ DELETE FROM loct_empty;
625+ ANALYZE ft_empty;
626+ EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft_empty ORDER BY c1;
627+ QUERY PLAN
628+ -------------------------------------------------------------------------------
629+ Foreign Scan on public.ft_empty
630+ Output: c1, c2
631+ Remote SQL: SELECT c1, c2 FROM public.loct_empty ORDER BY c1 ASC NULLS LAST
632+ (3 rows)
633+
616634-- ===================================================================
617635-- WHERE with remotely-executable conditions
618636-- ===================================================================
@@ -8928,7 +8946,7 @@ DO $d$
89288946 END;
89298947$d$;
89308948ERROR: invalid option "password"
8931- HINT: Valid options in this context are: service, passfile, channel_binding, connect_timeout, dbname, host, hostaddr, port, options, application_name, keepalives, keepalives_idle, keepalives_interval, keepalives_count, tcp_user_timeout, sslmode, sslcompression, sslcert, sslkey, sslrootcert, sslcrl, requirepeer, ssl_min_protocol_version, ssl_max_protocol_version, gssencmode, krbsrvname, gsslib, target_session_attrs, use_remote_estimate, fdw_startup_cost, fdw_tuple_cost, extensions, updatable, fetch_size, batch_size
8949+ HINT: Valid options in this context are: service, passfile, channel_binding, connect_timeout, dbname, host, hostaddr, port, options, application_name, keepalives, keepalives_idle, keepalives_interval, keepalives_count, tcp_user_timeout, sslmode, sslcompression, sslcert, sslkey, sslrootcert, sslcrl, sslcrldir, requirepeer, ssl_min_protocol_version, ssl_max_protocol_version, gssencmode, krbsrvname, gsslib, target_session_attrs, use_remote_estimate, fdw_startup_cost, fdw_tuple_cost, extensions, updatable, fetch_size, batch_size
89328950CONTEXT: SQL statement "ALTER SERVER loopback_nopw OPTIONS (ADD password 'dummypw')"
89338951PL/pgSQL function inline_code_block line 3 at EXECUTE
89348952-- If we add a password for our user mapping instead, we should get a different
@@ -9396,5 +9414,26 @@ SELECT COUNT(*) FROM batch_table;
93969414 66
93979415(1 row)
93989416
9417+ -- Check that enabling batched inserts doesn't interfere with cross-partition
9418+ -- updates
9419+ CREATE TABLE batch_cp_upd_test (a int) PARTITION BY LIST (a);
9420+ CREATE TABLE batch_cp_upd_test1 (LIKE batch_cp_upd_test);
9421+ CREATE FOREIGN TABLE batch_cp_upd_test1_f
9422+ PARTITION OF batch_cp_upd_test
9423+ FOR VALUES IN (1)
9424+ SERVER loopback
9425+ OPTIONS (table_name 'batch_cp_upd_test1', batch_size '10');
9426+ CREATE TABLE batch_cp_up_test1 PARTITION OF batch_cp_upd_test
9427+ FOR VALUES IN (2);
9428+ INSERT INTO batch_cp_upd_test VALUES (1), (2);
9429+ -- The following moves a row from the local partition to the foreign one
9430+ UPDATE batch_cp_upd_test t SET a = 1 FROM (VALUES (1), (2)) s(a) WHERE t.a = s.a;
9431+ SELECT tableoid::regclass, * FROM batch_cp_upd_test;
9432+ tableoid | a
9433+ ----------------------+---
9434+ batch_cp_upd_test1_f | 1
9435+ batch_cp_upd_test1_f | 1
9436+ (2 rows)
9437+
93999438-- Clean up
9400- DROP TABLE batch_table CASCADE;
9439+ DROP TABLE batch_table, batch_cp_upd_test CASCADE;
0 commit comments