Skip to content

sql: reduce (eliminate?) support for sessions without a current database set #23145

@knz

Description

@knz

Discussed with @nvanbenschoten and @jordanlewis while working on #21456 and #23045.

pg does not support client sessions without a current database set. The virtual schemas (especially pg_catalog) are not well-defined if there is no current database.

Also in their current implementation they can generate a large amount data if queried by a client without a current database set, putting pressure on the SQL allocation pool.

The discussion on #21456 suggests evolving CockroachDB so that client sessions more often find themselves with a current database set by default. There's a spectrum of approaches:

  • have the current database set to system if not specified in the conn string / pgwire options
  • have the current database set to some arbitrary constant (e.g. default) and encourage the user via cockroach sql to create the database if it doesn't exist yet
    • might be a UX issue since only admin users can create databases
  • have the current database set to the username (like in pg), encourage the user to create
    • same UX problem as above
  • make every new cluster contain a "default" database, set that as default current database for new sessions that don't specify otherwise
  • same as above, but create the "default" db on-demand automatically

cc @bdarnell

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-sql-pgcompatSemantic compatibility with PostgreSQLC-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)S-3-ux-surpriseIssue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions