Fix segfault when an expression is used.

If an expression is used, just don't create an hypothetical index. An
index on the remaining columns could be built, but it would not be
intuitive, and it may not remain any column left.

Thanks Thom Brown for reporting it.
This commit is contained in:
Julien Rouhaud 2015-07-01 16:52:29 +02:00
parent 87e7478376
commit b6baf06b67

View file

@ -390,8 +390,30 @@ entry_store_parsetree(IndexStmt *node)
int ncolumns;
ListCell *lc;
int j;
bool ok = true;
/* check first if there's an expression.
* the column list will probably be checked twice, but it avoids the need
* to worry about freeing memory later.
*/
foreach(lc, node->indexParams)
{
IndexElem *indexelem = (IndexElem *) lfirst(lc);
if (indexelem->expr != NULL)
{
ok = false;
break;
}
}
if (!ok)
{
elog(WARNING, "hypopg: hypothetical indexes on expression are not supported yet");
return false;
}
ncolumns = list_length(node->indexParams);
initStringInfo(&indexRelationName);