Skip to content

Commit

Permalink
Append IF NOT EXISTS to CREATE SERVER commands generated by pg_get_se…
Browse files Browse the repository at this point in the history
…rverdef_string
  • Loading branch information
onurctirtir committed Jun 1, 2020
1 parent fabe035 commit 8476a4d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/backend/distributed/deparser/citus_ruleutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ pg_get_serverdef_string(Oid tableRelationId)
StringInfoData buffer = { NULL, 0, 0, 0 };
initStringInfo(&buffer);

appendStringInfo(&buffer, "CREATE SERVER %s", quote_identifier(server->servername));
appendStringInfo(&buffer, "CREATE SERVER IF NOT EXISTS %s",
quote_identifier(server->servername));
if (server->servertype != NULL)
{
appendStringInfo(&buffer, " TYPE %s",
Expand Down
2 changes: 1 addition & 1 deletion src/test/regress/expected/multi_generate_ddl_commands.out
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ SELECT master_get_table_ddl_events('renamed_foreign_table');
NOTICE: foreign-data wrapper "fake_fdw" does not have an extension defined
master_get_table_ddl_events
---------------------------------------------------------------------
CREATE SERVER fake_fdw_server FOREIGN DATA WRAPPER fake_fdw
CREATE SERVER IF NOT EXISTS fake_fdw_server FOREIGN DATA WRAPPER fake_fdw
CREATE FOREIGN TABLE public.renamed_foreign_table (id bigint NOT NULL, rename_name character(8) DEFAULT ''::text NOT NULL) SERVER fake_fdw_server OPTIONS (encoding 'utf-8', compression 'true')
ALTER TABLE public.renamed_foreign_table OWNER TO postgres
(3 rows)
Expand Down

0 comments on commit 8476a4d

Please sign in to comment.