33 *
44 * Copyright 2000 by PostgreSQL Global Development Group
55 *
6- * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.70 2002/03/19 02:32:21 momjian Exp $
6+ * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.71 2002/03/27 19:16:13 petere Exp $
77 */
88#include "postgres_fe.h"
99#include "command.h"
5252static backslashResult exec_command (const char * cmd ,
5353const char * options_string ,
5454const char * * continue_parse ,
55- PQExpBuffer query_buf );
55+ PQExpBuffer query_buf ,
56+ volatile int * paren_level );
5657
5758/* different ways for scan_option to handle parameter words */
5859enum option_type
@@ -94,7 +95,8 @@ static bool do_shell(const char *command);
9495backslashResult
9596HandleSlashCmds (const char * line ,
9697PQExpBuffer query_buf ,
97- const char * * end_of_cmd )
98+ const char * * end_of_cmd ,
99+ volatile int * paren_level )
98100{
99101backslashResult status = CMD_SKIP_LINE ;
100102char * my_line ;
@@ -132,7 +134,7 @@ HandleSlashCmds(const char *line,
132134my_line [blank_loc ]= '\0' ;
133135}
134136
135- status = exec_command (my_line ,options_string ,& continue_parse ,query_buf );
137+ status = exec_command (my_line ,options_string ,& continue_parse ,query_buf , paren_level );
136138
137139if (status == CMD_UNKNOWN )
138140{
@@ -147,7 +149,7 @@ HandleSlashCmds(const char *line,
147149new_cmd [1 ]= '\0' ;
148150
149151/* use line for options, because my_line was clobbered above */
150- status = exec_command (new_cmd ,line + 1 ,& continue_parse ,query_buf );
152+ status = exec_command (new_cmd ,line + 1 ,& continue_parse ,query_buf , paren_level );
151153
152154/*
153155 * continue_parse must be relative to my_line for calculation
@@ -192,7 +194,8 @@ static backslashResult
192194exec_command (const char * cmd ,
193195const char * options_string ,
194196const char * * continue_parse ,
195- PQExpBuffer query_buf )
197+ PQExpBuffer query_buf ,
198+ volatile int * paren_level )
196199{
197200bool success = true;/* indicate here if the command ran ok or
198201 * failed */
@@ -636,6 +639,8 @@ exec_command(const char *cmd,
636639else if (strcmp (cmd ,"r" )== 0 || strcmp (cmd ,"reset" )== 0 )
637640{
638641resetPQExpBuffer (query_buf );
642+ if (paren_level )
643+ * paren_level = 0 ;
639644if (!quiet )
640645puts (gettext ("Query buffer reset (cleared)." ));
641646}