Skip to content

Commit c782330

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 8c6c960 commit c782330

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
@@ -4207,6 +4207,23 @@ int dbd_bind_ph(SV *sth, imp_sth_t *imp_sth, SV *param, SV *value,
42074207
attribs= attribs;
42084208
maxlen= maxlen;
42094209

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

0 commit comments

Comments
 (0)