makssent opened a new pull request, #40191:
URL: https://github.com/apache/shardingsphere/pull/40191
Changes proposed in this pull request:
- Added `loadSystemTables` to `FirebirdNonFixedLengthColumnSizeLoader`. It
reads the lengths of the `CHAR` and `VARCHAR` columns of system tables from
`RDB$RELATION_FIELDS` and `RDB$FIELDS`, and `FirebirdMetaDataLoader` now puts
them into `FirebirdNonFixedLengthColumnSizeRegistry`.
- The description of a text column of a system table is produced by
[Firebird](https://github.com/FirebirdSQL/firebird/blob/v5.0.4/src/dsql/metd.epp#L1298-L1331)
from the same tables and read by
[Jaybird](https://github.com/FirebirdSQL/jaybird/blob/v6.0.6/src/main/org/firebirdsql/gds/ng/StatementInfoProcessor.java#L150-L175).
- Previously, when the select list had a text column of a system table
(for example, `SELECT RDB$RELATION_NAME FROM RDB$RELATIONS`), the proxy had no
length for the column, and writing the column description failed. The client
got `op_response` with error `isc_random` instead of the prepare response. Now
the proxy answers with the column description as the Firebird server does
(precision 63 for `RDB$RELATION_NAME`, the same rows).
<details>
<summary>Verification</summary>
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
`T_PLAIN (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR(20))` is a table
of the database. Each query is prepared and executed, and the answer is the
precision of its columns and its rows with trimmed text values (`<owner>` is
the user who created `T_PLAIN`). The type name is not compared, because the
proxy describes `CHAR` as `VARCHAR` for all text columns, and this pull request
does not change that. Jaybird 5 and 6 give the same results.
Before the fix:
| Query | Proxy | Server | Match |
|---|---|---|---|
| `SELECT RDB$RELATION_NAME, RDB$OWNER_NAME, RDB$RELATION_ID FROM
RDB$RELATIONS WHERE RDB$RELATION_NAME = 'T_PLAIN'` | error `isc_random`
`Unknown exception.` | precision 63, 63, 5; rows (T_PLAIN, `<owner>`, 129) | no
|
| `SELECT RDB$FIELD_NAME, RDB$FIELD_SOURCE, RDB$FIELD_POSITION FROM
RDB$RELATION_FIELDS WHERE RDB$RELATION_NAME = 'T_PLAIN' ORDER BY
RDB$FIELD_POSITION` | the same error | precision 63, 63, 5; rows (ID, RDB$4,
0), (NAME, RDB$5, 1) | no |
| `SELECT RDB$FIELD_NAME, RDB$FIELD_LENGTH FROM RDB$FIELDS WHERE
RDB$FIELD_NAME = 'RDB$RELATION_NAME'` | the same error | precision 63, 5; rows
(RDB$RELATION_NAME, 252) | no |
| `SELECT RDB$CHARACTER_SET_NAME, RDB$BYTES_PER_CHARACTER FROM
RDB$CHARACTER_SETS WHERE RDB$CHARACTER_SET_NAME = 'UTF8'` | the same error |
precision 63, 5; rows (UTF8, 4) | no |
After the fix:
| Query | Proxy | Server | Match |
|---|---|---|---|
| `SELECT RDB$RELATION_NAME, RDB$OWNER_NAME, RDB$RELATION_ID FROM
RDB$RELATIONS WHERE RDB$RELATION_NAME = 'T_PLAIN'` | precision 63, 63, 5; rows
(T_PLAIN, `<owner>`, 129) | precision 63, 63, 5; rows (T_PLAIN, `<owner>`, 129)
| yes |
| `SELECT RDB$FIELD_NAME, RDB$FIELD_SOURCE, RDB$FIELD_POSITION FROM
RDB$RELATION_FIELDS WHERE RDB$RELATION_NAME = 'T_PLAIN' ORDER BY
RDB$FIELD_POSITION` | precision 63, 63, 5; rows (ID, RDB$4, 0), (NAME, RDB$5,
1) | precision 63, 63, 5; rows (ID, RDB$4, 0), (NAME, RDB$5, 1) | yes |
| `SELECT RDB$FIELD_NAME, RDB$FIELD_LENGTH FROM RDB$FIELDS WHERE
RDB$FIELD_NAME = 'RDB$RELATION_NAME'` | precision 63, 5; rows
(RDB$RELATION_NAME, 252) | precision 63, 5; rows (RDB$RELATION_NAME, 252) | yes
|
| `SELECT RDB$CHARACTER_SET_NAME, RDB$BYTES_PER_CHARACTER FROM
RDB$CHARACTER_SETS WHERE RDB$CHARACTER_SET_NAME = 'UTF8'` | precision 63, 5;
rows (UTF8, 4) | precision 63, 5; rows (UTF8, 4) | 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]