Skip to content

Commit 24b8ea5

Browse files
committed
Fix pg_dump error with invalid search_path. pg_dump set search_path to
empty string, appending the pgtt schema in this case make it fail.
1 parent af2af6c commit 24b8ea5

3 files changed

Lines changed: 9 additions & 48 deletions

File tree

pgtt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1983,7 +1983,7 @@ force_pgtt_namespace(void)
19831983
appendStringInfo(&search_path, "%s", pgtt_schema);
19841984
override = true;
19851985
}
1986-
else if (strstr(old_search_path, pgtt_schema) == NULL)
1986+
else if (strlen(old_search_path) > 0 && strstr(old_search_path, pgtt_schema) == NULL)
19871987
{
19881988
/*
19891989
* first look if pg_catalog is at end of the search path to keep

test/expected/13_searchpath.out

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,79 +5,36 @@
55
--
66
----
77
DROP EXTENSION pgtt;
8-
SHOW search_path ;
9-
search_path
10-
------------------------------
11-
"$user", public, pgtt_schema
12-
(1 row)
138

9+
SHOW search_path ;
1410
create schema first_schema;
1511
create schema second_schema;
1612
SET search_path TO "$user",public,pg_catalog,fisrt_schema,second_schema;
1713
SHOW search_path ;
18-
search_path
19-
-----------------------------------------------------------------------
20-
"$user", public, pg_catalog, fisrt_schema, second_schema, pgtt_schema
21-
(1 row)
22-
2314
CREATE EXTENSION pgtt;
2415
SHOW search_path ;
25-
search_path
26-
-----------------------------------------------------------------------
27-
"$user", public, pg_catalog, fisrt_schema, second_schema, pgtt_schema
28-
(1 row)
29-
3016
SET search_path TO pg_catalog;
3117
SHOW search_path ;
32-
search_path
33-
-------------------------
34-
pg_catalog, pgtt_schema
35-
(1 row)
36-
3718
SET search_path TO public;
3819
SHOW search_path ;
39-
search_path
40-
---------------------
41-
public, pgtt_schema
42-
(1 row)
4320

4421
-- Test only pg_catalog in search_path.
4522
DROP EXTENSION pgtt;
4623
\c - -
4724
SHOW search_path;
48-
search_path
49-
-----------------
50-
"$user", public
51-
(1 row)
52-
5325
SET search_path TO pg_catalog;
5426
SHOW search_path;
55-
search_path
56-
-------------
57-
pg_catalog
58-
(1 row)
59-
6027
CREATE EXTENSION pgtt;
6128
SHOW search_path;
62-
search_path
63-
--------------------------
64-
pgtt_schema, pg_catalog
65-
(1 row)
6629

6730
-- Test the pg_catalog at end of search_path.
6831
DROP EXTENSION pgtt;
6932
\c - -
7033
SET search_path TO "$user", public, pg_catalog;
7134
SHOW search_path;
72-
search_path
73-
-----------------------------
74-
"$user", public, pg_catalog
75-
(1 row)
76-
7735
CREATE EXTENSION pgtt;
7836
SHOW search_path;
79-
search_path
80-
------------------------------------------
81-
"$user", public, pgtt_schema, pg_catalog
82-
(1 row)
8337

38+
-- Test empty search path like set by pg_dump
39+
SELECT pg_catalog.set_config('search_path', '', false);
40+
SHOW search_path;

test/sql/13_searchpath.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ SET search_path TO "$user", public, pg_catalog;
3434
SHOW search_path;
3535
CREATE EXTENSION pgtt;
3636
SHOW search_path;
37+
38+
-- Test empty search path like set by pg_dump
39+
SELECT pg_catalog.set_config('search_path', '', false);
40+
SHOW search_path;

0 commit comments

Comments
 (0)