qc: Provide information about field usage

Together with the field names, now qc_get_field_info also returns
field usage information, that is, in what context a field is used.
This allows, for instance, the cache to take action if a a particular
field is selected (SELECT a FROM ...), but not if it is used in a
GROUP BY clause (...GROUP BY a).

This caused a significant modifications of qc_mysqlembedded that
earlier did not walk the parse-tree, but instead looped over of a
list of st_select_lex instances that, the name notwithstanding,
also contain information about other things but SELECTs. The former
approach lost all contextual information, so it was not possible
to know where a particular field was used.

Now the parse tree is walked, which means that the contextual
information is known, and thus the field usage can be updated.
This commit is contained in:
Johan Wikman
2016-11-08 18:05:00 +02:00
parent d7c476314e
commit 15e9652c46
6 changed files with 581 additions and 231 deletions

View File

@ -862,6 +862,7 @@ public:
: m_database(info.database ? info.database : "")
, m_table(info.table ? info.table : "")
, m_column(info.column ? info.column : "")
, m_usage(info.usage)
{}
bool eq(const QcFieldInfo& rhs) const
@ -869,7 +870,8 @@ public:
return
m_database == rhs.m_database &&
m_table == rhs.m_table &&
m_column == rhs.m_column;
m_column == rhs.m_column &&
m_usage == rhs.m_usage;
}
bool lt(const QcFieldInfo& rhs) const
@ -900,6 +902,14 @@ public:
{
rv = true;
}
else if (m_column > rhs.m_column)
{
rv = false;
}
else
{
rv = (m_usage < rhs.m_usage);
}
}
}
@ -921,12 +931,19 @@ public:
}
out << m_column;
out << "(";
char* s = qc_field_usage_mask_to_string(m_usage);
out << s;
free(s);
out << ")";
}
private:
std::string m_database;
std::string m_table;
std::string m_column;
uint32_t m_usage;
};
ostream& operator << (ostream& out, const QcFieldInfo& x)