Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading