Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaae70b2

Browse files
committed
more psql bug squashing:
\copy without arguments failedcommands with too many arguments were too silent
1 parent82849df commitaae70b2

File tree

4 files changed

+36
-28
lines changed

4 files changed

+36
-28
lines changed

‎doc/src/sgml/ref/psql-ref.sgml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.30 2000/03/27 17:14:43 thomas Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.31 2000/04/16 15:46:39 petere Exp $
33
Postgres documentation
44
-->
55

@@ -443,16 +443,12 @@ testdb=>
443443

444444

445445
<varlistentry>
446-
<term><literal>\do [ <replaceable class="parameter">pattern</replaceable> ]</literal></term>
446+
<term><literal>\do [ <replaceable class="parameter">name</replaceable> ]</literal></term>
447447
<listitem>
448448
<para>
449449
Lists available operators with their operand and return types.
450-
If <replaceable class="parameter">pattern</replaceable>
450+
If <replaceable class="parameter">name</replaceable>
451451
is specified, only operators with that name will be shown.
452-
(Since this is a regular expression, be sure to quote all special
453-
characters in you operator name with backslashes. To prevent
454-
interpretation of the backslash as a new command, you might also
455-
wish to quote the argument.)
456452
</para>
457453
</listitem>
458454
</varlistentry>

‎src/bin/psql/command.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.29 2000/04/14 23:43:44 petere Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.30 2000/04/16 15:46:40 petere Exp $
77
*/
88
#include"postgres.h"
99
#include"command.h"
@@ -137,8 +137,10 @@ HandleSlashCmds(const char *line,
137137

138138
status=exec_command(new_cmd,my_line+1,&continue_parse,query_buf);
139139

140+
#if0/* turned out to be too annoying */
140141
if (status!=CMD_UNKNOWN&&isalpha(new_cmd[0]))
141142
psql_error("Warning: this syntax is deprecated\n");
143+
#endif
142144
}
143145

144146
if (status==CMD_UNKNOWN)
@@ -179,7 +181,8 @@ exec_command(const char *cmd,
179181
boolquiet=QUIET();
180182
backslashResultstatus=CMD_SKIP_LINE;
181183
char*string,
182-
*string_cpy;
184+
*string_cpy,
185+
*val;
183186

184187
/*
185188
* The 'string' variable will be overwritten to point to the next
@@ -777,7 +780,8 @@ exec_command(const char *cmd,
777780
status=CMD_ERROR;
778781

779782
/* eat the rest of the options string */
780-
while (scan_option(&string,OT_NORMAL,NULL));
783+
while ((val=scan_option(&string,OT_NORMAL,NULL)))
784+
psql_error("\\%s: extra argument '%s' ignored\n",cmd,val);
781785

782786
if (options_string&&continue_parse)
783787
*continue_parse=options_string+ (string-string_cpy);

‎src/bin/psql/copy.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.14 2000/04/14 23:43:44 petere Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.15 2000/04/16 15:46:40 petere Exp $
77
*/
88
#include"postgres.h"
99
#include"copy.h"
@@ -34,7 +34,7 @@ boolcopy_in_state;
3434
* parse_slash_copy
3535
* -- parses \copy command line
3636
*
37-
* Accepted syntax: \copy [binary] table|"table" [with oids] from|to filename|'filename' using delimiters['<char>'] [ with null as 'string' ]
37+
* Accepted syntax: \copy [binary] table|"table" [with oids] from|to filename|'filename'[using delimiters '<char>'] [ with null as 'string' ]
3838
* (binary is not here yet)
3939
*
4040
* returns a malloc'ed structure with the options, or NULL on parsing error
@@ -74,7 +74,13 @@ parse_slash_copy(const char *args)
7474
boolerror= false;
7575
charquote;
7676

77-
line=xstrdup(args);
77+
if (args)
78+
line=xstrdup(args);
79+
else
80+
{
81+
psql_error("\\copy: arguments required\n");
82+
returnNULL;
83+
}
7884

7985
if (!(result=calloc(1,sizeof(structcopy_options))))
8086
{
@@ -191,6 +197,8 @@ parse_slash_copy(const char *args)
191197
}
192198
}
193199
}
200+
else
201+
error= true;
194202
}
195203
}
196204
}

‎src/bin/psql/describe.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.19 2000/04/12 17:16:22 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.20 2000/04/16 15:46:40 petere Exp $
77
*/
88
#include"postgres.h"
99
#include"describe.h"
@@ -52,7 +52,7 @@ describeAggregates(const char *name)
5252

5353
if (name)
5454
{
55-
strcat(buf," AND a.aggname ~* '^");
55+
strcat(buf," AND a.aggname ~ '^");
5656
strncat(buf,name,REGEXP_CUTOFF);
5757
strcat(buf,"'\n");
5858
}
@@ -67,7 +67,7 @@ describeAggregates(const char *name)
6767

