Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expression: Fix arg validation for tidb_mvcc_info() #58310

Merged
merged 4 commits into from
Dec 19, 2024
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
3 changes: 3 additions & 0 deletions pkg/expression/builtin_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,9 @@ type tidbMVCCInfoFunctionClass struct {
}

func (c *tidbMVCCInfoFunctionClass) getFunction(ctx BuildContext, args []Expression) (builtinFunc, error) {
if err := c.verifyArgs(args); err != nil {
return nil, err
}
bf, err := newBaseBuiltinFuncWithTp(ctx, c.funcName, args, types.ETString, types.ETString)
if err != nil {
return nil, err
Expand Down
3 changes: 0 additions & 3 deletions pkg/parser/ast/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,6 @@ const (
TiDBEncodeIndexKey = "tidb_encode_index_key"
TiDBDecodeBase64Key = "tidb_decode_base64_key"

// MVCC information fetching function.
GetMvccInfo = "get_mvcc_info"

// Sequence function.
NextVal = "nextval"
LastVal = "lastval"
Expand Down
1 change: 0 additions & 1 deletion pkg/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,6 @@ func TestBuiltin(t *testing.T) {
{`SELECT tidb_decode_key('abc');`, true, "SELECT TIDB_DECODE_KEY(_UTF8MB4'abc')"},
{`SELECT tidb_decode_base64_key('abc');`, true, "SELECT TIDB_DECODE_BASE64_KEY(_UTF8MB4'abc')"},
{`SELECT tidb_decode_sql_digests('[]');`, true, "SELECT TIDB_DECODE_SQL_DIGESTS(_UTF8MB4'[]')"},
{`SELECT get_mvcc_info('hex', '0xabc');`, true, "SELECT GET_MVCC_INFO(_UTF8MB4'hex', _UTF8MB4'0xabc')"},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIDB_MVCC_INFO() works, GET_MVCC_INFO() does not and seems to be a half renamed or half implemented thing.


// for time fsp
{"CREATE TABLE t( c1 TIME(2), c2 DATETIME(2), c3 TIMESTAMP(2) );", true, "CREATE TABLE `t` (`c1` TIME(2),`c2` DATETIME(2),`c3` TIMESTAMP(2))"},
Expand Down
2 changes: 2 additions & 0 deletions tests/integrationtest/r/expression/misc.result
Original file line number Diff line number Diff line change
Expand Up @@ -1021,3 +1021,5 @@ tab0 CREATE TABLE `tab0` (
`col1` int DEFAULT NULL,
`col2` int DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
SELECT TIDB_MVCC_INFO();
Error 1582 (42000): Incorrect parameter count in the call to native function 'tidb_mvcc_info'
4 changes: 4 additions & 0 deletions tests/integrationtest/t/expression/misc.test
Original file line number Diff line number Diff line change
Expand Up @@ -611,3 +611,7 @@ drop table if exists tab0;
CREATE TABLE tab0(col0 INTEGER, col1 INTEGER, col2 INTEGER);
SELECT + - (- CASE + col0 WHEN + CAST( col0 AS SIGNED ) THEN col1 WHEN 79 THEN NULL WHEN + - col1 THEN col0 / + col0 END ) * - 16 FROM tab0;
show create table tab0;

# TestTiDBMVCCInfo
-- error 1582
SELECT TIDB_MVCC_INFO();