Creating a new user sometimes creates `database does not exist` error when reconnecting
- Dominant language
- Go
- Stars
- 2.1k
- Forks
- 73
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 129
Description
Starting with a fresh doltgres server:
```
taylor@MacBook-Pro-3 dgs5 % doltgres --data-dir=.
INFO[0000] Server ready. Accepting connections.
WARN[0000] secure_file_priv is set to "", which is insecure.
WARN[0000] Any user with GRANT FILE privileges will be able to read any file which the sql-server process can read.
WARN[0000] Please consider restarting the server with secure_file_priv set to a safe (or non-existent) directory.
```
This is kinda hard to repro, but seems potentially related to specifying a host when connecting with the psql client
If I connect to the server using psql and don't specify a host, creating a new user works as expected
```
taylor@MacBook-Pro-3 ~ % psql -U postgres
Password for user postgres:
psql (15.10 (Homebrew), server 15.0)
Type "help" for help.
postgres=> create user test with password 'pass';
CREATE ROLE
postgres=> exit;
taylor@MacBook-Pro-3 ~ % psql -U postgres
Password for user postgres:
psql (15.10 (Homebrew), server 15.0)
Type "help" for help.
```
When specifying a host and then creating a user, I get a `database not found` error when I try to connect as that user. I have also witnessed this when creating a new user and then trying to connect as the default user `postgres`, but I could not repro for some reason
```
taylor@MacBook-Pro-3 ~ % psql -U postgres -h localhost
Password for user postgres:
psql (15.10 (Homebrew), server 15.0)
Type "help" for help.
postgres=> create table t (id int primary key);
CREATE TABLE
postgres=> create user test2 with superuser password 'pass';
CREATE ROLE
postgres=> exit;
taylor@MacBook-Pro-3 ~ % psql -U test2 -h localhost
Password for user test2:
psql: error: connection to server at "localhost" (::1), port 5432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: "database "test2" does not exist"
```
Contributor guide
Assessment
This issue has not been assessed yet.