Hola Álvaro,

What I'm going to do now is to write a patch to remove the \cset part of
the commit and post it, intending to push at some point next week.

Per your request, here is a patch which removes \cset from pgbench. Sigh.

--
Fabien.
diff --git a/doc/src/sgml/ref/pgbench.sgml b/doc/src/sgml/ref/pgbench.sgml
index 24833f46bc..b45e2f0896 100644
--- a/doc/src/sgml/ref/pgbench.sgml
+++ b/doc/src/sgml/ref/pgbench.sgml
@@ -963,48 +963,6 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
   </para>
 
   <variablelist>
-   <varlistentry id='pgbench-metacommand-cset'>
-    <term>
-     <literal>\cset [<replaceable>prefix</replaceable>]</literal>
-    </term>
-
-    <listitem>
-     <para>
-      This command may be used to end SQL queries, replacing an embedded
-      semicolon (<literal>\;</literal>) within a compound SQL command.
-     </para>
-
-     <para>
-      When this command is used, the preceding SQL query is expected to
-      return one row, the columns of which are stored into variables named after
-      column names, and prefixed with <replaceable>prefix</replaceable> if provided.
-     </para>
-
-     <para>
-      The following example sends four queries as one compound SQL command,
-      inducing one message sent at the protocol level.
-      The result of the first query is stored into variable <replaceable>one</replaceable>,
-      the results of the third query are stored into variables <replaceable>z_three</replaceable>
-      and <replaceable>z_four</replaceable>,
-      whereas the results of the other queries are discarded.
-<programlisting>
--- compound of four queries
-SELECT 1 AS one \cset
-SELECT 2 AS two \;
-SELECT 3 AS three, 4 AS four \cset z_
-SELECT 5;
-</programlisting>
-     </para>
-
-     <note>
-      <para>
-        <literal>\cset</literal> does not work when empty SQL queries appear
-        within a compound SQL command.
-      </para>
-     </note>
-    </listitem>
-   </varlistentry>
-
    <varlistentry id='pgbench-metacommand-gset'>
     <term>
      <literal>\gset [<replaceable>prefix</replaceable>]</literal>
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 4789ab92ee..43976d1d5d 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -490,7 +490,6 @@ typedef enum MetaCommand
 	META_SETSHELL,				/* \setshell */
 	META_SHELL,					/* \shell */
 	META_SLEEP,					/* \sleep */
-	META_CSET,					/* \cset */
 	META_GSET,					/* \gset */
 	META_IF,					/* \if */
 	META_ELIF,					/* \elif */
@@ -522,7 +521,7 @@ static const char *QUERYMODE[] = {"simple", "extended", "prepared"};
  *				string itself.  For SQL commands, after post-processing
  *				argv[0] is the same as 'lines' with variables substituted.
  * nqueries		In a multi-command SQL line, the number of queries.
- * varprefix 	SQL commands terminated with \gset or \cset have this set
+ * varprefix 	SQL commands terminated with \gset have this set
  *				to a non NULL value.  If nonempty, it's used to prefix the
  *				variable name that receives the value.
  * varprefix_max Allocated size of the varprefix array.
@@ -2614,8 +2613,6 @@ getMetaCommand(const char *cmd)
 		mc = META_ELSE;
 	else if (pg_strcasecmp(cmd, "endif") == 0)
 		mc = META_ENDIF;
-	else if (pg_strcasecmp(cmd, "cset") == 0)
-		mc = META_CSET;
 	else if (pg_strcasecmp(cmd, "gset") == 0)
 		mc = META_GSET;
 	else
@@ -4293,30 +4290,11 @@ free_command(Command *command)
 	}
 	/*
 	 * It should also free expr recursively, but this is currently not needed
-	 * as only \{g,c}set commands (which do not have an expression) are freed.
+	 * as only gset commands (which do not have an expression) are freed.
 	 */
 	pg_free(command);
 }
 
