Unusual behaviour with intarray

Started by Adam Witneyalmost 23 years ago4 messagesgeneral
Jump to latest
#1Adam Witney
awitney@sghms.ac.uk

Hi,

I am using intarray in contrib, and have seen some strange behaviour with
one of the operations. Anyone know whats going on here?

cabbage=# create table test (id int, writers int[]);
CREATE TABLE
cabbage=# insert into test values(1, '{}');
INSERT 1545023 1
cabbage=# select * from test;
id | writers
----+---------
1 | {}
(1 row)

cabbage=# update test set writers = (select writers - '{1}'::int[]);
UPDATE 1
cabbage=# select * from test;
id | writers
----+---------
1 | {}
(1 row)

cabbage=# update test set writers = (select writers - '{1}'::int[]);
UPDATE 1
cabbage=# select * from test;
id | writers
----+-----------
1 | {3044207}
(1 row)

Thanks for any help

Adam

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

#2Teodor Sigaev
teodor@sigaev.ru
In reply to: Adam Witney (#1)
Re: Unusual behaviour with intarray

Ok, this is a bug.
I'll post a patch as soon as possible.

Adam Witney wrote:

Hi,

I am using intarray in contrib, and have seen some strange behaviour with
one of the operations. Anyone know whats going on here?

cabbage=# create table test (id int, writers int[]);
CREATE TABLE
cabbage=# insert into test values(1, '{}');
INSERT 1545023 1
cabbage=# select * from test;
id | writers
----+---------
1 | {}
(1 row)

cabbage=# update test set writers = (select writers - '{1}'::int[]);
UPDATE 1
cabbage=# select * from test;
id | writers
----+---------
1 | {}
(1 row)

cabbage=# update test set writers = (select writers - '{1}'::int[]);
UPDATE 1
cabbage=# select * from test;
id | writers
----+-----------
1 | {3044207}
(1 row)

Thanks for any help

Adam

--
Teodor Sigaev E-mail: teodor@sigaev.ru

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Adam Witney (#1)
Re: Unusual behaviour with intarray

Adam Witney <awitney@sghms.ac.uk> writes:

I am using intarray in contrib, and have seen some strange behaviour with
one of the operations. Anyone know whats going on here?

I think unix_uniq() is broken for the case of a zero-element array ...

regards, tom lane

#4Teodor Sigaev
teodor@sigaev.ru
In reply to: Teodor Sigaev (#2)
Re: Unusual behaviour with intarray

Please apply patch for 7.3 CVS brach. Patch fixes the problem, for 7.4 it will
be later (with other changes).

Teodor Sigaev wrote:

Ok, this is a bug.
I'll post a patch as soon as possible.

Adam Witney wrote:

Hi,

I am using intarray in contrib, and have seen some strange behaviour with
one of the operations. Anyone know whats going on here?

cabbage=# create table test (id int, writers int[]);
CREATE TABLE
cabbage=# insert into test values(1, '{}');
INSERT 1545023 1
cabbage=# select * from test;
id | writers ----+---------
1 | {}
(1 row)

cabbage=# update test set writers = (select writers - '{1}'::int[]);
UPDATE 1
cabbage=# select * from test;
id | writers ----+---------
1 | {}
(1 row)

cabbage=# update test set writers = (select writers - '{1}'::int[]);
UPDATE 1
cabbage=# select * from test;
id | writers ----+-----------
1 | {3044207}
(1 row)

Thanks for any help

Adam

--
Teodor Sigaev E-mail: teodor@sigaev.ru

Attachments:

_int.patch.gzapplication/x-tar; name=_int.patch.gzDownload