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 1pfnme-0005hV-NT for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Mar 2023 20:13:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pfnmd-0004Qm-GS for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Mar 2023 20:13:07 +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 1pfnmd-0004Qc-7H for pgsql-hackers@lists.postgresql.org; Fri, 24 Mar 2023 20:13:07 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pfnma-0007Yc-QD for pgsql-hackers@postgresql.org; Fri, 24 Mar 2023 20:13:06 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 32OKCwLc2402444; Fri, 24 Mar 2023 16:12:58 -0400 From: Tom Lane To: "Daniel Verite" cc: "PostgreSQL Hackers" , Robert Haas , Jakub Wartak Subject: Re: psql's FETCH_COUNT (cursor) is not being respected for CTEs In-reply-to: References: Comments: In-reply-to "Daniel Verite" message dated "Wed, 01 Mar 2023 11:41:13 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2402442.1679688778.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 24 Mar 2023 16:12:58 -0400 Message-ID: <2402443.1679688778@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "Daniel Verite" writes: > PFA an updated patch. This gives me several "-Wincompatible-pointer-types" warnings (as are also reported by the cfbot): common.c: In function 'ExecQueryAndProcessResults': common.c:1686:24: warning: passing argument 1 of 'PrintQueryTuples' from i= ncompatible pointer type [-Wincompatible-pointer-types] PrintQueryTuples(result_array, ntuples, &my_popt, tuples_fout); ^~~~~~~~~~~~ common.c:679:35: note: expected 'const PGresult **' {aka 'const struct pg_= result **'} but argument is of type 'PGresult **' {aka 'struct pg_result *= *'} PrintQueryTuples(const PGresult **result, int nresults, const printQueryO= pt *opt, ~~~~~~~~~~~~~~~~~^~~~~~ common.c:1720:24: warning: passing argument 1 of 'PrintQueryTuples' from i= ncompatible pointer type [-Wincompatible-pointer-types] PrintQueryTuples(result_array, ntuples, &my_popt, tuples_fout); ^~~~~~~~~~~~ common.c:679:35: note: expected 'const PGresult **' {aka 'const struct pg_= result **'} but argument is of type 'PGresult **' {aka 'struct pg_result *= *'} PrintQueryTuples(const PGresult **result, int nresults, const printQueryO= pt *opt, ~~~~~~~~~~~~~~~~~^~~~~~ I think the cause is the inconsistency about whether PGresult pointers are pointer-to-const or not. Even without compiler warnings, I find code like this very ugly: - success =3D PrintQueryTuples(result, opt, printQueryFout); + success =3D PrintQueryTuples((const PGresult**)&result, 1, opt, print= QueryFout); I think what you probably ought to do to avoid all that is to change the arguments of PrintQueryResult and nearby routines to be "const PGresult *result" not just "PGresult *result". I find it sad that we can't get rid of ExecQueryUsingCursor(). Maybe a little effort towards reducing overhead in the single-row mode would help? regards, tom lane