Skip to content

cli: PGSERVICEFILE behaves differently between cockroach and psql clients #101848

Open
@dbist

Description

@dbist

Describe the problem

CockroachDB supports PGSERVICEFILE based on the issue. Unfortunately, it only supports the basic capabilities and not the full scope of capabilities with psql.

To Reproduce

# CockroachDB Serverless
[serverless]
host=serverless.cockroachlabs.cloud
port=26257
user=artem
application_name=pgservicefile
psql service=serverless
psql (15.2 (Homebrew), server 13.0.0)
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_128_GCM_SHA256, compression: off)
Type "help" for help.

artem=> show application_name;
 application_name 
------------------
 pgservicefile
(1 row)

with cockroach

cockroach sql --url "postgresql://[email protected]?sslmode=verify-full&service=serverless"
#
# Welcome to the CockroachDB SQL shell.
# All statements must be terminated by a semicolon.
# To exit, type: \q.
#
# Client version: CockroachDB CCL v22.2.8 (aarch64-apple-darwin21.2, built 2023/04/17 13:51:03, go1.19.6)
# Server version: CockroachDB CCL v22.2.7 (x86_64-pc-linux-gnu, built 2023/03/28 19:47:29, go1.19.6)

warning: server version older than client! proceed with caution; some features may not be available.

# Cluster ID: 20735006-5a39-49c3-29b8-3d4c8befcbf8
#
# Enter \? for a brief introduction.
#
[email protected]:26257/defaultdb> show application_name;
  application_name
--------------------
  $ cockroach sql
(1 row)

So the first thing you notice, it does not honor the application_name session variable. The other issue is you can't omit the user name from the connection string, even though it is in the file. You cannot omit the host either, the port however can be read from the file.

cockroach sql --url "postgresql://artem-serverless-3312.g8z.cockroachlabs.cloud?sslmode=verify-full&service=serverless"
#
# Welcome to the CockroachDB SQL shell.
# All statements must be terminated by a semicolon.
# To exit, type: \q.
#
Connecting to server "artem-serverless-3312.g8z.cockroachlabs.cloud:26257" as user "root".
Enter password: 

it prompts for password and it assumes the user is root.

Expected behavior

A UX similar to this should align with the way psql works

cockroach sql "service=serverless"
ERROR: unknown command "service=serverless" for "cockroach sql"
Failed running "sql"

Environment:

  • CockroachDB version 22.2.8
  • Server OS: Cockroach Cloud
  • Client app cockroach sql, psql

Jira issue: CRDB-27158

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cli-clientCLI commands that pertain to using SQL featuresC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions