JackieTien97 commented on code in PR #18977:
URL: https://github.com/apache/iotdb/pull/18977#discussion_r4535318938


##########
iotdb-client/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBTablePreparedStatement.java:
##########
@@ -233,7 +233,12 @@ private ResultSet 
processQueryResult(TSExecuteStatementResp resp) throws SQLExce
               resp.tracingInfo,
               (long) queryTimeout * 1000,
               resp.isSetMoreData() && resp.isMoreData(),
-              zoneId);
+              zoneId,
+              charset,
+              resp.isSetTableModel() && resp.isTableModel(),

Review Comment:
   Two scope notes on this call:
   
   1. `tableModel` is inert. `IoTDBRpcDataSet` takes the parameter but never 
reads it (declared at `IoTDBRpcDataSet.java:112`, no other use), so the 
previous hard-coded `false` had no observable effect. Forwarding it is fine for 
consistency with `IoTDBStatement`, but the PR description should not present it 
as one of the fixed bugs.
   2. The defensive copy is harmless but not required. The in-place 
`columnIndex2TsBlockColumnIndexList.add(0, -1)` in `IoTDBRpcDataSet` runs only 
when `ignoreTimeStamp == false`, which does not happen for the table model, and 
`IoTDBStatement` passes the Thrift list through the same constructor without 
copying. Keeping the copy is fine; please soften the "required" wording in the 
description, since readers may otherwise take it as evidence of a mutation path 
that does not exist here.



##########
iotdb-client/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBTablePreparedStatement.java:
##########
@@ -233,7 +233,12 @@ private ResultSet 
processQueryResult(TSExecuteStatementResp resp) throws SQLExce
               resp.tracingInfo,
               (long) queryTimeout * 1000,
               resp.isSetMoreData() && resp.isMoreData(),
-              zoneId);
+              zoneId,
+              charset,

Review Comment:
   Forwarding `charset` is a genuine behaviour fix, but it has no test. 
Measured on a live server with a connection opened with `charset=GBK`, reading 
a row whose value is `中文`:
   
   - master client, `getBytes(1)` on a `PreparedStatement`: `[-28, -72, -83, 
-26, -106, -121]` (UTF-8, wrong)
   - master client, same value through a plain `Statement`: `[-42, -48, -50, 
-60]` (GBK, correct)
   - PR client, both paths: `[-42, -48, -50, -60]`
   
   Please add a mock-based unit test for this (a `STRING`/`TEXT` column plus a 
non-default charset passed to the six-argument constructor, asserting 
`getBytes`), otherwise a future refactor can drop the argument again without 
any test failing.



##########
integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBTablePreparedStatementIT.java:
##########
@@ -382,4 +382,39 @@ public void testPrepareAndExecuteWithStringParameter() {
       fail("testPrepareAndExecuteWithStringParameter failed: " + 
e.getMessage());
     }
   }
+
+  @Test
+  public void testPrepareAndExecuteWithReorderedProjection() {

Review Comment:
   This case and `testPrepareAndExecuteWithRepeatedProjection` below do not 
exercise the code changed by this PR. SQL-level `PREPARE` / `EXECUTE` goes 
through `IoTDBStatement.executeQuery()` and the full `IoTDBJDBCResultSet` 
constructor, which already forwarded `columnIndex2TsBlockColumnIndexList` 
before this PR. The client-side `IoTDBTablePreparedStatement` (the 
`?`-parameter path through `executePreparedStatement` and `processQueryResult`) 
is never involved.
   
   Verified with the master client on a live 1C1D server, using the same two 
projections on an equivalent table (filtering on an INT32 column instead of 
`id`): `PREPARE ... FROM SELECT value, name ...` followed by `EXECUTE ... 
USING` already returns `200.3, Bob`, and the `name AS x, name AS y` variant 
already returns `Bob, Bob`. So both new cases pass with and without this fix.
   
   They are still useful as coverage for the server-side prepared-statement 
path, but please do not count them as regression tests for this fix in the PR 
description. The regression coverage for the changed code is the new unit tests 
plus `IoTDBTablePreparedStatementJDBCIT`, whose reordered / repeated / 
TIMESTAMP queries I confirmed fail against the master client.



-- 
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