]> granicus.if.org Git - postgresql/commitdiff
Dump the COLLATABLE attribute in CREATE TYPE
authorPeter Eisentraut <peter_e@gmx.net>
Tue, 1 Mar 2011 16:45:34 +0000 (18:45 +0200)
committerPeter Eisentraut <peter_e@gmx.net>
Tue, 1 Mar 2011 16:45:34 +0000 (18:45 +0200)
This was previously omitted by accident.

src/bin/pg_dump/pg_dump.c

index a9fa3357e795db484dbf2e6124dc97ea7e5593d2..7c0c64cc7ade7b696f5092fd929f61d12c35bc04 100644 (file)
@@ -7305,6 +7305,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
        char       *typbyval;
        char       *typalign;
        char       *typstorage;
+       char       *typcollatable;
        char       *typdefault;
        bool            typdefault_is_literal = false;
 
@@ -7312,7 +7313,27 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
        selectSourceSchema(tyinfo->dobj.namespace->dobj.name);
 
        /* Fetch type-specific details */
-       if (fout->remoteVersion >= 80400)
+       if (fout->remoteVersion >= 90100)
+       {
+               appendPQExpBuffer(query, "SELECT typlen, "
+                                                 "typinput, typoutput, typreceive, typsend, "
+                                                 "typmodin, typmodout, typanalyze, "
+                                                 "typinput::pg_catalog.oid AS typinputoid, "
+                                                 "typoutput::pg_catalog.oid AS typoutputoid, "
+                                                 "typreceive::pg_catalog.oid AS typreceiveoid, "
+                                                 "typsend::pg_catalog.oid AS typsendoid, "
+                                                 "typmodin::pg_catalog.oid AS typmodinoid, "
+                                                 "typmodout::pg_catalog.oid AS typmodoutoid, "
+                                                 "typanalyze::pg_catalog.oid AS typanalyzeoid, "
+                                                 "typcategory, typispreferred, "
+                                                 "typdelim, typbyval, typalign, typstorage, "
+                                                 "(typcollation = (SELECT oid FROM pg_catalog.pg_collation WHERE collname = 'default')) AS typcollatable, "
+                                                 "pg_catalog.pg_get_expr(typdefaultbin, 0) AS typdefaultbin, typdefault "
+                                                 "FROM pg_catalog.pg_type "
+                                                 "WHERE oid = '%u'::pg_catalog.oid",
+                                                 tyinfo->dobj.catId.oid);
+       }
+       else if (fout->remoteVersion >= 80400)
        {
                appendPQExpBuffer(query, "SELECT typlen, "
                                                  "typinput, typoutput, typreceive, typsend, "
@@ -7326,6 +7347,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
                                                  "typanalyze::pg_catalog.oid AS typanalyzeoid, "
                                                  "typcategory, typispreferred, "
                                                  "typdelim, typbyval, typalign, typstorage, "
+                                                 "false AS typcollatable, "
                                                  "pg_catalog.pg_get_expr(typdefaultbin, 0) AS typdefaultbin, typdefault "
                                                  "FROM pg_catalog.pg_type "
                                                  "WHERE oid = '%u'::pg_catalog.oid",
@@ -7346,6 +7368,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
                                                  "typanalyze::pg_catalog.oid AS typanalyzeoid, "
                                                  "'U' AS typcategory, false AS typispreferred, "
                                                  "typdelim, typbyval, typalign, typstorage, "
+                                                 "false AS typcollatable, "
                                                  "pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
                                                  "FROM pg_catalog.pg_type "
                                                  "WHERE oid = '%u'::pg_catalog.oid",
@@ -7365,6 +7388,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
                                                  "typanalyze::pg_catalog.oid AS typanalyzeoid, "
                                                  "'U' AS typcategory, false AS typispreferred, "
                                                  "typdelim, typbyval, typalign, typstorage, "
+                                                 "false AS typcollatable, "
                                                  "pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
                                                  "FROM pg_catalog.pg_type "
                                                  "WHERE oid = '%u'::pg_catalog.oid",
@@ -7384,6 +7408,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
                                                  "0 AS typanalyzeoid, "
                                                  "'U' AS typcategory, false AS typispreferred, "
                                                  "typdelim, typbyval, typalign, typstorage, "
+                                                 "false AS typcollatable, "
                                                  "pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
                                                  "FROM pg_catalog.pg_type "
                                                  "WHERE oid = '%u'::pg_catalog.oid",
@@ -7403,6 +7428,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
                                                  "0 AS typanalyzeoid, "
                                                  "'U' AS typcategory, false AS typispreferred, "
                                                  "typdelim, typbyval, typalign, typstorage, "
+                                                 "false AS typcollatable, "
                                                  "pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
                                                  "FROM pg_catalog.pg_type "
                                                  "WHERE oid = '%u'::pg_catalog.oid",
@@ -7426,6 +7452,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
                                                  "0 AS typanalyzeoid, "
                                                  "'U' AS typcategory, false AS typispreferred, "
                                                  "typdelim, typbyval, typalign, typstorage, "
+                                                 "false AS typcollatable, "
                                                  "NULL AS typdefaultbin, typdefault "
                                                  "FROM pg_type "
                                                  "WHERE oid = '%u'::oid",
@@ -7449,6 +7476,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
                                                  "0 AS typanalyzeoid, "
                                                  "'U' AS typcategory, false AS typispreferred, "
                                                  "typdelim, typbyval, typalign, typstorage, "
+                                                 "false AS typcollatable, "
                                                  "NULL AS typdefaultbin, NULL AS typdefault "
                                                  "FROM pg_type "
                                                  "WHERE oid = '%u'::oid",
@@ -7469,6 +7497,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
                                                  "'U' AS typcategory, false AS typispreferred, "
                                                  "typdelim, typbyval, typalign, "
                                                  "'p'::char AS typstorage, "
+                                                 "false AS typcollatable, "
                                                  "NULL AS typdefaultbin, NULL AS typdefault "
                                                  "FROM pg_type "
                                                  "WHERE oid = '%u'::oid",
@@ -7510,6 +7539,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
        typbyval = PQgetvalue(res, 0, PQfnumber(res, "typbyval"));
        typalign = PQgetvalue(res, 0, PQfnumber(res, "typalign"));
        typstorage = PQgetvalue(res, 0, PQfnumber(res, "typstorage"));
+       typcollatable = PQgetvalue(res, 0, PQfnumber(res, "typcollatable"));
        if (!PQgetisnull(res, 0, PQfnumber(res, "typdefaultbin")))
                typdefault = PQgetvalue(res, 0, PQfnumber(res, "typdefaultbin"));
        else if (!PQgetisnull(res, 0, PQfnumber(res, "typdefault")))
@@ -7566,6 +7596,9 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
                /* receive/send/typmodin/typmodout/analyze need not be printed */
        }
 
+       if (strcmp(typcollatable, "t") == 0)
+               appendPQExpBuffer(q, ",\n    COLLATABLE = true");
+
        if (typdefault != NULL)
        {
                appendPQExpBuffer(q, ",\n    DEFAULT = ");