perl5-dbi / DBD-MariaDB

Perl MariaDB driver

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DBD-MariaDB-1.22: Build warnings

twata1 opened this issue · comments

Hello,

Running Strawberry Perl 5.30.2 64 bit, I noticed the following message.

C:\home\sunlight2>cpan PALI/DBD-MariaDB-1.22.tar.gz

(snip)

Warning: duplicate function definition 'do' detected in MariaDB.xs, line 104
Warning: duplicate function definition 'rows' detected in MariaDB.xs, line 229
Warning: duplicate function definition 'last_insert_id' detected in MariaDB.xs, line 248

(snip)

Thank you,

What version of DBI do you have?

C:\home\sunlight2>module-version DBI

The version of DBI in C:/Strawberry/perl/vendor/lib is 1.643


C:\home\sunlight2>

More Info:
http://www.cpantesters.org/cpan/report/45699f69-6bff-1014-bc86-634176a13fd6

commented

Warning: duplicate function definition 'do' detected in MariaDB.xs, line 104

If you have DBI version 1.643 then following code for do definition is skipped:

DBD-MariaDB/MariaDB.xs

Lines 101 to 121 in ef11de2

#ifndef HAVE_DBI_1_642
IV
do(dbh, statement, attr=Nullsv, ...)
SV *dbh
SV *statement
SV *attr
CODE:
{
/* Compatibility for DBI version prior to 1.642 which does not support dbd_db_do6 API */
D_imp_dbh(dbh);
RETVAL = mariadb_db_do6(dbh, imp_dbh, statement, attr, items-3, ax+3);
if (RETVAL == 0) /* ok with no rows affected */
XSRETURN_PV("0E0"); /* (true but zero) */
else if (RETVAL < -1) /* -1 == unknown number of rows */
XSRETURN_UNDEF;
}
OUTPUT:
RETVAL
#endif


Warning: duplicate function definition 'last_insert_id' detected in MariaDB.xs, line 248

Same applies for last_insert_id definition, which is skipped too:

DBD-MariaDB/MariaDB.xs

Lines 245 to 263 in ef11de2

#ifndef HAVE_DBI_1_642
void
last_insert_id(sth, catalog=&PL_sv_undef, schema=&PL_sv_undef, table=&PL_sv_undef, field=&PL_sv_undef, attr=Nullsv)
SV *sth
SV *catalog
SV *schema
SV *table
SV *field
SV *attr
PPCODE:
{
/* Compatibility for DBI version prior to 1.642 which does not support dbd_st_last_insert_id API */
D_imp_sth(sth);
ST(0) = mariadb_st_last_insert_id(sth, imp_sth, catalog, schema, table, field, attr);
XSRETURN(1);
}
#endif

Seems that this is just false-positive warning generated by xsubpp compiler. Probably compiler generates these warnings at early stage prior code is fully parsed. Maybe you could open ticket for xsubpp compiler about this issue.

Important is that code is compiled correctly without duplicate functions.


Warning: duplicate function definition 'rows' detected in MariaDB.xs, line 229

This warning is quite tricky, but again it is false-positive warning.

During compilation of MariaDB.xs soure code DBI prepends its Driver.xst source code which contains helper functions, including this rows:

https://github.com/perl5-dbi/dbi/blob/ea91ab4ea7ea75e82c94acb0d283951ebadf29d2/Driver.xst#L508-L517

But as you can see, this helper function is compiler only when dbd_st_rows is defined -- which is not case for DBD::MariaDB. DBD::MariaDB does not use that helper function, instead it uses own implementation:

DBD-MariaDB/MariaDB.xs

Lines 228 to 243 in ef11de2

SV *
rows(sth)
SV* sth
CODE:
D_imp_sth(sth);
D_imp_dbh_from_sth;
if(imp_dbh->async_query_in_flight) {
if (mariadb_db_async_result(sth, &imp_sth->result) == (my_ulonglong)-1) {
XSRETURN_UNDEF;
}
}
if (imp_sth->row_num == (my_ulonglong)-1)
XSRETURN_IV(-1);
RETVAL = my_ulonglong2sv(imp_sth->row_num);
OUTPUT:
RETVAL

So there should not be any issue. They are just false-positive warnings which I do not know how to turn off.

Thank you for your detailed reply.
I will open ticket for ExtUtils-ParseXS-3.44 which uses xsubpp.

Thank you,