Skip to content

Can't compile because of inconsistence between types.h and quote.h ? #151

@damenc

Description

@damenc

I now realized that it's all about the new GCC 15 which is already discussed in #135

Hi all,

I'm trying to install the DBD::Pg@3.18.0 version for PERL 5.40.0 under arch linux (6.6.107-1-MANJARO) with postgresql 17.5-5installed. But the make (executed via cpanm with gcc 15.2.1) fails:

Pg.xs: In function 'XS_DBD__Pg__db_quote':
Pg.xs:330:22: Error: too many arguments for function 'type_info->quote'; expected 0, got 4
 330 |       quoted = type_info->quote(aTHX_ to_quote, len, &retlen, imp_dbh->pg_server_version >= 80100 ? 1 : 0);
   |                      ^~~~~~~~~          ~~~~~~~~
In file included from Pg.h:66:
types.h:11:15: Note: declared here
  11 |   char*  (*quote)();
   |               ^~~~~
make: *** [Makefile:359: Pg.o] Error 1

I can see the struct definition in types.h

typedef struct {
    ...
    char *(*quote)();
} sql_type_info_t;

If I remember right (C has been quite a while ago) char *(*quote)()is the old K&R syntax meaning "function pointer without parameters declared". But in PS.xs the call uses 4 parameters:

quoted = type_info->quote(aTHX_ to_quote, len, &retlen, imp_dbh->pg_server_version >= 80100 ? 1 : 0);

Wouldn't that mean that the struct in types.h has to be like

typedef struct {
    ...
    char *(*quote)(pTHX_ const char *value, STRLEN len, STRLEN *retlen, int std_strings);
} sql_type_info_t;

I changed as stated:

  • the errors concerning the quote(...) calls where gone
  • but then got similar errors for the dequote() calls:
dbdimp.c:2923:25: error: too many arguments for function coltype->dequote; 0 expected, 2 provided
2923 | coltype->dequote(aTHX_ string, &section_size);
    | ^~~~~~~ ~~~~~~

In file included from Pg.h:66,
from dbdimp.c:14:
types.h:12:15: note: declared here
12 | void (*dequote)();
    | ^~~~~~~

dbdimp.c: In function pg_st_fetch:

dbdimp.c:3841:21: error: too many arguments for function type_info->dequote; 0 expected, 2 provided
3841 | type_info->dequote(aTHX_ value, &value_len); /* dequote in place */
    | ^~~~~~~~~ ~~~~~

types.h:12:15: note: declared here
12 | void (*dequote)();
    | ^~~~~~~

I then tried to achieve the same for dequote() by adding one of the method parameters quote.h into the struct in types.h:

typedef struct sql_type_info {
   ...
    char*   (*quote)(pTHX_ const char *value, STRLEN len, STRLEN *retlen, int std_strings);
    void    (*dequote)(pTHX_ const char *string, STRLEN *retlen, int estring);
   ...
} sql_type_info_t;

But after compiling again it still complained about wrong number of parameters in dbimp.c

dbdimp.c: In function ‘pg_destringify_array’:
dbdimp.c:2923:25: error: too few arguments to function ‘coltype->dequote’; expected 3, got 2
2923 | coltype->dequote(aTHX_ string, &section_size);
      | ^~~~~~~
In file included from Pg.h:66,
from dbdimp.c:14:
types.h:12:15: note: declared here
12 | void (*dequote)(pTHX_ const char *string, STRLEN retlen, int estring);
    | ^~~~~~~
dbdimp.c: In function ‘pg_st_fetch’:
dbdimp.c:3841:21: error: too few arguments to function ‘type_info->dequote’; expected 3, got 2
3841 | type_info->dequote(aTHX_ value, &value_len); / dequote in place */
      | ^~~~~~~~~
types.h:12:15: note: declared here
12 | void (*dequote)(pTHX_ const char *string, STRLEN *retlen, int estring);
    | ^~~~~~~
make: *** [Makefile:359: dbdimp.o] Error 1

I can see that the third parameter (int estring) is used in several routines of quote.c so why isn't it handed over in dbimp.c ?

I've now adjusted the two calls in dbimp.c:

/* L2923 */ coltype->dequote(aTHX_ string, &section_size, imp_dbh->pg_server_version >= 80100 ? 1 : 0);
/* L3841 */ type_info->dequote(aTHX_ value, &value_len, imp_dbh->pg_server_version >= 80100 ? 1 : 0);

Which is fine, but now there are incompatibilities because of the const declaration in some of the (but not all) quote / dequote implementations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions