Thread: BUG #4956: Array Construct array() returning blank result
The following bug has been logged online: Bug reference: 4956 Logged by: Niranjan Pandit Email address: niranjan81@gmail.com PostgreSQL version: 8.4 Operating system: Windows Vista Ultimate Description: Array Construct array() returning blank result Details: Hi, I simply wanted to accumulate result of a subquery in to an array, so I did select array(select userid from user where <some condition>); Only when the condition gets evaluated to true with at least 2 columns with varying values the array gets constructed, in all other cases what we get is a complete blank output. the label of the result is as usual as ?column? but there is absolutely nothing in the cell below the label. I am sorry if I am repeating something already known to mankind :-) but after a lot search I could not get anything on it on the net. Thanks in advance. Best Wishes.
"Niranjan Pandit" <niranjan81@gmail.com> writes: > Only when the condition gets evaluated to true with at least 2 columns with > varying values the array gets constructed, in all other cases what we get is > a complete blank output. the label of the result is as usual as ?column? but > there is absolutely nothing in the cell below the label. Hmm, seems to work for me: regression=# select array(select unique1 from tenk1 where unique2 < 2); ?column? ------------- {8800,1891} (1 row) regression=# select array(select unique1 from tenk1 where unique2 < 1); ?column? ---------- {8800} (1 row) regression=# select array(select unique1 from tenk1 where unique2 < 0); ?column? ---------- {} (1 row) Pre-8.3 PG releases would return NULL instead of an empty array in the last case, but 8,4 should not. If you're seeing differently, we'll need a self-contained test case. regards, tom lane