-
Notifications
You must be signed in to change notification settings - Fork 0
Disable RETURNING clause for MySQL and MariaDB to fix SQL syntax errors #211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: renemadsen <[email protected]>
… MariaDB Co-authored-by: renemadsen <[email protected]>
|
@copilot Now that this is working, search documentation for MySQL versions 9.x and MariaDB versions 11.x and 12.x |
Research completed on MySQL 9.x and MariaDB 11.x/12.x RETURNING support: MySQL 9.x (9.0, 9.1, 9.2):
MariaDB 11.x (11.0-11.6):
MariaDB 12.0:
Conclusion:
The fallback mechanism (LAST_INSERT_ID() + SELECT) works correctly for all versions. |
|
@copilot With respect to the difference in MySQL and Mariadb, this is broken for MySQL v8.0.40, MariaDB 10.5.27, but it works in MariaDB 11.6.2: Failed Pomelo.EntityFrameworkCore.MySql.FunctionalTests.BulkUpdates.NorthwindBulkUpdatesMySqlTest.Delete_with_LeftJoin(async: False) [161 ms] |
This is a separate issue unrelated to the RETURNING clause fix. The error "You can't specify target table 'o' for update in FROM clause" is a known MySQL limitation when using DELETE with self-referencing subqueries. This is a MySQL/MariaDB version difference in how they handle DELETE statements with JOINs:
The RETURNING clause changes I made don't affect this behavior - they only change how generated values are retrieved after INSERT/UPDATE/DELETE operations. This appears to be a pre-existing compatibility issue with the bulk delete query generation that's exposed by the version differences. This would require a separate investigation into how |
MySQL 8.4.3 fails with syntax errors when attempting to use RETURNING clause in INSERT/UPDATE/DELETE statements. The code incorrectly assumed MySQL 8.0.21+ supported this PostgreSQL feature.
Changes
MySqlServerVersion.cs: SetReturningproperty to always returnfalse(was>= 8.0.21)MySqlUpdateSqlGenerator.cs: Updated comments to clarify RETURNING support statusTechnical Details
MySQL: Does not support RETURNING in any version (tested 8.0.39, 8.4.3)
MariaDB: Partial support exists (INSERT/DELETE work since 10.0/10.5, UPDATE does not work). Disabled because EF Core's
UpdateAndSelectSqlGeneratorrequires consistent support across all DML operations.Both databases now use the fallback mechanism:
Impact
Original prompt
This section details on the original issue you should resolve
<issue_title>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RETURNING
Id;</issue_title><issue_description>MySQL 8.4.3 failing with this error, ensure that any changes to fix this keeps working for MariaDB 11.6.2