Insert into a table with only a SERIAL - Mailing list pgsql-general

From
Subject Insert into a table with only a SERIAL
Date
Msg-id 14678.31782.627040.169981@crowfix.com
Whole thread Raw
Responses Re: Insert into a table with only a SERIAL
List pgsql-general
I am pretty much self taught using SQL, and I suspect that my problem
here is trying to do something silly.  I have since changed my tables
and avoided the problem, but I am curious as to why this happens, and
it's remotely possible I have even found a bug or two.

I created a table with only a sequence:

  CREATE TABLE aaa (
    id SERIAL,
  );

I can't insert into aaa unless I pass a value; these don't work:

  insert into aaa;
  insert into aaa values ();
  insert into aaa () values ();

But this does:

  insert into aaa values (1);

except that the value inserted is not known to the sequence.
(** This seems a bug to me **)

This also works:

  insert into aaa values (nextval('aaa_id_seq'));

but sort of defeats the purpose of using a type SERIAL rather than
hand rolling my own sequence.

--
            ... _._. ._ ._. . _._. ._. ___ .__ ._. . .__. ._ .. ._.
     Felix Finch: scarecrow repairman & rocket surgeon / felix@crowfix.com
  GPG = E987 4493 C860 246C 3B1E  6477 7838 76E9 182E 8151 ITAR license #4933
I've found a solution to Fermat's Last Theorem but I see I've run out of room o

pgsql-general by date:

Previous
From: Michael Fraley
Date:
Subject: ERROR: fmgr_info: function 19104: cache lookup failed
Next
From: John Gotts
Date:
Subject: SQL INSERT bug with 6.5.3 and 7.0.2