aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/collationcmds.c
diff options
context:
space:
mode:
authorDean Rasheed <dean.a.rasheed@gmail.com>2021-07-18 11:08:34 +0100
committerDean Rasheed <dean.a.rasheed@gmail.com>2021-07-18 11:08:34 +0100
commitba620760c4c8ca90ff83ecf7e4d46f5ec4dabd7b (patch)
treeeb7c694b7dc43eed9b295bf8ba5a74501a85dacc /src/backend/commands/collationcmds.c
parent8589299e03fff012e0bbb9716693750a0d68eef7 (diff)
downloadpostgresql-ba620760c4c8ca90ff83ecf7e4d46f5ec4dabd7b.tar.gz
postgresql-ba620760c4c8ca90ff83ecf7e4d46f5ec4dabd7b.zip
Improve error checking of CREATE COLLATION options.
Check for conflicting or redundant options, as we do for most other commands. Specifying any option more than once is at best redundant, and quite likely indicates a bug in the user's code. While at it, improve the error for conflicting locale options by adding detail text (the same as for CREATE DATABASE). Bharath Rupireddy, reviewed by Vignesh C. Some additional hacking by me. Discussion: https://postgr.es/m/CALj2ACWtL6fTLdyF4R_YkPtf1YEDb6FUoD5DGAki3rpD+sWqiA@mail.gmail.com
Diffstat (limited to 'src/backend/commands/collationcmds.c')
-rw-r--r--src/backend/commands/collationcmds.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c
index ebb0994db32..5a2ba56ceca 100644
--- a/src/backend/commands/collationcmds.c
+++ b/src/backend/commands/collationcmds.c
@@ -108,15 +108,22 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
parser_errposition(pstate, defel->location)));
break;
}
-
+ if (*defelp != NULL)
+ errorConflictingDefElem(defel, pstate);
*defelp = defel;
}
- if ((localeEl && (lccollateEl || lcctypeEl))
- || (fromEl && list_length(parameters) != 1))
+ if (localeEl && (lccollateEl || lcctypeEl))
+ ereport(ERROR,
+ errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("conflicting or redundant options"),
+ errdetail("LOCALE cannot be specified together with LC_COLLATE or LC_CTYPE."));
+
+ if (fromEl && list_length(parameters) != 1)
ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("conflicting or redundant options")));
+ errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("conflicting or redundant options"),
+ errdetail("FROM cannot be specified together with any other options."));
if (fromEl)
{