Skip to content

Harden SST compiler and query derivation #16

Description

@piraz

Summary

Harden the SQLok SST/compiler boundary after the initial CRUD and compiled-shape cache review.

The current implementation is a solid experimental foundation, but several correctness, security, and performance gaps must be resolved before the cache or public API is treated as production-ready.

Scope

  • Derive canonical query shapes from SST structure instead of trusting caller-supplied cache keys.
  • Include dialect, compiler version, and relevant model/schema descriptor versions in shape identity.
  • Reject stale or structurally incompatible cached statements before execution.
  • Define identifier validation and/or dialect-aware quoting for schema, table, and column names.
  • Reject SELECT roots without a projection instead of emitting invalid SQL.
  • Replace full AST argument traversal on cache hits with a real bind layout when practical.
  • Reconcile LIMIT/OFFSET semantics with the documented ANSI portability decision.
  • Clean up exported Go documentation and standardize benchmark APIs.

Security requirements

  • Runtime values must remain outside SQL templates and cache keys.
  • Dynamic identifiers must not be interpolated without validation or quoting.
  • A cache hit must never return SQL from a different structural statement.
  • Stale artifacts must be invalidated or rejected before an executor is called.

Acceptance criteria

  • Equivalent statement structures with different values share a canonical shape.
  • Different statement structures cannot collide silently.
  • Shape identity accounts for dialect and compiler/model/schema versions where relevant.
  • Invalid identifiers fail safely or are rendered through an explicit quoting policy.
  • SELECT without expressions returns a construction/compile error.
  • Cache-hit benchmarks measure automatic binding rather than a hand-written upper bound only.
  • Regression tests cover wrong-key reuse, invalidation, identifier safety, empty SELECTs, and parameter mutation.
  • go test ./..., go vet ./..., and relevant race/benchmark gates remain green.

Related work

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions