Skip to content

Improve error message for (unsupported) named parameter usage #475

@JKDingwall

Description

@JKDingwall

Lyrion Music Server added some new database queries using named parameters in the statement. This is supported by SQLite (via DBD-SQLite) but this is not available to DBD-mysql/MySQL (or MariaDB). When the query is executed the reported error is:

[25-05-02 18:47:27.2333] Slim::Schema::Storage::throw_exception (122) Error: DBI Exception: DBD::mysql::st bind_param failed: Illegal parameter number [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
                                "]
[25-05-02 18:47:27.2343] Slim::Schema::Storage::throw_exception (122) Backtrace:

Full report: LMS-Community/slimserver#1265

It took a bit of digging to discover this. It seems possible to add a more helpful error message which turns the error in to:

    [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
                                    "]

The change is based on the named parameter handling in DBD-SQLite: https://github.com/DBD-SQLite/DBD-SQLite/blob/60515b30f8b816cb09e9f40f2f0a5829af031899/dbdimp.c#L1559

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions