IF NOT EXISTS option for CREATE SERVER and CREATE USER MAPPING statements
I implemented IF NOT EXISTS option for CREATE SERVER and CREATE USER
MAPPING statements
for one of our customers.
I think other users can also find it useful for scripting and automated
tasks.
The patches themselves are small and simple. Documentation is updated as
well.
--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
On 01/13/2017 08:36 AM, Anastasia Lubennikova wrote:
I implemented IF NOT EXISTS option for CREATE SERVER and CREATE USER
MAPPING statements
for one of our customers.
I think other users can also find it useful for scripting and
automated tasks.
The patches themselves are small and simple. Documentation is updated
as well.
This looks good and useful. Please add some regression tests.
cheers
andrew
--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
13.02.2017 19:34, Andrew Dunstan:
On 01/13/2017 08:36 AM, Anastasia Lubennikova wrote:
I implemented IF NOT EXISTS option for CREATE SERVER and CREATE USER
MAPPING statements
for one of our customers.
I think other users can also find it useful for scripting and
automated tasks.
The patches themselves are small and simple. Documentation is updated
as well.This looks good and useful. Please add some regression tests.
Done.
--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
On 15.02.2017 20:54, Anastasia Lubennikova wrote:
Done.
I have gotten the error that AlterUserMappingStmt doesn't have
if_not_exists (in Russian):
gram.y: В функции «base_yyparse»:
gram.y:4918:7: ошибка: «AlterUserMappingStmt {aka struct AlterUserMappingStmt}» не содержит элемента с именем «if_not_exists»
n->if_not_exists = false;
^~
After applying the CREATE USER patch in gram.y I have:
AlterUserMappingStmt: ALTER USER MAPPING FOR auth_ident SERVER name alter_generic_options
{
AlterUserMappingStmt *n = makeNode(AlterUserMappingStmt);
n->user = $5;
n->servername = $7;
n->options = $8;
n->if_not_exists = false;
$$ = (Node *) n;
}
| CREATE USER MAPPING IF_P NOT EXISTS FOR auth_ident SERVER name create_generic_options
{
CreateUserMappingStmt *n = makeNode(CreateUserMappingStmt);
n->user = $8;
n->servername = $10;
n->options = $11;
n->if_not_exists = true;
$$ = (Node *) n;
}
;
Here ALTER USER MAPPING and CREATE USER MAPPING commands were mixed.
--
Artur Zakirov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
13.03.2017 11:53, Artur Zakirov:
On 15.02.2017 20:54, Anastasia Lubennikova wrote:
Done.
I have gotten the error that AlterUserMappingStmt doesn't have
if_not_exists (in Russian):gram.y: В функции «base_yyparse»:
gram.y:4918:7: ошибка: «AlterUserMappingStmt {aka struct
AlterUserMappingStmt}» не содержит элемента с именем «if_not_exists»
n->if_not_exists = false;
^~After applying the CREATE USER patch in gram.y I have:
AlterUserMappingStmt: ALTER USER MAPPING FOR auth_ident SERVER name
alter_generic_options
{
AlterUserMappingStmt *n =
makeNode(AlterUserMappingStmt);
n->user = $5;
n->servername = $7;
n->options = $8;
n->if_not_exists = false;
$$ = (Node *) n;
}
| CREATE USER MAPPING IF_P NOT EXISTS FOR auth_ident
SERVER name create_generic_options
{
CreateUserMappingStmt *n =
makeNode(CreateUserMappingStmt);
n->user = $8;
n->servername = $10;
n->options = $11;
n->if_not_exists = true;
$$ = (Node *) n;
}
;Here ALTER USER MAPPING and CREATE USER MAPPING commands were mixed.
Thanks for catching that.
It was caused by a conflict on applying of the patch.
Updated versions of both patches are attached.
--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
On 13.03.2017 13:01, Anastasia Lubennikova wrote:
Thanks for catching that.
It was caused by a conflict on applying of the patch.
Updated versions of both patches are attached.
I think the code is good and the patches are small. Documentation is
updated by the patches.
All regression tests are passed.
Marked the patch as "Ready for Commiter".
--
Artur Zakirov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Thanks for catching that.
It was caused by a conflict on applying of the patch.
Updated versions of both patches are attached.
We do not need extra line
<variablelist>
+
+ <varlistentry>
other usages of this do not have an extra line. Removed the extra line
in the attached patch.
I noticed that the earlier error message was using "server" instead of
"foreign server", while the new message uses the later one. Usually,
when converting an error to notice, we don't expect such changes. But
many other error messages are using "foreign server" instead of
"server", so probably this one needed a change anyway. But then, the
command to create a foreign server is not "CREATE FOREIGN SERVER",
it's "CREATE SERVER", so users are already getting confused?
I don't see similar change in the error message for the user mapping.
Do we need to change "server" to "foreign server" in case of user
mapping? The doc changes didn't compile with error
"osx:ref/create_user_mapping.sgml:52:15:E: document type does not
allow element "VARLISTENTRY" here; assuming missing "VARIABLELIST"
start-tag". The user mappings do not have name so the doc change was
slightly incorrect when it said "Do not throw an error if a user
mapping with the same name already exists.". I have corrected both
these things in the attached patch.
Other changes look good.
--
Best Wishes,
Ashutosh Bapat
EnterpriseDB Corporation
The Postgres Database Company
2017-03-14 15:55 GMT+03:00 Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>:
I noticed that the earlier error message was using "server" instead of
"foreign server", while the new message uses the later one. Usually,
when converting an error to notice, we don't expect such changes. But
many other error messages are using "foreign server" instead of
"server", so probably this one needed a change anyway. But then, the
command to create a foreign server is not "CREATE FOREIGN SERVER",
it's "CREATE SERVER", so users are already getting confused?
Actually, there are other messages with "server". For example, in the
AlterForeignServerOwner() or in the postgres_fdw code.
Maybe it is better to not change "server" to "foreign server" in
"create_foreign_server_if_not_exists.patch"? I think it will be better
to fix all such messages with a separate patch, If we will decide that
it is necessary to change "server" messages.
I don't see similar change in the error message for the user mapping.
Do we need to change "server" to "foreign server" in case of user
mapping? The doc changes didn't compile with error
"osx:ref/create_user_mapping.sgml:52:15:E: document type does not
allow element "VARLISTENTRY" here; assuming missing "VARIABLELIST"
Indeed! Missed that.
--
Arthur Zakirov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers