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

sql: refactor type types #10624

Merged
merged 4 commits into from
Feb 15, 2022
Merged

Commits on Feb 14, 2022

  1. repr: remove deref impls on Char and VarChar wrappers

    They don't seem to be used. Also improve the comments on the wrapper
    types.
    benesch committed Feb 14, 2022
    Configuration menu
    Copy the full SHA
    1e4b031 View commit details
    Browse the repository at this point in the history
  2. postgres-util,pgrepr,sql: redistribute responsibilities for postgres …

    …types
    
    Redistribute how PostgreSQL types are handled. Creating a PostgreSQL
    type from an OID and typmod is now handled entirely by `pgrepr::Type`.
    The `postgres_util::PgColumn` struct now stores a `pgrepr::Type`
    directly, rather than a separate `PgScalarType` enum that was relatively
    duplicative with `pgrepr::Type`.
    
    The `sql` crate now generates views for a PostgreSQL source by
    converting a `pgrepr::Type` to an `UnresolvedDataType` by way of a new
    `fmt::Display` implementation on `pgrepr::Type`.
    
    For safety, the modifiers on `ScalarType::{Numeric,VarChar,Char}` now
    have newtype wrappers that enforce the bounds at construction. For
    clarity, the `scale` parameter of `ScalarType::Numeric` has been renamed
    `max_scale` and the `length` parameter of `ScalarType::VarChar` has been
    renamed `max_length`, to better reflect that they are maximums, not hard
    requirements. This is in contrast to `ScalarType::Char`, where the
    length is in fact a hard requirement, not a maximum.
    benesch committed Feb 14, 2022
    Configuration menu
    Copy the full SHA
    4ede69f View commit details
    Browse the repository at this point in the history

Commits on Feb 15, 2022

  1. coord,sql: store types differently in catalog

    Store types in the catalog via a new CatalogType enum. This enum is
    nearly one-to-one with ScalarType, except that modifier fields are
    removed and embedded types are replaced with GlobalId references.
    
    This type is used throughout the SQL planner, in the plans returned by
    `CREATE TYPE` and in the type name resolution code.
    
    The motivation for this refactor is the removal of the "lossy"
    conversions from `pgrepr::Type` to `ScalarType`. Now, all conversions
    are either full fidelity or report an error if they would discard data.
    benesch committed Feb 15, 2022
    Configuration menu
    Copy the full SHA
    7a89637 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6141324 View commit details
    Browse the repository at this point in the history