Skip to content

Commit

Permalink
removeBackQuote
Browse files Browse the repository at this point in the history
  • Loading branch information
yanhuqing666 committed Mar 8, 2017
1 parent 0b144e5 commit 3c51b88
Show file tree
Hide file tree
Showing 18 changed files with 67 additions and 260 deletions.
7 changes: 0 additions & 7 deletions conf/dnindex.properties

This file was deleted.

170 changes: 0 additions & 170 deletions src/main/java/io/mycat/memory/unsafe/utils/sort/TestSorter.java

This file was deleted.

18 changes: 9 additions & 9 deletions src/main/java/io/mycat/meta/ProxyMetaManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,11 @@ private void alterTable(String schema, SQLAlterTableStatement alterStatement, bo
}
} else if (alterItem instanceof SQLAlterTableDropIndex) {
SQLAlterTableDropIndex dropIndex = (SQLAlterTableDropIndex) alterItem;
String dropName = StringUtil.removeBackquote(dropIndex.getIndexName().getSimpleName());
String dropName = StringUtil.removeBackQuote(dropIndex.getIndexName().getSimpleName());
dropIndex(tmBuilder, dropName);
} else if (alterItem instanceof SQLAlterTableDropKey) {
SQLAlterTableDropKey dropIndex = (SQLAlterTableDropKey) alterItem;
String dropName = StringUtil.removeBackquote(dropIndex.getKeyName().getSimpleName());
String dropName = StringUtil.removeBackQuote(dropIndex.getKeyName().getSimpleName());
dropIndex(tmBuilder, dropName);
} else if (alterItem instanceof MySqlAlterTableChangeColumn) {
autoColumnIndex = changeColumn(cols, (MySqlAlterTableChangeColumn) alterItem);
Expand Down Expand Up @@ -610,7 +610,7 @@ private void dropIndex(String schema, SQLDropIndexStatement dropIndexStatement,
}
if (orgTbMeta != null) {
TableMeta.Builder tmBuilder = orgTbMeta.toBuilder();
String dropName = StringUtil.removeBackquote(((SQLIdentifierExpr) dropIndexStatement.getIndexName()).getName());
String dropName = StringUtil.removeBackQuote(((SQLIdentifierExpr) dropIndexStatement.getIndexName()).getName());
dropIndex(tmBuilder, dropName);
}
} catch (Exception e) {
Expand Down Expand Up @@ -672,7 +672,7 @@ private int addColumn(List<ColumnMeta> columnMetas, SQLAlterTableAddColumn addCo
if (isFirst) {
addIndex = 0;
} else {
String afterColName = StringUtil.removeBackquote(afterColumn.getSimpleName());
String afterColName = StringUtil.removeBackQuote(afterColumn.getSimpleName());
for (int i = 0; i < columnMetas.size(); i++) {
String colName = columnMetas.get(i).getName();
if (afterColName.equalsIgnoreCase(colName)) {
Expand Down Expand Up @@ -701,7 +701,7 @@ private int addColumn(List<ColumnMeta> columnMetas, SQLAlterTableAddColumn addCo

private int changeColumn(List<ColumnMeta> columnMetas, MySqlAlterTableChangeColumn changeColumn) {
int autoColumnIndex = -1;
String changeColName = StringUtil.removeBackquote(changeColumn.getColumnName().getSimpleName());
String changeColName = StringUtil.removeBackQuote(changeColumn.getColumnName().getSimpleName());
for (int i = 0; i < columnMetas.size(); i++) {
String colName = columnMetas.get(i).getName();
if (changeColName.equalsIgnoreCase(colName)) {
Expand All @@ -715,7 +715,7 @@ private int changeColumn(List<ColumnMeta> columnMetas, MySqlAlterTableChangeColu
if (isFirst) {
changeIndex = 0;
} else if (afterColumn != null) {
String afterColName = StringUtil.removeBackquote(((SQLIdentifierExpr) afterColumn).getName());
String afterColName = StringUtil.removeBackQuote(((SQLIdentifierExpr) afterColumn).getName());
for (int i = 0; i < columnMetas.size(); i++) {
String colName = columnMetas.get(i).getName();
if (afterColName.equalsIgnoreCase(colName)) {
Expand All @@ -736,7 +736,7 @@ private int changeColumn(List<ColumnMeta> columnMetas, MySqlAlterTableChangeColu

private void dropColumn(List<ColumnMeta> columnMetas, SQLAlterTableDropColumnItem dropColumn) {
for (SQLName dropName : dropColumn.getColumns()) {
String dropColName = StringUtil.removeBackquote(dropName.getSimpleName());
String dropColName = StringUtil.removeBackQuote(dropName.getSimpleName());
for (int i = 0; i < columnMetas.size(); i++) {
String colName = columnMetas.get(i).getName();
if (dropColName.equalsIgnoreCase(colName)) {
Expand All @@ -750,7 +750,7 @@ private void dropColumn(List<ColumnMeta> columnMetas, SQLAlterTableDropColumnIte
private int modifyColumn(List<ColumnMeta> columnMetas, MySqlAlterTableModifyColumn modifyColumn) {
int autoColumnIndex = -1;
SQLColumnDefinition modifyColDef = modifyColumn.getNewColumnDefinition();
String modifyColName = StringUtil.removeBackquote(modifyColDef.getName().getSimpleName());
String modifyColName = StringUtil.removeBackQuote(modifyColDef.getName().getSimpleName());
for (int i = 0; i < columnMetas.size(); i++) {
String colName = columnMetas.get(i).getName();
if (modifyColName.equalsIgnoreCase(colName)) {
Expand All @@ -764,7 +764,7 @@ private int modifyColumn(List<ColumnMeta> columnMetas, MySqlAlterTableModifyColu
if (isFirst) {
modifyIndex = 0;
} else if (afterColumn != null) {
String afterColName = StringUtil.removeBackquote(((SQLIdentifierExpr) afterColumn).getName());
String afterColName = StringUtil.removeBackQuote(((SQLIdentifierExpr) afterColumn).getName());
for (int i = 0; i < columnMetas.size(); i++) {
String colName = columnMetas.get(i).getName();
if (afterColName.equalsIgnoreCase(colName)) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/mycat/meta/table/MetaHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ public static TableMeta initTableMeta(String table, SQLCreateTableStatement crea
*/
public static IndexMeta makeIndexMeta(String indexName, INDEX_TYPE indexType, List<SQLExpr> columnExprs) {
IndexMeta.Builder indexBuilder = IndexMeta.newBuilder();
indexBuilder.setName(StringUtil.removeBackquote(indexName));
indexBuilder.setName(StringUtil.removeBackQuote(indexName));
indexBuilder.setType(indexType.toString());
for (int i = 0; i < columnExprs.size(); i++) {
SQLIdentifierExpr column = (SQLIdentifierExpr) columnExprs.get(i);
indexBuilder.addColumns(StringUtil.removeBackquote(column.getName()));
indexBuilder.addColumns(StringUtil.removeBackQuote(column.getName()));
}
return indexBuilder.build();
}

public static ColumnMeta.Builder makeColumnMeta(SQLColumnDefinition column) {
ColumnMeta.Builder cmBuilder = ColumnMeta.newBuilder();
cmBuilder.setName(StringUtil.removeBackquote(column.getName().getSimpleName()));
cmBuilder.setName(StringUtil.removeBackQuote(column.getName().getSimpleName()));
cmBuilder.setDataType(column.getDataType().getName());
for (SQLColumnConstraint constraint : column.getConstraints()) {
if (constraint instanceof SQLNotNullConstraint) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/mycat/plan/visitor/MySQLPlanNodeVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ public boolean visit(SQLExprTableSource tableSource) {
SQLExpr expr = tableSource.getExpr();
if (expr instanceof SQLPropertyExpr) {
SQLPropertyExpr propertyExpr = (SQLPropertyExpr) expr;
table = new TableNode(StringUtil.removeBackquote(propertyExpr.getOwner().toString()), StringUtil.removeBackquote(propertyExpr.getName()));
table = new TableNode(StringUtil.removeBackQuote(propertyExpr.getOwner().toString()), StringUtil.removeBackQuote(propertyExpr.getName()));
} else if (expr instanceof SQLIdentifierExpr) {
SQLIdentifierExpr identifierExpr = (SQLIdentifierExpr) expr;
table = new TableNode(this.currentDb, StringUtil.removeBackquote(identifierExpr.getName()));
table = new TableNode(this.currentDb, StringUtil.removeBackQuote(identifierExpr.getName()));
}
if (tableSource.getAlias() != null) {
table.setSubAlias(tableSource.getAlias());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ private List<RouteCalculateUnit> buildRouteCalculateUnits(Map<String,String> tab
break;
}
if(checkConditionValues(values)) {
String columnName = StringUtil.removeBackquote(condition.getColumn().getName().toUpperCase());
String tableName = StringUtil.removeBackquote(condition.getColumn().getTable());
String columnName = StringUtil.removeBackQuote(condition.getColumn().getName().toUpperCase());
String tableName = StringUtil.removeBackQuote(condition.getColumn().getTable());
if (MycatServer.getInstance().getConfig().getSystem().isLowerCaseTableNames()) {
tableName = tableName.toLowerCase();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private HavingCols buildGroupByHaving(SQLExpr having) {
if (right instanceof SQLNumericLiteralExpr) {
rightValue = right.toString();
} else if (right instanceof SQLTextLiteralExpr) {
rightValue = StringUtil.removeBackquote(right.toString());
rightValue = StringUtil.removeBackQuote(right.toString());
}

return new HavingCols(leftValue, rightValue, operator.getName());
Expand Down Expand Up @@ -353,9 +353,9 @@ private String[] buildGroupByCols(List<SQLExpr> groupByItems, Map<String, String
SQLExpr expr = ((MySqlOrderingExpr) sqlExpr).getExpr();

if (expr instanceof SQLName) {
column = StringUtil.removeBackquote(((SQLName) expr).getSimpleName());
column = StringUtil.removeBackQuote(((SQLName) expr).getSimpleName());
} else {
column = StringUtil.removeBackquote(expr.toString());
column = StringUtil.removeBackQuote(expr.toString());
}
} else if (sqlExpr instanceof SQLPropertyExpr) {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ private void parserSingleInsert(SchemaInfo schemaInfo, RouteResultset rrs, Strin
List<SQLExpr> updateList = insertStmt.getDuplicateKeyUpdate();
for(SQLExpr expr : updateList) {
SQLBinaryOpExpr opExpr = (SQLBinaryOpExpr)expr;
String column = StringUtil.removeBackquote(opExpr.getLeft().toString().toUpperCase());
String column = StringUtil.removeBackQuote(opExpr.getLeft().toString().toUpperCase());
if(column.equals(partitionColumn)) {
String msg = "Sharding column can't be updated: " + schemaInfo.table + " -> " + partitionColumn;
LOGGER.warn(msg);
Expand Down Expand Up @@ -488,7 +488,7 @@ private int getShardingColIndex(SchemaInfo schemaInfo, MySqlInsertStatement inse
return shardingColIndex;
}
for (int i = 0; i < insertStmt.getColumns().size(); i++) {
if (partitionColumn.equalsIgnoreCase(StringUtil.removeBackquote(insertStmt.getColumns().get(i).toString()))) {
if (partitionColumn.equalsIgnoreCase(StringUtil.removeBackQuote(insertStmt.getColumns().get(i).toString()))) {
return i;
}
}
Expand Down Expand Up @@ -571,7 +571,7 @@ private String convertInsertSQL(SchemaInfo schemaInfo, MySqlInsertStatement inse
sb.append(columns.get(i).toString()).append(",");
else
sb.append(columns.get(i).toString());
String column = StringUtil.removeBackquote(insert.getColumns().get(i).toString());
String column = StringUtil.removeBackQuote(insert.getColumns().get(i).toString());
if (column.equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN))
idx = i;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private String convertUpdateSQL(SchemaInfo schemaInfo, MySqlUpdateStatement upda
SQLUpdateSetItem item = items.get(i);
String col = item.getColumn().toString();

if (StringUtil.removeBackquote(col).equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN)) {
if (StringUtil.removeBackQuote(col).equalsIgnoreCase(GlobalTableUtil.GLOBAL_TABLE_MYCAT_COLUMN)) {
flag = true;
SQLUpdateSetItem newItem = new SQLUpdateSetItem();
newItem.setColumn(item.getColumn());
Expand All @@ -146,9 +146,9 @@ private String convertUpdateSQL(SchemaInfo schemaInfo, MySqlUpdateStatement upda
private static boolean columnInExpr(SQLExpr sqlExpr, String colName) throws SQLNonTransientException {
String column;
if (sqlExpr instanceof SQLIdentifierExpr) {
column = StringUtil.removeBackquote(((SQLIdentifierExpr) sqlExpr).getName()).toUpperCase();
column = StringUtil.removeBackQuote(((SQLIdentifierExpr) sqlExpr).getName()).toUpperCase();
} else if (sqlExpr instanceof SQLPropertyExpr) {
column = StringUtil.removeBackquote(((SQLPropertyExpr) sqlExpr).getName()).toUpperCase();
column = StringUtil.removeBackQuote(((SQLPropertyExpr) sqlExpr).getName()).toUpperCase();
} else {
throw new SQLNonTransientException("Unhandled SQL AST node type encountered: " + sqlExpr.getClass());
}
Expand Down Expand Up @@ -255,7 +255,7 @@ private void confirmShardColumnNotUpdated(SQLUpdateStatement update,SchemaConfig
if (updateSetItem != null && updateSetItem.size() > 0) {
boolean hasParent = (schema.getTables().get(tableName).getParentTC() != null);
for (SQLUpdateSetItem item : updateSetItem) {
String column = StringUtil.removeBackquote(item.getColumn().toString().toUpperCase());
String column = StringUtil.removeBackQuote(item.getColumn().toString().toUpperCase());
//考虑别名,前面已经限制了update分片表的个数只能有一个,所以这里别名只能是分片表的
if (column.contains(StringUtil.TABLE_COLUMN_SEPARATOR)) {
column = column.substring(column.indexOf(".") + 1).trim().toUpperCase();
Expand Down
Loading

0 comments on commit 3c51b88

Please sign in to comment.