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 1myJSw-0004t4-K1 for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Dec 2021 20:04:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1myJSu-0000T7-Fc for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Dec 2021 20:04:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1myJSu-0000Sy-6N for pgsql-hackers@lists.postgresql.org; Fri, 17 Dec 2021 20:04:28 +0000 Received: from mail-io1-xd30.google.com ([2607:f8b0:4864:20::d30]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1myJSo-0001qR-Rr for pgsql-hackers@postgresql.org; Fri, 17 Dec 2021 20:04:27 +0000 Received: by mail-io1-xd30.google.com with SMTP id p23so4566880iod.7 for ; Fri, 17 Dec 2021 12:04:22 -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=qybhwuszZqnDKz/W7eHTurrmZMuQhGetjQiXpeNJBuM=; b=xo9nKBkOcVoWOl7R32NClBHeLeJ2z0y4yKIc+1oSNtbmNahXFntHzbJp3mZQgl32CR d+gx7aEGBWc+X2S3tmwe8qjdlFhglA0Pe2A0jVJsD6JPLVhDH7uSGSltcxxO5FzAvVvK RkTcuIqcIaCgccI+2q+bJwzjCX+Ic8BKSfAsqq/jix4P55uBsxrr+B/ND8Yry0KJQbhB q40nKHvjTjh8NsAxvqzGLg+Qbno/dl/FxfF2rBfm4sEnGnxoU3pwC035S548pQcZJ5pL qDUlH5mx8eit2lZ4fZb2d3QFx7//J2ss4F7UpyEOowSY8mpNhfWeevAjTBF+fxuhZnoE 6JRw== 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=qybhwuszZqnDKz/W7eHTurrmZMuQhGetjQiXpeNJBuM=; b=cLCknAQG4dsvXaxO6aXEXfupPaDp1uwcaal2yiukhPWQ/2xkyRKj32uOBOcN3saSc3 Nyg9QYEpwByUaMONNOAzuCuqbZ9K3R2w+UVpKIGbTarkaqG5ZI56ZXbxlJ5pAU7EKOBf eCwZnd2fgFfbVQG1/w3G4NTdA0uLX2HMCO2TrGU9E5S4KdqiklKS5WrSxMaLOhj8tJGE 047hJZG2rhfh5iZ3gKlOaXMKFdb4NgeSNM+JmTszEofq9LioAud++w5I/jThzytynMaZ 4IxoozYhVgwFBypQHzsrpzC8jyAouF0JPhCcMxMRpjzWr/loxY754+3z+JdyhcIXd3Qr cZ/g== X-Gm-Message-State: AOAM533GFs1GcBoEoKKCEbRE+jS38CxqmQySsH7SksCR58Dal3ENhjCY 7Swaxb2o68+zTniNxwgpauRTQA== X-Google-Smtp-Source: ABdhPJxWi3bDNSJR2MdGYnn/qxV4/dWp/9V+EZlfanV/dCPZuugdfGw/l3Qd6KB9Zda1e3+uuQdOaQ== X-Received: by 2002:a05:6602:24ce:: with SMTP id h14mr2476801ioe.87.1639771460990; Fri, 17 Dec 2021 12:04:20 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id r1sm4472641ilo.38.2021.12.17.12.04.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Dec 2021 12:04:20 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id BF0C9800825; Fri, 17 Dec 2021 14:04:19 -0600 (CST) Date: Fri, 17 Dec 2021 14:04:19 -0600 From: Justin Pryzby To: Melanie Plageman Cc: pgsql-hackers@postgresql.org, Andres Freund , Alvaro Herrera Subject: Re: make tuplestore helper function Message-ID: <20211217200419.GQ17618@telsasoft.com> References: <20211102202353.GG17618@telsasoft.com> <20211108201338.GU17618@telsasoft.com> <20211118182430.GO17618@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, Dec 13, 2021 at 05:27:52PM -0500, Melanie Plageman wrote: > Done in attached v4 Thanks. I think these comments can be removed from the callers: /* it's a simple type, so don't use get_call_result_type */ You removed one call to tuplestore_donestoring(), but not the others. I guess you could remove them all (optionally as a separate patch). The rest of these are questions more than comments, and I'm not necessarily suggesting to change the patch: This isn't new in your patch, but for me, it's more clear if the callers have a separate boolean for randomAccess, rather than having the long expression in the function call: + tupstore = MakeFuncResultTuplestore(fcinfo, NULL, + rsinfo->allowedModes & SFRM_Materialize_Random); vs randomAccess = (rsinfo->allowedModes & SFRM_Materialize_Random) != 0; - tupstore = tuplestore_begin_heap(randomAccess, false, work_mem); + tupstore = MakeFuncResultTuplestore(fcinfo, NULL, randomAccess); One could also argue for passing rsinfo->allowedModes, instead of (rsinfo->allowedModes & SFRM_Materialize_Random). There's a couples places that you're checking expectedDesc where it wasn't being checked before. Is that some kind of live bug ? pg_config() text_to_table() It'd be nice if the "expected tuple format" error didn't need to be duplicated for each SRFs. I suppose the helper function could just take a boolean determining whether or not to throw an error (passing "expectedDesc==NULL"). You'd have to call the helper before CreateTupleDescCopy() - which you're already doing in a couple places for similar reasons. I noticed that tuplestore.h isn't included most places. I suppose it's included via execnodes.h. Your patch doesn't change that, arguably it should've always been included. -- Justin