Skip to content

Five SQL and name forms real applications write - #2

Merged
RandomChirp merged 1 commit into
FoxDevCommunity:mainfrom
jefflroberts:sql-forms-real-apps
Sep 24, 2026
Merged

RandomChirp merged 1 commit into
FoxDevCommunity:mainfrom
jefflroberts:sql-forms-real-apps

Conversation

@jefflroberts

Copy link
Copy Markdown
Collaborator

Five spellings a real Visual FoxPro application uses that the reference examples do not. All were found while importing a 60,000-line CodeMine application (Shutter Ace) into FoxDev, and none of them is rare there:

  1. USE IN SELECT('alias') - a name with a bracket after it in an IN clause is a call whose answer is the work area. About 180 uses in the app.
  2. ?name parameters in SELECT-SQL. Measured in VFP 9: accepted only by SELECT (INSERT, UPDATE and DELETE - SQL each refuse it with a syntax error), and read as an ordinary expression - a name that is both a field and a variable is the field, ?m.name asks for the variable.
  3. INSERT INTO t [(fields)] SELECT ... - the query runs into a cursor of its own and each row goes by position to the fields named, or to the table's fields in order.
  4. UNION [ALL] - each SELECT runs into its own cursor, later rows are appended under the first, and the whole is one final SELECT [DISTINCT] * carrying the union's ORDER BY and INTO. Columns are the first SELECT's; rows fold unless every UNION said ALL.
  5. DO "path" and CREATE TABLE 'file.dbf' NAME x - a quoted name where the grammar took only a bare one. The NAME clause is read and dropped, since the container lists a table by its file stem.

Two VM faults came out on the way and are fixed here because the new forms could not be tested without them:

  • A select list of nothing but * read blank rows from a freshly opened table: no field read had fetched the page. A SqlTouch instruction now reads each starred source before the row is made.
  • INTO ARRAY put the program back in the last source's work area rather than its own, because the area was noted after the sources were opened.

Verification. crates/foxvm/tests/sql_forms.rs (15 tests) and the sql_forms golden, whose .expected was written by vfp9.exe. The full VM suite passes (311 tests). npm run argforms:check passes.

Recorded, not fixed (added to the parity plan under "Open, reported from the IDE"): a LOCAL shadows a field of the same name here where the product reads the field, and _TALLY is never set by any statement. Both belong to the resolver (system 3).

Effect on the application that prompted this: forms and class libraries compiling clean went from 26 of 47 to 36 of 47; parse issues across them from 463 to 229.

🤖 Generated with Claude Code

USE IN SELECT('alias'), ?name parameters in SELECT-SQL, INSERT INTO ... SELECT,
UNION [ALL], and a quoted name after DO and CREATE TABLE (with its NAME clause).
Every one was found in a 60,000-line CodeMine application, none of them rare
there, and each was measured in Visual FoxPro 9 before being written: ?name is
taken only by SELECT and is an ordinary expression, field first; INSERT ...
SELECT goes by position to the fields named; a UNION's columns are the first
SELECT's and its rows fold unless every UNION said ALL.

Two faults in the VM came out on the way and are fixed here because the new
forms could not be tested without them: a select list of nothing but `*` read
blank rows from a freshly opened table, since no field read had fetched the
page (SqlTouch now reads each starred source); and INTO ARRAY put the program
back in the last source's work area rather than its own, because the area was
noted after the sources were opened.

The sql_forms golden is written from the product. Two gaps it exposed are
recorded in the parity plan rather than fixed: a LOCAL shadows a field of the
same name here where the product reads the field, and _TALLY is never set.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@jefflroberts

Copy link
Copy Markdown
Collaborator Author

Hi! I had Claude/Fable 5.1 try to help me get a fairly large project working, and this is what it did. No worries if you don't want it! I am also working on a Windows machine running under Parallels Desktop, so there may be some ARM64 improvements or specific configs. I've still got a few issues so I may follow up with another pull request or two. If you want me to stop making pull requests, just let me know. Neat project! Have a great day!

@RandomChirp

Copy link
Copy Markdown
Contributor

@jefflroberts looks great, this was born out of experimentation so any help is greatly appreciated! If it works for you thats enough! Please keep them coming!

@RandomChirp
RandomChirp merged commit 75e1778 into FoxDevCommunity:main Sep 24, 2026
2 of 3 checks passed
RandomChirp added a commit that referenced this pull request Sep 24, 2026
…itted

PR #2 changed bytecode.rs and the site's stale-data check turned main red, which no
outside contributor could have foreseen. The data is derived from a file in this same
repository, so prebuild and predev write it and git does not carry it.
RandomChirp pushed a commit that referenced this pull request Sep 24, 2026
Measured in Visual FoxPro 9, and written into the select_clause_order golden
whose .expected vfp9.exe produced: the clauses after the select list may come
in any order - Microsoft's own wbmain.prg writes `INTO ARRAY ... ORDER BY name
GROUP BY name`, and a WHERE after INTO CURSOR, or an ORDER BY before WHERE,
is the same query written the usual way round. INTO CURSOR and INTO TABLE no
longer swallow the rest of the line, only their own option words.

_TALLY is set to the number of rows a SELECT answered with (it was never set);
wbmain.prg tests it straight after that query.

Builds on #2 (UNION is read by the same loop).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jefflroberts

Copy link
Copy Markdown
Collaborator Author

Thanks so much, and thanks for the careful reviews on the rest of the batch! I'll work through the changes requested on #6 and #7 and rebase #8 once #6 is settled.

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.

2 participants