Re: [PATCHES] [HACKERS] TRUNCATE TABLE with IDENTITY

2008-07-01 Thread Bruce Momjian
Alvaro Herrera wrote: > Tom Lane wrote: > > > 2. I had first dismissed Neil's idea of transactional sequence updates > > as impossible, but on second look it could be done. Suppose RESTART > > IDENTITY does this for each sequence; > > > > * obtain AccessExclusiveLock; > > * assign a new

Re: [PATCHES] [HACKERS] TRUNCATE TABLE with IDENTITY

2008-06-08 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> 2. I had first dismissed Neil's idea of transactional sequence updates >> as impossible, but on second look it could be done. Suppose RESTART >> IDENTITY does this for each sequence; >> >> * obtain AccessExclusiveLock; >> * assign a

Re: [PATCHES] [HACKERS] TRUNCATE TABLE with IDENTITY

2008-06-07 Thread Alvaro Herrera
Tom Lane wrote: > 2. I had first dismissed Neil's idea of transactional sequence updates > as impossible, but on second look it could be done. Suppose RESTART > IDENTITY does this for each sequence; > > * obtain AccessExclusiveLock; > * assign a new relfilenode; > * insert a se

Re: [PATCHES] [HACKERS] TRUNCATE TABLE with IDENTITY

2008-05-17 Thread Simon Riggs
On Sat, 2008-05-17 at 12:04 -0400, Tom Lane wrote: > So what I think we should do is leave the patch there, revise the > warning per Neil's complaint, and add a TODO item to reimplement > RESTART IDENTITY transactionally. Sounds good. -- Simon Riggs www.2ndQuadrant.com PostgreSQL T

Re: [PATCHES] [HACKERS] TRUNCATE TABLE with IDENTITY

2008-05-17 Thread Tom Lane
Simon Riggs <[EMAIL PROTECTED]> writes: > On Fri, 2008-05-16 at 21:50 -0400, Tom Lane wrote: >> Actually, I agree. Shall we just revert that feature? > Perhaps, but we should also take into account that TRUNCATE is not and > never will be MVCC compliant, so its not something you'd expect to run >

Re: [PATCHES] [HACKERS] TRUNCATE TABLE with IDENTITY

2008-05-17 Thread Simon Riggs
On Fri, 2008-05-16 at 21:50 -0400, Tom Lane wrote: > Neil Conway <[EMAIL PROTECTED]> writes: > > Ugh. The fact that the RESTART IDENTITY part of TRUNCATE is > > non-transactional is a pretty unsightly wort. > > Actually, I agree. Shall we just revert that feature? The ALTER > SEQUENCE part of t

Re: [PATCHES] [HACKERS] TRUNCATE TABLE with IDENTITY

2008-05-16 Thread Tom Lane
Neil Conway <[EMAIL PROTECTED]> writes: > Ugh. The fact that the RESTART IDENTITY part of TRUNCATE is > non-transactional is a pretty unsightly wort. Actually, I agree. Shall we just revert that feature? The ALTER SEQUENCE part of this patch is clean and useful, but I'm less than enamored of the

Re: [PATCHES] [HACKERS] TRUNCATE TABLE with IDENTITY

2008-05-16 Thread Neil Conway
On Fri, 2008-05-16 at 19:41 -0400, Tom Lane wrote: > Applied with corrections. Most notably, since ALTER SEQUENCE RESTART > is nontransactional like most other ALTER SEQUENCE operations, I > rearranged things to try to ensure that foreseeable failures like > deadlock and lack of permissions would

Re: [PATCHES] [HACKERS] TRUNCATE TABLE with IDENTITY

2008-05-16 Thread Tom Lane
I wrote: > One interesting point here is that the patch as submitted allowed > ALTER SEQUENCE MINVALUE/MAXVALUE to be used to set a sequence range > that the original START value was outside of. This would result in > a failure at ALTER SEQUENCE RESTART. Since, as stated above, we > really don't

