Open johnmudd opened 5 years ago
The seg fault occurs in src/query.c when get_collation_name(collid)
returns 0 (zero) and this is passed to strdup()
.
Here's a code change to src/query.c that seems to bypass the problem.
BEFORE
/* ORDER BY clauses having a COLLATE option will be RelabelType */
else if (IsA(expr, RelabelType) &&
IsA(((RelabelType *) expr)->arg, Var))
{
Var *var = (Var *)((RelabelType *) expr)->arg;
Oid collid = ((RelabelType *) expr)->resultcollid;
if (collid == DEFAULT_COLLATION_OID)
md->collate = NULL;
else
md->collate = (Name) strdup(get_collation_name(collid)); // Seg fault here.
md->attname = (Name) strdup(get_attname(foreigntableid, var->varattno, false));
md->attnum = var->varattno;
found = true;
}
AFTER
/* ORDER BY clauses having a COLLATE option will be RelabelType */
else if (IsA(expr, RelabelType) &&
IsA(((RelabelType *) expr)->arg, Var))
{
Var *var = (Var *)((RelabelType *) expr)->arg;
Oid collid = ((RelabelType *) expr)->resultcollid;
if (collid == DEFAULT_COLLATION_OID)
{
found = true;
md->collate = NULL;
}
else
{
if (get_collation_name(collid))
{
found = true;
md->collate = (Name) strdup(get_collation_name(collid));
}
}
if (found)
{
md->attname = (Name) strdup(get_attname(foreigntableid, var->varattno, false));
md->attnum = var->varattno;
}
}
I get a seg fault when use DISTINCT, MAX or MIN after upgrading to Postgres 11. My question for now is whether anyone running Multicorn with Postgres 11 gets the same sort of error. It doesn't matter if the column is indexed or not.
I build Postgres and Python from source using musl C library. I've used Multicorn w/o issue on Postgres 9 & 10. I can also use the functions w/o error using Postgres 11 on regular (non-FDW) tables. Linux psql example and traceback below.