makssent opened a new pull request, #40177:
URL: https://github.com/apache/shardingsphere/pull/40177
Changes proposed in this pull request:
- `FirebirdDMLStatementVisitor.visitInsert` visits `insertSelectClause`
when the statement has no `VALUES`; the new `visitInsertSelectClause` builds
the insert columns and the `SELECT` subquery with its parameter markers, as the
MySQL visitor does. Before, `visit(null)` threw `NullPointerException`.
- `FirebirdPrepareStatementCommandExecutor` describes the parameters of
`INSERT ... SELECT` by the `WHERE` of the query instead of the `?` of `VALUES`
rows, and answers `isc_info_sql_stmt_select` for `INSERT ... SELECT ...
RETURNING`, because Firebird returns a cursor with all inserted rows for it.
- The client can prepare and execute `INSERT ... SELECT` with and without
`RETURNING` instead of receiving `isc_random` "Unknown exception." 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))` with rows
(2901, 'a'), (2902, NULL), (2903, 'c'), inserted with the same results directly
and through the proxy. Each query is `INSERT INTO T_PLAIN ...`; 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 |
|---|---|---|---|
| `... (ID, NAME) SELECT ID + 100, NAME FROM T_PLAIN WHERE ID = ?`, 2901 |
error 335544382 `isc_random` "Unknown exception." | 1 parameter, updated 1 | no
|
| `... (ID, NAME) SELECT ID + 100, NAME FROM T_PLAIN WHERE ID >= ? AND ID
<= ? AND NAME IS NULL`, 2901, 2903 | the same error | 2 parameters, updated 1 |
no |
| `... SELECT ID + 200, NAME FROM T_PLAIN WHERE NAME = ?`, 'c' | the same
error | 1 parameter, updated 1 | no |
| `... (ID, NAME) SELECT ID + 300, NAME FROM T_PLAIN WHERE ID = ? AND NAME
= ?`, 2901, 'missing' | the same error | 2 parameters, updated 0 | no |
| `... (ID, NAME) SELECT ID + 301, NAME FROM T_PLAIN WHERE ID = ?`, 2903 |
the same error | 1 parameter, updated 1 | no |
| `... (ID, NAME) SELECT ID + 400, NAME FROM T_PLAIN WHERE ID >= ? AND ID
<= ? ORDER BY ID RETURNING ID, NAME`, 2901, 2903 | the same error | 2
parameters, result set [3301, a] [3302, null] [3303, c] | no |
| Rows read directly from the server | 2901 'a', 2902 NULL, 2903 'c' |
2901 'a', 2902 NULL, 2903 'c', 3001 'a', 3002 NULL, 3103 'c', 3204 'c', 3301
'a', 3302 NULL, 3303 'c' | no |
After the fix:
| Query | Proxy | Server | Match |
|---|---|---|---|
| `... (ID, NAME) SELECT ID + 100, NAME FROM T_PLAIN WHERE ID = ?`, 2901 |
1 parameter, updated 1 | 1 parameter, updated 1 | yes |
| `... (ID, NAME) SELECT ID + 100, NAME FROM T_PLAIN WHERE ID >= ? AND ID
<= ? AND NAME IS NULL`, 2901, 2903 | 2 parameters, updated 1 | 2 parameters,
updated 1 | yes |
| `... SELECT ID + 200, NAME FROM T_PLAIN WHERE NAME = ?`, 'c' | 1
parameter, updated 1 | 1 parameter, updated 1 | yes |
| `... (ID, NAME) SELECT ID + 300, NAME FROM T_PLAIN WHERE ID = ? AND NAME
= ?`, 2901, 'missing' | 2 parameters, updated 0 | 2 parameters, updated 0 | yes
|
| `... (ID, NAME) SELECT ID + 301, NAME FROM T_PLAIN WHERE ID = ?`, 2903 |
1 parameter, updated 1 | 1 parameter, updated 1 | yes |
| `... (ID, NAME) SELECT ID + 400, NAME FROM T_PLAIN WHERE ID >= ? AND ID
<= ? ORDER BY ID RETURNING ID, NAME`, 2901, 2903 | 2 parameters, result set
[3301, a] [3302, null] [3303, c] | 2 parameters, result set [3301, a] [3302,
null] [3303, c] | yes |
| Rows read directly from the server | 2901 'a', 2902 NULL, 2903 'c', 3001
'a', 3002 NULL, 3103 'c', 3204 'c', 3301 'a', 3302 NULL, 3303 'c' | 2901 'a',
2902 NULL, 2903 'c', 3001 'a', 3002 NULL, 3103 'c', 3204 'c', 3301 'a', 3302
NULL, 3303 'c' | 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]