Skip to content

Commit 32b7fed

Browse files
committed
Improve error message for unsupported named parameters:
Previously just 'Illegal parameter number' was logged, make this a more helpful message. ``` [25-05-06 20:46:04.2629] Slim::Schema::Storage::throw_exception (122) Error: DBI Exception: DBD::mysql::st bind_param failed: named parameters are unsupported: :album [for Statement " SELECT contributor_album.role AS role, contributors.name AS name, contributors.id AS id FROM contributor_album JOIN contributors ON contributors.id = contributor_album.contributor WHERE contributor_album.album = :album AND contributor_album.role IN (5,1) ORDER BY contributor_album.role, contributors.namesort "] ```
1 parent dbc575d commit 32b7fed

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

dbdimp.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4209,6 +4209,23 @@ int dbd_bind_ph(SV *sth, imp_sth_t *imp_sth, SV *param, SV *value,
42094209

42104210
if (param_num <= 0 || param_num > DBIc_NUM_PARAMS(imp_sth))
42114211
{
4212+
if (!looks_like_number(param))
4213+
{
4214+
STRLEN len;
4215+
char *paramstring;
4216+
paramstring = SvPV(param, len);
4217+
if(paramstring[len] == 0 && strlen(paramstring) == len)
4218+
{
4219+
do_error(sth, JW_ERR_ILLEGAL_PARAM_NUM, form("named parameters are unsupported: %s", paramstring), NULL);
4220+
return FALSE;
4221+
}
4222+
else
4223+
{
4224+
do_error(sth, JW_ERR_ILLEGAL_PARAM_NUM, "<param> could not be coerced to a C string", NULL);
4225+
return FALSE;
4226+
}
4227+
}
4228+
42124229
do_error(sth, JW_ERR_ILLEGAL_PARAM_NUM, "Illegal parameter number", NULL);
42134230
return FALSE;
42144231
}

0 commit comments

Comments
 (0)