*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.65 2002/02/20 22:47:12 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.66 2002/02/25 21:37:42 tgl Exp $
*/
#include "postgres_fe.h"
#include "command.h"
const char **continue_parse,
PQExpBuffer query_buf);
+/* different ways for scan_option to handle parameter words */
enum option_type
{
- OT_NORMAL, OT_SQLID, OT_FILEPIPE
+ OT_NORMAL, /* normal case */
+ OT_SQLID, /* treat as SQL identifier */
+ OT_SQLIDHACK, /* SQL identifier, but don't downcase */
+ OT_FILEPIPE /* it's a file or pipe */
};
-static char *scan_option(char **string, enum option_type type, char *quote, bool semicolon);
+
+static char *scan_option(char **string, enum option_type type,
+ char *quote, bool semicolon);
static char *unescape(const unsigned char *source, size_t len);
static bool do_edit(const char *filename_arg, PQExpBuffer query_buf);
char opt1q,
opt2q;
- opt1 = scan_option(&string, OT_SQLID, &opt1q, true);
- opt2 = scan_option(&string, OT_SQLID, &opt2q, true);
+ /*
+ * Ideally we should treat the arguments as SQL identifiers. But for
+ * backwards compatibility with 7.2 and older pg_dump files, we have
+ * to take unquoted arguments verbatim (don't downcase them).
+ * For now, double-quoted arguments may be stripped of double quotes
+ * (as if SQL identifiers). By 7.4 or so, pg_dump files can be
+ * expected to double-quote all mixed-case \connect arguments,
+ * and then we can get rid of OT_SQLIDHACK.
+ */
+ opt1 = scan_option(&string, OT_SQLIDHACK, &opt1q, true);
+ opt2 = scan_option(&string, OT_SQLIDHACK, &opt2q, true);
if (opt2)
/* gave username */
* then we strip out the double quotes
*/
- if (type == OT_SQLID)
+ if (type == OT_SQLID || type == OT_SQLIDHACK)
{
unsigned int k,
cc;
}
return_val[cc] = '\0';
}
-
else
{
strncpy(return_val, &options_string[pos], jj - pos + 1);