Fix 'modifying table not supported' message

When our grammar parser doesn't fully understand a create table
statement yet, it'll set a flag to indicate the modifying this table
will result in errors: the nonunderstood parts will be removed from the
table while editing it.

The code for this feature, however, had a bug that was triggered by some
compilers (gcc in my case) because of an ambiguous function call. That
ambiguity and thus the resulting bug are fixed by this commit, making
sure the warning appears on all systems.

This was fun to debug...
This commit is contained in:
Martin Kleusberg
2017-01-05 21:51:16 +01:00
parent 01e68f0821
commit 99a5d02925

View File

@@ -271,7 +271,12 @@ QPair<Table, bool> Table::parseSQL(const QString &sSQL)
{
parser.createtable();
CreateTableWalker ctw(parser.getAST());
return qMakePair(ctw.table(), ctw.modifysupported());
// Note: this needs to be done in two separate lines because otherwise the optimiser might decide to
// fetch the value for the second part of the pair (the modify supported flag) first. If it does so it will
// always be set to true because the table() method hasn't run yet and it's only set to false in there.
sqlb::Table tab = ctw.table();
return qMakePair(tab, ctw.modifysupported());
}
catch(antlr::ANTLRException& ex)
{