node-mysql2 icon indicating copy to clipboard operation
node-mysql2 copied to clipboard

[Feature Request] At library layer, bind prepared statements to their schema

Open PosicubeBeege opened this issue 5 years ago • 1 comments

This is related to #1234 (Nice).

When preparing statements, the table referenced in the query is specifically referenced in the prepared statement. This may not be clear, so as an example... If you prepare a statement in one schema and change to another schema, the prepared statement will reference the original table, despite any schema change.

Can execute be modified to reference the schema in the statement ID? I'm making guesses about how the underlying mechanics work. If the schema that the statement is prepared against is included in the statement name, this can allow seamless preparation of statements on different schemas.

If a connection knows about its current schema, I think this could be a trivial change. Otherwise, it may not be reasonable due to performance concerns, i.e. back-and-forth with the database to check the current schema.

Thoughts? Need clarification?

PosicubeBeege avatar Oct 27 '20 07:10 PosicubeBeege

sorry looks like I missed this and linked conversation. Can you log result of prepare ? There is quite a bit of info in it, both for returned fields and for input parameters

sidorares avatar Jan 28 '22 01:01 sidorares