Rename the new CREATE DATABASE options to set collation and ctype into
authorHeikki Linnakangas <heikki@enterprisedb.com>
Mon, 6 Apr 2009 08:42:53 +0000 (08:42 +0000)
committerHeikki Linnakangas <heikki@enterprisedb.com>
Mon, 6 Apr 2009 08:42:53 +0000 (08:42 +0000)
LC_COLLATE and LC_CTYPE, per discussion on pgsql-hackers.

doc/src/sgml/charset.sgml
doc/src/sgml/keywords.sgml
doc/src/sgml/ref/create_database.sgml
src/backend/commands/dbcommands.c
src/backend/parser/gram.y
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dumpall.c
src/bin/scripts/createdb.c
src/include/parser/kwlist.h
src/interfaces/ecpg/preproc/ecpg.trailer

index 2bb43a3533ab89f2d41f97f5ab105c1a4fc4bb69..dbd3ec05ca7133553d27b9613a1880a8e6d91180 100644 (file)
@@ -749,7 +749,7 @@ createdb -E EUC_KR -T template0 --lc-collate=ko_KR.euckr --lc-ctype=ko_KR.euckr
      Another way to accomplish this is to use this SQL command:
 
 <programlisting>
-CREATE DATABASE korean WITH ENCODING 'EUC_KR' COLLATE='ko_KR.euckr' CTYPE='ko_KR.euckr' TEMPLATE=template0;
+CREATE DATABASE korean WITH ENCODING 'EUC_KR' LC_COLLATE='ko_KR.euckr' LC_CTYPE='ko_KR.euckr' TEMPLATE=template0;
 </programlisting>
 
      The encoding for a database is stored in the system catalog
index 45b3d47a2bc9554bb89d254aba81509ee5bdf02e..3a34fea9b17b723d10200ab0887da5963931bce1 100644 (file)
     <entry>non-reserved</entry>
    </row>
    <row>
-    <entry><token>COLLATE</token></entry>
+    <entry><token>LC_COLLATE</token></entry>
     <entry>reserved</entry>
     <entry>reserved</entry>
     <entry>reserved</entry>
     <entry></entry>
    </row>
    <row>
-    <entry><token>CTYPE</token></entry>
+    <entry><token>LC_CTYPE</token></entry>
     <entry>non-reserved</entry>
     <entry></entry>
     <entry></entry>
index 50aff7fb5dbe6501d02869c68984e6f0b0a9a604..cf34925f7f83f50f9dc72a3e73cfc125bb8461bb 100644 (file)
@@ -25,8 +25,8 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
     [ [ WITH ] [ OWNER [=] <replaceable class="parameter">dbowner</replaceable> ]
            [ TEMPLATE [=] <replaceable class="parameter">template</replaceable> ]
            [ ENCODING [=] <replaceable class="parameter">encoding</replaceable> ]
-           [ COLLATE [=] <replaceable class="parameter">collate</replaceable> ]
-           [ CTYPE [=] <replaceable class="parameter">ctype</replaceable> ]
+           [ LC_COLLATE [=] <replaceable class="parameter">lc_collate</replaceable> ]
+           [ LC_CTYPE [=] <replaceable class="parameter">lc_ctype</replaceable> ]
            [ TABLESPACE [=] <replaceable class="parameter">tablespace</replaceable> ]
            [ CONNECTION LIMIT [=] <replaceable class="parameter">connlimit</replaceable> ] ]
 </synopsis>
@@ -207,7 +207,7 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
 
   <para>
    The character set encoding specified for the new database must be
-   compatible with the chosen COLLATE and CTYPE settings.
+   compatible with the chosen LC_COLLATE and LC_CTYPE settings.
    If <envar>LC_CTYPE</> is <literal>C</> (or equivalently
    <literal>POSIX</>), then all encodings are allowed, but for other
    locale settings there is only one encoding that will work properly.
@@ -219,9 +219,9 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
   </para>
 
   <para>
-   The <literal>COLLATE</> and <literal>CTYPE</> settings must match
+   The <literal>LC_COLLATE</> and <literal>LC_CTYPE</> settings must match
    those of the template database, except when template0 is used as
