Skip to content

Commit 1412805

Browse files
dossyarp242
andcommitted
Don't send empty startup parameters
That's also what libpq does; from src/interfaces/libpq/fe-protocol3.c if (conn->pguser && conn->pguser[0]) ADD_STARTUP_OPTION("user", conn->pguser); if (conn->dbName && conn->dbName[0]) ADD_STARTUP_OPTION("database", conn->dbName); if (conn->replication && conn->replication[0]) ADD_STARTUP_OPTION("replication", conn->replication); if (conn->pgoptions && conn->pgoptions[0]) ADD_STARTUP_OPTION("options", conn->pgoptions); if (conn->send_appname) { /* Use appname if present, otherwise use fallback */ val = conn->appname ? conn->appname : conn->fbappname; if (val && val[0]) ADD_STARTUP_OPTION("application_name", val); } if (conn->client_encoding_initial && conn->client_encoding_initial[0]) ADD_STARTUP_OPTION("client_encoding", conn->client_encoding_initial); Sending an empty value works for most systems, but not in Supavisor due to a bug there. Easy enough to fix here, so why not. Fixes #1259 Co-authored-by: Martin Tournoij <martin@arp242.net>
1 parent 0c529db commit 1412805

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
v1.11.2 (2025-02-10)
2+
--------------------
3+
This fixes two regressions:
4+
5+
- Don't send startup parameters if there is no value, improving compatibility
6+
with Supavisor ([#1260]).
7+
8+
- Don't send `dbname` as a startup parameter if `database=[..]` is used in the
9+
connection string. It's recommended to use dbname=, as database= is not a
10+
libpq option, and only worked by accident previously. ([#1261])
11+
12+
[#1260]: https://github.com/lib/pq/pull/1260
13+
[#1261]: https://github.com/lib/pq/pull/1261
14+
115
v1.11.1 (2025-01-29)
216
--------------------
317
This fixes two regressions present in the v1.11.0 release:

conn.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,20 +1188,27 @@ func (cn *conn) startup(cfg Config) error {
11881188
w := cn.writeBuf(0)
11891189
w.int32(proto.ProtocolVersion30)
11901190

1191-
w.string("user")
1192-
w.string(cfg.User)
1193-
w.string("database")
1194-
w.string(cfg.Database)
1191+
if cfg.User != "" {
1192+
w.string("user")
1193+
w.string(cfg.User)
1194+
}
1195+
if cfg.Database != "" {
1196+
w.string("database")
1197+
w.string(cfg.Database)
1198+
}
11951199
// w.string("replication") // Sent by libpq, but we don't support that.
1196-
w.string("options")
1197-
w.string(cfg.Options)
1200+
if cfg.Options != "" {
1201+
w.string("options")
1202+
w.string(cfg.Options)
1203+
}
11981204
if cfg.ApplicationName != "" {
11991205
w.string("application_name")
12001206
w.string(cfg.ApplicationName)
12011207
}
1202-
w.string("client_encoding")
1203-
w.string(cfg.ClientEncoding)
1204-
1208+
if cfg.ClientEncoding != "" {
1209+
w.string("client_encoding")
1210+
w.string(cfg.ClientEncoding)
1211+
}
12051212
for k, v := range cfg.Runtime {
12061213
w.string(k)
12071214
w.string(v)

0 commit comments

Comments
 (0)