2011-09-29 51 views
4

雖然沒有插入的數字是'大',但我在postgres中收到了「整數超出範圍」錯誤。他們遠低於一百萬。 查詢是通過Django ORM生成的,並且非常標準。 任何想法我在這裏失蹤? 謝謝!PostgreSql將小數字插入整數字段時整數超出範圍錯誤

# 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       
------------+--------------------------+---------------------------------------------------------- 
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 
+2

什麼'NEXTVAL( 'index_index_id_seq')'的價值?你是否超出了你的ID列? nextval返回一個bigint。 –

回答

8

也許序列超過了最大值。整數值(2147483647)。作爲一個序列基於bigint,這是可能的。

您可以測試使用SELECT nextval('index_index_id_seq')

+0

謝謝!我沒有想到這一點! – Harel