mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Add CREATE DATABASE LOCALE option
This sets both LC_COLLATE and LC_CTYPE with one option. Similar behavior is already supported in initdb, CREATE COLLATION, and createdb. Reviewed-by: Fabien COELHO <coelho@cri.ensmp.fr> Discussion: https://www.postgresql.org/message-id/flat/d9d5043a-dc70-da8a-0166-1e218e6e34d4%402ndquadrant.com
This commit is contained in:
@ -124,6 +124,7 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
|
||||
DefElem *downer = NULL;
|
||||
DefElem *dtemplate = NULL;
|
||||
DefElem *dencoding = NULL;
|
||||
DefElem *dlocale = NULL;
|
||||
DefElem *dcollate = NULL;
|
||||
DefElem *dctype = NULL;
|
||||
DefElem *distemplate = NULL;
|
||||
@ -184,6 +185,15 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
|
||||
parser_errposition(pstate, defel->location)));
|
||||
dencoding = defel;
|
||||
}
|
||||
else if (strcmp(defel->defname, "locale") == 0)
|
||||
{
|
||||
if (dlocale)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("conflicting or redundant options"),
|
||||
parser_errposition(pstate, defel->location)));
|
||||
dlocale = defel;
|
||||
}
|
||||
else if (strcmp(defel->defname, "lc_collate") == 0)
|
||||
{
|
||||
if (dcollate)
|
||||
@ -244,6 +254,12 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
|
||||
parser_errposition(pstate, defel->location)));
|
||||
}
|
||||
|
||||
if (dlocale && (dcollate || dctype))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("conflicting or redundant options"),
|
||||
errdetail("LOCALE cannot be specified together with LC_COLLATE or LC_CTYPE.")));
|
||||
|
||||
if (downer && downer->arg)
|
||||
dbowner = defGetString(downer);
|
||||
if (dtemplate && dtemplate->arg)
|
||||
@ -276,6 +292,11 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
|
||||
parser_errposition(pstate, dencoding->location)));
|
||||
}
|
||||
}
|
||||
if (dlocale && dlocale->arg)
|
||||
{
|
||||
dbcollate = defGetString(dlocale);
|
||||
dbctype = defGetString(dlocale);
|
||||
}
|
||||
if (dcollate && dcollate->arg)
|
||||
dbcollate = defGetString(dcollate);
|
||||
if (dctype && dctype->arg)
|
||||
|
Reference in New Issue
Block a user