Source:
<code>private void checkTableNameAndScrubResultColumns(ResultColumnList rcl, boolean isUpdateWithSubquery) throws StandardException { int columnCount = rcl.size(); int tableCount = ((SelectNode)resultSet).fromList.size(); TableName tableNameNode = null; for ( int i = 0; i < columnCount; i++ ) { boolean foundMatchingTable = false; ResultColumn column = (ResultColumn) rcl.elementAt( i ); String columnTableName = column.getTableName(); if (columnTableName != null) { for (int j = 0; j < tableCount; j++) { FromTable fromTable = (FromTable) ((SelectNode)resultSet). fromList.elementAt(j); final String tableName; if ( fromTable instanceof CurrentOfNode ) { tableName = ((CurrentOfNode)fromTable). getBaseCursorTargetTableName().getTableName(); tableNameNode = ((CurrentOfNode) fromTable).getExposedTableName(); } else { tableName = fromTable.getBaseTableName(); tableNameNode = makeTableName( null, fromTable.getExposedName()); } if (columnTableName.equals(tableName) || columnTableName.equals(tableNameNode.getTableName())) { foundMatchingTable = true; break; } } if (!foundMatchingTable) { throw StandardException.newException( SQLState.LANG_COLUMN_NOT_FOUND, column.getTableName() + "." + column.getName()); } } if (!isUpdateWithSubquery) { column.clearTableName(); } else { ValueNode expression = column.getExpression(); if (expression instanceof ColumnReference && expression.getColumnName().equals(column.getName())) { <START> ((ColumnReference) expression).setTableNameNode(tableNameNode); <END> } } } }</code><technical_language>If table name is set foundMatchingTable is false, setting wrong table name, right? need do this foundMatchingTable is true</technical_language>

Target:
private void checkTableNameAndScrubResultColumns(ResultColumnList rcl, boolean isUpdateWithSubquery) throws StandardException { int columnCount = rcl.size(); int tableCount = ((SelectNode)resultSet).fromList.size(); TableName tableNameNode = null; for ( int i = 0; i < columnCount; i++ ) { boolean foundMatchingTable = false; ResultColumn column = (ResultColumn) rcl.elementAt( i ); String columnTableName = column.getTableName(); if (columnTableName != null) { for (int j = 0; j < tableCount; j++) { FromTable fromTable = (FromTable) ((SelectNode)resultSet). fromList.elementAt(j); final String tableName; if ( fromTable instanceof CurrentOfNode ) { tableName = ((CurrentOfNode)fromTable). getBaseCursorTargetTableName().getTableName(); tableNameNode = ((CurrentOfNode) fromTable).getExposedTableName(); } else { tableName = fromTable.getBaseTableName(); tableNameNode = makeTableName( null, fromTable.getExposedName()); } if (columnTableName.equals(tableName) || columnTableName.equals(tableNameNode.getTableName())) { foundMatchingTable = true; break; } } if (!foundMatchingTable) { throw StandardException.newException( SQLState.LANG_COLUMN_NOT_FOUND, column.getTableName() + "." + column.getName()); } } if (!isUpdateWithSubquery) { column.clearTableName(); } else { String baseTableName = targetTable.getBaseTableName(); String exposedTableName = targetTable.getExposedName(); if (!baseTableName.equals(exposedTableName)) { ValueNode expression = column.getExpression(); if (expression != null && expression instanceof ColumnReference && baseTableName.equals(expression.getTableName())) ((ColumnReference) expression).setTableNameNode(makeTableName(null,exposedTableName)); } } } }