"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