pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Marina Polyakova <m.polyakova@postgrespro.ru>
To: pgsql-hackers@postgresql.org
Cc: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Cc: Julien Rouhaud <rjuju123@gmail.com>
Cc: Daniel Verite <daniel@manitou-mail.org>
Cc: pryzby@telsasoft.com
Cc: AndrewBille@gmail.com
Cc: michael@paquier.xyz
Subject: Re: ICU for global collation
Date: Mon, 05 Sep 2022 18:14:00 +0300
Message-ID: <7c99c132dc9c0ac630e0127f032ac480@postgrespro.ru> (raw)
In-Reply-To: <Yw4KoBm1mS+2xzIj@paquier.xyz>
References: <YrlRS847pNnxwu+v@paquier.xyz>
	<97f2c29e-24d9-3660-60cf-9138c0c47d90@enterprisedb.com>
	<20220628013205.GH19662@telsasoft.com>
	<f385ba25e7f8be427b8c582e5cca7d79@postgrespro.ru>
	<7d74b2d7-7fc6-f55b-3f77-c0e05569b64e@enterprisedb.com>
	<YwRUn4J8+uqlyUYQ@paquier.xyz>
	<7ad26354e75259f59c4a6c6997b8ee32@postgrespro.ru>
	<YwWrVEDpLNGFA4Mq@paquier.xyz>
	<20220824085923.jro5ao2m5b4mdll5@jrouhaud>
	<13468bee-a5b4-65aa-932c-c12584f4458d@enterprisedb.com>
	<Yw4KoBm1mS+2xzIj@paquier.xyz>

Hello!

IMO after adding ICU for global collations [1] the behaviour of createdb 
and CREATE DATABASE is a bit inconsistent when both locale and 
lc_collate (or locale and lc_ctype) options are used:

$ createdb mydb --locale C --lc-collate C --template template0
createdb: error: only one of --locale and --lc-collate can be specified
$ psql -c "create database mydb locale = 'C' lc_collate = 'C' template = 
'template0'" postgres
CREATE DATABASE

 From the CREATE DATABASE documentation [2]:

locale
This is a shortcut for setting LC_COLLATE and LC_CTYPE at once. If you 
specify this, you cannot specify either of those parameters.

The patch diff_return_back_create_database_error.patch returns back the 
removed code for CREATE DATABASE so it behaves like createdb as 
before...

[1] 
https://github.com/postgres/postgres/commit/f2553d43060edb210b36c63187d52a632448e1d2
[2] https://www.postgresql.org/docs/devel/sql-createdatabase.html

-- 
Marina Polyakova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Attachments:

  [text/x-diff] diff_return_back_create_database_error.patch (727B, ../7c99c132dc9c0ac630e0127f032ac480@postgrespro.ru/2-diff_return_back_create_database_error.patch)
  download | inline diff:
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 6ff48bb18f3639ae45d9528b32df51a4aebc60c0..0a22cace11d9df6b5fc085bfd7b86319f4b13165 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -851,6 +851,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)


view thread (111+ messages)  latest in thread

Message-ID: <7c99c132dc9c0ac630e0127f032ac480@postgrespro.ru>
Permalink:  ../7c99c132dc9c0ac630e0127f032ac480@postgrespro.ru/
Also on:    postgresql.org/message-id/7c99c132dc9c0ac630e0127f032ac480@postgrespro.ru

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: m.polyakova@postgrespro.ru, peter.eisentraut@enterprisedb.com, rjuju123@gmail.com, daniel@manitou-mail.org, pryzby@telsasoft.com, AndrewBille@gmail.com, michael@paquier.xyz
  Subject: Re: ICU for global collation
  In-Reply-To: <7c99c132dc9c0ac630e0127f032ac480@postgrespro.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox