qc: Do not collect HAVING names
A HAVING clause can only refer to names that already have been mentioned or if "SELECT *" is used. Either way, the HAVING names need not be separately collected.
This commit is contained in:
@ -2177,12 +2177,16 @@ void qc_get_field_info(GWBUF* buf, const QC_FIELD_INFO** infos, size_t* n_infos)
|
|||||||
&lex->current_select->item_list);
|
&lex->current_select->item_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(COLLECT_HAVING_AS_WELL)
|
||||||
|
// A HAVING clause can only refer to fields that already have been
|
||||||
|
// mentioned. Consequently, they need not be collected.
|
||||||
if (lex->current_select->having)
|
if (lex->current_select->having)
|
||||||
{
|
{
|
||||||
update_field_infos(pi, COLLECT_HAVING,
|
update_field_infos(pi, COLLECT_HAVING,
|
||||||
lex->current_select->having,
|
lex->current_select->having,
|
||||||
&lex->current_select->item_list);
|
&lex->current_select->item_list);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
lex->current_select = lex->current_select->next_select_in_list();
|
lex->current_select = lex->current_select->next_select_in_list();
|
||||||
}
|
}
|
||||||
|
@ -1029,7 +1029,11 @@ static void update_fields_infos_from_select(QC_SQLITE_INFO* info,
|
|||||||
if (pSelect->pHaving)
|
if (pSelect->pHaving)
|
||||||
{
|
{
|
||||||
info->has_clause = true;
|
info->has_clause = true;
|
||||||
|
#if defined(COLLECT_HAVING_AS_WELL)
|
||||||
|
// A HAVING clause can only refer to fields that already have been
|
||||||
|
// mentioned. Consequently, they need not be collected.
|
||||||
update_fields_infos(info, 0, pSelect->pHaving, QC_TOKEN_MIDDLE, pSelect->pEList);
|
update_fields_infos(info, 0, pSelect->pHaving, QC_TOKEN_MIDDLE, pSelect->pEList);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user