more psql bug squashing:

\copy without arguments failed
commands with too many arguments were too silent
This commit is contained in:
Peter Eisentraut 2000-04-16 15:46:40 +00:00
parent 82849df6c6
commit aae70b2dca
4 changed files with 36 additions and 28 deletions

View File

@ -1,5 +1,5 @@
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.30 2000/03/27 17:14:43 thomas Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.31 2000/04/16 15:46:39 petere Exp $
Postgres documentation
-->
@ -443,16 +443,12 @@ testdb=>
<varlistentry>
<term><literal>\do [ <replaceable class="parameter">pattern</replaceable> ]</literal></term>
<term><literal>\do [ <replaceable class="parameter">name</replaceable> ]</literal></term>
<listitem>
<para>
Lists available operators with their operand and return types.
If <replaceable class="parameter">pattern</replaceable>
If <replaceable class="parameter">name</replaceable>
is specified, only operators with that name will be shown.
(Since this is a regular expression, be sure to quote all special
characters in you operator name with backslashes. To prevent
interpretation of the backslash as a new command, you might also
wish to quote the argument.)
</para>
</listitem>
</varlistentry>

View File

@ -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);

View File

@ -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;
}
}
}

View File

@ -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");
}