Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] sql: refactor the statement pretty-printer and implement EXPLAIN(TYPES) #6406

Closed
wants to merge 10 commits into from

Commits on Apr 28, 2016

  1. sql: Implement downward type preference during type checking

    This is one of the cornerstones of the Summer typing algorithm.
    Type checking now takes a "desired" type, which is a hint to `Expr`s to
    resolve themselves as the type, if possible. It it up to the caller to
    assert that the type returned if correct, if it is actually required.
    nvanbenschoten committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    0acda81 View commit details
    Browse the repository at this point in the history
  2. sql: Split notion of pre and post-type checked expression trees

    This commit adds a `TypedExpr` interface which is a superset of Expr but
    can also perform expression evaluation and can return type annotations.
    nvanbenschoten committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    d08f138 View commit details
    Browse the repository at this point in the history
  3. sql: Pull out Constant literal interface and add string-like constants

    This change creates the types `NumVal` and `StrVal`, which both
    implement the new `Constant` interface. The interface is a super-set of
    `Expr`, but includes extra methods for literal values.
    nvanbenschoten committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    05f6921 View commit details
    Browse the repository at this point in the history
  4. sql: Create unexpectedTypeError and define a few error situations

    This commit creates a new error type to hold commonly seen errors. It
    then uses this error in a few previously ambiguous situations.
    nvanbenschoten committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    9441951 View commit details
    Browse the repository at this point in the history
  5. sql: Numeric constant folding now folds parentheses

    Previously `(1) + 2` would not have folded to `3`, now it does.
    nvanbenschoten committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    7f2d56b View commit details
    Browse the repository at this point in the history
  6. sql: Improve testing and documentation for constantFolderVisitor

    This change pulls the constant related visitors into constant.go and
    cleans up a few tests.
    nvanbenschoten committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    e4d3941 View commit details
    Browse the repository at this point in the history
  7. sql: Pull out operator overload sets and add lookup method

    This change creates the types `unaryOpOverload`, `binOpOverload`, and
    `cmpOpOverload`, each with a lookup method for an overload
    implementation for a given set of argument types. It also changes
    `ComparisonOp` to `ComparisonOperator` to stay consistent.
    nvanbenschoten committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    732a3a7 View commit details
    Browse the repository at this point in the history
  8. sql: Clean up code within the new typing system

    This commit cleans up a number of uses of the new `TypedExpr` interface,
    improves the type checking system, added new test cases, and adds in a few
    TODOs for future work.
    nvanbenschoten committed Apr 28, 2016
    Configuration menu
    Copy the full SHA
    f868aa0 View commit details
    Browse the repository at this point in the history

Commits on Apr 30, 2016

  1. sql: refactor the pretty-printing code.

    This patch replaces the pretty-printing using a tree of String() calls
    by a Formattable interface common to all syntax object. This interface
    allows caller code to pass formatting flags throughout the pretty
    printing. This can be used later to implement conditional
    printing of node details (e.g. typing information).
    
    A side effect is a performance improvement: prior to this patch String
    and bytes.Buffer objects would be created and destroyed throughout the
    recursion, causing pressure on memory allocation. With this patch a
    single Buffer object is used per top-level request to the
    pretty-printer.
    knz committed Apr 30, 2016
    Configuration menu
    Copy the full SHA
    9b243ea View commit details
    Browse the repository at this point in the history
  2. sql: implement EXPLAIN(TYPES).

    This patch introduces a new features: the statement `EXPLAIN (TYPES)`
    to inspect the types of intermediate results in a query plan.
    
    Known limitation: `EXPLAIN(TYPES)` cannot be applied on statements
    containing placeholders ($xxx).
    
    As a side effect this patch also fixes a bug, where EXPLAIN(PLAN)
    would cause a panic when invoked on an INSERT statement.
    knz committed Apr 30, 2016
    Configuration menu
    Copy the full SHA
    aca4d35 View commit details
    Browse the repository at this point in the history