-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
*: make sessionctx.Context depend on contexts in planner and expressi…
- Loading branch information
1 parent
fa340f3
commit 4e202a4
Showing
22 changed files
with
148 additions
and
66 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "context", | ||
srcs = ["context.go"], | ||
importpath = "github.com/pingcap/tidb/pkg/expression/context", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//pkg/infoschema/context", | ||
"//pkg/kv", | ||
"//pkg/sessionctx/variable", | ||
], | ||
) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2024 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package context | ||
|
||
import ( | ||
"fmt" | ||
|
||
infoschema "github.com/pingcap/tidb/pkg/infoschema/context" | ||
"github.com/pingcap/tidb/pkg/kv" | ||
"github.com/pingcap/tidb/pkg/sessionctx/variable" | ||
) | ||
|
||
// EvalContext is used to evaluate an expression | ||
type EvalContext interface { | ||
// GetSessionVars gets the session variables. | ||
GetSessionVars() *variable.SessionVars | ||
// Value returns the value associated with this context for key. | ||
Value(key fmt.Stringer) any | ||
// IsDDLOwner checks whether this session is DDL owner. | ||
IsDDLOwner() bool | ||
// GetAdvisoryLock acquires an advisory lock (aka GET_LOCK()). | ||
GetAdvisoryLock(string, int64) error | ||
// IsUsedAdvisoryLock checks for existing locks (aka IS_USED_LOCK()). | ||
IsUsedAdvisoryLock(string) uint64 | ||
// ReleaseAdvisoryLock releases an advisory lock (aka RELEASE_LOCK()). | ||
ReleaseAdvisoryLock(string) bool | ||
// ReleaseAllAdvisoryLocks releases all advisory locks that this session holds. | ||
ReleaseAllAdvisoryLocks() int | ||
// GetStore returns the store of session. | ||
GetStore() kv.Storage | ||
// GetInfoSchema returns the current infoschema | ||
GetInfoSchema() infoschema.InfoSchemaMetaVersion | ||
// GetDomainInfoSchema returns the latest information schema in domain | ||
GetDomainInfoSchema() infoschema.InfoSchemaMetaVersion | ||
} | ||
|
||
// BuildContext is used to build an expression | ||
type BuildContext interface { | ||
EvalContext | ||
// GetSessionVars gets the session variables. | ||
GetSessionVars() *variable.SessionVars | ||
// SetValue saves a value associated with this context for key. | ||
SetValue(key fmt.Stringer, value any) | ||
// BuiltinFunctionUsageInc increase the counting of each builtin function usage | ||
// Notice that this is a thread safe function | ||
BuiltinFunctionUsageInc(scalarFuncSigName string) | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "context", | ||
srcs = ["infoschema.go"], | ||
importpath = "github.com/pingcap/tidb/pkg/infoschema/context", | ||
visibility = ["//visibility:public"], | ||
) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2024 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package context | ||
|
||
// InfoSchemaMetaVersion is a workaround. Due to circular dependency, | ||
// can not return the complete interface. But SchemaMetaVersion is widely used for logging. | ||
// So we give a convenience for that. | ||
// FIXME: remove this interface | ||
type InfoSchemaMetaVersion interface { | ||
SchemaMetaVersion() int64 | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.