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

Commit4477b6f

Browse files
committed
Fixes:
updates the psql.1 manual page for \ options add row count and ties it to the header option updated manual pages and comment for above change got \? to display in one screen-full (almost, \? scrolls off top) moved \r to \E, and \z to \r (for historical reasons with monitor) small code alignment cleanupSubmitted by: Bruce Momjian <maillist@candle.pha.pa.us>
1 parent1af2cc0 commit4477b6f

File tree

1 file changed

+62
-65
lines changed

1 file changed

+62
-65
lines changed

‎src/bin/psql/psql.c

Lines changed: 62 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.14 1996/07/29 20:58:42 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.15 1996/07/31 02:11:23 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -109,7 +109,7 @@ usage(char *progname)
109109
fprintf(stderr,"\t -q run quietly (no messages, no prompts)\n");
110110
fprintf(stderr,"\t -s single step mode (prompts for each query)\n");
111111
fprintf(stderr,"\t -S single line mode (i.e. query terminated by newline)\n");
112-
fprintf(stderr,"\t -t turn off printing ofattribute headers\n");
112+
fprintf(stderr,"\t -t turn off printing ofheadings and row count\n");
113113
fprintf(stderr,"\t -T html set html3.0 table command options (cf. -H)\n");
114114
fprintf(stderr,"\t -x turn on expanded output (field names on left)\n");
115115
exit(1);
@@ -128,33 +128,30 @@ char *on(bool f)
128128
staticvoid
129129
slashUsage(PsqlSettings*ps)
130130
{
131+
fprintf(stderr,"\t \\? -- help\n");
131132
fprintf(stderr,"\t \\a -- toggle field-alignment (currenty %s)\n",on(ps->opt.align));
132133
fprintf(stderr,"\t \\C [<captn>] -- set html3 caption (currently '%s')\n",ps->opt.caption?ps->opt.caption:"");
133134
fprintf(stderr,"\t \\c <dbname> -- connect to new database (currently '%s')\n",PQdb(ps->db));
134-
fprintf(stderr,"\t \\d [<table>] -- list tables in database or columns in <table>\n");
135-
fprintf(stderr,"\t \\d * -- list tables in database and columns in all tables\n");
136-
fprintf(stderr,"\t \\e [<fname>] -- edit the current query buffer or <fname>\n");
135+
fprintf(stderr,"\t \\d [<table>] -- list tables in database or columns in <table>,* for all\n");
136+
fprintf(stderr,"\t \\e [<fname>] -- edit the current query buffer or <fname>, \E execute too\n");
137137
fprintf(stderr,"\t \\f [<sep>] -- change field separater (currently '%s')\n",ps->opt.fieldSep);
138138
fprintf(stderr,"\t \\g [<fname>] -- send query to backend [and place results in <fname>]\n");
139139
fprintf(stderr,"\t \\g |<cmd> -- send query to backend and pipe results into <cmd>\n");
140-
fprintf(stderr,"\t \\h [<cmd>] -- help on syntax of sql commands\n");
141-
fprintf(stderr,"\t \\h * -- complete description of all sql commands\n");
140+
fprintf(stderr,"\t \\h [<cmd>] -- help on syntax of sql commands, * for all commands\n");
142141
fprintf(stderr,"\t \\H -- toggle html3 output (currently %s)\n",on(ps->opt.html3));
143142
fprintf(stderr,"\t \\i <fname> -- read and execute queries from filename\n");
144143
fprintf(stderr,"\t \\l -- list all databases\n");
145-
fprintf(stderr,"\t \\m -- toggle monitor-liketype-setting (currently %s)\n",on(ps->opt.standard));
144+
fprintf(stderr,"\t \\m -- toggle monitor-liketable display (currently %s)\n",on(ps->opt.standard));
146145
fprintf(stderr,"\t \\o [<fname>] -- send all query results to <fname> or stdout\n");
147146
fprintf(stderr,"\t \\o |<cmd> -- pipe all query results through <cmd>\n");
148147
fprintf(stderr,"\t \\p -- print the current query buffer\n");
149148
fprintf(stderr,"\t \\q -- quit\n");
150-
fprintf(stderr,"\t \\r[<fname>] -- edit <fname> then execute on save\n");
149+
fprintf(stderr,"\t \\r -- reset(clear) the query buffer\n");
151150
fprintf(stderr,"\t \\s [<fname>] -- print history or save it in <fname>\n");
152-
fprintf(stderr,"\t \\t -- toggle tableoutput header (currently %s)\n",on(ps->opt.header));
151+
fprintf(stderr,"\t \\t -- toggle tableheadings and row count (currently %s)\n",on(ps->opt.header));
153152
fprintf(stderr,"\t \\T [<html>] -- set html3.0 <table ...> options (currently '%s')\n",ps->opt.tableOpt?ps->opt.tableOpt:"");
154153
fprintf(stderr,"\t \\x -- toggle expanded output (currently %s)\n",on(ps->opt.expanded));
155-
fprintf(stderr,"\t \\z -- zorch current query buffer (i.e clear it)\n");
156154
fprintf(stderr,"\t \\! [<cmd>] -- shell escape or command\n");
157-
fprintf(stderr,"\t \\? -- help\n");
158155
}
159156

