Skip to content

Commit

Permalink
sql: support read-only SERVER_VERSION
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanlewis committed Dec 8, 2016
1 parent 0b9a770 commit ee2dfac
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/sql/pgwire/v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ var statusReportParams = map[string]string{
// of this package. We specify this version to avoid having to support old
// code paths which various client tools fall back to if they can't
// determine that the server is new enough.
"server_version": "9.5.0",
"server_version": sql.PgServerVersion,
}

// handleAuthentication should discuss with the client to arrange
Expand Down
6 changes: 6 additions & 0 deletions pkg/sql/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ import (
"github.com/pkg/errors"
)

const (
// PgServerVersion is the latest version of postgres that we claim to support.
PgServerVersion = "9.5.0"
)

var varGen = map[string]func(p *planner) string{
`DATABASE`: func(p *planner) string { return p.session.Database },
`DEFAULT_TRANSACTION_ISOLATION`: func(p *planner) string { return p.session.DefaultIsolationLevel.String() },
Expand All @@ -37,6 +42,7 @@ var varGen = map[string]func(p *planner) string{
`TRANSACTION PRIORITY`: func(p *planner) string { return p.txn.UserPriority.String() },
`MAX_INDEX_KEYS`: func(_ *planner) string { return "32" },
`SEARCH_PATH`: func(p *planner) string { return strings.Join(p.session.SearchPath, ", ") },
`SERVER_VERSION`: func(_ *planner) string { return PgServerVersion },
}
var varNames = func() []string {
res := make([]string, 0, len(varGen))
Expand Down
3 changes: 3 additions & 0 deletions pkg/sql/testdata/pg_catalog
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,7 @@ database test NULL NULL NULL s
default_transaction_isolation SERIALIZABLE NULL NULL NULL string
max_index_keys 32 NULL NULL NULL string
search_path pg_catalog NULL NULL NULL string
server_version 9.5.0 NULL NULL NULL string
syntax Traditional NULL NULL NULL string
time zone UTC NULL NULL NULL string
transaction isolation level SERIALIZABLE NULL NULL NULL string
Expand All @@ -867,6 +868,7 @@ database test NULL user NULL test
default_transaction_isolation SERIALIZABLE NULL user NULL SERIALIZABLE SERIALIZABLE
max_index_keys 32 NULL user NULL 32 32
search_path pg_catalog NULL user NULL pg_catalog pg_catalog
server_version 9.5.0 NULL user NULL 9.5.0 9.5.0
syntax Traditional NULL user NULL Traditional Traditional
time zone UTC NULL user NULL UTC UTC
transaction isolation level SERIALIZABLE NULL user NULL SERIALIZABLE SERIALIZABLE
Expand All @@ -880,6 +882,7 @@ database NULL NULL NULL NULL NULL
default_transaction_isolation NULL NULL NULL NULL NULL
max_index_keys NULL NULL NULL NULL NULL
search_path NULL NULL NULL NULL NULL
server_version NULL NULL NULL NULL NULL
syntax NULL NULL NULL NULL NULL
time zone NULL NULL NULL NULL NULL
transaction isolation level NULL NULL NULL NULL NULL
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/testdata/set
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ DATABASE foo
DEFAULT_TRANSACTION_ISOLATION SERIALIZABLE
MAX_INDEX_KEYS 32
SEARCH_PATH pg_catalog
SERVER_VERSION 9.5.0
SYNTAX Modern
TIME ZONE UTC
TRANSACTION ISOLATION LEVEL SERIALIZABLE
Expand Down

0 comments on commit ee2dfac

Please sign in to comment.