Re: Change the behaviour of the SERIAL "Type" - Mailing list pgsql-sql

From Randall Lucas
Subject Re: Change the behaviour of the SERIAL "Type"
Date
Msg-id FA785BC0-A7EF-11D7-8248-000A957653D6@tercent.net
Whole thread Raw
In response to Re: Change the behaviour of the SERIAL "Type"  (Bruno Wolff III <bruno@wolff.to>)
Responses Re: Change the behaviour of the SERIAL "Type"
List pgsql-sql
Wow, I had never actually faced this problem (yet) but I spied it as a 
possible stumbling block for porting MySQL apps, for which the standard 
practice is inserting a NULL.  As I have made a fairly thorough reading 
of the docs (but may have not cross-correlated every piece of data yet, 
obviously), I was surprised to find I hadn't figured this out myself.  
It /seems/ obvious in retrospect, but it really baked my noodle when I 
first looked at some ugly MySQL queries.

Respectfully, then, I move that a sentence outlining this functionality 
be added to User Manual section 5.1.4, "The Serial Types."  
Furthermore, anyone who has written or is writing a MySQL porting guide 
should include this, if he hasn't.

Best,

Randall


On Thursday, June 26, 2003, at 08:49 AM, Bruno Wolff III wrote:

> On Thu, Jun 26, 2003 at 14:31:34 +0200,
>   Dani Oderbolz <oderbolz@ecologic.de> wrote:
>>
>> It was written for MySQL, which can take NULL and then assign an
>> auto_increment.
>> However, in PostgreSQL I am getting problems, because it would not let
>> me insert NULL
>> into a NOT NULL column (which is perfectly sensible from my point of 
>> view).
>> But as the author has also left out the column list in the insert, its
>> really tedious to change
>> the code.
>
> You can use the keyword DEFAULT instead of NULL and it will do what you
> want.
>
>> This way, there would be no possibility to circumvent the Value which
>> comes from the Sequence.
>
> You can use a unique constraint to enforce uniqueness.
>
>> Is there a way to change SERIAL this way?
>
> Well you can certainly write your own trigger to do this.
>
> ---------------------------(end of 
> broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faqs/FAQ.html
>



pgsql-sql by date:

Previous
From: Bruce Young
Date:
Subject: contrib/tsearch - chopped words?
Next
From: Michael A Nachbaur
Date:
Subject: Temporary table performance?