makssent opened a new pull request, #40178:
URL: https://github.com/apache/shardingsphere/pull/40178
Changes proposed in this pull request:
- The Firebird grammar accepts `UPDATE OR INSERT INTO tableName
insertValuesClause matchingClause? returningClause?` as an alternative of the
`insert` rule, with the new `matchingClause` (`MATCHING columnNames`) and the
token `MATCHING`, which stays a non-reserved word (`unreservedWord`) as in
Firebird.
- The existing `FirebirdDMLStatementVisitor.visitInsert` builds an
`InsertStatement` from the table, the values and `RETURNING` of the statement,
so the proxy prepares it and describes its parameters like `INSERT`; without
`RETURNING` the statement type is `isc_info_sql_stmt_insert`, as from the
server.
- The client can execute `UPDATE OR INSERT` with and without `MATCHING`,
with parameters or literals and with `RETURNING`, instead of receiving
`isc_dsql_error` "You have an error in your SQL syntax" at prepare.
Verification:
The same queries were executed directly against a real database and through
the proxy, and the results were compared.
* Server: Firebird 5.0
* Clients: Jaybird 5.0.13 and 6.0.6
Table `T_PLAIN (ID INTEGER PRIMARY KEY, NAME VARCHAR(20))`. Each query is
`UPDATE OR INSERT INTO T_PLAIN (ID, NAME) VALUES ...`; the table shows the rest
of it and the values. Each answer is the parameter count of the prepared
statement and the result; at the end the rows are read directly from the server.
Before the fix:
| Query | Proxy | Server | Match |
|---|---|---|---|
| `... VALUES (?, ?) MATCHING (ID)`, (2801, 'first') | error 335544569
`isc_dsql_error` "Dynamic SQL Error; You have an error in your SQL syntax:
UPDATE OR INSERT ..., null" | 2 parameters, updated 1 | no |
| the same, (2801, 'second') | the same error | 2 parameters, updated 1 |
no |
| `... VALUES (?, ?)`, (2802, 'by key') | the same error | 2 parameters,
updated 1 | no |
| the same, (2802, NULL) | the same error | 2 parameters, updated 1 | no |
| the same, (2803, '') | the same error | 2 parameters, updated 1 | no |
| `... VALUES (2804, 'literal') MATCHING (ID)` | the same error | 0
parameters, updated 1 | no |
| `... VALUES (?, ?) MATCHING (ID) RETURNING ID, NAME`, (2805, 'returned')
| the same error | 2 parameters, result set [2805, returned] | no |
| the same, (2805, 'returned again') | the same error | 2 parameters,
result set [2805, returned again] | no |
| Rows read directly from the server | none | 2801 'second', 2802 NULL,
2803 '', 2804 'literal', 2805 'returned again' | no |
After the fix:
| Query | Proxy | Server | Match |
|---|---|---|---|
| `... VALUES (?, ?) MATCHING (ID)`, (2801, 'first') | 2 parameters,
updated 1 | 2 parameters, updated 1 | yes |
| the same, (2801, 'second') | 2 parameters, updated 1 | 2 parameters,
updated 1 | yes |
| `... VALUES (?, ?)`, (2802, 'by key') | 2 parameters, updated 1 | 2
parameters, updated 1 | yes |
| the same, (2802, NULL) | 2 parameters, updated 1 | 2 parameters, updated
1 | yes |
| the same, (2803, '') | 2 parameters, updated 1 | 2 parameters, updated 1
| yes |
| `... VALUES (2804, 'literal') MATCHING (ID)` | 0 parameters, updated 1 |
0 parameters, updated 1 | yes |
| `... VALUES (?, ?) MATCHING (ID) RETURNING ID, NAME`, (2805, 'returned')
| 2 parameters, result set [2805, returned] | 2 parameters, result set [2805,
returned] | yes |
| the same, (2805, 'returned again') | 2 parameters, result set [2805,
returned again] | 2 parameters, result set [2805, returned again] | yes |
| Rows read directly from the server | 2801 'second', 2802 NULL, 2803 '',
2804 'literal', 2805 'returned again' | 2801 'second', 2802 NULL, 2803 '', 2804
'literal', 2805 'returned again' | yes |
---
Before committing this PR, I'm sure that I have checked the following
options:
- [x] My code follows the [code of
conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/)
of this project.
- [x] I have self-reviewed the commit code.
- [ ] I have (or in comment I request) added corresponding labels for the
pull request.
- [ ] I have passed maven check locally : `./mvnw clean install -B -T1C
-Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
- [ ] I have made corresponding changes to the documentation.
- [x] I have added corresponding unit tests for my changes.
- [ ] I have updated the Release Notes of the current development version.
For more details, see [Update Release
Note](https://shardingsphere.apache.org/community/en/involved/contribute/contributor/)
- [ ] I have specified the tool and the affected files or area for
substantial AI assistance, as required by the [AI-assisted contribution policy].
[AI-assisted contribution policy]:
https://github.com/apache/shardingsphere/blob/master/AI_POLICY.md
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]