Re: [PATCHES] [HACKERS] TRUNCATE TABLE with IDENTITY

2008-05-16 Thread Tom Lane
Zoltan Boszormenyi <[EMAIL PROTECTED]> writes: >> Attached patch implements the extension found in the current SQL200n draft, >> implementing stored start value and supporting ALTER SEQUENCE seq RESTART; > Updated patch implements TRUNCATE ... RESTART IDENTITY > which restarts all owned sequences

Re: [HACKERS] TRUNCATE TABLE with IDENTITY

2008-04-22 Thread Alvaro Herrera
Zoltan Boszormenyi wrote: > I just saw this on the CommitFest:May page: > > "alvherre says: I'm not sure if this is the same patch in the previous > entry, or a different feature" > > I wanted to clarify, the second patch contains two features. > 1. stored start value for sequences, ALTER SEQUEN

Re: [HACKERS] TRUNCATE TABLE with IDENTITY

2008-04-22 Thread Zoltan Boszormenyi
Hi, Zoltan Boszormenyi írta: Updated patch implements TRUNCATE ... RESTART IDENTITY which restarts all owned sequences for the truncated table(s). Regression tests updated, documentation added. pg_dump was also extended to output original[1] START value for creating SEQUENCEs. [1] For 8.3 and b

Re: [HACKERS] TRUNCATE TABLE with IDENTITY

2008-04-21 Thread Zoltan Boszormenyi
Zoltan Boszormenyi írta: Zoltan Boszormenyi írta: Decibel! írta: On Apr 3, 2008, at 12:52 AM, Zoltan Boszormenyi wrote: Where is the info in the sequence to provide restarting with the _original_ start value? There isn't any. If you want the sequence to start at some magic value, adjust the

Re: [HACKERS] TRUNCATE TABLE with IDENTITY

2008-04-08 Thread Zoltan Boszormenyi
Zoltan Boszormenyi írta: Decibel! írta: On Apr 3, 2008, at 12:52 AM, Zoltan Boszormenyi wrote: Where is the info in the sequence to provide restarting with the _original_ start value? There isn't any. If you want the sequence to start at some magic value, adjust the minimum value. There's

Re: [HACKERS] TRUNCATE TABLE with IDENTITY

2008-04-07 Thread Zoltan Boszormenyi
Decibel! írta: On Apr 3, 2008, at 12:52 AM, Zoltan Boszormenyi wrote: Where is the info in the sequence to provide restarting with the _original_ start value? There isn't any. If you want the sequence to start at some magic value, adjust the minimum value. There's the START WITH option for

Re: [HACKERS] TRUNCATE TABLE with IDENTITY

2008-04-07 Thread Decibel!
On Apr 3, 2008, at 12:52 AM, Zoltan Boszormenyi wrote: Where is the info in the sequence to provide restarting with the _original_ start value? There isn't any. If you want the sequence to start at some magic value, adjust the minimum value. -- Decibel!, aka Jim C. Nasby, Database Architect

Re: [HACKERS] TRUNCATE TABLE with IDENTITY

2008-04-02 Thread Zoltan Boszormenyi
Decibel! írta: On Mar 25, 2008, at 11:40 AM, Zoltan Boszormenyi wrote: All of them? PostgreSQL allow multiple SERIALs to be present, the standard allows only one IDENTITY column in a table. And what about this case below? CREATE TABLE t1 (id1 serial, ...); ALTER SEQUENCE seq_t1_id1 RESTART WITH

Re: [HACKERS] TRUNCATE TABLE with IDENTITY

2008-04-02 Thread Decibel!
On Mar 25, 2008, at 11:40 AM, Zoltan Boszormenyi wrote: All of them? PostgreSQL allow multiple SERIALs to be present, the standard allows only one IDENTITY column in a table. And what about this case below? CREATE TABLE t1 (id1 serial, ...); ALTER SEQUENCE seq_t1_id1 RESTART WITH 5432 CYCLE; or

Re: [HACKERS] TRUNCATE TABLE with IDENTITY

