cockroachdb / cockroachdb/cockroach
cli: PGSERVICEFILE behaves differently between cockroach and psql clients
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Describe the problem**
CockroachDB supports PGSERVICEFILE based on the [issue](https://github.com/cockroachdb/cockroach/pull/82389). Unfortunately, it only supports the basic capabilities and not the full scope of capabilities with psql.
**To Reproduce**
```bash
# CockroachDB Serverless
[serverless]
host=serverless.cockroachlabs.cloud
port=26257
user=artem
application_name=pgservicefile
```
```sql
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
```bash
cockroach sql --url "postgresql://artem@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.
#
# 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.
#
artem@artem-serverless-3312.g8z.cockroachlabs.cloud: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.
```bash
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
```bash
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
Epic CRDB-23743
Contributor guide
Assessment
This issue has not been assessed yet.