6868
if (name)
6969
{
70-
strcat(buf," AND a.aggname ~* '^");
70+
strcat(buf," AND a.aggname ~ '^");
7171
strncat(buf,name,REGEXP_CUTOFF);
7272
strcat(buf,"'\n");
7373
}
@@ -121,7 +121,7 @@ describeFunctions(const char *name, bool verbose)
121121

122122
if (name)
123123
{
124-
strcat(buf," AND p.proname ~* '^");
124+
strcat(buf," AND p.proname ~ '^");
125125
strncat(buf,name,REGEXP_CUTOFF);
126126
strcat(buf,"'\n");
127127
}
@@ -166,7 +166,7 @@ describeTypes(const char *name, bool verbose)
166166

167167
if (name)
168168
{
169-
strcat(buf," AND t.typname ~* '^");
169+
strcat(buf," AND t.typname ~ '^");
170170
strncat(buf,name,REGEXP_CUTOFF);
171171
strcat(buf,"' ");
172172
}
@@ -212,7 +212,7 @@ describeOperators(const char *name)
212212
" o.oprright = t2.oid\n");
213213
if (name)
214214
{
215-
strcat(buf," AND o.oprname~ '^");
215+
strcat(buf," AND o.oprname= '");
216216
strncat(buf,name,REGEXP_CUTOFF);
217217
strcat(buf,"'\n");
218218
}
@@ -230,7 +230,7 @@ describeOperators(const char *name)
230230
" o.oprright = t1.oid\n");
231231
if (name)
232232
{
233-
strcat(buf,"AND o.oprname~ '^");
233+
strcat(buf,"AND o.oprname= '");
234234
strncat(buf,name,REGEXP_CUTOFF);
235235
strcat(buf,"'\n");
236236
}
@@ -248,7 +248,7 @@ describeOperators(const char *name)
248248
" o.oprleft = t1.oid\n");
249249
if (name)
250250
{
251-
strcat(buf,"AND o.oprname~ '^");
251+
strcat(buf,"AND o.oprname= '");
252252
strncat(buf,name,REGEXP_CUTOFF);
253253
strcat(buf,"'\n");
254254
}
@@ -388,7 +388,7 @@ objectDescription(const char *object)
388388
"WHERE a.oid = d.objoid\n");
389389
if (object)
390390
{
391-
strcat(descbuf," AND a.aggname ~* '^");
391+
strcat(descbuf," AND a.aggname ~ '^");
392392
strncat(descbuf,object,REGEXP_CUTOFF);
393393
strcat(descbuf,"'\n");
394394
}
@@ -400,7 +400,7 @@ objectDescription(const char *object)
400400
"WHERE p.oid = d.objoid AND (p.pronargs = 0 or oidvectortypes(p.proargtypes) != '')\n");
401401
if (object)
402402
{
403-
strcat(descbuf," AND p.proname ~* '^");
403+
strcat(descbuf," AND p.proname ~ '^");
404404
strncat(descbuf,object,REGEXP_CUTOFF);
405405
strcat(descbuf,"'\n");
406406
}
@@ -413,7 +413,7 @@ objectDescription(const char *object)
413413
"WHERE RegprocToOid(o.oprcode) = d.objoid\n");
414414
if (object)
415415
{
416-
strcat(descbuf," AND o.oprname~ '^");
416+
strcat(descbuf," AND o.oprname= '");
417417
strncat(descbuf,object,REGEXP_CUTOFF);
418418
strcat(descbuf,"'\n");
419419
}
@@ -425,7 +425,7 @@ objectDescription(const char *object)
425425
"WHERE t.oid = d.objoid\n");
426426
if (object)
427427
{
428-
strcat(descbuf," AND t.typname ~* '^");
428+
strcat(descbuf," AND t.typname ~ '^");
429429
strncat(descbuf,object,REGEXP_CUTOFF);
430430
strcat(descbuf,"'\n");
431431
}
@@ -437,7 +437,7 @@ objectDescription(const char *object)
437437
"WHERE c.oid = d.objoid\n");
438438
if (object)
439439
{
440-
strcat(descbuf," AND c.relname ~* '^");
440+
strcat(descbuf," AND c.relname ~ '^");
441441
strncat(descbuf,object,REGEXP_CUTOFF);
442442
strcat(descbuf,"'\n");
443443
}
@@ -449,7 +449,7 @@ objectDescription(const char *object)
449449
"WHERE r.oid = d.objoid AND r.rulename !~ '^_RET'\n");
450450
if (object)
451451
{
452-
strcat(descbuf," AND r.rulename ~* '^");
452+
strcat(descbuf," AND r.rulename ~ '^");
453453
strncat(descbuf,object,REGEXP_CUTOFF);
454454
strcat(descbuf,"'\n");
455455
}
@@ -461,7 +461,7 @@ objectDescription(const char *object)
461461
"WHERE t.oid = d.objoid\n");
462462
if (object)
463463
{
464-
strcat(descbuf," AND t.tgname ~* '^");
464+
strcat(descbuf," AND t.tgname ~ '^");
465465
strncat(descbuf,object,REGEXP_CUTOFF);
466466
strcat(descbuf,"'\n");
467467
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp