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

Commitb8032f4

Browse files
committed
postgres_fdw: set search_path to 'pg_catalog' while deparsing constants.
The motivation for this is to ensure successful transmission of thevalues of constants of regconfig and other reg* types. The remotewill be reading them with search_path = 'pg_catalog', so schemaqualification is necessary when referencing objects in other schemas.Per bug #17483 from Emmanuel Quincerot. Back-patch to all supportedversions. (There's some other stuff to do here, but it's lessback-patchable.)Discussion:https://postgr.es/m/1423433.1652722406@sss.pgh.pa.us
1 parent91377a4 commitb8032f4

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

‎contrib/postgres_fdw/expected/postgres_fdw.out

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,26 @@ SELECT * FROM ft1 WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'bar' EN
11631163
Remote SQL: SELECT "C 1", c2, c3, c4, c5, c6, c7, c8 FROM "S 1"."T 1"
11641164
(4 rows)
11651165

1166+
-- check schema-qualification of regconfig constant
1167+
CREATE TEXT SEARCH CONFIGURATION public.custom_search
1168+
(COPY = pg_catalog.english);
1169+
EXPLAIN (VERBOSE, COSTS OFF)
1170+
SELECT c1, to_tsvector('custom_search'::regconfig, c3) FROM ft1
1171+
WHERE c1 = 642 AND length(to_tsvector('custom_search'::regconfig, c3)) > 0;
1172+
QUERY PLAN
1173+
----------------------------------------------------------------------------------------------------------------------------------------------
1174+
Foreign Scan on public.ft1
1175+
Output: c1, to_tsvector('custom_search'::regconfig, c3)
1176+
Remote SQL: SELECT "C 1", c3 FROM "S 1"."T 1" WHERE (("C 1" = 642)) AND ((length(to_tsvector('public.custom_search'::regconfig, c3)) > 0))
1177+
(3 rows)
1178+
1179+
SELECT c1, to_tsvector('custom_search'::regconfig, c3) FROM ft1
1180+
WHERE c1 = 642 AND length(to_tsvector('custom_search'::regconfig, c3)) > 0;
1181+
c1 | to_tsvector
1182+
-----+-------------
1183+
642 | '00642':1
1184+
(1 row)
1185+
11661186
-- ===================================================================
11671187
-- JOIN queries
11681188
-- ===================================================================

‎contrib/postgres_fdw/postgres_fdw.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3899,6 +3899,14 @@ set_transmission_modes(void)
38993899
PGC_USERSET,PGC_S_SESSION,
39003900
GUC_ACTION_SAVE, true,0, false);
39013901

3902+
/*
3903+
* In addition force restrictive search_path, in case there are any
3904+
* regproc or similar constants to be printed.
3905+
*/
3906+
(void)set_config_option("search_path","pg_catalog",
3907+
PGC_USERSET,PGC_S_SESSION,
3908+
GUC_ACTION_SAVE, true,0, false);
3909+
39023910
returnnestlevel;
39033911
}
39043912

‎contrib/postgres_fdw/sql/postgres_fdw.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,15 @@ SELECT * FROM ft1 WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END;
442442
EXPLAIN (VERBOSE, COSTS OFF)
443443
SELECT*FROM ft1WHERE CASE c3 COLLATE"C" WHEN c6 THEN true ELSE c3<'bar' END;
444444

445+
-- check schema-qualification of regconfig constant
446+
CREATETEXT SEARCH CONFIGURATIONpublic.custom_search
447+
(COPY=pg_catalog.english);
448+
EXPLAIN (VERBOSE, COSTS OFF)
449+
SELECT c1, to_tsvector('custom_search'::regconfig, c3)FROM ft1
450+
WHERE c1=642AND length(to_tsvector('custom_search'::regconfig, c3))>0;
451+
SELECT c1, to_tsvector('custom_search'::regconfig, c3)FROM ft1
452+
WHERE c1=642AND length(to_tsvector('custom_search'::regconfig, c3))>0;
453+
445454
-- ===================================================================
446455
-- JOIN queries
447456
-- ===================================================================

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp