Re: psql's FETCH_COUNT (cursor) is not being respected for CTEs - Mailing list pgsql-hackers

From Tom Lane
Subject Re: psql's FETCH_COUNT (cursor) is not being respected for CTEs
Date
Msg-id 2402443.1679688778@sss.pgh.pa.us
Whole thread Raw
In response to Re: psql's FETCH_COUNT (cursor) is not being respected for CTEs  ("Daniel Verite" <daniel@manitou-mail.org>)
Responses Re: psql's FETCH_COUNT (cursor) is not being respected for CTEs  ("Daniel Verite" <daniel@manitou-mail.org>)
List pgsql-hackers
"Daniel Verite" <daniel@manitou-mail.org> 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 incompatible 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 printQueryOpt *opt,
                  ~~~~~~~~~~~~~~~~~^~~~~~
common.c:1720:24: warning: passing argument 1 of 'PrintQueryTuples' from incompatible 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 printQueryOpt *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 = PrintQueryTuples(result, opt, printQueryFout);
+                success = PrintQueryTuples((const PGresult**)&result, 1, opt, printQueryFout);

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



pgsql-hackers by date:

Previous
From: Mark Dilger
Date:
Subject: Re: running logical replication as the subscription owner
Next
From: Tom Lane
Date:
Subject: Re: Make fop less verbose when building PDF