Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ahLi1-0000FD-De for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Mar 2016 18:34:45 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1ahLi0-0008Ki-WD for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Mar 2016 18:34:45 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ahLhz-0008Jn-8x for pgsql-hackers@postgresql.org; Sat, 19 Mar 2016 18:34:43 +0000 Received: from smtp-auth.no-ip.com ([8.23.224.61] helo=out.smtp-auth.no-ip.com) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1ahLhv-0003cZ-LO for pgsql-hackers@postgresql.org; Sat, 19 Mar 2016 18:34:41 +0000 X-No-IP: alvh.no-ip.org@noip-smtp X-Report-Spam-To: abuse@no-ip.com Received: from alvin.alvh.no-ip.org (unknown [200.83.202.40]) (Authenticated sender: alvh.no-ip.org@noip-smtp) by smtp-auth.no-ip.com (Postfix) with ESMTPA id 84B954005BC; Sat, 19 Mar 2016 11:34:32 -0700 (PDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 72C4116FA; Sat, 19 Mar 2016 15:34:30 -0300 (CLT) Date: Sat, 19 Mar 2016 15:34:30 -0300 From: Alvaro Herrera To: Jeff Janes Cc: Fabien COELHO , Michael Paquier , "pgsql-hackers@postgresql.org" Subject: Re: pgbench stats per script & other stuff Message-ID: <20160319183430.GA294957@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Qxx1br4bt0+wmkIi" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Pg-Spam-Score: -1.1 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --Qxx1br4bt0+wmkIi Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Jeff Janes wrote: > On Sat, Mar 19, 2016 at 8:41 AM, Alvaro Herrera > wrote: > > I pushed your 25, with some additional minor tweaks. I hope I didn't > > break anything; please test. > > I'm now getting compiler warnings: > > gcc version 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC) > > > pgbench.c: In function 'process_builtin': > pgbench.c:2765: warning: 'ps.stats.lag.sum2' is used uninitialized in > this function Fair complaints. I suppose the following should fix them? -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --Qxx1br4bt0+wmkIi Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pgbench-warns.patch" diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index ecabff0..4606fb0 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -2649,11 +2649,23 @@ read_line_from_file(FILE *fd) } /* + * Initialize a ParsedScript + */ +static void +initParsedScript(ParsedScript *ps, const char *desc, int alloc_num, int weight) +{ + ps->commands = (Command **) pg_malloc(sizeof(Command *) * alloc_num); + ps->desc = desc; + ps->weight = weight; + initStats(&ps->stats, 0.0); +} + +/* * Given a file name, read it and return its ParsedScript representation. "-" * means to read stdin. */ static ParsedScript -process_file(char *filename) +process_file(char *filename, int weight) { #define COMMANDS_ALLOC_NUM 128 ParsedScript ps; @@ -2673,8 +2685,7 @@ process_file(char *filename) } alloc_num = COMMANDS_ALLOC_NUM; - ps.commands = (Command **) pg_malloc(sizeof(Command *) * alloc_num); - ps.desc = filename; + initParsedScript(&ps, filename, alloc_num, weight); lineno = 0; index = 0; @@ -2710,7 +2721,7 @@ process_file(char *filename) /* Parse the given builtin script and return the parsed representation */ static ParsedScript -process_builtin(BuiltinScript *bi) +process_builtin(BuiltinScript *bi, int weight) { int lineno, index; @@ -2720,8 +2731,7 @@ process_builtin(BuiltinScript *bi) ParsedScript ps; alloc_num = COMMANDS_ALLOC_NUM; - ps.desc = bi->desc; - ps.commands = (Command **) pg_malloc(sizeof(Command *) * alloc_num); + initParsedScript(&ps, bi->desc, alloc_num, weight); lineno = 0; index = 0; @@ -2860,7 +2870,7 @@ parseScriptWeight(const char *option, char **script) /* append a script to the list of scripts to process */ static void -addScript(ParsedScript script, int weight) +addScript(ParsedScript script) { if (script.commands == NULL || script.commands[0] == NULL) { @@ -2875,8 +2885,6 @@ addScript(ParsedScript script, int weight) } sql_script[num_scripts] = script; - sql_script[num_scripts].weight = weight; - initStats(&sql_script[num_scripts].stats, 0.0); num_scripts++; } @@ -3251,24 +3259,24 @@ main(int argc, char **argv) } weight = parseScriptWeight(optarg, &script); - addScript(process_builtin(findBuiltin(script)), weight); + addScript(process_builtin(findBuiltin(script), weight)); benchmarking_option_set = true; internal_script_used = true; break; case 'S': - addScript(process_builtin(findBuiltin("select-only")), 1); + addScript(process_builtin(findBuiltin("select-only"), 1)); benchmarking_option_set = true; internal_script_used = true; break; case 'N': - addScript(process_builtin(findBuiltin("simple-update")), 1); + addScript(process_builtin(findBuiltin("simple-update"), 1)); benchmarking_option_set = true; internal_script_used = true; break; case 'f': weight = parseScriptWeight(optarg, &script); - addScript(process_file(script), weight); + addScript(process_file(script, weight)); benchmarking_option_set = true; break; case 'D': @@ -3406,7 +3414,7 @@ main(int argc, char **argv) /* set default script if none */ if (num_scripts == 0 && !is_init_mode) { - addScript(process_builtin(findBuiltin("tpcb-like")), 1); + addScript(process_builtin(findBuiltin("tpcb-like"), 1)); benchmarking_option_set = true; internal_script_used = true; } --Qxx1br4bt0+wmkIi Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --Qxx1br4bt0+wmkIi--