gset_fix.patch

application/octet-stream

Filename: gset_fix.patch
Type: application/octet-stream
Part: 0
Message: Re: proposal - assign result of query to psql variable

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
src/bin/psql/command.c 13 13
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 645ba5b..d36e5de 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -71,6 +71,7 @@ static void printSSLInfo(void);
 static void checkWin32Codepage(void);
 #endif
 
+
 /*
  * Possible states for simple state machine, that is used for
  * parsing target list - list of varnames separated by comma.
@@ -760,7 +761,7 @@ exec_command(const char *cmd,
 	/* \gset send query and store result */
 	else if (strcmp(cmd, "gset") == 0)
 	{
-		char *packet;
+		char	   *packet;
 		VarlistParserState state = VARLIST_INITIAL;
 
 		/* expected valid target list */
@@ -768,32 +769,31 @@ exec_command(const char *cmd,
 		pset.gvars = NULL;
 
 		/*
-		 * So we would to enable subtitution, but we know so target varname should
-		 * not use comma. Recheck of variable name is done by variable setting routine.
-		 * psql_scan_slash_option can returns zero or more identifiers separated by
-		 * comma. We cennot to use OT_WHOLE_LINE, because variable substitution is not
-		 * supported there.
+		 * So we would to enable substitution, but we know so target varname
+		 * should not use comma. Recheck of variable name is done by variable
+		 * setting routine.  psql_scan_slash_option can returns zero or more
+		 * identifiers separated by comma. We cannot to use OT_WHOLE_LINE,
+		 * because variable substitution is not supported there.
 		 */
 		while ((packet = psql_scan_slash_option(scan_state,
-											 OT_NORMAL, NULL, false)))
+												OT_NORMAL, NULL, false)))
 		{
-			char *token = packet;
-			bool process_comma = false;
+			char	   *token = packet;
+			bool		process_comma = false;
 
 			while (success && (*token || process_comma))
 			{
 				if (process_comma)
 				{
 					if (state == VARLIST_INITIAL ||
-							state == VARLIST_EXPECTED_COMMA_OR_IDENT)
+						state == VARLIST_EXPECTED_COMMA_OR_IDENT)
 						pset.gvars = tglist_add(pset.gvars, NULL);
 					state = VARLIST_EXPECTED_COMMA_OR_IDENT;
-
 					process_comma = false;
 				}
 				else
 				{
-					char *ptr = token;
+					char	   *ptr = token;
 
 					/* skip initial blank chars */
 					while (*ptr && isblank(*ptr))
@@ -816,7 +816,7 @@ exec_command(const char *cmd,
 					if (token != ptr)
 					{
 						if (state == VARLIST_INITIAL ||
-								state == VARLIST_EXPECTED_COMMA_OR_IDENT)
+							state == VARLIST_EXPECTED_COMMA_OR_IDENT)
 						{
 							pset.gvars = tglist_add(pset.gvars, token);
 							state = VARLIST_EXPECTED_COMMA;