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

   AI disclosure: this change was prepared with AI coding agents, reviewed and 
revised line by line by me.
   
   Fixes #39537.
   
   Changes proposed in this pull request:
     - For queries on rule-enhanced tables, the result column count, names, 
labels and the label-index map were derived from projections expanded against 
ShardingSphere metadata and paired positionally with the actual backend rows. 
After out-of-band DDL on the backend (the issue adds a column directly on 
MySQL), the metadata view drifts from the live schema, and clients silently 
receive values attributed to wrong columns. Regression window: #27440 (5.1.1 
reports the columns correctly).
     - The backend result set metadata truthfully describes the actual rows, so 
the projection-derived description is now used only when its column count 
matches the actual result set metadata; otherwise the result set metadata is 
authoritative (`ShardingSphereResultSetUtils.useExpandedProjections`).
     - `QueryHeaderBuilderEngine` delegates to 
`ShardingSphereResultSetMetaData` instead of duplicating the projection lookup, 
and `StandardDatabaseProxyConnector` derives the header count from the same 
source, so the JDBC driver and the Proxy share one decision point.
     - Known limitation: same-count drift (for example an out-of-band `RENAME 
COLUMN`) still requires `REFRESH TABLE METADATA`, because a per-label 
comparison cannot distinguish drift from legitimate rule rewriting (encrypt 
substitutes cipher column names without aliases).
     - Unit tests: new cases in `ShardingSphereResultSetMetaDataTest` and 
`ShardingSphereResultSetUtilsTest` fail on master and pass with the fix; 
count-matching cases keep the projection-derived labels, which encrypt relies 
on.
   
   ---
   
   Before committing this PR, I'm sure 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.
   - [x] 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/)
   


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