serial type (text instead of integer) and duplicate keys - Mailing list pgsql-general

From Carlos Costa
Subject serial type (text instead of integer) and duplicate keys
Date
Msg-id afa69462050412044472b668b3@mail.gmail.com
Whole thread Raw
Responses Re: serial type (text instead of integer) and duplicate  (Richard Huxton <dev@archonet.com>)
List pgsql-general
Hello all!

There is an extrange error in my logfile:

update articles set online='t' where id = 391 ;
ERROR:  duplicate key violates unique constraint "articles_pkey"

(the error exists only with this id)

I've checked (well, almost imposible) if there was more than one
article with this id:

select count(*) from articles where id=391 ;
 count
-------
     1
(1 row)

Then, I checked the table:

                                     Table "public.articles"
      Column       |          Type          |                      Modifiers
-------------------+------------------------+-----------------------------------------------------
 id                | integer                | not null default
nextval('"articles_id_seq"'::text)

Here is the origin of my problem, I think: "text". "text"?. The
"serial" type generate text instead of integer. Really extrange.

So, my next query:
select id from articles where id like '%391%' ;
 id
-----
 391
 391
(2 rows)

The problem is easy to solve: delete and re-create the rows. But I
would like to know the origin of this error. Any tip?


Thanks in advance,
Carlos

--
[ http://www.improveyourweb.com/ ]
web.log.about.web.development

pgsql-general by date:

Previous
From: Michael Ben-Nes
Date:
Subject: Re: PostgreSQL 8.0.2 Now Available
Next
From: Richard Huxton
Date:
Subject: Re: serial type (text instead of integer) and duplicate