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

   Changes proposed in this pull request:
     - The `STRING_` rule of the Firebird lexer (`Literals.g4`) no longer 
treats a backslash as an escape character: inside quotes it accepts any 
character except a quote, and a doubled quote, as the Firebird server lexer 
does. Before, `\'` was read as an escaped quote, so literals such as 
`'C:\dir\'` or the escape character `'\'` did not end.
     - Statements with such literals (`LIKE 'a\_b' ESCAPE '\'`, `NAME = 
'C:\dir\'`, `INSERT`, `UPDATE` and `DELETE`) now return the results of the 
server instead of `isc_dsql_error` "You have an error in your SQL syntax".
   
   `DatabaseMetaData.getColumns` and `getTables` of Jaybird, which use `ESCAPE 
'\'`, now pass parsing, but still fail later when the proxy describes their 
parameters; this is a separate bug.
   
   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 3801 to 3804 of `T_PLAIN (ID, NAME)` are inserted with the names 
`a_b`, `axb`, `C:\dir\` and `O'Brien\`, queried, updated and deleted. Every 
`WHERE` also has `AND ID BETWEEN 3801 AND 3804`; a `SELECT ID[, NAME] FROM 
T_PLAIN WHERE ... ORDER BY ID` row shows only its condition and the returned 
rows. Jaybird 5 and 6 give the same results.
   
     Before the fix:
   
     | Query | Proxy | Server | Match |
     |---|---|---|---|
     | `INSERT` of rows 3801 `a_b` and 3802 `axb` | updated 1 each | updated 1 
each | yes |
     | `INSERT INTO T_PLAIN (ID, NAME) VALUES (3803, 'C:\dir\')` | error 
335544569 `isc_dsql_error` "Dynamic SQL Error; You have an error in your SQL 
syntax: INSERT INTO T_PLAIN (ID, NAME) VALUES (3803, 'C:\dir\'), null" | 
updated 1 | no |
     | `INSERT INTO T_PLAIN (ID, NAME) VALUES (3804, 'O''Brien\')` | the same 
error with this statement | updated 1 | no |
     | `NAME LIKE 'a\_b' ESCAPE '\'` | error 335544569 `isc_dsql_error` 
"Dynamic SQL Error; You have an error in your SQL syntax: no viable alternative 
at input '''" | 3801 | no |
     | `NAME LIKE 'a!_b' ESCAPE '!'` | 3801 | 3801 | yes |
     | `NAME = 'C:\dir\'` | error 335544569 `isc_dsql_error` "... SQL syntax: 
SELECT ..., null" | 3803 `C:\dir\` | no |
     | `NAME LIKE '%\'` | error 335544569 `isc_dsql_error` "... no viable 
alternative at input '''" | 3803 `C:\dir\`, 3804 `O'Brien\` | no |
     | `UPDATE T_PLAIN SET NAME = 'D:\' WHERE NAME = 'C:\dir\' AND ...` | error 
335544569 `isc_dsql_error` "... SQL syntax: UPDATE ..., null" | updated 1 | no |
     | `DELETE FROM T_PLAIN WHERE NAME = 'O''Brien\' AND ...` | error 335544569 
`isc_dsql_error` "... SQL syntax: DELETE ..., null" | updated 1 | no |
     | `SELECT` of all rows | 3801 `a_b`, 3802 `axb` | 3801 `a_b`, 3802 `axb`, 
3803 `D:\` | no |
     | `DELETE` of all rows | updated 2 | updated 3 | no |
   
     After the fix:
   
     | Query | Proxy | Server | Match |
     |---|---|---|---|
     | `INSERT` of rows 3801 to 3804 | updated 1 each | updated 1 each | yes |
     | `NAME LIKE 'a\_b' ESCAPE '\'` | 3801 | 3801 | yes |
     | `NAME LIKE 'a!_b' ESCAPE '!'` | 3801 | 3801 | yes |
     | `NAME = 'C:\dir\'` | 3803 `C:\dir\` | 3803 `C:\dir\` | yes |
     | `NAME LIKE '%\'` | 3803 `C:\dir\`, 3804 `O'Brien\` | 3803 `C:\dir\`, 
3804 `O'Brien\` | yes |
     | `UPDATE T_PLAIN SET NAME = 'D:\' WHERE NAME = 'C:\dir\' AND ...` | 
updated 1 | updated 1 | yes |
     | `DELETE FROM T_PLAIN WHERE NAME = 'O''Brien\' AND ...` | updated 1 | 
updated 1 | yes |
     | `SELECT` of all rows | 3801 `a_b`, 3802 `axb`, 3803 `D:\` | 3801 `a_b`, 
3802 `axb`, 3803 `D:\` | yes |
     | `DELETE` of all rows | updated 3 | updated 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]

Reply via email to