Commit d79eeef3 authored by Tom Lane's avatar Tom Lane

Treat a zero-D array as empty in int_enum(), per Andrew@supernews.

parent 38428924
...@@ -243,7 +243,8 @@ int_enum(PG_FUNCTION_ARGS) ...@@ -243,7 +243,8 @@ int_enum(PG_FUNCTION_ARGS)
pc->flags = 0; pc->flags = 0;
} }
/* Now that we have a detoasted array, verify dimensions */ /* Now that we have a detoasted array, verify dimensions */
if (pc->p->a.ndim != 1) /* We'll treat a zero-D array as empty, below */
if (pc->p->a.ndim > 1)
elog(ERROR, "int_enum only accepts 1-D arrays"); elog(ERROR, "int_enum only accepts 1-D arrays");
pc->num = 0; pc->num = 0;
fcinfo->context = (Node *) pc; fcinfo->context = (Node *) pc;
...@@ -252,7 +253,7 @@ int_enum(PG_FUNCTION_ARGS) ...@@ -252,7 +253,7 @@ int_enum(PG_FUNCTION_ARGS)
else /* use an existing one */ else /* use an existing one */
pc = (CTX *) fcinfo->context; pc = (CTX *) fcinfo->context;
/* Are we done yet? */ /* Are we done yet? */
if (pc->num >= pc->p->items) if (pc->p->a.ndim < 1 || pc->num >= pc->p->items)
{ {
/* We are done */ /* We are done */
if (pc->flags & TOASTED) if (pc->flags & TOASTED)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment