Skip to content

Commit

Permalink
优化api
Browse files Browse the repository at this point in the history
  • Loading branch information
Verthandii committed Jan 7, 2021
1 parent 99a0cd4 commit ea41016
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
9 changes: 5 additions & 4 deletions const.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ const (
_preparedStatementHeader = "X-Presto-Prepared-Statement"
_preparedStatementName = "_trino_go"

XTrinoUserHeader = "X-Trino-User"
_xTrinoUserHeader = "X-Trino-User"
_xTrinoSourceHeader = "X-Trino-Source"
_xTrinoCatalogHeader = "X-Trino-Catalog"
_xTrinoSchemaHeader = "X-Trino-Schema"
_xTrinoSessionHeader = "X-Trino-Session"

XPrestoUserHeader = "X-Presto-User"
_xPrestoUserHeader = "X-Presto-User"
_xPrestoSourceHeader = "X-Presto-Source"
_xPrestoCatalogHeader = "X-Presto-Catalog"
_xPrestoSchemaHeader = "X-Presto-Schema"
_xPrestoSessionHeader = "X-Presto-Session"

UserHeader = "User"
CallbackHeader = "Callback"

KerberosEnabledConfig = "KerberosEnabled"
Expand All @@ -29,14 +30,14 @@ const (
var (
vhs = map[version]map[string]string{
_trinoVersion: {
"user": XTrinoUserHeader,
"user": _xTrinoUserHeader,
"source": _xTrinoSourceHeader,
"catalog": _xTrinoCatalogHeader,
"schema": _xTrinoSchemaHeader,
"session": _xTrinoSessionHeader,
},
_prestoVersion: {
"user": XPrestoUserHeader,
"user": _xPrestoUserHeader,
"source": _xPrestoSourceHeader,
"catalog": _xPrestoCatalogHeader,
"schema": _xPrestoSchemaHeader,
Expand Down
3 changes: 2 additions & 1 deletion statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func (st *driverStmt) NumInput() int {
}

func (st *driverStmt) Exec(args []driver.Value) (driver.Result, error) {

return nil, ErrOperationNotSupported
}

Expand Down Expand Up @@ -134,7 +135,7 @@ func (st *driverStmt) QueryContext(ctx context.Context, args []driver.NamedValue
var ss []string
for _, arg := range args {
switch arg.Name {
case vhs[v]["user"]:
case UserHeader:
st.user = arg.Value.(string)
hs.Add(vhs[v]["user"], st.user)
case CallbackHeader:
Expand Down
10 changes: 6 additions & 4 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@ package trino

type version string

var (
v version = "Trino"
)

const (
_trinoVersion version = "Trino"
_prestoVersion version = "Presto"
)

var (
v = _trinoVersion
)

// VersionTrion 设置当前 header 头为 trino 所需的
func VersionTrino() {
v = _trinoVersion
}

// VersionPresto 设置当前 header 头为 persto 所需的
func VersionPresto() {
v = _prestoVersion
}

0 comments on commit ea41016

Please sign in to comment.