Re: [GENERAL] Moving from MySQL to PGSQL....some questions (multilevel

2004-03-05 Thread Mike Mascari
Michael Chaney wrote: On Thu, Mar 04, 2004 at 10:50:50AM -0500, Tom Lane wrote: If I understood the requirements correctly, it might be sufficient to put a unique index on (id1,id2). If two transactions simultaneously try to insert for the same id1, one would get a duplicate-index-entry failure,

Re: [GENERAL] Moving from MySQL to PGSQL....some questions (multilevel

2004-03-04 Thread Michael Chaney
On Thu, Mar 04, 2004 at 10:50:50AM -0500, Tom Lane wrote: > If I understood the requirements correctly, it might be sufficient to > put a unique index on (id1,id2). If two transactions simultaneously try > to insert for the same id1, one would get a duplicate-index-entry > failure, and it would ha

Re: [GENERAL] Moving from MySQL to PGSQL....some questions (multilevel

2004-03-03 Thread Tom Lane
Michael Chaney <[EMAIL PROTECTED]> writes: > begin; > lock table test in exclusive mode; > insert into test values (1,(select max(id2) from test where id1=1)+1); > commit; > It's not pretty, and it'll probably slow down as the table grows. As-is, that will definitely get pretty slow on large tabl

Re: [GENERAL] Moving from MySQL to PGSQL....some questions (multilevel

2004-03-03 Thread Michael Chaney
On Wed, Mar 03, 2004 at 06:45:56AM +0100, Paulovi?? Michal wrote: > Yes I know, > > But how you do this at PgSQL You have to lock the table exclusively, get the max value for your particular "id1", increment it, insert the row, and commit: begin; lock table test in exclusive mode; insert int

Re: [GENERAL] Moving from MySQL to PGSQL....some questions (multilevel

2004-03-03 Thread Paulovič Michal
Bruno Wolff III wrote: On Wed, Mar 03, 2004 at 18:12:18 +0100, Paulovi?? Michal <[EMAIL PROTECTED]> wrote: You don't build secent level unique You have to create uniqe index under both levels (first and second) together. But in MySQL there is no problem. I alredy have table with mulitlevel au

Re: [GENERAL] Moving from MySQL to PGSQL....some questions (multilevel

2004-03-03 Thread scott.marlowe
On Wed, 3 Mar 2004, [UTF-8] Paulovič Michal wrote: > Yes I know, > > But how you do this at PgSQL OK, I just read the response where someone showed me how to make such a table in mysql. What an odd, and non-intuitive behaviour that is. Anyway, first off, upgrade your version of postgresql

Re: [GENERAL] Moving from MySQL to PGSQL....some questions (multilevel

2004-03-03 Thread Bruno Wolff III
On Wed, Mar 03, 2004 at 18:12:18 +0100, Paulovi?? Michal <[EMAIL PROTECTED]> wrote: > You don't build secent level unique > You have to create uniqe index under both levels (first and second) > together. But in MySQL there is no problem. > I alredy have table with mulitlevel autoincrement (in My

Re: [GENERAL] Moving from MySQL to PGSQL....some questions (multilevel

2004-03-03 Thread Paulovič Michal
Harald Fuchs wrote: In article <[EMAIL PROTECTED]>, "scott.marlowe" <[EMAIL PROTECTED]> writes: On Tue, 2 Mar 2004, [UTF-8] PauloviÃÂ Michal wrote: how you solve the problem with multilevel autoicrement? In MySQL you create table with col1, col2. Col 2 is AUTOICRE

Re: [GENERAL] Moving from MySQL to PGSQL....some questions (multilevel

2004-03-02 Thread Paulovič Michal
how you solve the problem with multilevel autoicrement? In MySQL you create table with col1, col2. Col 2 is AUTOICREMENT and you have to create UNIQUE INDEX (Col1, Col2). If you insert to this table for col1 volume 1, col2 automaticaly increase by one. Example: Insert into table values (1); Ins