Index: command.h =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/psql/command.h,v retrieving revision 1.13 diff -c -r1.13 command.h *** command.h 2001/11/05 17:46:30 1.13 --- command.h 2002/03/23 17:15:50 *************** *** 18,23 **** --- 18,24 ---- { CMD_UNKNOWN = 0, /* not done parsing yet (internal only) */ CMD_SEND, /* query complete; send off */ + CMD_SEND_X, /* query complete; send off, toggle expanded mode */ CMD_SKIP_LINE, /* keep building query */ CMD_TERMINATE, /* quit program */ CMD_NEWEDIT, /* query buffer was changed (e.g., via \e) */ Index: command.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/psql/command.c,v retrieving revision 1.70 diff -c -r1.70 command.c *** command.c 2002/03/19 02:32:21 1.70 --- command.c 2002/03/23 17:15:52 *************** *** 494,499 **** --- 494,514 ---- status = CMD_SEND; } + /* \G means toggle expanded mode, send query, then toggle expanded mode + again after query completion. */ + else if (strcmp(cmd, "G") == 0) + { + char *fname = scan_option(&string, OT_FILEPIPE, NULL, false); + success = do_pset("expanded", NULL, &pset.popt, true); + + if (!fname) + pset.gfname = NULL; + else + pset.gfname = xstrdup(fname); + free(fname); + status = CMD_SEND_X; + } + /* help */ else if (strcmp(cmd, "h") == 0 || strcmp(cmd, "help") == 0) { Index: help.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/psql/help.c,v retrieving revision 1.50 diff -c -r1.50 help.c *** help.c 2002/03/19 03:01:01 1.50 --- help.c 2002/03/23 17:15:53 *************** *** 45,50 **** --- 45,51 ---- * print out command line arguments */ #define ON(var) (var ? _("on") : _("off")) + #define OFF(var) (var ? _("off") : _("on")) void usage(void) *************** *** 177,183 **** if (pset.notty == 0 && (pagerenv = getenv("PAGER")) && (pagerenv[0] != '\0') && ! screen_size.ws_row <= 46 && (fout = popen(pagerenv, "w"))) { usePipe = true; --- 178,184 ---- if (pset.notty == 0 && (pagerenv = getenv("PAGER")) && (pagerenv[0] != '\0') && ! screen_size.ws_row <= 48 && (fout = popen(pagerenv, "w"))) { usePipe = true; *************** *** 215,220 **** --- 216,223 ---- fprintf(fout, _(" \\encoding [ENCODING] show or set client encoding\n")); fprintf(fout, _(" \\f [STRING] show or set field separator for unaligned query output\n")); fprintf(fout, _(" \\g [FILE] send query buffer to server (and results to file or |pipe)\n")); + fprintf(fout, _(" \\G [FILE] same as \\g but with expanded mode %s\n"), + OFF(pset.popt.topt.expanded)); fprintf(fout, _(" \\h [NAME] help on syntax of SQL commands, * for all commands\n")); fprintf(fout, _(" \\H toggle HTML output mode (currently %s)\n"), ON(pset.popt.topt.format == PRINT_HTML)); Index: mainloop.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/psql/mainloop.c,v retrieving revision 1.46 diff -c -r1.46 mainloop.c *** mainloop.c 2002/02/18 05:57:41 1.46 --- mainloop.c 2002/03/23 17:15:54 *************** *** 469,482 **** success = slashCmdStatus != CMD_ERROR; ! if ((slashCmdStatus == CMD_SEND || slashCmdStatus == CMD_NEWEDIT) && query_buf->len == 0) { /* copy previous buffer to current for handling */ appendPQExpBufferStr(query_buf, previous_buf->data); } ! if (slashCmdStatus == CMD_SEND) { success = SendQuery(query_buf->data); query_start = i + thislen; --- 469,482 ---- success = slashCmdStatus != CMD_ERROR; ! if ((slashCmdStatus == CMD_SEND || slashCmdStatus == CMD_SEND_X || slashCmdStatus == CMD_NEWEDIT) && query_buf->len == 0) { /* copy previous buffer to current for handling */ appendPQExpBufferStr(query_buf, previous_buf->data); } ! if (slashCmdStatus == CMD_SEND || slashCmdStatus == CMD_SEND_X) { success = SendQuery(query_buf->data); query_start = i + thislen; *************** *** 492,497 **** --- 492,506 ---- /* process anything left after the backslash command */ i += end_of_cmd - &line[i]; query_start = i; + + /* special case for \G: call the backslash + handler a second time to silently retoggle expanded mode */ + if(slashCmdStatus == CMD_SEND_X) + { + slashCmdStatus = HandleSlashCmds((char *)"G\0", + NULL, + NULL); + } }