-   template. This is because <literal>COLLATE</> and <literal>CTYPE</>
+   template. This is because <literal>LC_COLLATE</> and <literal>LC_CTYPE</>
    affects the ordering in indexes, so that any indexes copied from the
    template database would be invalid in the new database with different
    settings. <literal>template0</literal>, however, is known to not
index d08e3d0853999fadbc24def415f4aea8b3dcf607..43ab2c90d408c4564ddfe574d199cd5595511da0 100644 (file)
@@ -169,7 +169,7 @@ createdb(const CreatedbStmt *stmt)
                                                 errmsg("conflicting or redundant options")));
                        dencoding = defel;
                }
-               else if (strcmp(defel->defname, "collate") == 0)
+               else if (strcmp(defel->defname, "lc_collate") == 0)
                {
                        if (dcollate)
                                ereport(ERROR,
@@ -177,7 +177,7 @@ createdb(const CreatedbStmt *stmt)
                                                 errmsg("conflicting or redundant options")));
                        dcollate = defel;
                }
-               else if (strcmp(defel->defname, "ctype") == 0)
+               else if (strcmp(defel->defname, "lc_ctype") == 0)
                {
                        if (dctype)
                                ereport(ERROR,
@@ -362,7 +362,7 @@ createdb(const CreatedbStmt *stmt)
                                (errmsg("encoding %s does not match locale %s",
                                                pg_encoding_to_char(encoding),
                                                dbctype),
-                        errdetail("The chosen CTYPE setting requires encoding %s.",
+                        errdetail("The chosen LC_CTYPE setting requires encoding %s.",
                                           pg_encoding_to_char(ctype_encoding))));
 
        if (!(collate_encoding == encoding ||
@@ -375,7 +375,7 @@ createdb(const CreatedbStmt *stmt)
                                (errmsg("encoding %s does not match locale %s",
                                                pg_encoding_to_char(encoding),
                                                dbcollate),
-                        errdetail("The chosen COLLATE setting requires encoding %s.",
+                        errdetail("The chosen LC_COLLATE setting requires encoding %s.",
                                           pg_encoding_to_char(collate_encoding))));
 
        /*
@@ -394,8 +394,8 @@ createdb(const CreatedbStmt *stmt)
 
                if (strcmp(dbctype, src_ctype))
                        ereport(ERROR,
-                                       (errmsg("new ctype is incompatible with the ctype of the template database (%s)", src_ctype),
-                                        errhint("Use the same ctype as in the template database, or use template0 as template")));
+                                       (errmsg("new LC_CTYPE is incompatible with LC_CTYPE of the template database (%s)", src_ctype),
+                                        errhint("Use the same LC_CTYPE as in the template database, or use template0 as template")));
        }
 
        /* Resolve default tablespace for new database */
index e1de04e7611bd9fb62117c7a813f693dcadb90d4..b4ee8ba227f90edde3dcbb27aa2f7248888e81a1 100644 (file)
@@ -437,7 +437,7 @@ static TypeName *TableFuncTypeName(List *columns);
        CLUSTER COALESCE COLLATE COLUMN COMMENT COMMIT
        COMMITTED CONCURRENTLY CONFIGURATION CONNECTION CONSTRAINT CONSTRAINTS
        CONTENT_P CONTINUE_P CONVERSION_P COPY COST CREATE CREATEDB
-       CREATEROLE CREATEUSER CROSS CSV CTYPE CURRENT_P
+       CREATEROLE CREATEUSER CROSS CSV CURRENT_P
        CURRENT_CATALOG CURRENT_DATE CURRENT_ROLE CURRENT_SCHEMA
        CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
 
@@ -464,9 +464,9 @@ static TypeName *TableFuncTypeName(List *columns);
 
        KEY
 
-       LANCOMPILER LANGUAGE LARGE_P LAST_P LEADING LEAST LEFT LEVEL
-       LIKE LIMIT LISTEN LOAD LOCAL LOCALTIME LOCALTIMESTAMP LOCATION
-       LOCK_P LOGIN_P
+       LANCOMPILER LANGUAGE LARGE_P LAST_P LC_COLLATE_P LC_CTYPE_P LEADING
+       LEAST LEFT LEVEL LIKE LIMIT LISTEN LOAD LOCAL LOCALTIME LOCALTIMESTAMP
+       LOCATION LOCK_P LOGIN_P
 
        MAPPING MATCH MAXVALUE MINUTE_P MINVALUE MODE MONTH_P MOVE
 
@@ -6011,21 +6011,21 @@ createdb_opt_item:
                                {
                                        $$ = makeDefElem("encoding", NULL);
                                }
-                       | COLLATE opt_equal Sconst
+                       | LC_COLLATE_P opt_equal Sconst
                                {
-                                       $$ = makeDefElem("collate", (Node *)makeString($3));
+                                       $$ = makeDefElem("lc_collate", (Node *)makeString($3));
                                }
-                       | COLLATE opt_equal DEFAULT
+                       | LC_COLLATE_P opt_equal DEFAULT
                                {
-                                       $$ = makeDefElem("collate", NULL);
+                                       $$ = makeDefElem("lc_collate", NULL);
                                }
-                       | CTYPE opt_equal Sconst
+                       | LC_CTYPE_P opt_equal Sconst
                                {
-                                       $$ = makeDefElem("ctype", (Node *)makeString($3));
+                                       $$ = makeDefElem("lc_ctype", (Node *)makeString($3));
                                }
-                       | CTYPE opt_equal DEFAULT
+                       | LC_CTYPE_P opt_equal DEFAULT
                                {
-                                       $$ = makeDefElem("ctype", NULL);
+                                       $$ = makeDefElem("lc_ctype", NULL);
                                }
                        | CONNECTION LIMIT opt_equal SignedIconst
                                {
@@ -10169,7 +10169,6 @@ unreserved_keyword:
                        | CREATEROLE
                        | CREATEUSER
                        | CSV
-                       | CTYPE
                        | CURRENT_P
                        | CURSOR
                        | CYCLE
@@ -10236,6 +10235,8 @@ unreserved_keyword:
                        | LANGUAGE
                        | LARGE_P
                        | LAST_P
+                       | LC_COLLATE_P
+                       | LC_CTYPE_P
                        | LEVEL
                        | LISTEN
                        | LOAD
index 2a3e49b8b49f52ca00c909614fd2a73954aa1280..0e2bbcf7911dd5127d99bc9d9530a6d555bdb425 100644 (file)
@@ -1716,12 +1716,12 @@ dumpDatabase(Archive *AH)
        }
        if (strlen(collate) > 0)
        {
-               appendPQExpBuffer(creaQry, " COLLATE = ");
+               appendPQExpBuffer(creaQry, " LC_COLLATE = ");
                appendStringLiteralAH(creaQry, collate, AH);
        }
        if (strlen(ctype) > 0)
        {
-               appendPQExpBuffer(creaQry, " CTYPE = ");
+               appendPQExpBuffer(creaQry, " LC_CTYPE = ");
                appendStringLiteralAH(creaQry, ctype, AH);
        }
        if (strlen(tablespace) > 0 && strcmp(tablespace, "pg_default") != 0)
index 5a79819e59b8ae40043bd803ea2e1c80efa90cb8..889e7280a9f7aaf60de540b8606b5030e4311427 100644 (file)
@@ -1048,13 +1048,13 @@ dumpCreateDB(PGconn *conn)
 
                        if (strlen(dbcollate) != 0)
                        {
-                               appendPQExpBuffer(buf, " COLLATE = ");
+                               appendPQExpBuffer(buf, " LC_COLLATE = ");
                                appendStringLiteralConn(buf, dbcollate, conn);
                        }
 
                        if (strlen(dbctype) != 0)
                        {
-                               appendPQExpBuffer(buf, " CTYPE = ");
+                               appendPQExpBuffer(buf, " LC_CTYPE = ");
                                appendStringLiteralConn(buf, dbctype, conn);
                        }
 
index 6ea03feab8fe63be791b28ee113ef9707b7a55b5..395bc6926a20dd6620d9837fd5541962a9a4533e 100644 (file)
@@ -186,9 +186,9 @@ main(int argc, char *argv[])
        if (template)
                appendPQExpBuffer(&sql, " TEMPLATE %s", fmtId(template));
        if (lc_collate)
-               appendPQExpBuffer(&sql, " COLLATE '%s'", lc_collate);
+               appendPQExpBuffer(&sql, " LC_COLLATE '%s'", lc_collate);
        if (lc_ctype)
-               appendPQExpBuffer(&sql, " CTYPE '%s'", lc_ctype);
+               appendPQExpBuffer(&sql, " LC_CTYPE '%s'", lc_ctype);
 
        appendPQExpBuffer(&sql, ";\n");
 
index 6fbe997278d6261a2952d9cea5512996734728bd..67e9cb4d4b26a97879efa127d25470fcbdbe2d2b 100644 (file)
@@ -98,7 +98,6 @@ PG_KEYWORD("createrole", CREATEROLE, UNRESERVED_KEYWORD)
 PG_KEYWORD("createuser", CREATEUSER, UNRESERVED_KEYWORD)
 PG_KEYWORD("cross", CROSS, TYPE_FUNC_NAME_KEYWORD)
 PG_KEYWORD("csv", CSV, UNRESERVED_KEYWORD)
-PG_KEYWORD("ctype", CTYPE, UNRESERVED_KEYWORD)
 PG_KEYWORD("current", CURRENT_P, UNRESERVED_KEYWORD)
 PG_KEYWORD("current_catalog", CURRENT_CATALOG, RESERVED_KEYWORD)
 PG_KEYWORD("current_date", CURRENT_DATE, RESERVED_KEYWORD)
@@ -209,6 +208,8 @@ PG_KEYWORD("lancompiler", LANCOMPILER, UNRESERVED_KEYWORD)
 PG_KEYWORD("language", LANGUAGE, UNRESERVED_KEYWORD)
 PG_KEYWORD("large", LARGE_P, UNRESERVED_KEYWORD)
 PG_KEYWORD("last", LAST_P, UNRESERVED_KEYWORD)
+PG_KEYWORD("lc_collate", LC_COLLATE_P, UNRESERVED_KEYWORD)
+PG_KEYWORD("lc_ctype", LC_CTYPE_P, UNRESERVED_KEYWORD)
 PG_KEYWORD("leading", LEADING, RESERVED_KEYWORD)
 PG_KEYWORD("least", LEAST, COL_NAME_KEYWORD)
 PG_KEYWORD("left", LEFT, TYPE_FUNC_NAME_KEYWORD)
index 6f97d679ed174a350ec2ff21982728e993fb792f..e968ae2c4ac84d189656a46a03681ba59c646b45 100644 (file)
@@ -1547,7 +1547,6 @@ ECPGunreserved_con:         ABORT_P                       { $$ = make_str("abort"); }
                | CREATEROLE            { $$ = make_str("createrole"); }
                | CREATEUSER            { $$ = make_str("createuser"); }
                | CSV                           { $$ = make_str("csv"); }
-               | CTYPE                 { $$ = make_str("ctype"); }
                | CURSOR                        { $$ = make_str("cursor"); }
                | CYCLE                         { $$ = make_str("cycle"); }
                | DATA_P                        { $$ = make_str("data"); }
@@ -1610,6 +1609,8 @@ ECPGunreserved_con:         ABORT_P                       { $$ = make_str("abort"); }
                | LANGUAGE                      { $$ = make_str("language"); }
                | LARGE_P                       { $$ = make_str("large"); }
                | LAST_P                        { $$ = make_str("last"); }
+               | LC_COLLATE_P          { $$ = make_str("lc_collate"); }
+               | LC_CTYPE_P            { $$ = make_str("lc_ctype"); }
                | LEVEL                         { $$ = make_str("level"); }
                | LISTEN                        { $$ = make_str("listen"); }
                | LOAD                          { $$ = make_str("load"); }