aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/explain.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/explain.c')
-rw-r--r--src/backend/commands/explain.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index de09ded65b9..094e977fb5c 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -14,7 +14,6 @@
#include "postgres.h"
#include "access/xact.h"
-#include "catalog/pg_collation.h"
#include "catalog/pg_type.h"
#include "commands/createas.h"
#include "commands/defrem.h"
@@ -2347,11 +2346,13 @@ show_sortorder_options(StringInfo buf, Node *sortexpr,
TYPECACHE_LT_OPR | TYPECACHE_GT_OPR);
/*
- * Print COLLATE if it's not default. There are some cases where this is
- * redundant, eg if expression is a column whose declared collation is
- * that collation, but it's hard to distinguish that here.
+ * Print COLLATE if it's not default for the column's type. There are
+ * some cases where this is redundant, eg if expression is a column whose
+ * declared collation is that collation, but it's hard to distinguish that
+ * here (and arguably, printing COLLATE explicitly is a good idea anyway
+ * in such cases).
*/
- if (OidIsValid(collation) && collation != DEFAULT_COLLATION_OID)
+ if (OidIsValid(collation) && collation != get_typcollation(sortcoltype))
{
char *collname = get_collation_name(collation);