pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Peter Geoghegan <pg@bowt.ie>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Daniel Verite <daniel@manitou-mail.org>
Cc: PostgreSQL mailing lists <pgsql-bugs@postgresql.org>
Subject: Re: Crash report for some ICU-52 (debian8) COLLATE and work_mem values
Date: Mon, 14 Aug 2017 13:22:09 -0400
Message-ID: <5261d23c-1864-bec9-538c-24f25c7629cc@2ndquadrant.com> (raw)
In-Reply-To: <CAH2-Wzm18GG_1by_pYRLg3npoxTBUW2=oxZDtVmaqKteZWaybw@mail.gmail.com>
References: <57860965-169f-461b-81f0-60d398894938@manitou-mail.org>
	<10186.1501989988@sss.pgh.pa.us>
	<1b0681a0-83d6-4cce-cf6d-f90cfe3b2069@2ndquadrant.com>
	<32388.1502127050@sss.pgh.pa.us>
	<CA+TgmoZXmrFu9oYbPXcDbHcDSYpZzPRm-VZc7pVoiDOiHMSGNw@mail.gmail.com>
	<CAH2-WznjeN2Wb7q5Gkbbiz-gfG7HB=igNsakCPafVKiamckYiw@mail.gmail.com>
	<10910.1502302068@sss.pgh.pa.us>
	<CAH2-WznaMH3SNE9saGzcJPm7-uUL=g3bTS5itR7cEmBZhWcS2A@mail.gmail.com>
	<CAH2-Wz=CNO0u7BALZoRYqNpW=jC9ntFMek9goLqioaGJxWmJ2Q@mail.gmail.com>
	<8830.1502313961@sss.pgh.pa.us>
	<CAH2-Wzm18GG_1by_pYRLg3npoxTBUW2=oxZDtVmaqKteZWaybw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On 8/9/17 17:29, Peter Geoghegan wrote:
> On Wed, Aug 9, 2017 at 2:26 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Peter Geoghegan <pg@bowt.ie> writes:
>>> It would help if CREATE COLLATION left new
>>> ICU collations with the same useful "Description" as initdb created
>>> collations will have; maybe that should be added.

I had been thinking about that, too, while I was writing it, but there
is the semantic objection:

>> I do not think it is CREATE COLLATION's job to provide a comment;
>> no other CREATE command does so.

How about a special option in the CREATE COLLATION to create the comment
automatically on demand?  Sample patch attached.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Attachments:

0001-Add-CREATE-COLLATION-auto_comment-option.patch (text/plain, 2.4K) download From ca6c6e4c7a42eb02ddf3e9e6e1669f433b72f77b Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <peter_e@gmx.net> Date: Mon, 14 Aug 2017 13:18:57 -0400 Subject: [RFC PATCH] Add CREATE COLLATION auto_comment option --- src/backend/commands/collationcmds.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c index 96a6bc9bf0..d5a4dcbdbd 100644 --- a/src/backend/commands/collationcmds.c +++ b/src/backend/commands/collationcmds.c @@ -37,6 +37,11 @@ #include "utils/syscache.h" +#ifdef USE_ICU +static char *get_icu_locale_comment(const char *localename); +#endif + + typedef struct { char *localename; /* name of locale, as per "locale -a" */ @@ -56,11 +61,13 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e AclResult aclresult; ListCell *pl; DefElem *fromEl = NULL; + DefElem *autocommentEl = NULL; DefElem *localeEl = NULL; DefElem *lccollateEl = NULL; DefElem *lcctypeEl = NULL; DefElem *providerEl = NULL; DefElem *versionEl = NULL; + bool autocomment = false; char *collcollate = NULL; char *collctype = NULL; char *collproviderstr = NULL; @@ -84,6 +91,8 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e if (pg_strcasecmp(defel->defname, "from") == 0) defelp = &fromEl; + else if (pg_strcasecmp(defel->defname, "auto_comment") == 0) + defelp = &autocommentEl; else if (pg_strcasecmp(defel->defname, "locale") == 0) defelp = &localeEl; else if (pg_strcasecmp(defel->defname, "lc_collate") == 0) @@ -143,6 +152,9 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e errmsg("collation \"default\" cannot be copied"))); } + if (autocommentEl) + autocomment = defGetBoolean(autocommentEl); + if (localeEl) { collcollate = defGetString(localeEl); @@ -224,6 +236,18 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e ObjectAddressSet(address, CollationRelationId, newoid); +#ifdef USE_ICU + if (autocomment && collprovider == COLLPROVIDER_ICU) + { + char *icucomment; + + icucomment = get_icu_locale_comment(collcollate); + if (icucomment) + CreateComments(newoid, CollationRelationId, 0, + icucomment); + } +#endif + return address; } base-commit: ea0ca75d5d14e0c98782a2188405685af4a475a0 -- 2.14.1

view thread (85+ messages)  latest in thread

Message-ID: <5261d23c-1864-bec9-538c-24f25c7629cc@2ndquadrant.com>
Permalink:  ../5261d23c-1864-bec9-538c-24f25c7629cc@2ndquadrant.com/
Also on:    postgresql.org/message-id/5261d23c-1864-bec9-538c-24f25c7629cc@2ndquadrant.com

 ·  · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: peter.eisentraut@2ndquadrant.com, pg@bowt.ie, tgl@sss.pgh.pa.us, robertmhaas@gmail.com, daniel@manitou-mail.org
  Subject: Re: Crash report for some ICU-52 (debian8) COLLATE and work_mem values
  In-Reply-To: <5261d23c-1864-bec9-538c-24f25c7629cc@2ndquadrant.com>
  References: <57860965-169f-461b-81f0-60d398894938@manitou-mail.org> <10186.1501989988@sss.pgh.pa.us> <1b0681a0-83d6-4cce-cf6d-f90cfe3b2069@2ndquadrant.com> <32388.1502127050@sss.pgh.pa.us> <CA+TgmoZXmrFu9oYbPXcDbHcDSYpZzPRm-VZc7pVoiDOiHMSGNw@mail.gmail.com> <CAH2-WznjeN2Wb7q5Gkbbiz-gfG7HB=igNsakCPafVKiamckYiw@mail.gmail.com> <10910.1502302068@sss.pgh.pa.us> <CAH2-WznaMH3SNE9saGzcJPm7-uUL=g3bTS5itR7cEmBZhWcS2A@mail.gmail.com> <CAH2-Wz=CNO0u7BALZoRYqNpW=jC9ntFMek9goLqioaGJxWmJ2Q@mail.gmail.com> <8830.1502313961@sss.pgh.pa.us> <CAH2-Wzm18GG_1by_pYRLg3npoxTBUW2=oxZDtVmaqKteZWaybw@mail.gmail.com> <5261d23c-1864-bec9-538c-24f25c7629cc@2ndquadrant.com>

* 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