Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mkB1b-00066b-90 for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Nov 2021 20:13:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mkB1Z-0003Fu-2U for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Nov 2021 20:13:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mkB1Y-00037h-K6 for pgsql-hackers@lists.postgresql.org; Mon, 08 Nov 2021 20:13:48 +0000 Received: from mail-il1-x12e.google.com ([2607:f8b0:4864:20::12e]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mkB1R-0002TE-5S for pgsql-hackers@postgresql.org; Mon, 08 Nov 2021 20:13:47 +0000 Received: by mail-il1-x12e.google.com with SMTP id j28so18281929ila.1 for ; Mon, 08 Nov 2021 12:13:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=zVLv8qzme5MGp6/nJc2LTsRBAcIuTYmrQksolW8OKSs=; b=z4/e6NlxOGRkP6xP624XEhRCysqcrIcLrOMNF7rzONwLusDIDqJNwiW0z/ZsRqoTU3 6U+Vy040/eX7tJn4YLW1s6NarV5FoClrITCIkpV+elIMRT0ci2CFpkZhISgnxRkEFDbZ Ndy0ie0AzwSenJMeX57VelSEowsCGFBzzXA6TXO4TlDkGf/IJvRZhF69a3A4jaLVHi3d +ydTRG+CNKDHoPZLiTYzzM6dxPiNLbdwQCV+N2r47+6DiXhYhQ4vcGMObbqpjIznw36m 2kljbTGMgYSzLkOF8lziypw2D5s7lHEZcUWXefQ56kPotMJJ6uhhBqC75hdUxKwILuWJ y4yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=zVLv8qzme5MGp6/nJc2LTsRBAcIuTYmrQksolW8OKSs=; b=5AtaoWWTMDPvEW/km12Nc3ozPzxF8koWaYg5A/Sbsz4zAQtLqkthdgnULlzh1SF9kS 1Wj+543cY2NbAly/+fvW3C1CNTi7HLBXejP4r5tigO5FNt8HKTB8ibu3ecZYHUDcd/j/ 3lmhNf2C1MI1OxJrycJrkXYEHfgmmUU0kLz3w8IKqjE/KejChRYiR2gbb95KDFYKVzUW 1DomAu2PrLQBGflh3yjQ/JEO64e0SyI6S2P4DKJBy0EnaQWNm5syouu3CZUn+qJqv3yA PsmUKVO9UzPg02xc3Yz0K5OyXhYLTL8Im1vBHUTa/0CEpYWkzwFfg9WJYSmFlzsyPw+x 394A== X-Gm-Message-State: AOAM530ILzckzN4bivMsVnezJzZVKYJaRmo0IndGmn02Uxz/J7abVV7a qgR4e9M35eS6W9QdvOvcTI4I/A== X-Google-Smtp-Source: ABdhPJy30bwMjcm4BA5E0R7RY0+kyZxXHQUhEXJkgFpF+FtIcYgMMNB4+LXlbSiJ2kSF5aLWWC+1DA== X-Received: by 2002:a05:6e02:168c:: with SMTP id f12mr1267431ila.171.1636402420199; Mon, 08 Nov 2021 12:13:40 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id a14sm11231518ilv.86.2021.11.08.12.13.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Nov 2021 12:13:39 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 60D34800897; Mon, 8 Nov 2021 14:13:38 -0600 (CST) Date: Mon, 8 Nov 2021 14:13:38 -0600 From: Justin Pryzby To: Melanie Plageman Cc: pgsql-hackers@postgresql.org, Andres Freund , Alvaro Herrera Subject: Re: make tuplestore helper function Message-ID: <20211108201338.GU17618@telsasoft.com> References: <20211102202353.GG17618@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Nov 08, 2021 at 02:52:28PM -0500, Melanie Plageman wrote: > On Tue, Nov 2, 2021 at 4:23 PM Justin Pryzby wrote: > > > > Several places have a conditional value for the first argument (randomAccess), > > but your patch changes the behavior to a constant "true". I didn't review the > > patch beyond that. > > > > > @@ -740,18 +724,14 @@ pg_prepared_statement(PG_FUNCTION_ARGS) > > > - tupstore = > > > - tuplestore_begin_heap(rsinfo->allowedModes & SFRM_Materialize_Random, > > > - false, work_mem); > > > > > @@ -2701,42 +2701,13 @@ pg_hba_file_rules(PG_FUNCTION_ARGS) > > > - tuple_store = > > > - tuplestore_begin_heap(rsi->allowedModes & SFRM_Materialize_Random, > > > - false, work_mem); > > > > > @@ -4799,31 +4797,8 @@ pg_timezone_names(PG_FUNCTION_ARGS) > > > - randomAccess = (rsinfo->allowedModes & SFRM_Materialize_Random) != 0; > > > - tupstore = tuplestore_begin_heap(randomAccess, false, work_mem); > > > > > @@ -575,38 +575,12 @@ pg_ls_dir_1arg(PG_FUNCTION_ARGS) > > > - randomAccess = (rsinfo->allowedModes & SFRM_Materialize_Random) != 0; > > > - tupstore = tuplestore_begin_heap(randomAccess, false, work_mem); > > > > > @@ -1170,17 +1154,12 @@ pg_cursor(PG_FUNCTION_ARGS) > > > - tupstore = > > > - tuplestore_begin_heap(rsinfo->allowedModes & SFRM_Materialize_Random, > > > - false, work_mem); > > > > > +++ b/src/backend/utils/fmgr/funcapi.c > > > + tupstore = tuplestore_begin_heap(true, false, maxKBytes); > > I believe the patch has preserved the same behavior. All of the callers > for which I replaced tuplestore_begin_heap() which passed a variable for > the randomAccess parameter had set that variable to something which was > effectively the same as passing true -- SFRM_Materialize_Random. I don't think so ? They callers aren't passing SFRM_Materialize_Random, but rather (allowedModes & SFRM_Materialize_Random) != 0 Where allowedModes is determined EXEC_FLAG_BACKWARD. src/include/executor/executor.h:extern Tuplestorestate *ExecMakeTableFunctionResult(SetExprState *setexpr, src/include/executor/executor.h- ExprContext *econtext, src/include/executor/executor.h- MemoryContext argContext, src/include/executor/executor.h- TupleDesc expectedDesc, src/include/executor/executor.h- bool randomAccess); src/backend/executor/nodeFunctionscan.c=FunctionNext(FunctionScanState *node) src/backend/executor/nodeFunctionscan.c: ExecMakeTableFunctionResult(node->funcstates[0].setexpr, src/backend/executor/nodeFunctionscan.c- node->ss.ps.ps_ExprContext, src/backend/executor/nodeFunctionscan.c- node->argcontext, src/backend/executor/nodeFunctionscan.c- node->funcstates[0].tupdesc, src/backend/executor/nodeFunctionscan.c- node->eflags & EXEC_FLAG_BACKWARD); -- Justin