Thread: Error message that is a bit misleading / weird result from || null
Hi, While trying to find a way to get indexed access to a table based on it's xmin, I ran into the following error message that seems a bit misleading: db=# select xmin || ' ' from <anytable> limit 1; ERROR: array value must start with "{" or dimension information Toying a bit more with this result resulted in: megafox=# select xmin || null from <anytable> limit 1; ?column? ------------ {12115328} (1 row) As it seems, the result is actually a correct array: db=# select (xmin || null)[1] from <anytable> limit 1; ?column? ---------- 12115328 (1 row) And comparing the result to for example an int, works. Now I understand that there are no standard casts of xid to something else, but the interpretation if this concatenation surprised at least me ;) Sidenote: since it does solve my problem, I can now build an index based on such an interpretation of xmin, I'm a bit anxious as to how this will be 'fixed', if at all ;) db=# select version(); version ------------------------------------------------------------------------ PostgreSQL 8.2.4 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.3 (1 row) -- Best, Frank.
"Frank van Vugt" <ftm.van.vugt@foxi.nl> writes: > Sidenote: since it does solve my problem, I can now build an index based on > such an interpretation of xmin, I'm a bit anxious as to how this will > be 'fixed', if at all ;) Actually this was noticed only recently but that was precisely because it was related to some significant changes that were being made. Because of those changes 8.3 behaves markedly different in this area: postgres=# select xmin || 'x' from w limit 1; ?column? ---------- 1679x (1 row) -- Gregory Stark EnterpriseDB http://www.enterprisedb.com
Frank van Vugt <ftm.van.vugt@foxi.nl> writes: > While trying to find a way to get indexed access to a table based on it's > xmin, I ran into the following error message that seems a bit misleading: > db=# select xmin || ' ' from <anytable> limit 1; > ERROR: array value must start with "{" or dimension information Yeah, it's being captured by the "anyelement || anyarray" operator for lack of any other possible interpretation. We found a reasonable fix for 8.3, in connection with removing implicit casts to text. See long-running thread beginning here http://archives.postgresql.org/pgsql-hackers/2007-02/msg01729.php final solution invented beginning here http://archives.postgresql.org/pgsql-hackers/2007-06/msg00116.php regards, tom lane