pgbench-lineno-perf-fix.patch

text/plain

Filename: pgbench-lineno-perf-fix.patch
Type: text/plain
Part: 0
Message: pgbench client-side performance issue on large scripts

Patch

Format: unified
File+
src/bin/pgbench/pgbench.c 6 4
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 5e1fcf59c61..c3617acae2a 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -5952,7 +5952,6 @@ ParseScript(const char *script, const char *desc, int weight)
 	PQExpBufferData line_buf;
 	int			alloc_num;
 	int			index;
-	int			lineno;
 	int			start_offset;
 
 #define COMMANDS_ALLOC_NUM 128
@@ -5990,7 +5989,6 @@ ParseScript(const char *script, const char *desc, int weight)
 		Command    *command = NULL;
 
 		resetPQExpBuffer(&line_buf);
-		lineno = expr_scanner_get_lineno(sstate, start_offset);
 
 		sr = psql_scan(sstate, &line_buf, &prompt);
 
@@ -6017,7 +6015,9 @@ ParseScript(const char *script, const char *desc, int weight)
 					Command    *cmd;
 
 					if (index == 0)
-						syntax_error(desc, lineno, NULL, NULL,
+						syntax_error(desc,
+									 expr_scanner_get_lineno(sstate, start_offset),
+									 NULL, NULL,
 									 "\\gset must follow an SQL command",
 									 NULL, -1);
 
@@ -6025,7 +6025,9 @@ ParseScript(const char *script, const char *desc, int weight)
 
 					if (cmd->type != SQL_COMMAND ||
 						cmd->varprefix != NULL)
-						syntax_error(desc, lineno, NULL, NULL,
+						syntax_error(desc,
+									 expr_scanner_get_lineno(sstate, start_offset),
+									 NULL, NULL,
 									 "\\gset must follow an SQL command",
 									 cmd->first_line, -1);