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

Commit9672d38

Browse files
committed
Adjusted psql echoing options (-a and -e)
1 parenta2226ad commit9672d38

File tree

9 files changed

+57
-37
lines changed

9 files changed

+57
-37
lines changed

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

Lines changed: 23 additions & 10 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.24 2000/02/10 20:08:55 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.25 2000/02/13 21:45:13 petere Exp $
33
Postgres documentation
44
-->
55

@@ -609,7 +609,7 @@ Tue Oct 26 21:40:57 CEST 1999
609609
<note>
610610
<para>
611611
If you want to see the lines on the screen as they are read you must set
612-
the variable <envar>ECHO</envar> to <literal>full</literal>.
612+
the variable <envar>ECHO</envar> to <literal>all</literal>.
613613
</para>
614614
</note>
615615
</listitem>
@@ -1189,6 +1189,18 @@ Access permissions for database "test"
11891189

11901190
<para>
11911191
<variablelist>
1192+
<varlistentry>
1193+
<term>-a, --echo-all</term>
1194+
<listitem>
1195+
<para>
1196+
Print all the lines to the screen as they are read. This is more useful for
1197+
script processing rather than interactive mode.
1198+
This is equivalent to setting the variable <envar>ECHO</envar> to <literal>all</literal>.
1199+
</para>
1200+
</listitem>
1201+
</varlistentry>
1202+
1203+
11921204
<varlistentry>
11931205
<term>-A, --no-align</term>
11941206
<listitem>
@@ -1234,11 +1246,12 @@ Access permissions for database "test"
12341246

12351247

12361248
<varlistentry>
1237-
<term>-e, --echo</term>
1249+
<term>-e, --echo-queries</term>
12381250
<listitem>
12391251
<para>
1240-
In non-interactive mode, all lines are printed to the screen as they are read.
1241-
This is equivalent to setting the variable <envar>ECHO</envar> to <literal>full</literal>.
1252+
Show all queries that are sent to the backend.
1253+
This is equivalent to setting the variable <envar>ECHO</envar>
1254+
to <literal>queries</literal>.
12421255
</para>
12431256
</listitem>
12441257
</varlistentry>
@@ -1621,12 +1634,12 @@ bar
16211634
<term><envar>ECHO</envar></term>
16221635
<listitem>
16231636
<para>
1624-
If set to <quote><literal>full</literal></quote>, all lines entered or from a script
1637+
If set to <quote><literal>all</literal></quote>, all lines entered or from a script
16251638
are written to the standard output before they
1626-
are parsed or executed. To specify this on program startup,in conjunction withthe
1627-
<option>-f</option> option perhaps, use the switch <option>-e</option>.
1628-
If set to <quote><literal>brief</literal></quote>, <application>psql</application>
1629-
merely prints all queries as they are sent to the backend.
1639+
are parsed or executed. To specify this on program startup,usethe switch
1640+
<option>-a</option>. If set to <quote><literal>queries</literal></quote>,
1641+
<application>psql</application> merely prints all queries as they are sent to the
1642+
backend. The option for this is <option>-e</option>.
16301643
</para>
16311644
</listitem>
16321645
</varlistentry>

‎src/bin/psql/common.c

Lines changed: 2 additions & 2 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/common.c,v 1.12 2000/02/07 23:10:06 petere Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.13 2000/02/13 21:45:14 petere Exp $
77
*/
88
#include<c.h>
99
#include"common.h"
@@ -382,7 +382,7 @@ SendQuery(const char *query)
382382
else
383383
{
384384
constchar*var=GetVariable(pset.vars,"ECHO");
385-
if (var&&strcmp(var,"brief")==0)
385+
if (var&&strncmp(var,"queries",strlen(var))==0)
386386
puts(query);
387387
}
388388

‎src/bin/psql/help.c

Lines changed: 2 additions & 2 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/help.c,v 1.17 2000/02/10 20:08:56 petere Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.18 2000/02/13 21:45:14 petere Exp $
77
*/
88
#include<c.h>
99
#include"help.h"
@@ -72,7 +72,7 @@ usage(void)
7272
puts("Usage:");
7373
puts(" psql [options] [dbname [username]]\n");
7474
puts("Options:");
75-
/*puts( " -a Echo all input from script");*/
75+
puts(" -a Echo all input from script");
7676
puts(" -A Unaligned table output mode (-P format=unaligned)");
7777
puts(" -c <query> Run only single query (or slash command) and exit");
7878