-/*
- * append "more" text to current compound command which had been interrupted
- * by \cset.
- */
-static void
-append_sql_command(Command *my_command, char *more, int numqueries)
-{
-	Assert(my_command->type == SQL_COMMAND && my_command->lines.len > 0);
-
-	more = skip_sql_comments(more);
-	if (more == NULL)
-		return;
-
-	/* append command text, embedding a ';' in place of the \cset */
-	appendPQExpBuffer(&my_command->lines, ";\n%s", more);
-
-	my_command->nqueries += numqueries;
-}
-
 /*
  * Once an SQL command is fully parsed, possibly by accumulating several
  * parts, complete other fields of the Command structure.
@@ -4549,7 +4527,7 @@ process_backslash_command(PsqlScanState sstate, const char *source)
 			syntax_error(source, lineno, my_command->first_line, my_command->argv[0],
 						 "unexpected argument", NULL, -1);
 	}
-	else if (my_command->meta == META_CSET || my_command->meta == META_GSET)
+	else if (my_command->meta == META_GSET)
 	{
 		if (my_command->argc > 2)
 			syntax_error(source, lineno, my_command->first_line, my_command->argv[0],
@@ -4637,7 +4615,6 @@ ParseScript(const char *script, const char *desc, int weight)
 	PQExpBufferData line_buf;
 	int			alloc_num;
 	int			index;
-	bool		saw_cset = false;
 	int			lineno;
 	int			start_offset;
 
@@ -4683,22 +4660,12 @@ ParseScript(const char *script, const char *desc, int weight)
 
 		semicolons = psql_scan_get_escaped_semicolons(sstate);
 
-		if (saw_cset)
-		{
-			/* the previous multi-line command ended with \cset */
-			append_sql_command(ps.commands[index - 1], line_buf.data,
-							   semicolons + 1);
-			saw_cset = false;
-		}
-		else
-		{
-			/* If we collected a new SQL command, process that */
-			command = create_sql_command(&line_buf, desc, semicolons + 1);
+		/* If we collected a new SQL command, process that */
+		command = create_sql_command(&line_buf, desc, semicolons + 1);
 
-			/* store new command */
-			if (command)
-				ps.commands[index++] = command;
-		}
+		/* store new command */
+		if (command)
+			ps.commands[index++] = command;
 
 		/* If we reached a backslash, process that */
 		if (sr == PSCAN_BACKSLASH)
@@ -4708,49 +4675,42 @@ ParseScript(const char *script, const char *desc, int weight)
 			if (command)
 			{
 				/*
-				 * If this is gset/cset, merge into the preceding command. (We
+				 * If this is gset, merge into the preceding command. (We
 				 * don't use a command slot in this case).
 				 */
-				if (command->meta == META_CSET ||
-					command->meta == META_GSET)
+				if (command->meta == META_GSET)
 				{
 					int			cindex;
 					Command    *cmd;
 
-					/*
-					 * If \cset is seen, set flag to leave the command pending
-					 * for the next iteration to process.
-					 */
-					saw_cset = command->meta == META_CSET;
-
 					if (index == 0)
 						syntax_error(desc, lineno, NULL, NULL,
-									 "\\gset/cset cannot start a script",
+									 "\\gset cannot start a script",
 									 NULL, -1);
 
 					cmd = ps.commands[index - 1];
 
 					if (cmd->type != SQL_COMMAND)
 						syntax_error(desc, lineno, NULL, NULL,
-									 "\\gset/cset must follow a SQL command",
+									 "\\gset must follow a SQL command",
 									 cmd->first_line, -1);
 
-					/* this {g,c}set applies to the previous query */
+					/* this gset applies to the previous query */
 					cindex = cmd->nqueries - 1;
 
 					/*
-					 * now that we know there's a {g,c}set in this command,
+					 * now that we know there's a gset in this command,
 					 * allocate space for the variable name prefix array.
 					 */
 					allocate_command_varprefix(cmd, cmd->nqueries);
 
 					/*
-					 * Don't allow the previous command be a gset/cset; that
+					 * Don't allow the previous command be a gset; that
 					 * would make no sense.
 					 */
 					if (cmd->varprefix[cindex] != NULL)
 						syntax_error(desc, lineno, NULL, NULL,
-									 "\\gset/cset cannot follow one another",
+									 "\\gset cannot follow one another",
 									 NULL, -1);
 
 					/* get variable prefix */
diff --git a/src/bin/pgbench/t/001_pgbench_with_server.pl b/src/bin/pgbench/t/001_pgbench_with_server.pl
index 45888dc12e..1ccc803ba3 100644
--- a/src/bin/pgbench/t/001_pgbench_with_server.pl
+++ b/src/bin/pgbench/t/001_pgbench_with_server.pl
@@ -538,22 +538,17 @@ pgbench(
 }
 	});
 
