Skip to content

Add RowsFromExpr AST node for ROWS FROM table expressions#454

Draft
myers wants to merge 3 commits intodolthub:mainfrom
myers:rows-from-table-function
Draft

Add RowsFromExpr AST node for ROWS FROM table expressions#454
myers wants to merge 3 commits intodolthub:mainfrom
myers:rows-from-table-function

Conversation

@myers
Copy link

@myers myers commented Feb 1, 2026

Summary

Adds RowsFromExpr AST type to represent PostgreSQL ROWS FROM syntax which executes multiple set-returning functions in parallel and zips their results together.

type RowsFromExpr struct {
    Exprs          SelectExprs  // Function expressions
    WithOrdinality bool         // Whether to add ordinality column
    Alias          TableIdent   // Table alias
    Columns        Columns      // Column aliases
}

Implements iTableExpr() interface method.

Related PRs

Test plan

  • Tests in doltgresql repository cover multi-argument UNNEST and ROWS FROM functionality

myers added 2 commits January 16, 2026 21:46
When RequireSecureTransport is set to true but TLSConfig is nil, the server
was not advertising the CLIENT_SSL capability in the initial handshake packet.
This caused MySQL clients to connect without SSL, only to be rejected later
with a "Code: UNAVAILABLE" error.

This fix ensures that CLIENT_SSL capability is advertised in the handshake
when either TLSConfig is configured OR RequireSecureTransport is enabled,
allowing clients to properly negotiate SSL connections per MySQL protocol.

Changes:
- Modified handle() in go/mysql/server.go to check both l.TLSConfig != nil
  and l.RequireSecureTransport when determining enableTLS parameter
- This ensures writeHandshakeV10() sets CapabilityClientSSL flag correctly

Fixes the MySQL protocol violation where the server requires SSL but doesn't
advertise the capability during handshake negotiation.
Adds RowsFromExpr type to represent PostgreSQL ROWS FROM syntax
which executes multiple set-returning functions in parallel and
zips their results together.

Fields:
- Exprs: SelectExprs containing the function expressions
- WithOrdinality: whether to add an ordinality column
- Alias: table alias
- Columns: column aliases
myers added a commit to myers/doltgresql that referenced this pull request Feb 1, 2026
Expands multi-argument UNNEST(arr1, arr2, ...) into
ROWS FROM(unnest(arr1), unnest(arr2), ...) which properly
zips results together with NULL padding for shorter arrays.

Changes:
- table_expr.go: Detect and expand multi-arg UNNEST to RowsFromExpr
- aliased_table_expr.go: Support WITH ORDINALITY via RowsFromExpr
- select_clause.go: Update multi-arg UNNEST rewrite to use RowsFromExpr

Depends on:
- dolthub/vitess#454
- dolthub/go-mysql-server#3412
myers added a commit to myers/doltgresql that referenced this pull request Feb 3, 2026
- Add comprehensive tests for explicit ROWS FROM syntax:
  - ROWS FROM with generate_series
  - ROWS FROM with unnest
  - ROWS FROM with mixed functions
- Fix table_expr.go and aliased_table_expr.go to use RowsFromExpr
  for all multi-function ROWS FROM cases, not just multi-arg UNNEST

Depends on:
- dolthub/vitess#454
- dolthub/go-mysql-server#3412
@zachmu
Copy link
Member

zachmu commented Feb 4, 2026

Thanks for the contribution, we're going to give these a look today.

Add Columns and WithOrdinality fields to TableFuncExpr (Doltgres
extensions, not used by MySQL) and delete the separate RowsFromExpr AST
node. TableFuncExpr now handles both named table functions and nameless
ROWS FROM expressions via an empty Name field.
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