serial type (text instead of integer) and duplicate keys

From: Carlos Costa <ccosta(at)gmail(dot)com>
To: psql mailing list <pgsql-general(at)postgresql(dot)org>
Subject: serial type (text instead of integer) and duplicate keys
Date: 2005-04-12 11:44:40
Message-ID: afa69462050412044472b668b3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2005-04-12 12:00:04 Re: serial type (text instead of integer) and duplicate
Previous Message Fritz Bayer 2005-04-12 10:41:31 Re: Encoding Issue with UNICODE