lua-resty-mysql icon indicating copy to clipboard operation
lua-resty-mysql copied to clipboard

CLIENT_FOUND_ROWS option in `connect()`

Open hdamala opened this issue 7 years ago • 0 comments

Can an option be exposed in connect() to set the connection capability flag for CLIENT_FOUND_ROWS? Currently, lua-resty-mysql sets the flag by default.

My use case is when I use INSERT INTO... ON DUPLICATE KEY UPDATE... form. Not setting CLIENT_ROWS_FOUND lets me know whether the row was upserted into the DB or no change has happened.

From mysql documentation:

With ON DUPLICATE KEY UPDATE, the affected-rows value per row is 1 if the row is inserted as a new row, 2 if an existing row is updated, and 0 if an existing row is set to its current values. If you specify the CLIENT_FOUND_ROWS flag to the mysql_real_connect() C API function when connecting to mysqld, the affected-rows value is 1 (not 0) if an existing row is set to its current values.

hdamala avatar Nov 08 '18 07:11 hdamala