Skip to content

Commit

Permalink
Merge branch 'slack-19.0' into slack-19.0-vtorc-messages
Browse files Browse the repository at this point in the history
  • Loading branch information
makinje16 committed Feb 4, 2025
2 parents 1534eba + d2d0c36 commit 6c7c5e8
Show file tree
Hide file tree
Showing 23 changed files with 6,529 additions and 6,373 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ require (
github.com/kr/text v0.2.0
github.com/mitchellh/mapstructure v1.5.0
github.com/nsf/jsondiff v0.0.0-20210926074059-1e845ec5d249
github.com/slackhq/vitess-addons v0.19.7
github.com/slackhq/vitess-addons v0.19.8
github.com/slok/noglog v0.2.0
github.com/spf13/afero v1.11.0
github.com/spf13/jwalterweatherman v1.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,8 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/sjmudd/stopwatch v0.1.1 h1:x45OvxFB5OtCkjvYtzRF5fWB857Jzjjk84Oyd5C5ebw=
github.com/sjmudd/stopwatch v0.1.1/go.mod h1:BLw0oIQJ1YLXBO/q9ufK/SgnKBVIkC2qrm6uy78Zw6U=
github.com/slackhq/vitess-addons v0.19.7 h1:3rP5jIjTMAJSInl92ePn6BevACvVVT4DV3oynwuQKRo=
github.com/slackhq/vitess-addons v0.19.7/go.mod h1:slG5BxqN541wVV5Y5tuHE3z1CwCXj9GVRmLX5wkI/zw=
github.com/slackhq/vitess-addons v0.19.8 h1:AjAbXkrvdciDeiJ4a3CG57rKcg1MAHm5JPsfwryu3XU=
github.com/slackhq/vitess-addons v0.19.8/go.mod h1:slG5BxqN541wVV5Y5tuHE3z1CwCXj9GVRmLX5wkI/zw=
github.com/slok/noglog v0.2.0 h1:1czu4l2EoJ8L92UwdSXXa1Y+c5TIjFAFm2P+mjej95E=
github.com/slok/noglog v0.2.0/go.mod h1:TfKxwpEZPT+UA83bQ6RME146k0MM4e8mwHLf6bhcGDI=
github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
Expand Down
1 change: 1 addition & 0 deletions go/test/endtoend/vtgate/queries/misc/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ func TestHighNumberOfParams(t *testing.T) {
}

func TestPrepareStatements(t *testing.T) {
utils.SkipIfBinaryIsBelowVersion(t, 17, "vtgate")
mcmp, closer := start(t)
defer closer()

Expand Down
91 changes: 91 additions & 0 deletions go/vt/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,94 @@ func (lrms *logRotateMaxSize) String() string {
func (lrms *logRotateMaxSize) Type() string {
return "uint64"
}

type PrefixedLogger struct {
prefix string
}

func NewPrefixedLogger(prefix string) *PrefixedLogger {
return &PrefixedLogger{prefix: prefix + ": "}
}

func (pl *PrefixedLogger) V(level glog.Level) glog.Verbose {
return V(level)
}

func (pl *PrefixedLogger) Flush() {
Flush()
}

func (pl *PrefixedLogger) Info(args ...any) {
args = append([]interface{}{pl.prefix}, args...)
Info(args...)
}

func (pl *PrefixedLogger) Infof(format string, args ...any) {
args = append([]interface{}{pl.prefix}, args...)
Infof("%s"+format, args...)
}

func (pl *PrefixedLogger) InfoDepth(depth int, args ...any) {
args = append([]interface{}{pl.prefix}, args...)
InfoDepth(depth, args...)
}

func (pl *PrefixedLogger) Warning(args ...any) {
args = append([]interface{}{pl.prefix}, args...)
Warning(args...)
}

func (pl *PrefixedLogger) Warningf(format string, args ...any) {
args = append([]interface{}{pl.prefix}, args...)
Warningf("%s"+format, args...)
}

func (pl *PrefixedLogger) WarningDepth(depth int, args ...any) {
args = append([]interface{}{pl.prefix}, args...)
WarningDepth(depth, args...)
}

func (pl *PrefixedLogger) Error(args ...any) {
args = append([]interface{}{pl.prefix}, args...)
Error(args...)
}

func (pl *PrefixedLogger) Errorf(format string, args ...any) {
args = append([]interface{}{pl.prefix}, args...)
Errorf("%s"+format, args...)
}

func (pl *PrefixedLogger) ErrorDepth(depth int, args ...any) {
args = append([]interface{}{pl.prefix}, args...)
ErrorDepth(depth, args...)
}

func (pl *PrefixedLogger) Exit(args ...any) {
args = append([]interface{}{pl.prefix}, args...)
Exit(args...)
}

func (pl *PrefixedLogger) Exitf(format string, args ...any) {
args = append([]interface{}{pl.prefix}, args...)
Exitf("%s"+format, args...)
}

func (pl *PrefixedLogger) ExitDepth(depth int, args ...any) {
args = append([]interface{}{pl.prefix}, args...)
ExitDepth(depth, args...)
}

func (pl *PrefixedLogger) Fatal(args ...any) {
args = append([]interface{}{pl.prefix}, args...)
Fatal(args...)
}

func (pl *PrefixedLogger) Fatalf(format string, args ...any) {
args = append([]interface{}{pl.prefix}, args...)
Fatalf("%s"+format, args...)
}

func (pl *PrefixedLogger) FatalDepth(depth int, args ...any) {
args = append([]interface{}{pl.prefix}, args...)
FatalDepth(depth, args...)
}
2 changes: 1 addition & 1 deletion go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -2498,7 +2498,7 @@ type (
// supported functions are documented in the grammar
CurTimeFuncExpr struct {
Name IdentifierCI
Fsp int // fractional seconds precision, integer from 0 to 6 or an Argument
Fsp Expr // fractional seconds precision, integer from 0 to 6 or an Argument
}

// JSONPrettyExpr represents the function and argument for JSON_PRETTY()
Expand Down
1 change: 1 addition & 0 deletions go/vt/sqlparser/ast_clone.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion go/vt/sqlparser/ast_copy_on_rewrite.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions go/vt/sqlparser/ast_equals.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions go/vt/sqlparser/ast_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -1548,8 +1548,8 @@ func (node *WeightStringFuncExpr) Format(buf *TrackedBuffer) {

// Format formats the node.
func (node *CurTimeFuncExpr) Format(buf *TrackedBuffer) {
if node.Fsp > 0 {
buf.astPrintf(node, "%#s(%d)", node.Name.String(), node.Fsp)
if node.Fsp != nil {
buf.astPrintf(node, "%#s(%v)", node.Name.String(), node.Fsp)
} else {
buf.astPrintf(node, "%#s()", node.Name.String())
}
Expand Down
4 changes: 2 additions & 2 deletions go/vt/sqlparser/ast_format_fast.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions go/vt/sqlparser/ast_rewrite.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions go/vt/sqlparser/ast_visit.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions go/vt/sqlparser/cached_size.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions go/vt/sqlparser/normalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ func (nz *normalizer) walkStatementUp(cursor *Cursor) bool {
if !isLiteral {
return true
}
_, isCurTimeFunc := cursor.Parent().(*CurTimeFuncExpr)
if isCurTimeFunc {
return true
}
nz.convertLiteral(node, cursor)
return nz.err == nil // only continue if we haven't found any errors
}
Expand Down Expand Up @@ -133,6 +137,8 @@ func (nz *normalizer) walkDownSelect(node, parent SQLNode) bool {
case *ConvertType:
// we should not rewrite the type description
return false
case *CurTimeFuncExpr:
return false
}
return nz.err == nil // only continue if we haven't found any errors
}
Expand Down
12 changes: 12 additions & 0 deletions go/vt/sqlparser/normalizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,18 @@ func TestNormalize(t *testing.T) {
"bv1": sqltypes.Int64BindVariable(1),
"bv2": sqltypes.Int64BindVariable(0),
},
}, {
// we don't want to replace literals in cur time function calls.
in: `insert into t1(id2) values (NOW(1))`,
outstmt: `insert into t1(id2) values (now(1))`,
outbv: map[string]*querypb.BindVariable{},
}, {
// we don't want to replace literals in cur time function calls.
in: `select (select now(2)) from (select 1 from dual where NOW(1) < 2) as t`,
outstmt: `select (select now(2) from dual) from (select 1 from dual where now(1) < :bv1 /* INT64 */) as t`,
outbv: map[string]*querypb.BindVariable{
"bv1": sqltypes.Int64BindVariable(2),
},
}}
parser := NewTestParser()
for _, tc := range testcases {
Expand Down
2 changes: 2 additions & 0 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,8 @@ var (
input: "select /* utc_timestamp as func */ utc_timestamp() from t",
}, {
input: "select /* utc_timestamp with fsp */ utc_timestamp(1) from t",
}, {
input: "select /* utc_timestamp with fsp */ utc_timestamp(:val1) from t",
}, {
input: "select /* utc_time */ utc_time() from t",
}, {
Expand Down
Loading

0 comments on commit 6c7c5e8

Please sign in to comment.