@@ -919,11 +919,13 @@ func (c *tidbMVCCInfoFunctionClass) getFunction(ctx BuildContext, args []Express
919
919
type builtinTiDBMVCCInfoSig struct {
920
920
baseBuiltinFunc
921
921
expropt.KVStorePropReader
922
+ expropt.PrivilegeCheckerPropReader
922
923
}
923
924
924
925
// RequiredOptionalEvalProps implements the RequireOptionalEvalProps interface.
925
926
func (b * builtinTiDBMVCCInfoSig ) RequiredOptionalEvalProps () OptionalEvalPropKeySet {
926
- return b .KVStorePropReader .RequiredOptionalEvalProps ()
927
+ return b .KVStorePropReader .RequiredOptionalEvalProps () |
928
+ b .PrivilegeCheckerPropReader .RequiredOptionalEvalProps ()
927
929
}
928
930
929
931
func (b * builtinTiDBMVCCInfoSig ) Clone () builtinFunc {
@@ -934,7 +936,11 @@ func (b *builtinTiDBMVCCInfoSig) Clone() builtinFunc {
934
936
935
937
// evalString evals a builtinTiDBMVCCInfoSig.
936
938
func (b * builtinTiDBMVCCInfoSig ) evalString (ctx EvalContext , row chunk.Row ) (string , bool , error ) {
937
- if ! ctx .RequestVerification ("" , "" , "" , mysql .SuperPriv ) {
939
+ privChecker , err := b .GetPrivilegeChecker (ctx )
940
+ if err != nil {
941
+ return "" , false , err
942
+ }
943
+ if ! privChecker .RequestVerification ("" , "" , "" , mysql .SuperPriv ) {
938
944
return "" , false , plannererrors .ErrSpecificAccessDenied .FastGenByArgs ("SUPER" )
939
945
}
940
946
s , isNull , err := b .args [0 ].EvalString (ctx , row )
@@ -1006,12 +1012,14 @@ type builtinTiDBEncodeRecordKeySig struct {
1006
1012
baseBuiltinFunc
1007
1013
expropt.InfoSchemaPropReader
1008
1014
expropt.SessionVarsPropReader
1015
+ expropt.PrivilegeCheckerPropReader
1009
1016
}
1010
1017
1011
1018
// RequiredOptionalEvalProps implements the RequireOptionalEvalProps interface.
1012
1019
func (b * builtinTiDBEncodeRecordKeySig ) RequiredOptionalEvalProps () OptionalEvalPropKeySet {
1013
1020
return b .InfoSchemaPropReader .RequiredOptionalEvalProps () |
1014
- b .SessionVarsPropReader .RequiredOptionalEvalProps ()
1021
+ b .SessionVarsPropReader .RequiredOptionalEvalProps () |
1022
+ b .PrivilegeCheckerPropReader .RequiredOptionalEvalProps ()
1015
1023
}
1016
1024
1017
1025
func (b * builtinTiDBEncodeRecordKeySig ) Clone () builtinFunc {
@@ -1029,7 +1037,11 @@ func (b *builtinTiDBEncodeRecordKeySig) evalString(ctx EvalContext, row chunk.Ro
1029
1037
if EncodeRecordKeyFromRow == nil {
1030
1038
return "" , false , errors .New ("EncodeRecordKeyFromRow is not initialized" )
1031
1039
}
1032
- recordKey , isNull , err := EncodeRecordKeyFromRow (ctx , is , b .args , row )
1040
+ privChecker , err := b .GetPrivilegeChecker (ctx )
1041
+ if err != nil {
1042
+ return "" , false , err
1043
+ }
1044
+ recordKey , isNull , err := EncodeRecordKeyFromRow (ctx , privChecker , is , b .args , row )
1033
1045
if isNull || err != nil {
1034
1046
if errors .ErrorEqual (err , plannererrors .ErrSpecificAccessDenied ) {
1035
1047
sv , err2 := b .GetSessionVars (ctx )
@@ -1072,12 +1084,14 @@ type builtinTiDBEncodeIndexKeySig struct {
1072
1084
baseBuiltinFunc
1073
1085
expropt.InfoSchemaPropReader
1074
1086
expropt.SessionVarsPropReader
1087
+ expropt.PrivilegeCheckerPropReader
1075
1088
}
1076
1089
1077
1090
// RequiredOptionalEvalProps implements the RequireOptionalEvalProps interface.
1078
1091
func (b * builtinTiDBEncodeIndexKeySig ) RequiredOptionalEvalProps () OptionalEvalPropKeySet {
1079
1092
return b .InfoSchemaPropReader .RequiredOptionalEvalProps () |
1080
- b .SessionVarsPropReader .RequiredOptionalEvalProps ()
1093
+ b .SessionVarsPropReader .RequiredOptionalEvalProps () |
1094
+ b .PrivilegeCheckerPropReader .RequiredOptionalEvalProps ()
1081
1095
}
1082
1096
1083
1097
func (b * builtinTiDBEncodeIndexKeySig ) Clone () builtinFunc {
@@ -1095,7 +1109,11 @@ func (b *builtinTiDBEncodeIndexKeySig) evalString(ctx EvalContext, row chunk.Row
1095
1109
if EncodeIndexKeyFromRow == nil {
1096
1110
return "" , false , errors .New ("EncodeIndexKeyFromRow is not initialized" )
1097
1111
}
1098
- idxKey , isNull , err := EncodeIndexKeyFromRow (ctx , is , b .args , row )
1112
+ privChecker , err := b .GetPrivilegeChecker (ctx )
1113
+ if err != nil {
1114
+ return "" , false , err
1115
+ }
1116
+ idxKey , isNull , err := EncodeIndexKeyFromRow (ctx , privChecker , is , b .args , row )
1099
1117
if isNull || err != nil {
1100
1118
if errors .ErrorEqual (err , plannererrors .ErrSpecificAccessDenied ) {
1101
1119
sv , err2 := b .GetSessionVars (ctx )
@@ -1133,10 +1151,10 @@ func (c *tidbDecodeKeyFunctionClass) getFunction(ctx BuildContext, args []Expres
1133
1151
var DecodeKeyFromString func (types.Context , infoschema.MetaOnlyInfoSchema , string ) string
1134
1152
1135
1153
// EncodeRecordKeyFromRow is used to encode record key by expressions.
1136
- var EncodeRecordKeyFromRow func (ctx EvalContext , is infoschema.MetaOnlyInfoSchema , args []Expression , row chunk.Row ) ([]byte , bool , error )
1154
+ var EncodeRecordKeyFromRow func (ctx EvalContext , checker expropt. PrivilegeChecker , is infoschema.MetaOnlyInfoSchema , args []Expression , row chunk.Row ) ([]byte , bool , error )
1137
1155
1138
1156
// EncodeIndexKeyFromRow is used to encode index key by expressions.
1139
- var EncodeIndexKeyFromRow func (ctx EvalContext , is infoschema.MetaOnlyInfoSchema , args []Expression , row chunk.Row ) ([]byte , bool , error )
1157
+ var EncodeIndexKeyFromRow func (ctx EvalContext , checker expropt. PrivilegeChecker , is infoschema.MetaOnlyInfoSchema , args []Expression , row chunk.Row ) ([]byte , bool , error )
1140
1158
1141
1159
type builtinTiDBDecodeKeySig struct {
1142
1160
baseBuiltinFunc
@@ -1173,14 +1191,20 @@ func (b *builtinTiDBDecodeKeySig) evalString(ctx EvalContext, row chunk.Row) (st
1173
1191
1174
1192
type tidbDecodeSQLDigestsFunctionClass struct {
1175
1193
baseFunctionClass
1194
+ expropt.PrivilegeCheckerPropReader
1176
1195
}
1177
1196
1178
1197
func (c * tidbDecodeSQLDigestsFunctionClass ) getFunction (ctx BuildContext , args []Expression ) (builtinFunc , error ) {
1179
1198
if err := c .verifyArgs (args ); err != nil {
1180
1199
return nil , err
1181
1200
}
1182
1201
1183
- if ! ctx .GetEvalCtx ().RequestVerification ("" , "" , "" , mysql .ProcessPriv ) {
1202
+ privChecker , err := c .GetPrivilegeChecker (ctx .GetEvalCtx ())
1203
+ if err != nil {
1204
+ return nil , err
1205
+ }
1206
+
1207
+ if ! privChecker .RequestVerification ("" , "" , "" , mysql .ProcessPriv ) {
1184
1208
return nil , errSpecificAccessDenied .GenWithStackByArgs ("PROCESS" )
1185
1209
}
1186
1210
@@ -1202,12 +1226,14 @@ type builtinTiDBDecodeSQLDigestsSig struct {
1202
1226
baseBuiltinFunc
1203
1227
expropt.SessionVarsPropReader
1204
1228
expropt.SQLExecutorPropReader
1229
+ expropt.PrivilegeCheckerPropReader
1205
1230
}
1206
1231
1207
1232
// RequiredOptionalEvalProps implements the RequireOptionalEvalProps interface.
1208
1233
func (b * builtinTiDBDecodeSQLDigestsSig ) RequiredOptionalEvalProps () OptionalEvalPropKeySet {
1209
1234
return b .SessionVarsPropReader .RequiredOptionalEvalProps () |
1210
- b .SQLExecutorPropReader .RequiredOptionalEvalProps ()
1235
+ b .SQLExecutorPropReader .RequiredOptionalEvalProps () |
1236
+ b .PrivilegeCheckerPropReader .RequiredOptionalEvalProps ()
1211
1237
}
1212
1238
1213
1239
func (b * builtinTiDBDecodeSQLDigestsSig ) Clone () builtinFunc {
@@ -1217,6 +1243,15 @@ func (b *builtinTiDBDecodeSQLDigestsSig) Clone() builtinFunc {
1217
1243
}
1218
1244
1219
1245
func (b * builtinTiDBDecodeSQLDigestsSig ) evalString (ctx EvalContext , row chunk.Row ) (string , bool , error ) {
1246
+ privChecker , err := b .GetPrivilegeChecker (ctx )
1247
+ if err != nil {
1248
+ return "" , true , err
1249
+ }
1250
+
1251
+ if ! privChecker .RequestVerification ("" , "" , "" , mysql .ProcessPriv ) {
1252
+ return "" , true , errSpecificAccessDenied .GenWithStackByArgs ("PROCESS" )
1253
+ }
1254
+
1220
1255
args := b .getArgs ()
1221
1256
digestsStr , isNull , err := args [0 ].EvalString (ctx , row )
1222
1257
if err != nil {
@@ -1443,11 +1478,13 @@ type builtinNextValSig struct {
1443
1478
baseBuiltinFunc
1444
1479
expropt.SequenceOperatorPropReader
1445
1480
expropt.SessionVarsPropReader
1481
+ expropt.PrivilegeCheckerPropReader
1446
1482
}
1447
1483
1448
1484
func (b * builtinNextValSig ) RequiredOptionalEvalProps () OptionalEvalPropKeySet {
1449
1485
return b .SequenceOperatorPropReader .RequiredOptionalEvalProps () |
1450
- b .SessionVarsPropReader .RequiredOptionalEvalProps ()
1486
+ b .SessionVarsPropReader .RequiredOptionalEvalProps () |
1487
+ b .PrivilegeCheckerPropReader .RequiredOptionalEvalProps ()
1451
1488
}
1452
1489
1453
1490
func (b * builtinNextValSig ) Clone () builtinFunc {
@@ -1477,7 +1514,11 @@ func (b *builtinNextValSig) evalInt(ctx EvalContext, row chunk.Row) (int64, bool
1477
1514
}
1478
1515
// Do the privilege check.
1479
1516
user := vars .User
1480
- if ! ctx .RequestVerification (db , seq , "" , mysql .InsertPriv ) {
1517
+ privChecker , err := b .GetPrivilegeChecker (ctx )
1518
+ if err != nil {
1519
+ return 0 , false , err
1520
+ }
1521
+ if ! privChecker .RequestVerification (db , seq , "" , mysql .InsertPriv ) {
1481
1522
return 0 , false , errSequenceAccessDenied .GenWithStackByArgs ("INSERT" , user .AuthUsername , user .AuthHostname , seq )
1482
1523
}
1483
1524
nextVal , err := sequence .GetSequenceNextVal ()
@@ -1510,11 +1551,13 @@ type builtinLastValSig struct {
1510
1551
baseBuiltinFunc
1511
1552
expropt.SequenceOperatorPropReader
1512
1553
expropt.SessionVarsPropReader
1554
+ expropt.PrivilegeCheckerPropReader
1513
1555
}
1514
1556
1515
1557
func (b * builtinLastValSig ) RequiredOptionalEvalProps () OptionalEvalPropKeySet {
1516
1558
return b .SequenceOperatorPropReader .RequiredOptionalEvalProps () |
1517
- b .SessionVarsPropReader .RequiredOptionalEvalProps ()
1559
+ b .SessionVarsPropReader .RequiredOptionalEvalProps () |
1560
+ b .PrivilegeCheckerPropReader .RequiredOptionalEvalProps ()
1518
1561
}
1519
1562
1520
1563
func (b * builtinLastValSig ) Clone () builtinFunc {
@@ -1544,7 +1587,11 @@ func (b *builtinLastValSig) evalInt(ctx EvalContext, row chunk.Row) (int64, bool
1544
1587
}
1545
1588
// Do the privilege check.
1546
1589
user := vars .User
1547
- if ! ctx .RequestVerification (db , seq , "" , mysql .SelectPriv ) {
1590
+ privChecker , err := b .GetPrivilegeChecker (ctx )
1591
+ if err != nil {
1592
+ return 0 , false , err
1593
+ }
1594
+ if ! privChecker .RequestVerification (db , seq , "" , mysql .SelectPriv ) {
1548
1595
return 0 , false , errSequenceAccessDenied .GenWithStackByArgs ("SELECT" , user .AuthUsername , user .AuthHostname , seq )
1549
1596
}
1550
1597
return vars .SequenceState .GetLastValue (sequence .GetSequenceID ())
@@ -1571,11 +1618,13 @@ type builtinSetValSig struct {
1571
1618
baseBuiltinFunc
1572
1619
expropt.SequenceOperatorPropReader
1573
1620
expropt.SessionVarsPropReader
1621
+ expropt.PrivilegeCheckerPropReader
1574
1622
}
1575
1623
1576
1624
func (b * builtinSetValSig ) RequiredOptionalEvalProps () OptionalEvalPropKeySet {
1577
1625
return b .SequenceOperatorPropReader .RequiredOptionalEvalProps () |
1578
- b .SessionVarsPropReader .RequiredOptionalEvalProps ()
1626
+ b .SessionVarsPropReader .RequiredOptionalEvalProps () |
1627
+ b .PrivilegeCheckerPropReader .RequiredOptionalEvalProps ()
1579
1628
}
1580
1629
1581
1630
func (b * builtinSetValSig ) Clone () builtinFunc {
@@ -1605,7 +1654,11 @@ func (b *builtinSetValSig) evalInt(ctx EvalContext, row chunk.Row) (int64, bool,
1605
1654
}
1606
1655
// Do the privilege check.
1607
1656
user := vars .User
1608
- if ! ctx .RequestVerification (db , seq , "" , mysql .InsertPriv ) {
1657
+ privChecker , err := b .GetPrivilegeChecker (ctx )
1658
+ if err != nil {
1659
+ return 0 , false , err
1660
+ }
1661
+ if ! privChecker .RequestVerification (db , seq , "" , mysql .InsertPriv ) {
1609
1662
return 0 , false , errSequenceAccessDenied .GenWithStackByArgs ("INSERT" , user .AuthUsername , user .AuthHostname , seq )
1610
1663
}
1611
1664
setValue , isNull , err := b .args [1 ].EvalInt (ctx , row )
0 commit comments