sidorares / sidorares/node-mysql2
ER_MAX_PREPARED_STMT_COUNT_REACHED
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.4k
- Forks
- 680
- Avg merge
- 9h 7m
- Merged PRs (30d)
- 59
Description
Hi,
Can someone please explain why I get this error ER_MAX_PREPARED_STMT_COUNT_REACHED when I am following this documentation
Here is my code:
export const getById = (id) => {
return db().then(async (connection) => {
const sql = await connection.format(`
SELECT * FROM ${baseTables}
WHERE ${baseWhere}
AND status = 'ACTIVE'
AND id = ?`,
[ id ]
);
const resultSet = await connection.execute(sql);
const row = get(resultSet, "[0].[0]");
if (row) {
const rowItem = t.buildRow(row);
connection.unprepare(sql);
connection.release();
return rowItem;
}
});
};
Yet every couple months I get this error: ER_MAX_PREPARED_STMT_COUNT_REACHED
I have read:
https://github.com/sidorares/node-mysql2/issues/158
https://github.com/sidorares/node-mysql2/issues/393
https://github.com/sidorares/node-mysql2/issues/702
Should I do the manual version, and do it like this instead?
export const getById = (id) => {
return db().then(async (connection) => {
const sql = await connection.prepare(`
SELECT * FROM ${baseTables}
WHERE ${baseWhere}
AND status = 'ACTIVE'
AND id = ?`,
[ id ]
);
const resultSet = await connection.execute(sql);
const row = get(resultSet, "[0].[0]");
if (row) {
const rowItem = t.buildRow(row);
connection.close();
return rowItem;
}
});
};
Thanks.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read documentation/Prepared-Statements.md first, then compare the reported connection.format/execute/unprepare flow with the examples and linked issues #158, #393, and #702. Confirm the documented cause and whether the proposed manual prepare flow is valid; done means a clear maintainer-backed explanation or documentation correction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, mysql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100