-# working \gset and \cset
+# working \gset
 pgbench(
 	'-t 1', 0,
-	[ qr{type: .*/001_pgbench_gset_and_cset}, qr{processed: 1/1} ],
+	[ qr{type: .*/001_pgbench_gset}, qr{processed: 1/1} ],
 	[   qr{command=3.: int 0\b},
 		qr{command=5.: int 1\b},
 		qr{command=6.: int 2\b},
 		qr{command=8.: int 3\b},
-		qr{command=9.: int 4\b},
-		qr{command=10.: int 5\b},
-		qr{command=12.: int 6\b},
-		qr{command=13.: int 7\b},
-		qr{command=14.: int 8\b},
-		qr{command=16.: int 9\b} ],
-	'pgbench gset and cset commands',
-	{   '001_pgbench_gset_and_cset' => q{-- test gset and cset
+		qr{command=10.: int 4\b} ],
+	'pgbench gset command',
+	{   '001_pgbench_gset' => q{-- test gset
 -- no columns
 SELECT \gset
 -- one value
@@ -563,21 +558,12 @@ SELECT 0 AS i0 \gset
 SELECT 1 AS i1, 2 AS i2 \gset
 \set i debug(:i1)
 \set i debug(:i2)
--- cset & gset to follow
-SELECT :i2 + 1 AS i3, :i2 * :i2 AS i4 \cset
-  SELECT 5 AS i5 \gset
-\set i debug(:i3)
-\set i debug(:i4)
-\set i debug(:i5)
 -- with prefix
-SELECT 6 AS i6, 7 AS i7 \cset x_
-  SELECT 8 AS i8 \gset y_
-\set i debug(:x_i6)
-\set i debug(:x_i7)
-\set i debug(:y_i8)
+SELECT 3 AS i3 \gset x_
+\set i debug(:x_i3)
 -- overwrite existing variable
-SELECT 0 AS i9, 9 AS i9 \gset
-\set i debug(:i9)
+SELECT 0 AS i4, 4 AS i4 \gset
+\set i debug(:i4)
 } });
 
 # trigger many expression errors
@@ -772,20 +758,17 @@ SELECT LEAST(}.join(', ', (':i') x 256).q{)}
 	[   'bad boolean',                     2,
 		[qr{malformed variable.*trueXXX}], q{\set b :badtrue or true} ],
 
-	# GSET & CSET
+	# GSET
 	[   'gset no row',                    2,
 		[qr{expected one row, got 0\b}], q{SELECT WHERE FALSE \gset} ],
-	[   'cset no row',                    2,
-		[qr{expected one row, got 0\b}], q{SELECT WHERE FALSE \cset
-SELECT 1 AS i\gset}, 1 ],
-	[ 'gset alone', 1, [qr{gset/cset cannot start a script}], q{\gset} ],
+	[ 'gset alone', 1, [qr{gset cannot start a script}], q{\gset} ],
 	[   'gset no SQL',                        1,
-		[qr{gset/cset must follow a SQL command}], q{\set i +1
+		[qr{gset must follow a SQL command}], q{\set i +1
 \gset} ],
 	[   'gset too many arguments',                   1,
 		[qr{too many arguments}], q{SELECT 1 \gset a b} ],
 	[   'gset after gset',                        1,
-	    [qr{gset/cset cannot follow one another}], q{SELECT 1 AS i \gset
+	    [qr{gset cannot follow one another}], q{SELECT 1 AS i \gset
 \gset} ],
 	[   'gset non SELECT', 2,
 		[qr{expected one row, got 0}],

Reply via email to