Re: regarding isolation between threads

From: Richard Huxton <dev(at)archonet(dot)com>
To: Surabhi Ahuja <surabhi(dot)ahuja(at)iiitb(dot)ac(dot)in>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: regarding isolation between threads
Date: 2005-08-11 11:40:49
Message-ID: 42FB3941.9080006@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Surabhi Ahuja wrote:
> void *connect(void* threadid)
> {
> char command[100];
> int *id_ptr, taskid;
> id_ptr = (int *) threadid;
> taskid = *id_ptr;
> if(taskid == 0)
> strcpy(command, "select insert (1)");
> else if(taskid == 1)
> strcpy(command, "select insert (1)");
...

> the kind of output i am expecting is:
>
> table x: 1 3 4 5
> table a: 1
> and no error message
>
> but the output is something like
>
> table x : 1 3 4 5
> table some_other_table :
> it has nothing
> and error message is displayed : "error in stored proc "insert(..... primary key violation .."
> this error is because
>
> two threads are simultaneoulsy trying to insert the values "1" each and thats where they interfere with each other.

That's because that's what you've asked them to do (see code fragment).

Oh, and personally, I think "insert" is a bad name for a function - it
just took me 5 minutes to figure out what you meant.

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Christopher Browne 2005-08-11 12:11:09 Re: What's up with EnterpriseDB?
Previous Message Surabhi Ahuja 2005-08-11 10:34:00 regarding isolation between threads