160157
PGresult*
@@ -624,7 +621,7 @@ HandleSlashCmds(PsqlSettings *settings,
624621
decode(optarg);
625622
}
626623
switch (line[1])
627-
{
624+
{
628625
case'a':/* toggles to align fields on output */
629626
toggle(settings,&settings->opt.align,"field alignment");
630627
break;
@@ -641,7 +638,7 @@ HandleSlashCmds(PsqlSettings *settings,
641638
}
642639
break;
643640
case'c':/* \c means connect to new database */
644-
{
641+
{
645642
char*dbname=PQdb(settings->db);
646643
if (!optarg) {
647644
fprintf(stderr,"\\c must be followed by a database name\n");
@@ -687,7 +684,7 @@ HandleSlashCmds(PsqlSettings *settings,
687684
}
688685
break;
689686
case'e':
690-
{
687+
{
691688
intfd;
692689
chartmp[64];
693690
char*fname;
@@ -743,7 +740,46 @@ HandleSlashCmds(PsqlSettings *settings,
743740
if (query[strlen(query)-1]==';')
744741
return0;
745742
break;
746-
}
743+
}
744+
case'E':
745+
{
746+
FILE*fd;
747+
staticchar*lastfile;
748+
structstatst,st2;
749+
if (optarg)
750+
{
751+
if (lastfile)
752+
free(lastfile);
753+
lastfile=malloc(strlen(optarg+1));
754+
if (!lastfile)
755+
{
756+
perror("malloc");
757+
exit(1);
758+
}
759+
strcpy(lastfile,optarg);
760+
}elseif (!lastfile)
761+
{
762+
fprintf(stderr,"\\r must be followed by a file name initially\n");
763+
break;
764+
}
765+
stat(lastfile,&st);
766+
editFile(lastfile);
767+
if ((stat(lastfile,&st2)==-1)|| ((fd=fopen(lastfile,"r"))==NULL))
768+
{
769+
perror(lastfile);
770+
break;
771+
}
772+
if (st2.st_mtime==st.st_mtime)
773+
{
774+
if (!settings->quiet)
775+
fprintf(stderr,"warning: %s not modified. query not executed\n",lastfile);
776+
fclose(fd);
777+
break;
778+
}
779+
MainLoop(settings,fd);
780+
fclose(fd);
781+
break;
782+
}
747783
case'f':
748784
{
749785
char*fs=DEFAULT_FIELD_SEP;
@@ -760,12 +796,12 @@ HandleSlashCmds(PsqlSettings *settings,
760796
fprintf(stderr,"field separater changed to '%s'\n",settings->opt.fieldSep);
761797
break;
762798
}
763-
case'g':/* \g means send query */
799+
case'g':/* \g means send query */
764800
settings->gfname=optarg;
765801
status=0;
766802
break;
767803
case'h':
768-
{
804+
{
769805
char*cmd;
770806
inti,numCmds;
771807
intall_help=0;
@@ -811,7 +847,7 @@ HandleSlashCmds(PsqlSettings *settings,
811847
printf("command not found, try \\h with no arguments to see available help\n");
812848
}
813849
break;
814-
}
850+
}
815851
case'i':/* \i is include file */
816852
{
817853
FILE*fd;
@@ -829,7 +865,7 @@ HandleSlashCmds(PsqlSettings *settings,
829865
MainLoop(settings,fd);
830866
fclose(fd);
831867
break;
832-
}
868+
}
833869
case'l':/* \l is list database */
834870
listAllDbs(settings);
835871
break;
@@ -850,45 +886,11 @@ HandleSlashCmds(PsqlSettings *settings,
850886
case'q':/* \q is quit */
851887
status=2;
852888
break;
853-
case'r':
854-
{
855-
FILE*fd;
856-
staticchar*lastfile;
857-
structstatst,st2;
858-
if (optarg)
859-
{
860-
if (lastfile)
861-
free(lastfile);
862-
lastfile=malloc(strlen(optarg+1));
863-
if (!lastfile)
864-
{
865-
perror("malloc");
866-
exit(1);
867-
}
868-
strcpy(lastfile,optarg);
869-
}elseif (!lastfile)
870-
{
871-
fprintf(stderr,"\\r must be followed by a file name initially\n");
872-
break;
873-
}
874-
stat(lastfile,&st);
875-
editFile(lastfile);
876-
if ((stat(lastfile,&st2)==-1)|| ((fd=fopen(lastfile,"r"))==NULL))
877-
{
878-
perror(lastfile);
879-
break;
880-
}
881-
if (st2.st_mtime==st.st_mtime)
882-
{
883-
if (!settings->quiet)
884-
fprintf(stderr,"warning: %s not modified. query not executed\n",lastfile);
885-
fclose(fd);
886-
break;
887-
}
888-
MainLoop(settings,fd);
889-
fclose(fd);
890-
break;
891-
}
889+
case'r':/* reset(clear) the buffer */
890+
query[0]='\0';
891+
if (!settings->quiet)
892+
fprintf(stderr,"buffer reset(cleared)\n");
893+
break;
892894
case's':/* \s is save history to a file */
893895
if (!optarg)
894896
optarg="/dev/tty";
@@ -913,7 +915,7 @@ HandleSlashCmds(PsqlSettings *settings,
913915
}
914916
break;
915917
case't':/* toggle headers */
916-
toggle(settings,&settings->opt.header,"outputheaders");
918+
toggle(settings,&settings->opt.header,"outputheadings and row count");
917919
break;
918920
case'T':/* define html <table ...> option */
919921
if (settings->opt.tableOpt)
@@ -930,11 +932,6 @@ HandleSlashCmds(PsqlSettings *settings,
930932
case'x':
931933
toggle(settings,&settings->opt.expanded,"expanded table representation");
932934
break;
933-
case'z':/* zorch buffer */
934-
query[0]='\0';
935-
if (!settings->quiet)
936-
fprintf(stderr,"zorched current query buffer\n");
937-
break;
938935
case'!':
939936
if (!optarg) {
940937
char*sys;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp