Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gNyRV-0001Sc-3U for pgsql-hackers@arkaria.postgresql.org; Sat, 17 Nov 2018 11:07:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gNyRT-0004FS-3b for pgsql-hackers@arkaria.postgresql.org; Sat, 17 Nov 2018 11:07:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gNyRS-0004FL-Ow for pgsql-hackers@lists.postgresql.org; Sat, 17 Nov 2018 11:07:10 +0000 Received: from mail-qk1-x743.google.com ([2607:f8b0:4864:20::743]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gNyRL-0004W2-40 for pgsql-hackers@postgresql.org; Sat, 17 Nov 2018 11:07:09 +0000 Received: by mail-qk1-x743.google.com with SMTP id q70so24079312qkh.6 for ; Sat, 17 Nov 2018 03:07:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=DLu7BXs4vR2a1Pt2UX+wtatk3pVf5MXWgoZI66AGi9Y=; b=yOTs2J+1ml/0eGnp/cTfGU2Tr7jzUV5ura2o3eg4siswQKs5fwqZZgaFeXPjbCKKcL fpzdbjj6MVcBHTEPrViNJWJO6PDxT4TlL4kin04tG5pxV4NXmHK2O7p4eG0vc7gDOyh3 vOpr+jfq6tR1OavvHFGUfhnOd8oi3osMNAXCT7NxRwUpnUHYhI7aFxdN1fMKJTi6oGKd olhJx9HTSXnAjp6v/6A2E+D3o+qWU65xfvt5H9Zsm/DpYfLiaetsNcmX0v7Q21KLJj7I wIEuJVqlmQ1ZN2Ss+JoHLTbrTY0SPXzhALRiEHrbPFjbWvR/IyM+s0c+X1/02cn/tI1W AiFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=DLu7BXs4vR2a1Pt2UX+wtatk3pVf5MXWgoZI66AGi9Y=; b=iHN9C7hPExtF875MNXb42mTC7cuQWeVG7QBnKFk6adpzertNjdNlpWsISZ+WGx5rzm 98Q5epw/wa+XxU6fFlZ0RgcWv6Mfa52qJAGYXrvgQx0R1C+rk2LRn8Ez5NR8oX8Nkw3g DL2NsznssHXTw87A2LVCChmM5fiPuSW3KAzPx3/YwZJPzHvRywxjEakLB5kfkvqKk3jz ZFyJ45nIJTs0OsROdms05Rz1K17O+o0MemOCX3su1Ry3t8kaiHTtxiCuOphMlKExg0SD motdDgF7eakigy8hAbDf074GjnPRb/HjbR7t8ltVUDiqMz92+6amC6HhcRKI8R/wOCHk bIKA== X-Gm-Message-State: AGRZ1gJU2mTz6u5mFmhJ5PMPEyrsVV9x4rpoEC+V/66AseP1lF3/7Gmr aOkfHt2eEjcMy0Ntyla2252e9w== X-Google-Smtp-Source: AJdET5drrfs5m97lExt6w8fPdXgwwXoqS/C5cWjKim7RdEckcYcGlOgz5V77Q/sujhdUrmrv7f7VBA== X-Received: by 2002:a37:3008:: with SMTP id w8mr13406393qkw.75.1542452822147; Sat, 17 Nov 2018 03:07:02 -0800 (PST) Received: from alvin.alvh.no-ip.org ([201.186.80.75]) by smtp.gmail.com with ESMTPSA id p75sm18212337qki.90.2018.11.17.03.07.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 17 Nov 2018 03:07:01 -0800 (PST) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 3C47F4EE; Sat, 17 Nov 2018 08:06:54 -0300 (-03) Date: Sat, 17 Nov 2018 08:06:54 -0300 From: Alvaro Herrera To: Fabien COELHO Cc: Michael Paquier , Stephen Frost , Andrew Dunstan , PostgreSQL Developers Subject: Re: [HACKERS] pgbench - allow to store select results into variables Message-ID: <20181117110654.ekd2duiss4lwph6y@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: NeoMutt/20180716 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018-Nov-17, Fabien COELHO wrote: > > > I think this patch's Command->lines would benefit from using PQExpBuffer > > (or maybe StringInfo?) for the command string instead of open-coding > > string manipulation and allocation. > > Indeed it could be used, but it is not used anywhere in "pgbench": not for > lines, not for variable subtitutions, not for the PREPARE stuff... So I did > not think that it was time to start, I just kept the current style. > > Probably it could be a refactoring patch to replace all basic string stuff > with PQExpBuffer infrastructure within pgbench. Well, I think command handling was mostly straightforward before, but it's not as straightforward after your patch. Also, PQExpBuffer is already in use in pgbench when interacting with the lexer, so yeah I think we should fix that. I don't think we should replace *ALL* string handling in pgbench with PQExpBuffer, just the command stuff. > > I'm not sure that Command->first_line is really all that useful. It > > seems we go to a lot of trouble to keep it up to date. Isn't it easier > > to chop Command->lines at the first newline when it is needed? > > Hmmm, it is needed quite often (about 12 times) to report errors, that would > mean having to handle the truncation in many places, so I felt it was worth > the trouble. Ok, as long as we don't repeat the work during script execution. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services