Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1abuhM-000834-Fi for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Mar 2016 18:43:36 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1abuhL-00045k-JA for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Mar 2016 18:43:35 +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) (envelope-from ) id 1abufz-0001WI-Vx for pgsql-hackers@postgresql.org; Fri, 04 Mar 2016 18:42:12 +0000 Received: from out.smtp-auth.no-ip.com ([8.23.224.60]) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1abufs-0005T3-P4 for pgsql-hackers@postgresql.org; Fri, 04 Mar 2016 18:42:10 +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 [186.37.20.156]) (Authenticated sender: alvh.no-ip.org@noip-smtp) by smtp-auth.no-ip.com (Postfix) with ESMTPA id 1F1EB400FCC; Fri, 4 Mar 2016 10:42:03 -0800 (PST) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 1CF4C58B; Fri, 4 Mar 2016 15:41:57 -0300 (CLT) Date: Fri, 4 Mar 2016 15:41:57 -0300 From: Alvaro Herrera To: Fabien COELHO Cc: Michael Paquier , "pgsql-hackers@postgresql.org" Subject: Re: pgbench stats per script & other stuff Message-ID: <20160304184157.GA726930@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 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 Fabien COELHO wrote: > >However, this is still a bit broken -- you cannot return a stack > >variable from process_file, because the stack goes away once the > >function returns. You need to malloc it. > > That is why the "fs" variable in process_file is declared "static", and why > I wrote "some hidden awkwarness". > > I did want to avoid a malloc because then who would free the struct? > addScript cannot to it systematically because builtins are static. Or it > would have to create an on purpose struct, but I then that would be more > awkwarness, and malloc/free to pass arguments between functions is not > efficient nor very elegant. > > So the "static" option looked like the simplest & most elegant version. Surely that trick breaks if you have more than one -f switch, no? Oh, I see what you're doing: you only use the command list, which is allocated, so it doesn't matter that the rest of the struct changes later. That seems rather nasty to me -- I'd avoid that. I'm not concerned about freeing the struct; what's the problem with it surviving until the program terminates? If somebody specifies thousands of -f switches, they will waste a few bytes with each, but I'm hardly concerned about a few dozen kilobytes there ... -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers