Re: BUG #14826: Malformed array dimensions for empty arrays in return column "lexemes" of ts_debug()

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: brsaweda@gmail.com
Cc: pgsql-bugs@postgresql.org
Date: 2017-09-23T16:26:08Z
Lists: pgsql-bugs
brsaweda@gmail.com writes:
> test=# SELECT token, lexemes, lexemes = '{}'::text[]
> test-# FROM   ts_debug('a title');
>  token | lexemes | ?column?
> -------+---------+----------
>  a     | {}      | f
>        |         |
>  title | {titl}  | f

> The root of the problem seems to be malformed array dimensions.
> array_dims(lexemes) returns [1:0], while I would expect NULL:

Yeah, that's a bug --- looks like ts_lexize is the root problem.

I'm a bit tempted to fix this centrally by having construct_array()
do something different for zero-dimensioned input, rather than
putting a special case into ts_lexize().  We've been bitten by
this type of insect a few times too many.  The question is
whether there's any code that relies on being able to construct
such malformed arrays ...

			regards, tom lane


Commits

  1. Make construct_[md_]array return a valid empty array for zero-size input.