Commit ee48ba62 authored by Jarosław Staniek's avatar Jarosław Staniek
Browse files

Fix crash when accessing a query with duplicated table names

Example query that crashed: SELECT t.foo FROM t, t.
Now error message is displayed so user can fix the statement.

BUG:315852
FIXED-IN:2.8.4
REVIEW:118519
parent caf6b848
......@@ -818,17 +818,11 @@ bool VariableExpr::validate(ParseInfo& parseInfo)
// check if table or alias is used twice and both have the same column
// (so the column is ambiguous)
int numberOfTheSameFields = 0;
foreach(int position, positionsList) {
TableSchema *otherTS = parseInfo.querySchema->tables()->at(position);
if (otherTS->field(fieldName))
numberOfTheSameFields++;
if (numberOfTheSameFields > 1) {
parseInfo.errMsg = i18n("Ambiguous \"%1.%2\" expression", tableName, fieldName);
parseInfo.errDescr = i18n("More than one \"%1\" table or alias defined containing \"%2\" field",
tableName, fieldName);
return false;
}
if (positionsList.count() > 1) {
parseInfo.errMsg = i18n("Ambiguous \"%1.%2\" expression", tableName, fieldName);
parseInfo.errDescr = i18n("More than one \"%1\" table or alias defined containing \"%2\" field",
tableName, fieldName);
return false;
}
field = realField; //store
tablePositionForField = tablePosition;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment