Skip to content

Commit d79eeef

Browse files
committed
Treat a zero-D array as empty in int_enum(), per Andrew@supernews.
1 parent 3842892 commit d79eeef

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

contrib/intagg/int_aggregate.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ int_enum(PG_FUNCTION_ARGS)
243243
pc->flags = 0;
244244
}
245245
/* Now that we have a detoasted array, verify dimensions */
246-
if (pc->p->a.ndim != 1)
246+
/* We'll treat a zero-D array as empty, below */
247+
if (pc->p->a.ndim > 1)
247248
elog(ERROR, "int_enum only accepts 1-D arrays");
248249
pc->num = 0;
249250
fcinfo->context = (Node *) pc;
@@ -252,7 +253,7 @@ int_enum(PG_FUNCTION_ARGS)
252253
else /* use an existing one */
253254
pc = (CTX *) fcinfo->context;
254255
/* Are we done yet? */
255-
if (pc->num >= pc->p->items)
256+
if (pc->p->a.ndim < 1 || pc->num >= pc->p->items)
256257
{
257258
/* We are done */
258259
if (pc->flags & TOASTED)

0 commit comments

Comments
 (0)