2008-03-25 Thread Zoltan Boszormenyi
Zoltan Boszormenyi írta: Simon Riggs írta: On Tue, 2008-03-25 at 09:08 -0700, Steve Crawford wrote: Simon Riggs wrote: RESTART IDENTITY will reset the SERIAL sequences back to the original start value. Assuming this feature were to be added In cases where the same sequence

Re: [HACKERS] TRUNCATE TABLE with IDENTITY

2008-03-25 Thread Gregory Stark
"Simon Riggs" <[EMAIL PROTECTED]> writes: > SQL200n specifies a new qualifier on a TRUNCATE command > > TRUNCATE TABLE foo > [ CONTINUE IDENTITY | RESTART IDENTITY ] > > CONTINUE IDENTITY is the default and does nothing, like now. > > RESTART IDENTITY will reset the SERIAL sequences back to

Re: [HACKERS] TRUNCATE TABLE with IDENTITY

2008-03-25 Thread Bruce Momjian
Zoltan Boszormenyi wrote: > All of them? PostgreSQL allow multiple SERIALs to be present, > the standard allows only one IDENTITY column in a table. > And what about this case below? > > CREATE TABLE t1 (id1 serial, ...); > ALTER SEQUENCE seq_t1_id1 RESTART WITH 5432 CYCLE; > > or the equivalent

Re: [HACKERS] TRUNCATE TABLE with IDENTITY

2008-03-25 Thread Zoltan Boszormenyi
Simon Riggs írta: On Tue, 2008-03-25 at 09:08 -0700, Steve Crawford wrote: Simon Riggs wrote: RESTART IDENTITY will reset the SERIAL sequences back to the original start value. Assuming this feature were to be added In cases where the same sequence has been used across m

Re: [HACKERS] TRUNCATE TABLE with IDENTITY

2008-03-25 Thread Simon Riggs
On Tue, 2008-03-25 at 09:08 -0700, Steve Crawford wrote: > Simon Riggs wrote: > > RESTART IDENTITY will reset the SERIAL sequences back to the original > > start value. > > > Assuming this feature were to be added > > In cases where the same sequence has been used across multiple tables, >

Re: [HACKERS] TRUNCATE TABLE with IDENTITY

2008-03-25 Thread Steve Crawford
Simon Riggs wrote: RESTART IDENTITY will reset the SERIAL sequences back to the original start value. Assuming this feature were to be added In cases where the same sequence has been used across multiple tables, what will be the appropriate response when a user attempts to TRUNCATE one

Re: [HACKERS] TRUNCATE TABLE with IDENTITY

2008-03-25 Thread Simon Riggs
On Tue, 2008-03-25 at 11:48 -0400, Tom Lane wrote: > Simon Riggs <[EMAIL PROTECTED]> writes: > > SQL200n specifies a new qualifier on a TRUNCATE command > > TRUNCATE TABLE foo > > [ CONTINUE IDENTITY | RESTART IDENTITY ] > > > CONTINUE IDENTITY is the default and does nothing, like now. > > >

Re: [HACKERS] TRUNCATE TABLE with IDENTITY

2008-03-25 Thread Tom Lane
Simon Riggs <[EMAIL PROTECTED]> writes: > SQL200n specifies a new qualifier on a TRUNCATE command > TRUNCATE TABLE foo > [ CONTINUE IDENTITY | RESTART IDENTITY ] > CONTINUE IDENTITY is the default and does nothing, like now. > RESTART IDENTITY will reset the SERIAL sequences back to the ori

[HACKERS] TRUNCATE TABLE with IDENTITY

2008-03-25 Thread Simon Riggs
SQL200n specifies a new qualifier on a TRUNCATE command TRUNCATE TABLE foo [ CONTINUE IDENTITY | RESTART IDENTITY ] CONTINUE IDENTITY is the default and does nothing, like now. RESTART IDENTITY will reset the SERIAL sequences back to the original start value. Seems like a % project for