fix(plugin-snowflake): take the affected row count from the statement type, not a column name - #2469
Merged
datlechin merged 1 commit intoAug 26, 2026
Conversation
… type, not a column name Claude-Session: https://claude.ai/code/session_01Qk1xfY3vnneRifC22eV2r7
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
datlechin
added a commit
that referenced
this pull request
Aug 26, 2026
…dpoint sends (#2466) * fix(plugin-snowflake): decode the wire encodings the query-request endpoint sends Claude-Session: https://claude.ai/code/session_01Qk1xfY3vnneRifC22eV2r7 * fix(plugin-snowflake): give every statement builder one SQL escaper (#2467) Claude-Session: https://claude.ai/code/session_01Qk1xfY3vnneRifC22eV2r7 * fix(plugin-snowflake): keep a timestamp offset the date parser cannot represent as text (#2468) Claude-Session: https://claude.ai/code/session_01Qk1xfY3vnneRifC22eV2r7 * fix(plugin-snowflake): take the affected row count from the statement type, not a column name (#2469) Claude-Session: https://claude.ai/code/session_01Qk1xfY3vnneRifC22eV2r7 * fix(plugin-snowflake): key the shared session on the saved connection and scope Stop to its own driver (#2470) Claude-Session: https://claude.ai/code/session_01Qk1xfY3vnneRifC22eV2r7 --------- Co-authored-by: Ngo Quoc Dat <datlechin@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while investigating #2454.
The defect
extractAffectedRowsdecided what a result meant by reading its column names:It is wrong in both directions.
It misses real counts. An
UPDATEreturns two columns,number of rows updatedandnumber of multi-joined rows updated, and a multi-clauseMERGEreturns one per clause.columns.count == 1rejects them, so a save that changed rows reported none: the completion message dropped the count and query history recorded0.It invents counts that never happened.
SELECT COUNT(*) AS "number of rows" FROM ordersis one column with that name holding1523, so a plain read was reported as having changed 1523 rows.The fix
The server already says what the statement was. The response carries
statementTypeId, which the driver never read, so the count now comes from that and the sum of the count row:The range and the summing both follow the official Go driver, which gates on
isDml(data.Data.StatementTypeID)and whoseupdateRowssums every column of the first row rather than reading one:statementTypeIDSelect = 0x1000statementTypeIDDml = 0x3000statementTypeIDMultiTableInsert = statementTypeIDDml + 0x500statementTypeIDMultistatement = 0xA000A
SELECTis no longer DML whatever its columns are called, and a DML statement reports the sum of its counts however many it has.This is the same rule the ClickHouse driver already follows: classify a result from the server's answer, never from its shape.
Tests
SnowflakeStatementTypeTests, 5 cases: the DML range and its boundaries at0x2FFFand0x3501, a single count, anUPDATEand a three-clauseMERGEsummed, aSELECTholding1523in a column namednumber of rowsreporting nothing, and an unreadable or missing count reporting nothing rather than a guess.Verified: build PASS, 43/43 across this and the neighbouring Snowflake suites, SwiftLint 0 violations.