Skip site navigation (1) Skip section navigation (2)

Maybe a bug found with nextval() function

From: Alexander Troppmann <talex(at)cocktaildreams(dot)de>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Maybe a bug found with nextval() function
Date: 2004-02-19 18:16:42
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
                        POSTGRESQL BUG REPORT TEMPLATE

Your name           : Alexander Troppmann
Your email address  : talex(at)cocktaildreams(dot)de

System Configuration
Architecture        : AMD Duron
Operating System    : Fedora Core 1.A (Linux 2.4.22-1.2174.nptl)
PostgreSQL version  : PostgreSQL-7.3.4
Compiler used       : gcc-3.3.2

Please enter a FULL description of your problem:

The nextval() function returns instead of the next valid integer value in the
corresponding SEQUENCE a whole range of exactly 435 values with each function
call... The sequence and tables have been migrated from a previous PostgreSQL
version - newer created tables and sequences work fine!

Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible:

My database has been migrated from previous versions of PostgreSQL. One table
is called "recipe" and has a column "id" of type SERIAL as primary key:

 Column  | Type      |             Modifiers
 id      | integer   | not null default nextval('"recipe_id_seq"'::text)

I din't use the features from a SERIAL type on this table before but at the
moment I'm working on a complete new database frontend.... So first I tried
to update the value of the "recipe_id_seq" SEQUENCE appropriate to the
latest value:

   SELECT SETVAL('recipe_id_seq', max(id)) FROM recipe;

returns the following output:

   (1 row)

Now I tried to fetch the next free primary key id for my "recipe" table:

   SELECT NEXTVAL('recipe_id_seq') FROM receipt;

I just wonder because the NEXTVAL query returns after every call exactly
435 rows of increasing integer values...?! Also I tested some other tables
with a SERIAL primary key and the same result - instead of the next valid
integer value I get a whole range of values, 435 times...

A table created with a PostgreSQL 7.3.x version works fine - the SEQUENCE
returns exactly (the next valid) integer value - so maybe the migrated table
structures/data from my previous PostgreSQL installations cause the troubles?

I already tried to fix the problem by dropping the "recipe_id_seq" and 
creating a new one - with any success... :-(

best regards,
Alex Troppmann


pgsql-bugs by date

Next:From: Roopali SharmaDate: 2004-02-19 18:26:06
Subject: pg_restore problems
Previous:From: Tom LaneDate: 2004-02-18 16:36:17
Subject: Re: Select (str)::FLOAT8 BUG

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group