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

cli,sql: improve the UX for viewing and updating zone configurations #28612

Merged
merged 4 commits into from
Sep 6, 2018

Commits on Sep 5, 2018

  1. sql/parser,cli: improve the UX for configuring zones

    This is part 1/3 of the general project to improve the UX of zone
    configurations in CockroachDB 2.1.
    
    This patch does the following:
    
    - it removes the EXPERIMENTAL keyword from the grammar for statements
      that view or change zone configurations.
    - it adds missing SQL contextual help strings.
    - it removes the "skip doc" parser annotation so that syntax diagrams
      can be generated.
    - it modifies the `cockroach zone` CLI utility to avoid using
      the EXPERIMENTAL keyword. For compatibility with pre-2.1 nodes,
      the code falls back to using EXPERIMENTAL if the syntax without
      EXPERIMENTAL is not recognized.
    
    Release note (cli change): `cockroach zone rm` will now produce no
    output unless an error occurs.
    knz committed Sep 5, 2018
    Configuration menu
    Copy the full SHA
    d46f353 View commit details
    Browse the repository at this point in the history
  2. sql: improve the UX of zone configurations

    This is part 2/3 of of the general project to improve the UX of zone
    configurations in CockroachDB 2.1.
    
    This patch does the following:
    
    - it creates a new column `config_sql` in `crdb_internal.zones` and
      the output of SHOW ZONE CONFIGURATION. This contains a
      copy of the allowed ALTER syntax which will be introduced in the
      next patch.
    
    - it cleans up and simplifies the implementation ALTER ... CONFIGURE
      ZONE, thereby simplifying further improvements.
    
    This patch also makes ALTER ... CONFIGURE ZONE able to accept strings
    that do not contain a terminating newline. This makes it possible to
    specify unescaped strings, for example `ALTER ... CONFIGURE ZONE
    'num_replicas: 3'` where previously one would have needed to specify
    `e'num_replicas:3 \n'`.
    
    The behavior for deletion is preserved: a NULL values requests a
    removal of the zone configuration; an empty string (or containing only
    whitespace) is a no-op (not a deletion).
    
    Release note: None
    knz committed Sep 5, 2018
    Configuration menu
    Copy the full SHA
    75c4225 View commit details
    Browse the repository at this point in the history
  3. sql: improve the UX of zone configurations (cont.)

    This is part 3/3 of the general project to improve the UX of zone
    configurations in CockroachDB 2.1.
    
    This patch introduces the extended syntax for the ALTER ... CONFIGURE
    ZONE statement. The following forms are now supported:
    
    ```
    -- New: remove a zone configuration.
    ALTER ... CONFIGURE ZONE DISCARD;
    
    -- New: reset a zone config to the inherited defaults.
    ALTER ... CONFIGURE ZONE USING DEFAULT;
    
    -- New: configure parameters using SQL expressions.
    -- Setting `constraints` and `lease_preferences` still uses YAML.
    ALTER ... CONFIGURE ZONE USING
        num_replicas = 1, gc.ttlseconds = 3600,
        constraints = '[+attr=ssd]';
    
    -- Preserved for backward compatibility:
    -- set multiple variables at once using YAML.
    ALTER ... CONFIGURE ZONE = '...yaml...';
    
    -- Preserved for backward compatibility;
    -- equivalent to ALTER ... CONFIGURE ZONE DISCARD:
    ALTER ... CONFIGURE ZONE = NULL;
    ```
    
    The disambiguation using either `=` (or, equivalently, TO) or USING is
    necessary to disambiguate the grammar (`ZONE foo = bar` would be
    parsable as either the first form with expression `(foo = bar)` or the
    second form with a single parameter set).
    
    Additionally, this patch ensures (and tests) that the ALTER
    ... CONFIGURE ZONE statements can be prepared and use placeholders.
    
    Release note (sql change): CockroachDB now recognizes `ALTER
    ... CONFIGURE ZONE` to add, modify, reset and remove zone
    configurations.
    
    Release note (sql change): The SQL statements to modify zone
    configurations can now use placeholders (`$1`, etc) and be prepared
    for multiple executions.
    knz committed Sep 5, 2018
    Configuration menu
    Copy the full SHA
    a7dbffd View commit details
    Browse the repository at this point in the history
  4. cli: mark cockroach zone commands as deprecated

    Requested/suggested by @benesch: this patch makes the various
    `cockroach zone` sub-commands report a deprecation warning and a
    reference to the new SQL interface:
    
    ```
    $ cockroach zone ls
    Command "ls" is deprecated, use SHOW ZONE CONFIGURATIONS in a SQL client instead.
    
    $ cockroach zone get .default
    Command "get" is deprecated, use SHOW ZONE CONFIGURATION FOR ... in a SQL client instead.
    
    $ cockroach zone set .default
    Command "set" is deprecated, use ALTER ... CONFIGURE ZONE in a SQL client instead.
    
    $ cockroach zone rm liveness
    Command "rm" is deprecated, use ALTER ... CONFIGURE ZONE DISCARD in a SQL client instead.
    ```
    
    Release note (cli change): The various `cockroach zone` sub-commands
    are now deprecated and will be removed in a future version of
    CockroachDB. Clients should use the SQL interface instead via `SHOW
    ZONE CONFIGURATION(s)` or `ALTER ... CONFIGURE ZONE`.
    knz committed Sep 5, 2018
    Configuration menu
    Copy the full SHA
    bfc190d View commit details
    Browse the repository at this point in the history