Skip to content

Commit bd6c187

Browse files
committed
Nicer error
It's okay to assume 3.x for now; there may never be a 4.x protocol and easy enough to fix if there is.
1 parent 2483f7d commit bd6c187

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ func (cn *conn) startup(cfg Config) error {
12471247
newestMinor := r.int32()
12481248
serverVersion := proto.ProtocolVersion30&0xFFFF0000 | newestMinor
12491249
if serverVersion < cfg.MinProtocolVersion.proto() {
1250-
return fmt.Errorf("pq: server does not support minimum protocol version (server newest minor: %d)", newestMinor)
1250+
return fmt.Errorf("pq: protocol version mismatch: min_protocol_version=%s; server supports up to 3.%d", cfg.MinProtocolVersion, newestMinor)
12511251
}
12521252
case proto.ReadyForQuery:
12531253
cn.processReadyForQuery(r)

connector_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ func TestProtocolVersion(t *testing.T) {
818818
{3.2, "3.2", "3.2", key32, ""},
819819

820820
{3.0, "3.0", "3.2", key30, ""},
821-
{3.0, "3.2", "3.2", key30, `server does not support minimum protocol version (server newest minor: 0)`},
821+
{3.0, "3.2", "3.2", key30, `pq: protocol version mismatch: min_protocol_version=3.2; server supports up to 3.0`},
822822

823823
{3.2, "3.9", "3.0", nil, `"3.9" is not supported`},
824824
{3.2, "3.0", "3.9", nil, `"3.9" is not supported`},

0 commit comments

Comments
 (0)