makssent opened a new pull request, #40173:
URL: https://github.com/apache/shardingsphere/pull/40173
Changes proposed in this pull request:
- The `predicate` rule of the Firebird grammar (`BaseRule.g4`) no longer
has an empty first alternative. With it, `expr` could match nothing, and a
string literal without `AS` in the select list (`SELECT ID, 'x' FROM ...`) was
parsed as the alias of an empty expression, so
`FirebirdStatementVisitor.visitPredicate` failed with `NullPointerException`.
- `FirebirdPrepareStatementCommandExecutor` describes a literal of the
select list with the new `processLiteralColumn`: the name `CONSTANT`, the alias
or `CONSTANT` as the label, and for a string the length in characters (a
doubled quote counts as one), as Firebird does. Before, a string literal was
described as `VARCHAR` without a length, so `FirebirdReturnColumnPacket` failed
with `NullPointerException`, and a numeric literal had an empty name.
- The client now gets the rows and the column description of the server
instead of `isc_random` "Unknown exception." when it executes or prepares such
a query.
The type of a string literal (`CHAR` on the server, `VARCHAR` through the
proxy) and its NULL flag are not changed here: the proxy describes them by its
common rules for all text columns and for nullability.
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
Rows (4101, 'a') and (4102, 'b') are inserted into `T_PLAIN (ID, NAME)`
and deleted with the same results directly and through the proxy. Each query is
executed, and prepared to read the name, label and precision of its columns,
shown as `name/label precision`. Jaybird 5 and 6 give the same results.
Before the fix:
| Query | Proxy | Server | Match |
|---|---|---|---|
| `SELECT ID, 'x' FROM T_PLAIN WHERE ID BETWEEN 4101 AND 4102 ORDER BY ID`
| error 335544382 `isc_random` "Unknown exception." when executed and when
prepared | 4101 x, 4102 x; `ID/ID 10`, `CONSTANT/CONSTANT 1` | no |
| `SELECT 'abc', NAME FROM T_PLAIN WHERE ID = 4101` | the same error | abc
a; `CONSTANT/CONSTANT 3`, `NAME/NAME 20` | no |
| `SELECT 'Привет' AS P, '' AS E, 'it''s' FROM T_PLAIN WHERE ID = 4101` |
the same error | Привет, empty string, it's; `CONSTANT/P 6`, `CONSTANT/E 0`,
`CONSTANT/CONSTANT 4` | no |
| `SELECT 'x' FROM RDB$DATABASE` | the same error | x; `CONSTANT/CONSTANT
1` | no |
| `SELECT ID, 1, 'one' AS ONE FROM T_PLAIN WHERE ID BETWEEN 4101 AND 4102
ORDER BY ID` | the same error | 4101 1 one, 4102 1 one; `ID/ID 10`,
`CONSTANT/CONSTANT 10`, `CONSTANT/ONE 3` | no |
After the fix:
| Query | Proxy | Server | Match |
|---|---|---|---|
| `SELECT ID, 'x' FROM T_PLAIN WHERE ID BETWEEN 4101 AND 4102 ORDER BY ID`
| 4101 x, 4102 x; `ID/ID 10`, `CONSTANT/CONSTANT 1` | 4101 x, 4102 x; `ID/ID
10`, `CONSTANT/CONSTANT 1` | yes |
| `SELECT 'abc', NAME FROM T_PLAIN WHERE ID = 4101` | abc a;
`CONSTANT/CONSTANT 3`, `NAME/NAME 20` | abc a; `CONSTANT/CONSTANT 3`,
`NAME/NAME 20` | yes |
| `SELECT 'Привет' AS P, '' AS E, 'it''s' FROM T_PLAIN WHERE ID = 4101` |
Привет, empty string, it's; `CONSTANT/P 6`, `CONSTANT/E 0`, `CONSTANT/CONSTANT
4` | Привет, empty string, it's; `CONSTANT/P 6`, `CONSTANT/E 0`,
`CONSTANT/CONSTANT 4` | yes |
| `SELECT 'x' FROM RDB$DATABASE` | x; `CONSTANT/CONSTANT 1` | x;
`CONSTANT/CONSTANT 1` | yes |
| `SELECT ID, 1, 'one' AS ONE FROM T_PLAIN WHERE ID BETWEEN 4101 AND 4102
ORDER BY ID` | 4101 1 one, 4102 1 one; `ID/ID 10`, `CONSTANT/CONSTANT 10`,
`CONSTANT/ONE 3` | 4101 1 one, 4102 1 one; `ID/ID 10`, `CONSTANT/CONSTANT 10`,
`CONSTANT/ONE 3` | 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]