Skip to content

Commit 3f05e8c

Browse files
committed
去掉多余代码
1 parent 9dbad45 commit 3f05e8c

File tree

1 file changed

+0
-49
lines changed

1 file changed

+0
-49
lines changed

src/main/java/io/mycat/server/interceptor/impl/GlobalTableUtil.java

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -353,55 +353,6 @@ public static String convertUpdateSQL(String sql){
353353
}
354354
}
355355

356-
/**
357-
* UPDATE [LOW_PRIORITY] [IGNORE] table_reference
358-
SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...
359-
[WHERE where_condition]
360-
[ORDER BY ...]
361-
[LIMIT row_count]
362-
363-
Multiple-table syntax:
364-
365-
UPDATE [LOW_PRIORITY] [IGNORE] table_references
366-
SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...
367-
[WHERE where_condition]
368-
369-
update user, tuser set user.name='dddd',tuser.pwd='aaa'
370-
where user.id=2 and tuser.id=0;
371-
* @param sql update tuser set pwd='aaa', name='digdee' where id=0;
372-
* @return
373-
*/
374-
private static String convertUpdateSQL2(String sql, String tableName){
375-
// update user, tuser set user.name='dddd',tuser.pwd='aaa'
376-
if(tableName.indexOf(',') != -1){
377-
LOGGER.warn("Do not support Multiple-table udpate syntax...");
378-
return sql;
379-
}
380-
try{
381-
if(!isGlobalTable(tableName))
382-
return sql;
383-
384-
// update company set name=xx, _mycat_op_time=11111111,sex=xxx where id=2
385-
String regStr = ".*(?i)update.*set.*" + GLOBAL_TABLE_MYCAT_COLUMN + "\\s*=.*";
386-
if(Pattern.matches(regStr, sql)){
387-
LOGGER.warn("Do not update value to inner column: " + GLOBAL_TABLE_MYCAT_COLUMN);
388-
// "update company set name=xx, _mycat_op_time=11111111,addr=xxx;";
389-
// "update company set name=xx, _mycat_op_time='11111111',addr=xxx;";
390-
// "update company set name=xx, _mycat_op_time=\"11111111\",addr=xxx";
391-
return sql.replaceAll(GLOBAL_TABLE_MYCAT_COLUMN+"=[\"|']{0,1}\\d*[\"|']{0,1}",
392-
GLOBAL_TABLE_MYCAT_COLUMN+"="+operationTimestamp);
393-
}
394-
395-
return new StringBuilder(100).append(sql.substring(0, sql.length()-1)) // 先去掉末尾的;
396-
.append(",").append(GLOBAL_TABLE_MYCAT_COLUMN).append("=")
397-
.append(operationTimestamp).append(";").toString(); // 在加上末尾的;
398-
399-
}catch(Exception e){
400-
LOGGER.warn(e.getMessage());
401-
return sql;
402-
}
403-
}
404-
405356
private static void getGlobalTable(){
406357
MycatConfig config = MycatServer.getInstance().getConfig();
407358
Map<String, SchemaConfig> schemaMap = config.getSchemas();

0 commit comments

Comments
 (0)