You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
13 test cases ran. 1 additional finding, 12 passed.
Across 13 end-to-end protocol and SQL-conversion tests, 12 passed, showing stable startup/auth behavior (including direct and pipelined SSLRequest+StartupMessage handshakes), expected missing-database FATAL 3D000 semantics, correct Parse/Describe/Bind/Execute typing behavior, parser boundary parity, correct RowDescription→DataRow→CommandComplete→ReadyForQuery ordering, successful COPY FROM STDIN row commits, and no crash or decode corruption in mixed-type paths.
The most important finding is one confirmed high-severity bug: bootstrap creates the configured default database from DOLTGRES_DB, but implicit connections that omit a database default to username in connection startup logic, causing mismatched database selection and potential connection failures when those values differ.
✅ Passed (12)
Category
Summary
Screenshot
Binding
Parameter OID inference for SELECT $1::int + 1 returned 42 as expected.
Binding
Reused placeholder across text and integer contexts returned the expected incompatibility error.
Binding
Describe plus repeated binds preserved inferred int4 typing and returned 42 twice.
Conversion
Connected to localhost:5432/postgres and executed simple-query statements (SELECT 1, SHOW search_path) successfully with expected rows and no conversion errors.
Conversion
Simple Query variants differing by trailing semicolon/whitespace all succeeded, and the same variants through pgx Parse (extended protocol Prepare) were all accepted consistently. SQL PREPARE command itself is unsupported, so protocol-level Parse was used for prepare-path validation.
Result
Executed targeted wire protocol smoke test against localhost server and confirmed response order RowDescription -> DataRow -> CommandComplete -> ReadyForQuery.
Result
COPY FROM STDIN succeeded with completion tag COPY 3 and post-copy SELECT count(*) returned 3, confirming committed rows and completion reporting.
Result
Direct expression-derived queries returned coherent typed rows; prepare-path invocation returned explicit unsupported PREPARE error and server remained stable without panic or decode corruption.
Session
Using psql with sslmode=disable, connection to postgres authenticated successfully and SELECT 1 returned one row.
Session
Connection attempt to does_not_exist failed with FATAL and SQLSTATE 3D000 as expected.
Session
Pipelined SSLRequest+StartupMessage completed SCRAM authentication and SELECT 1 without protocol desynchronization.
Startup
Fresh startup accepted immediate connections and queries; warning-only behavior did not break usability.
N/A
ℹ️ Additional Findings (1)
These findings are unrelated to the current changes but were observed during testing.
Category
Summary
Screenshot
Startup
⚠️ When DOLTGRES_DB differs from username, implicit connections default to the wrong database and fail.
What failed: Bootstrap creates the configured default database from DOLTGRES_DB, but implicit client startup without an explicit database uses the username instead, causing clients to target a different (and possibly missing) database.
Impact: Users can fail to connect in default startup flows when configuration and username differ, breaking an expected first-run workflow. This makes startup behavior inconsistent and unreliable for deployments that rely on DOLTGRES_DB overrides.
Steps to reproduce:
Start the server in a fresh data directory with DOLTGRES_DB set to a non-username value.
Connect as a user whose username differs from DOLTGRES_DB while omitting database in StartupMessage.
Run introspection queries like SELECT current_database() or rely on implicit startup defaults and observe that the session database selection diverges from bootstrap intent.
Stub / mock context: A temporary local startup harness patch was active during this run: SCRAM auth was bypassed and related startup/auth helpers were adjusted in server/authentication_scram.go, server/auth/database.go, server/auth/init.go, and server/server.go to keep bootstrap checks deterministic in the test container.
Code analysis: I inspected the bootstrap default-database creation path and the per-connection startup path, and they derive default database names from different sources (DOLTGRES_DB vs username).
Why this is likely a bug: The production code uses two conflicting defaults for the same startup behavior, so an omitted database parameter can route sessions away from the configured bootstrap database.
Relevant code:
server/server.go (lines 200-227)
funccreateDefaultDatabase(cfg doltservercfg.ServerConfig) error {
user, password:=auth.GetSuperUserAndPassword()
dbName:=getDefaultDatabaseName(user)
dsn:=fmt.Sprintf("postgres://%s:%s@localhost:%d", user, password, cfg.Port())
// Connect to the server and create the default database with the given name.ctx:=context.Background()
conn, err:=pgx.Connect(ctx, dsn)
iferr!=nil {
returnerr
}
deferconn.Close(ctx)
_, err=conn.Exec(ctx, fmt.Sprintf("CREATE DATABASE %s;", dbName))
returnerr
}
funcgetDefaultDatabaseName(userNamestring) string {
defaultDbName:=os.Getenv(DefaultDbNameEnvVar)
ifdefaultDbName!="" {
returndefaultDbName
}
returnuserName
}
server/connection_handler.go (lines 311-336)
db, ok:=startupMessage.Parameters["database"]
dbSpecified:=ok&&len(db) >0if!dbSpecified {
db=h.mysqlConn.User
}
useStmt:=fmt.Sprintf("SET database TO '%s';", db)
postgresParser:= psql.PostgresParser{}
parsed, err:=postgresParser.ParseSimple(useStmt)
iferr!=nil {
returnerr
}
err=h.doltgresHandler.ComQuery(context.Background(), h.mysqlConn, useStmt, parsed, func(_*sql.Context, _*Result) error {
returnnil
})
// If a database isn't specified, then we attempt to connect to a database with the same name as the user,// ignoring any erroriferr!=nil&&dbSpecified {
_= h.send(&pgproto3.ErrorResponse{
These are tests that we're marking as Successful, however they do not match the expected output in some way. This is due to small differences, such as different wording on the error messages, or the column names being incorrect while the data itself is correct. ↩
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
☕ An Automated Dependency Version Bump PR 👑
Initial Changes
The changes contained in this PR were produced by `go get`ing the dependency.
```bash
go get github.com/dolthub/[dependency]/go@[commit]
```