aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2017-06-13 08:49:41 -0400
committerPeter Eisentraut <peter_e@gmx.net>2017-06-13 08:49:41 -0400
commit17082a88eadfca79b50c04c5a78a2c38ee4f5d9c (patch)
tree53b98f6185e94f85d6e9b42f2afd920f2aa0d8b5
parent78a030a441966d91bc7e932ef84da39c3ea7d970 (diff)
downloadpostgresql-17082a88eadfca79b50c04c5a78a2c38ee4f5d9c.tar.gz
postgresql-17082a88eadfca79b50c04c5a78a2c38ee4f5d9c.zip
Prevent copying default collation
This will not have the desired effect and might lead to crashes when the copied collation is used. Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
-rw-r--r--src/backend/commands/collationcmds.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c
index ab702c2479c..91b65b174d3 100644
--- a/src/backend/commands/collationcmds.c
+++ b/src/backend/commands/collationcmds.c
@@ -120,6 +120,18 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
collprovider = ((Form_pg_collation) GETSTRUCT(tp))->collprovider;
ReleaseSysCache(tp);
+
+ /*
+ * Copying the "default" collation is not allowed because most code
+ * checks for DEFAULT_COLLATION_OID instead of COLLPROVIDER_DEFAULT,
+ * and so having a second collation with COLLPROVIDER_DEFAULT would
+ * not work and potentially confuse or crash some code. This could be
+ * fixed with some legwork.
+ */
+ if (collprovider == COLLPROVIDER_DEFAULT)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+ errmsg("collation \"default\" cannot be copied")));
}
if (localeEl)