}
//只用于update语句
@Override
protected Column readTableColumn(TableFilter filter) {
Table t = filter.getTable();
if (!t.supportsColumnFamily())
return super.readTableColumn(filter);
//完整的语法是: catalogName(也就是数据库名).tableAlias.columnFamilyName.columnName
//如果没有使用表别名,tableAlias实际上就是原始表名
String columnFamilyName = null;
String columnName = readColumnIdentifier();
if (readIf(".")) {
columnFamilyName = columnName;
columnName = readColumnIdentifier();
if (readIf(".")) {
String tableAlias = columnFamilyName;
columnFamilyName = columnName;
columnName = readColumnIdentifier();
if (readIf(".")) {
String schema = tableAlias;
tableAlias = columnFamilyName;
columnFamilyName = columnName;
columnName = readColumnIdentifier();
if (readIf(".")) {
String catalogName = schema;
schema = tableAlias;
tableAlias = columnFamilyName;
columnFamilyName = columnName;
columnName = readColumnIdentifier();
if (!equalsToken(catalogName, database.getShortName())) {
throw DbException.get(ErrorCode.DATABASE_NOT_FOUND_1, catalogName);
}
}
if (!equalsToken(schema, filter.getTable().getSchema().getName())) {
throw DbException.get(ErrorCode.SCHEMA_NOT_FOUND_1, schema);
}
}
if (!equalsToken(tableAlias, filter.getTableAlias())) {
throw DbException.get(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, tableAlias);
}
}
}
if (database.getSettings().rowId) {
if (Column.ROWID.equals(columnName)) {
return filter.getRowIdColumn();
}
}
if (columnFamilyName == null) {
return t.getColumn(columnName);
} else if (!t.doesColumnFamilyExist(columnFamilyName)) {
//当columnFamilyName不存在时,有可能是想使用简化的tableAlias.columnName语法
if (!equalsToken(columnFamilyName, filter.getTableAlias())) {
throw DbException.get(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, columnFamilyName);
}
return t.getColumn(columnName);
} else {
return t.getColumn(columnFamilyName, columnName, false);
}
}