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

   Changes proposed in this pull request:
     - `FirebirdPrepareStatementCommandExecutor` now describes a `?` of the 
`LIKE` pattern and of `ESCAPE` by the column on the left, and a `?` on the left 
(`? LIKE NAME`) by the pattern column.
       - The type of such a parameter is produced by 
[Firebird](https://github.com/FirebirdSQL/firebird/blob/v5.0.4/src/dsql/BoolNodes.cpp#L465-L478)
 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 a statement had a `?` in `LIKE` (for example, `NAME 
LIKE ?`, `NAME LIKE ? ESCAPE ?` or `? LIKE NAME`), the proxy described it as 
`VARCHAR` without a length and answered `op_prepare_statement` with error 
`isc_random`. The client could not prepare the statement. Now the proxy 
describes the parameter as the Firebird server does (`VARCHAR(20)` for a 
`VARCHAR(20)` column).
   
   <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
   
     Table `T_PLAIN (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR(20))` has 
rows (4301, 'alpha'), (4302, 'beta_1'), (4303, 'a%'). A row with only a 
predicate is `SELECT ID FROM T_PLAIN WHERE <predicate> AND ID BETWEEN 4301 AND 
4303 ORDER BY ID`; `UPDATE` and `DELETE` have the same `ID` range. Each answer 
is the parameter description and the result; at the end the rows are read 
through the same connection. Jaybird 5 and 6 give the same results.
   
     Before the fix:
   
     | Query | Proxy | Server | Match |
     |---|---|---|---|
     | `NAME LIKE ?`, 'al%' | prepare error `isc_random` `Unknown exception. 
More details: java.lang.NullPointerException: Cannot invoke 
"java.lang.Integer.intValue()" because "this.columnLength" is null` | 
VARCHAR(20); rows 4301 | no |
     | `NAME LIKE ? ESCAPE '#'`, 'beta#_%' | the same error | VARCHAR(20); rows 
4302 | no |
     | `NAME LIKE ? ESCAPE ?`, 'beta#_%', '#' | the same error | VARCHAR(20), 
VARCHAR(20); rows 4302 | no |
     | `NAME NOT LIKE ?`, 'al%' | the same error | VARCHAR(20); rows 4302, 4303 
| no |
     | `? LIKE NAME`, 'a%' | the same error | VARCHAR(20); rows 4303 | no |
     | `SELECT ID, NAME FROM T_PLAIN WHERE NAME LIKE ? AND ID = ?`, 'be%', 4302 
| the same error | VARCHAR(20), INTEGER(10); rows (4302, beta_1) | no |
     | `UPDATE T_PLAIN SET NAME = NAME \|\| '!' WHERE NAME LIKE ?`, 'be%' | the 
same error | VARCHAR(20); updated 1 | no |
     | `DELETE FROM T_PLAIN WHERE NAME LIKE ?`, 'al%' | the same error | 
VARCHAR(20); updated 1 | no |
     | Rows at the end; `DELETE` of them | (4301, alpha), (4302, beta_1), 
(4303, a%); 3 | (4302, beta_1!), (4303, a%); 2 | no |
   
     After the fix:
   
     | Query | Proxy | Server | Match |
     |---|---|---|---|
     | `NAME LIKE ?` | VARCHAR(20); rows 4301 | VARCHAR(20); rows 4301 | yes |
     | `NAME LIKE ? ESCAPE '#'` | VARCHAR(20); rows 4302 | VARCHAR(20); rows 
4302 | yes |
     | `NAME LIKE ? ESCAPE ?` | VARCHAR(20), VARCHAR(20); rows 4302 | 
VARCHAR(20), VARCHAR(20); rows 4302 | yes |
     | `NAME NOT LIKE ?` | VARCHAR(20); rows 4302, 4303 | VARCHAR(20); rows 
4302, 4303 | yes |
     | `? LIKE NAME` | VARCHAR(20); rows 4303 | VARCHAR(20); rows 4303 | yes |
     | `NAME LIKE ? AND ID = ?` | VARCHAR(20), INTEGER(10); rows (4302, beta_1) 
| VARCHAR(20), INTEGER(10); rows (4302, beta_1) | yes |
     | `UPDATE` | VARCHAR(20); updated 1 | VARCHAR(20); updated 1 | yes |
     | `DELETE` | VARCHAR(20); updated 1 | VARCHAR(20); updated 1 | yes |
     | Rows at the end; `DELETE` of them | (4302, beta_1!), (4303, a%); 2 | 
(4302, beta_1!), (4303, a%); 2 | 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]

Reply via email to