makssent opened a new pull request, #40179:
URL: https://github.com/apache/shardingsphere/pull/40179

   Changes proposed in this pull request:
     - The Firebird grammar accepts an optional `NULLS FIRST` or `NULLS LAST` 
after `ASC | DESC` in `orderByItem`; the new token `NULLS` is added to 
`unreservedWord`, because Firebird does not reserve this word.
     - `FirebirdStatementVisitor.visitOrderByItem` passes the `NullsOrderType` 
of the item to the order by item segments, so the requested place of NULL 
values is also kept when the proxy merges rows of several shards.
     - The client receives the rows in the order of the server instead of 
`isc_dsql_error` "You have an error in your SQL syntax".
   
   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
   
     `T_PLAIN (ID, NAME)` rows (2701, 'b'), (2702, NULL), (2703, 'a'), (2704, 
NULL), (2705, 'c') are inserted and deleted with the same results directly and 
through the proxy. Each query is `SELECT ID, NAME FROM T_PLAIN WHERE ID BETWEEN 
2701 AND 2706 ORDER BY ...`; the table shows its `ORDER BY` items and the 
returned rows.
   
     Before the fix:
   
     | Query | Proxy | Server | Match |
     |---|---|---|---|
     | `ORDER BY NAME NULLS FIRST, ID` | error 335544569 `isc_dsql_error` 
"Dynamic SQL Error; You have an error in your SQL syntax: SELECT ..., null" | 
2702 NULL, 2704 NULL, 2703 a, 2701 b, 2705 c | no |
     | `ORDER BY NAME NULLS LAST, ID` | the same error | 2703 a, 2701 b, 2705 
c, 2702 NULL, 2704 NULL | no |
     | `ORDER BY NAME ASC NULLS LAST, ID` | the same error | 2703 a, 2701 b, 
2705 c, 2702 NULL, 2704 NULL | no |
     | `ORDER BY NAME DESC NULLS FIRST, ID` | the same error | 2702 NULL, 2704 
NULL, 2705 c, 2701 b, 2703 a | no |
     | `ORDER BY NAME DESC NULLS LAST, ID` | the same error | 2705 c, 2701 b, 
2703 a, 2702 NULL, 2704 NULL | no |
     | `ORDER BY 2 NULLS LAST, 1` | error 335544569 `isc_dsql_error` "Dynamic 
SQL Error; You have an error in your SQL syntax: no viable alternative at input 
'2NULLS'" | 2703 a, 2701 b, 2705 c, 2702 NULL, 2704 NULL | no |
     | `ORDER BY UPPER(NAME) DESC NULLS FIRST, ID` | error 335544569 
`isc_dsql_error` "Dynamic SQL Error; You have an error in your SQL syntax: 
SELECT ..., null" | 2702 NULL, 2704 NULL, 2705 c, 2701 b, 2703 a | no |
   
     After the fix:
   
     | Query | Proxy | Server | Match |
     |---|---|---|---|
     | `ORDER BY NAME NULLS FIRST, ID` | 2702 NULL, 2704 NULL, 2703 a, 2701 b, 
2705 c | 2702 NULL, 2704 NULL, 2703 a, 2701 b, 2705 c | yes |
     | `ORDER BY NAME NULLS LAST, ID` | 2703 a, 2701 b, 2705 c, 2702 NULL, 2704 
NULL | 2703 a, 2701 b, 2705 c, 2702 NULL, 2704 NULL | yes |
     | `ORDER BY NAME ASC NULLS LAST, ID` | 2703 a, 2701 b, 2705 c, 2702 NULL, 
2704 NULL | 2703 a, 2701 b, 2705 c, 2702 NULL, 2704 NULL | yes |
     | `ORDER BY NAME DESC NULLS FIRST, ID` | 2702 NULL, 2704 NULL, 2705 c, 
2701 b, 2703 a | 2702 NULL, 2704 NULL, 2705 c, 2701 b, 2703 a | yes |
     | `ORDER BY NAME DESC NULLS LAST, ID` | 2705 c, 2701 b, 2703 a, 2702 NULL, 
2704 NULL | 2705 c, 2701 b, 2703 a, 2702 NULL, 2704 NULL | yes |
     | `ORDER BY 2 NULLS LAST, 1` | 2703 a, 2701 b, 2705 c, 2702 NULL, 2704 
NULL | 2703 a, 2701 b, 2705 c, 2702 NULL, 2704 NULL | yes |
     | `ORDER BY UPPER(NAME) DESC NULLS FIRST, ID` | 2702 NULL, 2704 NULL, 2705 
c, 2701 b, 2703 a | 2702 NULL, 2704 NULL, 2705 c, 2701 b, 2703 a | 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]

Reply via email to