makssent opened a new pull request, #40189:
URL: https://github.com/apache/shardingsphere/pull/40189
Changes proposed in this pull request:
- Added `isAllocated` and `releaseStatementId` to
`FirebirdStatementIdGenerator`, and `InvalidStatementStateException`, mapped to
`isc_bad_req_handle` or `isc_unprepared_stmt`.
- `FirebirdSQLInfoExecutor` and `FirebirdFreeStatementCommandExecutor` now
check the handle, and `DSQL_drop` releases it.
- `op_info_sql` is written by
[Jaybird](https://github.com/FirebirdSQL/jaybird/blob/v6.0.6/src/main/org/firebirdsql/gds/ng/wire/AbstractFbWireDatabase.java#L346-L373)
and read by
[Firebird](https://github.com/FirebirdSQL/firebird/blob/v5.0.4/src/remote/server/server.cpp#L4709-L4715).
- `op_free_statement` is written by
[Jaybird](https://github.com/FirebirdSQL/jaybird/blob/v6.0.6/src/main/org/firebirdsql/gds/ng/wire/version10/V10Statement.java#L100-L106)
and read by
[Firebird](https://github.com/FirebirdSQL/firebird/blob/v5.0.4/src/remote/server/server.cpp#L3362-L3379).
- `isc_bad_req_handle` comes from
[Firebird](https://github.com/FirebirdSQL/firebird/blob/v5.0.4/src/remote/remote.h#L1494-L1506),
`isc_unprepared_stmt` from
[Firebird](https://github.com/FirebirdSQL/firebird/blob/v5.0.4/src/remote/server/server.cpp#L2257-L2261).
- Previously, when `op_info_sql` or `op_free_statement` came with a handle
never allocated (for example, `0x7FFF`) or already dropped, or `op_info_sql`
with an unprepared statement, the proxy answered success, and `op_info_sql`
returned zero record counts. Now the proxy answers with an error as the
Firebird server does (`isc_bad_req_handle` or `isc_unprepared_stmt`), and the
connection stays usable.
<details>
<summary>Verification</summary>
The same protocol packets were executed directly against a real database and
through the proxy, and the results were compared.
* Server: Firebird 5.0
* Clients: Jaybird 6.0.6
All packets go in one transaction, each followed by `op_batch_sync`
(success on both sides, not shown). `op_info_sql` requests
`isc_info_sql_records`.
Before the fix:
| Packet | Proxy | Server | Match |
|---|---|---|---|
| `op_info_sql`, unknown handle `0x7FFF` | success, zero record counts |
error `isc_bad_req_handle` `invalid request handle` | no |
| `op_free_statement` `DSQL_drop`, unknown handle `0x7FFF` | success |
error `isc_bad_req_handle` `invalid request handle` | no |
| `op_allocate_statement` | success | success | yes |
| `op_info_sql`, statement not prepared | success, zero record counts |
error `isc_unprepared_stmt` `Attempt to execute an unprepared dynamic SQL
statement.` | no |
| `op_free_statement` `DSQL_drop` | success | success | yes |
| `op_info_sql` after `DSQL_drop` | success, zero record counts | error
`isc_bad_req_handle` `invalid request handle` | no |
| `op_free_statement` `DSQL_unprepare` of a prepared `INSERT` | success |
success | yes |
| `op_info_sql` after `DSQL_unprepare` | success, zero record counts |
error `isc_unprepared_stmt` `Attempt to execute an unprepared dynamic SQL
statement.` | no |
| `DSQL_drop`, then commit | success | success | yes |
After the fix:
| Packet | Proxy | Server | Match |
|---|---|---|---|
| `op_info_sql`, unknown handle `0x7FFF` | error `isc_bad_req_handle`
`invalid request handle` | error `isc_bad_req_handle` `invalid request handle`
| yes |
| `op_free_statement` `DSQL_drop`, unknown handle `0x7FFF` | error
`isc_bad_req_handle` `invalid request handle` | error `isc_bad_req_handle`
`invalid request handle` | yes |
| `op_allocate_statement` | success | success | yes |
| `op_info_sql`, statement not prepared | error `isc_unprepared_stmt`
`Attempt to execute an unprepared dynamic SQL statement.` | error
`isc_unprepared_stmt` `Attempt to execute an unprepared dynamic SQL statement.`
| yes |
| `op_free_statement` `DSQL_drop` | success | success | yes |
| `op_info_sql` after `DSQL_drop` | error `isc_bad_req_handle` `invalid
request handle` | error `isc_bad_req_handle` `invalid request handle` | yes |
| `op_free_statement` `DSQL_unprepare` of a prepared `INSERT` | success |
success | yes |
| `op_info_sql` after `DSQL_unprepare` | error `isc_unprepared_stmt`
`Attempt to execute an unprepared dynamic SQL statement.` | error
`isc_unprepared_stmt` `Attempt to execute an unprepared dynamic SQL statement.`
| yes |
| `DSQL_drop`, then commit | success | success | yes |
</details>
---
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]