fix: 3 RDD compat bugs — FIELD->, AsNumInt Double, PACK/ZAP with index

Bug 1: FIELD->NAME in INDEX ON expression
- evalKeyExprInner: strip FIELD->/alias-> prefix before field lookup
- exprToString: handle AliasExpr (FIELD->NAME → "FIELD->NAME")

Bug 2: AsNumInt() on Double returned IEEE 754 raw bits
- Value.AsNumInt(): check tDouble and convert via Float64frombits
- Fixed array index crash when index is result of % modulo

Bug 3: PACK/ZAP crash with open indexes
- OrderListRebuild: fully implemented (was TODO stub)
  Saves index info, closes all, sets idxState=nil, recreates
- OrderCreate: set current=-1 during key evaluation (natural GoTo)
- PACK/ZAP: save/restore idxState, rebuild after operation
- Register __DBPACK, __DBZAP, DBRECALL symbol aliases

Harbour vs Five: 45/47 match (96%), 2 diffs are duplicate-key sort order

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-06 04:41:19 +09:00
parent 53370e7cbc
commit 6e78d12cc2
6 changed files with 108 additions and 7 deletions

View File

@@ -155,7 +155,12 @@ func (v Value) AsLong() int64 { return int64(v.scalar) }
func (v Value) AsDouble() float64 { return math.Float64frombits(v.scalar) }
func (v Value) AsJulian() int64 { return int64(v.scalar) }
func (v Value) AsTimeMs() int32 { return int32(v.info & auxMask) }
func (v Value) AsNumInt() int64 { return int64(v.scalar) }
func (v Value) AsNumInt() int64 {
if v.Type() == tDouble {
return int64(math.Float64frombits(v.scalar))
}
return int64(v.scalar)
}
// AsNumDouble returns a double value from any numeric type.
func (v Value) AsNumDouble() float64 {