Skip site navigation (1) Skip section navigation (2)

Bug #851: cast() no longer works in array inserts

From: pgsql-bugs(at)postgresql(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: Bug #851: cast() no longer works in array inserts
Date: 2002-12-19 03:30:58
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
Malcolm Tredinnick (malcolm(at)commsecure(dot)com(dot)au) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
cast() no longer works in array inserts

Long Description
If I have a table containing an array (e.g. a bigint[] field), then it does not appear to be possible to insert values using the cast() function. This used to work in PostgreSQL 7.1, but no longer works in 7.2 or 7.3. I cannot see anything in the release notes saying the previous behaviour was considered incorrect and the documentation seems to indicate it should be possible.

If this is not meant to work, then this is a documentation bug, because it is unclear how to insert a constant like 0 into a bigint field in an array.

The example code below works in 7.1, but not in later versions. The error message given is 

   ERROR:  Bad int8 external representation "{0::bigint, 0::bigint}"

for the first example and similarly for the second (with the appropriate cast statements substituted).

Sample Code
create table foo (bar bigint[]);

insert into foo values ('{"0"::bigint, "0"::bigint}');

insert into foo values ('{cast("0" as decimal(12)), cast("0" as decimal(12))}');

No file was uploaded with this report


pgsql-bugs by date

Next:From: Tom LaneDate: 2002-12-19 05:48:17
Subject: Re: Bug #851: cast() no longer works in array inserts
Previous:From: Böhm, Sebastian (Vendor)Date: 2002-12-19 00:18:13
Subject: Re: strange problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group