Major changes since last commit: - FiveSql2 SQL:1999 engine (10,458 LOC) — 43/43 ALL PASS - 21 compiler/runtime bugs fixed (short-circuit AND/OR, FOR LOOP, etc.) - @byref pass-by-reference via RefCell pattern - Mutable closure capture (EnsureLocalRef + RefCell sharing) - RTL: 400 → 479 functions (+79: file, string, datetime, hash, UTF-8) - DateTime/Timestamp fully working (hb_DateTime, hb_Hour/Min/Sec, display) - Reserved word guard (39 keywords blocked from function calls) - AEval arg order fix (element before index) - Closure capture redecl fix (unique _cap_ names per block) - Hash/string indexing in ArrayPush/ArrayPop - Harbour compat test suite: 51/51 - 4 docs: Porting Report, Implementation Plan, Optimization Plan, Commercialization Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
67 lines
1.7 KiB
Plaintext
67 lines
1.7 KiB
Plaintext
#include "FiveSqlDef.ch"
|
|
#include "hbclass.ch"
|
|
|
|
FUNCTION Main()
|
|
LOCAL oSql, oLexer, oParser, aTokens, hQuery, oExec
|
|
|
|
dbCreate("dbg_test", { {"ID","N",4,0}, {"NAME","C",20,0} })
|
|
USE "dbg_test" NEW EXCLUSIVE
|
|
APPEND BLANK
|
|
REPLACE ID WITH 1, NAME WITH "Alice"
|
|
APPEND BLANK
|
|
REPLACE ID WITH 2, NAME WITH "Bob"
|
|
CLOSE ALL
|
|
|
|
oLexer := TSqlLexer():New("SELECT * FROM dbg_test")
|
|
oLexer:Tokenize()
|
|
aTokens := oLexer:GetTokens()
|
|
oParser := TSqlParser2():New(aTokens, {})
|
|
hQuery := oParser:Parse()
|
|
oExec := TSqlExecutor():New(hQuery, {})
|
|
|
|
// Manually trace RunSelect steps
|
|
? "hQuery type:", hQuery["type"]
|
|
? "tables:", Len(hQuery["tables"])
|
|
? "tables[1]:", ValType(hQuery["tables"][1])
|
|
IF ValType(hQuery["tables"][1]) == "A"
|
|
? " table name:", hQuery["tables"][1][1]
|
|
? " table alias:", hQuery["tables"][1][2]
|
|
ENDIF
|
|
|
|
// Trace the executor's OpenTable
|
|
? "aTables:", ValType(oExec:aTables)
|
|
? "oExec:hQuery:", ValType(oExec:hQuery)
|
|
|
|
// Set aTables like RunSelect does
|
|
oExec:aTables := hQuery["tables"]
|
|
? "aTables set, len:", Len(oExec:aTables)
|
|
|
|
// Try opening table
|
|
LOCAL cTable, cAlias, nWA
|
|
cTable := oExec:aTables[1][1]
|
|
? "cTable:", cTable
|
|
|
|
BEGIN SEQUENCE
|
|
nWA := oExec:OpenTable(cTable, "")
|
|
? "OpenTable returned:", nWA
|
|
RECOVER
|
|
? "OpenTable exception"
|
|
END SEQUENCE
|
|
|
|
// Try manual scan
|
|
IF nWA != NIL .AND. nWA > 0
|
|
dbSelectArea(nWA)
|
|
? "FCount:", FCount()
|
|
dbGoTop()
|
|
? "EOF:", Eof()
|
|
DO WHILE !Eof()
|
|
? " Row:", FieldGet(1), FieldGet(2)
|
|
dbSkip()
|
|
ENDDO
|
|
ENDIF
|
|
|
|
oExec:CloseOpened()
|
|
FErase("dbg_test.dbf")
|
|
? "DONE"
|
|
RETURN NIL
|