Thread: BUG #2913: Subscript on multidimensional array yields no value
The following bug has been logged online: Bug reference: 2913 Logged by: Roman Nowak Email address: roman_nowak@poczta.onet.pl PostgreSQL version: 8.2.1 Operating system: Windows XP Description: Subscript on multidimensional array yields no value Details: SELECT (ARRAY[[1,2],[3,4]])[1]; does not return [1,2] (testes in psql and pgAdmin III): show info that one row was returned but does not display its value following statment works OK btw SELECT (ARRAY[[1,2],[3,4]])[1:1];
I can confirm this is a bug. Added to the TODO list: o ARRAY[[1,2],[3,4]])[1] should return the same values as ARRAY[[1,2],[3,4]])[1:1]; --------------------------------------------------------------------------- Roman Nowak wrote: > > The following bug has been logged online: > > Bug reference: 2913 > Logged by: Roman Nowak > Email address: roman_nowak@poczta.onet.pl > PostgreSQL version: 8.2.1 > Operating system: Windows XP > Description: Subscript on multidimensional array yields no value > Details: > > SELECT (ARRAY[[1,2],[3,4]])[1]; > > does not return [1,2] > (testes in psql and pgAdmin III): show info that one row was returned but > does not display its value > > following statment works OK btw > SELECT (ARRAY[[1,2],[3,4]])[1:1]; > > ---------------------------(end of broadcast)--------------------------- > TIP 1: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly -- Bruce Momjian bruce@momjian.us EnterpriseDB http://www.enterprisedb.com + If your life is a hard drive, Christ can be your backup. +
Bruce Momjian <bruce@momjian.us> writes: > I can confirm this is a bug. Added to the TODO list: > o ARRAY[[1,2],[3,4]])[1] should return the same values as > ARRAY[[1,2],[3,4]])[1:1]; This is not a bug, this is a definitional disagreement, and your TODO entry presupposes an answer that I don't particularly agree with. regards, tom lane
Tom Lane wrote: > Bruce Momjian <bruce@momjian.us> writes: > > I can confirm this is a bug. Added to the TODO list: > > o ARRAY[[1,2],[3,4]])[1] should return the same values as > > ARRAY[[1,2],[3,4]])[1:1]; > > This is not a bug, this is a definitional disagreement, and your TODO > entry presupposes an answer that I don't particularly agree with. Well, our documentation suggests thaat [1] is the same as [1:1]: http://www.postgresql.org/docs/8.2/static/arrays.html#AEN5791 What is the issue here that makes that not true? -- Bruce Momjian bruce@momjian.us EnterpriseDB http://www.enterprisedb.com + If your life is a hard drive, Christ can be your backup. +
Bruce Momjian <bruce@momjian.us> writes: > Tom Lane wrote: >> This is not a bug, this is a definitional disagreement, and your TODO >> entry presupposes an answer that I don't particularly agree with. > Well, our documentation suggests thaat [1] is the same as [1:1]: > http://www.postgresql.org/docs/8.2/static/arrays.html#AEN5791 It says absolutely no such thing. A subscript expression involving m:n produces a "slice", hence an array of different dimensionality from the original, whereas a subscript expression not involving any colon produces a single element --- that is, not an array at all. You could make a fair case that the (ARRAY[[1,2],[3,4]])[1] example should throw an error instead of returning null. But to claim it is the same as a slice expression is a typing violation. regards, tom lane
Tom Lane wrote: > Bruce Momjian <bruce@momjian.us> writes: > > I can confirm this is a bug. Added to the TODO list: > > o ARRAY[[1,2],[3,4]])[1] should return the same values as > > ARRAY[[1,2],[3,4]])[1:1]; > > This is not a bug, this is a definitional disagreement, and your TODO > entry presupposes an answer that I don't particularly agree with. TODO item removed, now that I understand the array behavior. -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://www.enterprisedb.com + If your life is a hard drive, Christ can be your backup. +