Skip to content

fix(engine): don't truncate a compound index expression to a field name - #134

Open
russimicro wants to merge 1 commit into
FiveTechSoft:mainfrom
russimicro:fix/compound-index-expr-key-length
Open

fix(engine): don't truncate a compound index expression to a field name#134
russimicro wants to merge 1 commit into
FiveTechSoft:mainfrom
russimicro:fix/compound-index-expr-key-length

Conversation

@russimicro

Copy link
Copy Markdown
Collaborator

Table::field_index retries a lookup longer than 10 characters against name.substr(0, 10), because DBF CREATE truncates field names to 10 (a proc __output column databasepath lands as DATABASEPA).

An index expression whose first component is a 10-character field — CCODIGOCON+CDOCUMETRA, CPREFIJTRA+CDOCUMETRA — therefore matched that field and reported itself as a bare field name. AdsCreateIndex61 then took the bare-field branch and pinned the key length to the first component's width, so every later component fell out of the key: records sharing the first component collapsed onto one key and ordered by recno. GotoTop on the compound tag landed on the wrong record, and an exact AdsSeek matched the wrong row.

The retry now only fires for a plain identifier (alphanumeric/underscore), which is the case it was written for.

Test: abi_cdx_estaelec_compound_test — two distinct compound tags over the same table (con+doc and pre+doc) must order differently, plus a computed DTOS() tag, a FOR-clause tag, and an exact seek on a compound key.

Found while running a Harbour/FiveWin ERP's real index set on OpenADS.

Suite: 1179/1191 — the same 12 pre-existing SQL-parser (7200) failures as pristine v1.8.31, verified on this branch in isolation (MSVC x64 Release).

🤖 Generated with Claude Code

Table::field_index retries a lookup longer than 10 characters against
name.substr(0, 10), because DBF CREATE truncates field names to 10 (a proc
__output column 'databasepath' lands as DATABASEPA).

An index expression whose first component is a 10-character field —
CCODIGOCON+CDOCUMETRA, CPREFIJTRA+CDOCUMETRA — therefore matched that field
and reported itself as a bare field name. AdsCreateIndex61 then took the
bare-field branch and pinned the key length to the first component's width,
so every later component fell out of the key: records sharing the first
component collapsed onto one key and ordered by recno. GotoTop on the
compound tag landed on the wrong record, and an exact AdsSeek matched the
wrong row.

The retry now only fires for a plain identifier (alphanumeric/underscore),
which is the case it was written for.

New test abi_cdx_estaelec_compound_test: two distinct compound tags over the
same table (con+doc and pre+doc) must order differently, plus a computed
DTOS() tag, a FOR-clause tag and an exact seek on a compound key.

Found while running a Harbour/FiveWin ERP's real index set on OpenADS.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

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