aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2000-04-16 15:46:40 +0000
committerPeter Eisentraut <peter_e@gmx.net>2000-04-16 15:46:40 +0000
commitaae70b2dca2de4b0aa7f81a210b86626ef2e081e (patch)
tree78fa6e8fbe80394ebe7da12c26d74a584638168c /src
parent82849df6c637c09fe484ed11e1035c158f128e81 (diff)
downloadpostgresql-aae70b2dca2de4b0aa7f81a210b86626ef2e081e.tar.gz
postgresql-aae70b2dca2de4b0aa7f81a210b86626ef2e081e.zip
more psql bug squashing:
\copy without arguments failed commands with too many arguments were too silent
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/command.c10
-rw-r--r--src/bin/psql/copy.c14
-rw-r--r--src/bin/psql/describe.c30
3 files changed, 33 insertions, 21 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index ca4099d53eb..4387c567ed8 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.29 2000/04/14 23:43:44 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.30 2000/04/16 15:46:40 petere Exp $
*/
#include "postgres.h"
#include "command.h"
@@ -137,8 +137,10 @@ HandleSlashCmds(const char *line,
status = exec_command(new_cmd, my_line + 1, &continue_parse, query_buf);
+#if 0 /* turned out to be too annoying */
if (status != CMD_UNKNOWN && isalpha(new_cmd[0]))
psql_error("Warning: this syntax is deprecated\n");
+#endif
}
if (status == CMD_UNKNOWN)
@@ -179,7 +181,8 @@ exec_command(const char *cmd,
bool quiet = QUIET();
backslashResult status = CMD_SKIP_LINE;
char *string,
- *string_cpy;
+ *string_cpy,
+ *val;
/*
* The 'string' variable will be overwritten to point to the next
@@ -777,7 +780,8 @@ exec_command(const char *cmd,
status = CMD_ERROR;
/* eat the rest of the options string */
- while (scan_option(&string, OT_NORMAL, NULL));
+ while ((val = scan_option(&string, OT_NORMAL, NULL)))
+ psql_error("\\%s: extra argument '%s' ignored\n", cmd, val);
if (options_string && continue_parse)
*continue_parse = options_string + (string - string_cpy);
diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c
index 7b38d26a639..86893da5abd 100644
--- a/src/bin/psql/copy.c
+++ b/src/bin/psql/copy.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.14 2000/04/14 23:43:44 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.15 2000/04/16 15:46:40 petere Exp $
*/
#include "postgres.h"
#include "copy.h"
@@ -34,7 +34,7 @@ bool copy_in_state;
* parse_slash_copy
* -- parses \copy command line
*
- * Accepted syntax: \copy [binary] table|"table" [with oids] from|to filename|'filename' using delimiters ['<char>'] [ with null as 'string' ]
+ * Accepted syntax: \copy [binary] table|"table" [with oids] from|to filename|'filename' [ using delimiters '<char>'] [ with null as 'string' ]
* (binary is not here yet)
*
* returns a malloc'ed structure with the options, or NULL on parsing error
@@ -74,7 +74,13 @@ parse_slash_copy(const char *args)
bool error = false;
char quote;
- line = xstrdup(args);
+ if (args)
+ line = xstrdup(args);
+ else
+ {
+ psql_error("\\copy: arguments required\n");
+ return NULL;
+ }
if (!(result = calloc(1, sizeof(struct copy_options))))
{
@@ -191,6 +197,8 @@ parse_slash_copy(const char *args)
}
}
}
+ else
+ error = true;
}
}
}
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 75c9df37143..9db62ce9bdb 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.19 2000/04/12 17:16:22 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.20 2000/04/16 15:46:40 petere Exp $
*/
#include "postgres.h"
#include "describe.h"
@@ -52,7 +52,7 @@ describeAggregates(const char *name)
if (name)
{
- strcat(buf, " AND a.aggname ~* '^");
+ strcat(buf, " AND a.aggname ~ '^");
strncat(buf, name, REGEXP_CUTOFF);
strcat(buf, "'\n");
}
@@ -67,7 +67,7 @@ describeAggregates(const char *name)
if (name)
{
- strcat(buf, " AND a.aggname ~* '^");
+ strcat(buf, " AND a.aggname ~ '^");
strncat(buf, name, REGEXP_CUTOFF);
strcat(buf, "'\n");
}
@@ -121,7 +121,7 @@ describeFunctions(const char *name, bool verbose)
if (name)
{
- strcat(buf, " AND p.proname ~* '^");
+ strcat(buf, " AND p.proname ~ '^");
strncat(buf, name, REGEXP_CUTOFF);
strcat(buf, "'\n");
}
@@ -166,7 +166,7 @@ describeTypes(const char *name, bool verbose)
if (name)
{
- strcat(buf, " AND t.typname ~* '^");
+ strcat(buf, " AND t.typname ~ '^");
strncat(buf, name, REGEXP_CUTOFF);
strcat(buf, "' ");
}
@@ -212,7 +212,7 @@ describeOperators(const char *name)
" o.oprright = t2.oid\n");
if (name)
{
- strcat(buf, " AND o.oprname ~ '^");
+ strcat(buf, " AND o.oprname = '");
strncat(buf, name, REGEXP_CUTOFF);
strcat(buf, "'\n");
}
@@ -230,7 +230,7 @@ describeOperators(const char *name)
" o.oprright = t1.oid\n");
if (name)
{
- strcat(buf, "AND o.oprname ~ '^");
+ strcat(buf, "AND o.oprname = '");
strncat(buf, name, REGEXP_CUTOFF);
strcat(buf, "'\n");
}
@@ -248,7 +248,7 @@ describeOperators(const char *name)
" o.oprleft = t1.oid\n");
if (name)
{
- strcat(buf, "AND o.oprname ~ '^");
+ strcat(buf, "AND o.oprname = '");
strncat(buf, name, REGEXP_CUTOFF);
strcat(buf, "'\n");
}
@@ -388,7 +388,7 @@ objectDescription(const char *object)
"WHERE a.oid = d.objoid\n");
if (object)
{
- strcat(descbuf, " AND a.aggname ~* '^");
+ strcat(descbuf, " AND a.aggname ~ '^");
strncat(descbuf, object, REGEXP_CUTOFF);
strcat(descbuf, "'\n");
}
@@ -400,7 +400,7 @@ objectDescription(const char *object)
"WHERE p.oid = d.objoid AND (p.pronargs = 0 or oidvectortypes(p.proargtypes) != '')\n");
if (object)
{
- strcat(descbuf, " AND p.proname ~* '^");
+ strcat(descbuf, " AND p.proname ~ '^");
strncat(descbuf, object, REGEXP_CUTOFF);
strcat(descbuf, "'\n");
}
@@ -413,7 +413,7 @@ objectDescription(const char *object)
"WHERE RegprocToOid(o.oprcode) = d.objoid\n");
if (object)
{
- strcat(descbuf, " AND o.oprname ~ '^");
+ strcat(descbuf, " AND o.oprname = '");
strncat(descbuf, object, REGEXP_CUTOFF);
strcat(descbuf, "'\n");
}
@@ -425,7 +425,7 @@ objectDescription(const char *object)
"WHERE t.oid = d.objoid\n");
if (object)
{
- strcat(descbuf, " AND t.typname ~* '^");
+ strcat(descbuf, " AND t.typname ~ '^");
strncat(descbuf, object, REGEXP_CUTOFF);
strcat(descbuf, "'\n");
}
@@ -437,7 +437,7 @@ objectDescription(const char *object)
"WHERE c.oid = d.objoid\n");
if (object)
{
- strcat(descbuf, " AND c.relname ~* '^");
+ strcat(descbuf, " AND c.relname ~ '^");
strncat(descbuf, object, REGEXP_CUTOFF);
strcat(descbuf, "'\n");
}
@@ -449,7 +449,7 @@ objectDescription(const char *object)
"WHERE r.oid = d.objoid AND r.rulename !~ '^_RET'\n");
if (object)
{
- strcat(descbuf, " AND r.rulename ~* '^");
+ strcat(descbuf, " AND r.rulename ~ '^");
strncat(descbuf, object, REGEXP_CUTOFF);
strcat(descbuf, "'\n");
}
@@ -461,7 +461,7 @@ objectDescription(const char *object)
"WHERE t.oid = d.objoid\n");
if (object)
{
- strcat(descbuf, " AND t.tgname ~* '^");
+ strcat(descbuf, " AND t.tgname ~ '^");
strncat(descbuf, object, REGEXP_CUTOFF);
strcat(descbuf, "'\n");
}