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: reduce UX surprise with DROP DATABASE and ALTER DATABASE RENAME #24246

Merged
merged 1 commit into from
Mar 27, 2018

Commits on Mar 27, 2018

  1. sql: reduce UX surprise with DROP DATABASE and ALTER DATABASE RENAME

    Prior to this patch, a user logged into the CLI shell and taking a
    database name's away while it is set as "current database", either via
    DROP DATABASE or ALTER DATABASE RENAME, would cause the subsequent
    prompt refresh and possibly further statements to fail, due to an
    inexistent current database.
    
    This behavior is arguably surprising and raises the question for
    unsuspecting/beginner users: why does the thing let me do something
    that breaks everything afterwards?
    
    This patch enhances the issue by preventing DROP or ALTER DATABASE
    RENAME if the name taken away is set as current database, when
    `sql_safe_updates` is set. (It is set for interactive sessions with
    `cockroach sql`).
    
    The following alternatives were explored but eventually dismissed:
    
    - prevent DROP or ALTER DATABASE RENAME altogether on the current
      database. This is unfriendly to client apps which may expect "DROP
      DATABASE" followed immediately by "CREATE DATABASE" to keep the
      session valid.
    
    - allow DROP and ALTER DATABASE RENAME but silently change the current
      database to empty (or some other valid value, like "system"). This
      is unfriendly to client apps which only set the current database via
      a URL path and expect the setting to remain stable.
    
    Release note (sql change): `DROP DATABASE` and `ALTER DATABASE RENAME`
    now prevent the removal of a database name if that database is set as
    the current database (`SET database` / `USE`) and the session setting
    `sql_safe_updates` is also set.
    knz committed Mar 27, 2018
    Configuration menu
    Copy the full SHA
    36b2780 View commit details
    Browse the repository at this point in the history