PostgreSql Integer out of range error when inserting small numbers into integer fields
I'm getting an "integer out of range" error in postgres, though none of the numbers inserted are 'big'. They are well under a million. The query is generated via the Django ORM, and is pretty standard looking. Any idea what I'm missing here? Thanks!
# INSERT INTO "index_index" ("word_id", "ad_id", "field", "position", "created_at") VALUES (98036, 703906, E'y.x', 0, E'2011-09-29 22:02:40.252332') RETURNING "index_index"."id";
ERROR: integer out of range
# \d index_index;
Table "public.index_index"
Column | Type | Modifiers 开发者_如何学C
------------+--------------------------+----------------------------------------------------------
id | integer | not null default nextval('index_index_id_seq'::regclass)
word_id | integer | not null
ad_id | integer | not null
field | character varying(50) | not null
position | integer | not null
created_at | timestamp with time zone | not null
Indexes:
"index_index_pkey" PRIMARY KEY, btree (id)
"index_index_ad_id" btree (ad_id)
"index_index_word_id" btree (word_id)
Foreign-key constraints:
"index_index_ad_id_fkey" FOREIGN KEY (ad_id) REFERENCES campaigns_ad(id) DEFERRABLE INITIALLY DEFERRED
"index_index_word_id_fkey" FOREIGN KEY (word_id) REFERENCES index_word(id) DEFERRABLE INITIALLY DEFERRED
Maybe the sequence has exceeded the max. value for an integer (2147483647). As a sequence is based on a bigint, this is possible.
You can test that using SELECT nextval('index_index_id_seq')
精彩评论