Add sanity check to ensure delimiter and quote are different in CSV mode
authorAndrew Dunstan <andrew@dunslane.net>
Sun, 30 Dec 2007 14:46:52 +0000 (14:46 +0000)
committerAndrew Dunstan <andrew@dunslane.net>
Sun, 30 Dec 2007 14:46:52 +0000 (14:46 +0000)
src/backend/commands/copy.c

index c2bad846a2b0e1ac98ff961ab2bf988424162cea..018d69d5e6d39f23431ad03ef445f68a7228d1ba 100644 (file)
@@ -906,6 +906,11 @@ DoCopy(const CopyStmt *stmt, const char *queryString)
                                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                                 errmsg("COPY quote must be a single ASCII character")));
 
+       if (cstate->csv_mode && cstate->delim[0] == cstate->quote[0])
+               ereport(ERROR,
+                               (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                                errmsg("COPY delimiter and quote must be different")));
+
        /* Check escape */
        if (!cstate->csv_mode && cstate->escape != NULL)
                ereport(ERROR,