Commit 16143d64 authored by Peter Eisentraut's avatar Peter Eisentraut

Dump the COLLATABLE attribute in CREATE TYPE

This was previously omitted by accident.
parent 09b49a84
...@@ -7305,6 +7305,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo) ...@@ -7305,6 +7305,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
char *typbyval; char *typbyval;
char *typalign; char *typalign;
char *typstorage; char *typstorage;
char *typcollatable;
char *typdefault; char *typdefault;
bool typdefault_is_literal = false; bool typdefault_is_literal = false;
...@@ -7312,7 +7313,27 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo) ...@@ -7312,7 +7313,27 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
selectSourceSchema(tyinfo->dobj.namespace->dobj.name); selectSourceSchema(tyinfo->dobj.namespace->dobj.name);
/* Fetch type-specific details */ /* 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, " appendPQExpBuffer(query, "SELECT typlen, "
"typinput, typoutput, typreceive, typsend, " "typinput, typoutput, typreceive, typsend, "
...@@ -7326,6 +7347,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo) ...@@ -7326,6 +7347,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
"typanalyze::pg_catalog.oid AS typanalyzeoid, " "typanalyze::pg_catalog.oid AS typanalyzeoid, "
"typcategory, typispreferred, " "typcategory, typispreferred, "
"typdelim, typbyval, typalign, typstorage, " "typdelim, typbyval, typalign, typstorage, "
"false AS typcollatable, "
"pg_catalog.pg_get_expr(typdefaultbin, 0) AS typdefaultbin, typdefault " "pg_catalog.pg_get_expr(typdefaultbin, 0) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type " "FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid", "WHERE oid = '%u'::pg_catalog.oid",
...@@ -7346,6 +7368,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo) ...@@ -7346,6 +7368,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
"typanalyze::pg_catalog.oid AS typanalyzeoid, " "typanalyze::pg_catalog.oid AS typanalyzeoid, "
"'U' AS typcategory, false AS typispreferred, " "'U' AS typcategory, false AS typispreferred, "
"typdelim, typbyval, typalign, typstorage, " "typdelim, typbyval, typalign, typstorage, "
"false AS typcollatable, "
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault " "pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type " "FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid", "WHERE oid = '%u'::pg_catalog.oid",
...@@ -7365,6 +7388,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo) ...@@ -7365,6 +7388,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
"typanalyze::pg_catalog.oid AS typanalyzeoid, " "typanalyze::pg_catalog.oid AS typanalyzeoid, "
"'U' AS typcategory, false AS typispreferred, " "'U' AS typcategory, false AS typispreferred, "
"typdelim, typbyval, typalign, typstorage, " "typdelim, typbyval, typalign, typstorage, "
"false AS typcollatable, "
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault " "pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type " "FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid", "WHERE oid = '%u'::pg_catalog.oid",
...@@ -7384,6 +7408,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo) ...@@ -7384,6 +7408,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
"0 AS typanalyzeoid, " "0 AS typanalyzeoid, "
"'U' AS typcategory, false AS typispreferred, " "'U' AS typcategory, false AS typispreferred, "
"typdelim, typbyval, typalign, typstorage, " "typdelim, typbyval, typalign, typstorage, "
"false AS typcollatable, "
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault " "pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type " "FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid", "WHERE oid = '%u'::pg_catalog.oid",
...@@ -7403,6 +7428,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo) ...@@ -7403,6 +7428,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
"0 AS typanalyzeoid, " "0 AS typanalyzeoid, "
"'U' AS typcategory, false AS typispreferred, " "'U' AS typcategory, false AS typispreferred, "
"typdelim, typbyval, typalign, typstorage, " "typdelim, typbyval, typalign, typstorage, "
"false AS typcollatable, "
"pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault " "pg_catalog.pg_get_expr(typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, typdefault "
"FROM pg_catalog.pg_type " "FROM pg_catalog.pg_type "
"WHERE oid = '%u'::pg_catalog.oid", "WHERE oid = '%u'::pg_catalog.oid",
...@@ -7426,6 +7452,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo) ...@@ -7426,6 +7452,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
"0 AS typanalyzeoid, " "0 AS typanalyzeoid, "
"'U' AS typcategory, false AS typispreferred, " "'U' AS typcategory, false AS typispreferred, "
"typdelim, typbyval, typalign, typstorage, " "typdelim, typbyval, typalign, typstorage, "
"false AS typcollatable, "
"NULL AS typdefaultbin, typdefault " "NULL AS typdefaultbin, typdefault "
"FROM pg_type " "FROM pg_type "
"WHERE oid = '%u'::oid", "WHERE oid = '%u'::oid",
...@@ -7449,6 +7476,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo) ...@@ -7449,6 +7476,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
"0 AS typanalyzeoid, " "0 AS typanalyzeoid, "
"'U' AS typcategory, false AS typispreferred, " "'U' AS typcategory, false AS typispreferred, "
"typdelim, typbyval, typalign, typstorage, " "typdelim, typbyval, typalign, typstorage, "
"false AS typcollatable, "
"NULL AS typdefaultbin, NULL AS typdefault " "NULL AS typdefaultbin, NULL AS typdefault "
"FROM pg_type " "FROM pg_type "
"WHERE oid = '%u'::oid", "WHERE oid = '%u'::oid",
...@@ -7469,6 +7497,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo) ...@@ -7469,6 +7497,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
"'U' AS typcategory, false AS typispreferred, " "'U' AS typcategory, false AS typispreferred, "
"typdelim, typbyval, typalign, " "typdelim, typbyval, typalign, "
"'p'::char AS typstorage, " "'p'::char AS typstorage, "
"false AS typcollatable, "
"NULL AS typdefaultbin, NULL AS typdefault " "NULL AS typdefaultbin, NULL AS typdefault "
"FROM pg_type " "FROM pg_type "
"WHERE oid = '%u'::oid", "WHERE oid = '%u'::oid",
...@@ -7510,6 +7539,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo) ...@@ -7510,6 +7539,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
typbyval = PQgetvalue(res, 0, PQfnumber(res, "typbyval")); typbyval = PQgetvalue(res, 0, PQfnumber(res, "typbyval"));
typalign = PQgetvalue(res, 0, PQfnumber(res, "typalign")); typalign = PQgetvalue(res, 0, PQfnumber(res, "typalign"));
typstorage = PQgetvalue(res, 0, PQfnumber(res, "typstorage")); typstorage = PQgetvalue(res, 0, PQfnumber(res, "typstorage"));
typcollatable = PQgetvalue(res, 0, PQfnumber(res, "typcollatable"));
if (!PQgetisnull(res, 0, PQfnumber(res, "typdefaultbin"))) if (!PQgetisnull(res, 0, PQfnumber(res, "typdefaultbin")))
typdefault = PQgetvalue(res, 0, PQfnumber(res, "typdefaultbin")); typdefault = PQgetvalue(res, 0, PQfnumber(res, "typdefaultbin"));
else if (!PQgetisnull(res, 0, PQfnumber(res, "typdefault"))) else if (!PQgetisnull(res, 0, PQfnumber(res, "typdefault")))
...@@ -7566,6 +7596,9 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo) ...@@ -7566,6 +7596,9 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
/* receive/send/typmodin/typmodout/analyze need not be printed */ /* receive/send/typmodin/typmodout/analyze need not be printed */
} }
if (strcmp(typcollatable, "t") == 0)
appendPQExpBuffer(q, ",\n COLLATABLE = true");
if (typdefault != NULL) if (typdefault != NULL)
{ {
appendPQExpBuffer(q, ",\n DEFAULT = "); appendPQExpBuffer(q, ",\n DEFAULT = ");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment