Skip to content

fix(contrib/drivers/oracle): fix GBK decode and quoted identifiers - #4836

Open
yuyinw wants to merge 2 commits into
gogf:masterfrom
yuyinw:codex/fix-go-ora-gbk-decode-panic
Open

fix(contrib/drivers/oracle): fix GBK decode and quoted identifiers#4836
yuyinw wants to merge 2 commits into
gogf:masterfrom
yuyinw:codex/fix-go-ora-gbk-decode-panic

Conversation

@yuyinw

@yuyinw yuyinw commented Aug 6, 2026

Copy link
Copy Markdown

Why

The Oracle driver had two independent issues:

  1. github.com/sijms/go-ora/v2 v2.7.10 can panic while decoding truncated GBK input. In charset case 0x354, the old guard allowed a trailing one-byte slice to reach binary.BigEndian.Uint16(input[index:]), which requires two bytes.
  2. Driver.DoFilter removed every double quote from SQL before parsing. Oracle treats double-quoted identifiers as case-sensitive, so raw SQL targeting mixed-case table or column names was sent as unquoted identifiers and Oracle uppercased them.

What changed

  • Upgrade github.com/sijms/go-ora/v2 to v2.7.18, the smallest upstream release that includes the GBK decode bounds-check fix.
  • Preserve explicit double quotes in raw SQL filtering so users can address case-sensitive Oracle identifiers.
  • Return empty quote chars for generated Oracle SQL so normal framework table/model operations keep using Oracle's unquoted identifier behavior.
  • Add focused tests for the GBK trailing lead byte regression and the Oracle SQL filter behavior.
  • Record both feedback fixes in OpenSpec.

Testing

  • go test -run 'TestDriver(DoFilterPreservesQuotedIdentifiers|GetCharsDoesNotAddImplicitQuotes)$|^TestStringConverterDecodeGBKTrailingLeadByte$' ./...
  • go test -run '^$' ./...

Codex added 2 commits August 6, 2026 10:43
Upgrade github.com/sijms/go-ora/v2 from v2.7.10 to v2.7.18, the smallest upstream release that fixes StringConverter.Decode for charset case 0x354.

In v2.7.10, the case 0x354 branch checked index+1 > len(input) before calling binary.BigEndian.Uint16(input[index:]). When input[index:] contained only one trailing byte and input[index] was greater than 0x80, Uint16 required two bytes and panicked with index out of range. v2.7.18 changes the guard to index+1 >= len(input), returning safely for truncated input.

Add a focused dependency regression test that decodes a trailing GBK lead byte without requiring an Oracle database connection, and record the feedback in OpenSpec.
Oracle treats double-quoted identifiers as case-sensitive. The previous DoFilter removed every double quote before parsing SQL, so raw SQL targeting mixed-case table or column names was sent as unquoted identifiers and Oracle uppercased them.

Keep explicit quotes in raw SQL and make generated SQL use Oracle's unquoted identifier path by returning empty quote chars. This preserves ordinary lowercase model/table operations while allowing users to opt in to case-sensitive identifiers explicitly.

Add focused filter tests for quoted identifiers, placeholder conversion, LIMIT rewriting, and default quote chars.
@yuyinw yuyinw changed the title fix(contrib/drivers/oracle): update go-ora for GBK decode panic fix(contrib/drivers/oracle): fix GBK decode and quoted identifiers Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant