On Tue, Mar 31, 2009 at 7:45 AM, Brendan Jurd <direvus@xxxxxxxxx> wrote: > My first thought was that it should be a zero-element array, because > then the string_to_array() behaviour would conform to the notion that > it returns an array with 1 element per string fragment bounded by the > delimiter. > > However, I note that if you provide an empty delimiter, or one which > doesn't occur anywhere in the source string, you get an array with one > element, being the entire source string. Yeah, actually the more I think about it the more I think it would be strange for most uses to get a singleton array for this case. What do you really expect to be returned for things like select count_elements(string_to_array('butter,tea,milk',',')) select count_elements(string_to_array('butter,tea',',')) select count_elements(string_to_array('butter',',')) select count_elements(string_to_array('',',')) ... I could see lists like this being stored when people gather data using a web form or something and don't want to bother normalizing some trivial bit of data collection which they'll never individually, but have to unnest the list for some display purposes. The cases where it makes more sense to return a singleton array are going to be parsing things like /etc/password where there are specific meanings for each element, but when some are optional. I can't think of any examples offhand though. -- greg -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general