‎src/bin/psql/mainloop.c

Lines changed: 2 additions & 2 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/mainloop.c,v 1.18 2000/02/10 20:08:56 petere Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.19 2000/02/13 21:45:14 petere Exp $
77
*/
88
#include<c.h>
99
#include"mainloop.h"
@@ -217,7 +217,7 @@ MainLoop(FILE *source)
217217

218218
/* echo back if flag is set */
219219
var=GetVariable(pset.vars,"ECHO");
220-
if (var&&strcmp(var,"full")==0)
220+
if (var&&strcmp(var,"all")==0)
221221
puts(line);
222222
fflush(stdout);
223223

‎src/bin/psql/startup.c

Lines changed: 13 additions & 11 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/startup.c,v 1.22 2000/02/07 23:10:06 petere Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.23 2000/02/13 21:45:14 petere Exp $
77
*/
88
#include<c.h>
99

@@ -280,17 +280,17 @@ parse_options(int argc, char *argv[], struct adhoc_opts * options)
280280
#ifdefHAVE_GETOPT_LONG
281281
staticstructoptionlong_options[]=
282282
{
283+
{"echo-all",no_argument,NULL,'a'},
283284
{"no-align",no_argument,NULL,'A'},
284285
{"command",required_argument,NULL,'c'},
285286
{"dbname",required_argument,NULL,'d'},
286-
{"echo",no_argument,NULL,'e'},
287+
{"echo-queries",no_argument,NULL,'e'},
287288
{"echo-hidden",no_argument,NULL,'E'},
288289
{"file",required_argument,NULL,'f'},
289290
{"field-separator",required_argument,NULL,'F'},
290291
{"host",required_argument,NULL,'h'},
291292
{"html",no_argument,NULL,'H'},
292293
{"list",no_argument,NULL,'l'},
293-
{"no-readline",no_argument,NULL,'n'},
294294
{"output",required_argument,NULL,'o'},
295295
{"port",required_argument,NULL,'p'},
296296
{"pset",required_argument,NULL,'P'},
@@ -320,18 +320,20 @@ parse_options(int argc, char *argv[], struct adhoc_opts * options)
320320
memset(options,0,sizeof*options);
321321

322322
#ifdefHAVE_GETOPT_LONG
323-
while ((c=getopt_long(argc,argv,"Ac:d:eEf:F:lh:Hno:p:P:qRsStT:uU:v:VWx?",long_options,&optindex))!=-1)
323+
while ((c=getopt_long(argc,argv,"aAc:d:eEf:F:lh:Hno:p:P:qRsStT:uU:v:VWx?",long_options,&optindex))!=-1)
324324
#else/* not HAVE_GETOPT_LONG */
325-
326325
/*
327326
* Be sure to leave the '-' in here, so we can catch accidental long
328327
* options.
329328
*/
330-
while ((c=getopt(argc,argv,"Ac:d:eEf:F:lh:Hno:p:P:qRsStT:uU:v:VWx?-"))!=-1)
329+
while ((c=getopt(argc,argv,"aAc:d:eEf:F:lh:Hno:p:P:qRsStT:uU:v:VWx?-"))!=-1)
331330
#endif/* not HAVE_GETOPT_LONG */
332331
{
333332
switch (c)
334333
{
334+
case'a':
335+
SetVariable(pset.vars,"ECHO","all");
336+
break;
335337
case'A':
336338
pset.popt.topt.format=PRINT_UNALIGNED;
337339
break;
@@ -346,10 +348,10 @@ parse_options(int argc, char *argv[], struct adhoc_opts * options)
346348
options->dbname=optarg;
347349
break;
348350
case'e':
349-
SetVariable(pset.vars,"ECHO","full");
351+
SetVariable(pset.vars,"ECHO","queries");
350352
break;
351353
case'E':
352-
SetVariable(pset.vars,"ECHO_HIDDEN","");
354+
SetVariableBool(pset.vars,"ECHO_HIDDEN");
353355
break;
354356
case'f':
355357
options->action=ACT_FILE;
@@ -402,16 +404,16 @@ parse_options(int argc, char *argv[], struct adhoc_opts * options)
402404
break;
403405
}
404406
case'q':
405-
SetVariable(pset.vars,"QUIET","");
407+
SetVariableBool(pset.vars,"QUIET");
406408
break;
407409
case'R':
408410
pset.popt.topt.recordSep=xstrdup(optarg);
409411
break;
410412
case's':
411-
SetVariable(pset.vars,"SINGLESTEP","");
413+
SetVariableBool(pset.vars,"SINGLESTEP");
412414
break;
413415
case'S':
414-
SetVariable(pset.vars,"SINGLELINE","");
416+
SetVariableBool(pset.vars,"SINGLELINE");
415417
break;
416418
case't':
417419
pset.popt.topt.tuples_only= true;

‎src/bin/psql/variables.c

Lines changed: 9 additions & 1 deletion
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/variables.c,v 1.5 2000/01/29 16:58:49 petere Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/variables.c,v 1.6 2000/02/13 21:45:14 petere Exp $
77
*/
88
#include<c.h>
99
#include"variables.h"
@@ -111,6 +111,14 @@ SetVariable(VariableSpace space, const char *name, const char *value)
111111

112112

113113

114+
bool
115+
SetVariableBool(VariableSpacespace,constchar*name)
116+
{
117+
returnSetVariable(space,name,"");
118+
}
119+
120+
121+
114122
bool
115123
DeleteVariable(VariableSpacespace,constchar*name)
116124
{

‎src/bin/psql/variables.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/variables.h,v 1.5 2000/01/29 16:58:49 petere Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/variables.h,v 1.6 2000/02/13 21:45:14 petere Exp $
77
*/
88

99
/*
1010
* This implements a sort of variable repository. One could also think of it
1111
* as cheap version of an associative array. In each one of these
1212
* datastructures you can store name/value pairs.
13-
*
14-
* All functions (should) follow the Shit-In-Shit-Out (SISO) principle, i.e.,
15-
* you can pass them NULL pointers and the like and they will return something
16-
* appropriate.
1713
*/
1814

1915
#ifndefVARIABLES_H
@@ -37,6 +33,7 @@ VariableSpace CreateVariableSpace(void);
3733
constchar*GetVariable(VariableSpacespace,constchar*name);
3834
boolGetVariableBool(VariableSpacespace,constchar*name);
3935
boolSetVariable(VariableSpacespace,constchar*name,constchar*value);
36+
boolSetVariableBool(VariableSpacespace,constchar*name);
4037
boolDeleteVariable(VariableSpacespace,constchar*name);
4138
voidDestroyVariableSpace(VariableSpacespace);
4239

‎src/test/regress/regress.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
2-
# $Header: /cvsroot/pgsql/src/test/regress/Attic/regress.sh,v 1.39 2000/01/09 20:54:36 tgl Exp $
2+
# $Header: /cvsroot/pgsql/src/test/regress/Attic/regress.sh,v 1.40 2000/02/13 21:45:15 petere Exp $
33
#
44
if [$#-eq 0 ]
55
then
@@ -30,7 +30,7 @@ fi
3030
PGTZ="PST8PDT";export PGTZ
3131
PGDATESTYLE="Postgres,US";export PGDATESTYLE
3232

33-
FRONTEND="psql$HOSTLOC -n -e -q"
33+
FRONTEND="psql$HOSTLOC -a -q"
3434

3535
# ----------
3636
# Scan resultmap file to find which platform-specific expected files to use.

‎src/test/regress/run_check.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
#
3-
# $Header: /cvsroot/pgsql/src/test/regress/Attic/run_check.sh,v 1.7 2000/01/16 20:05:00 petere Exp $
3+
# $Header: /cvsroot/pgsql/src/test/regress/Attic/run_check.sh,v 1.8 2000/02/13 21:45:15 petere Exp $
44

55
# ----------
66
# Check call syntax
@@ -86,7 +86,7 @@ PGDATESTYLE="Postgres,US"; export PGDATESTYLE
8686
# ----------
8787
# The SQL shell to use during this test
8888
# ----------
89-
FRONTEND="$BINDIR/psql$HOSTLOC -n -e -q"
89+
FRONTEND="$BINDIR/psql$HOSTLOC -a -q"
9090

9191
# ----------
9292
# Scan resultmap file to find which platform-specific expected files to use.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp