Search Postgresql Archives

Re: regarding isolation between threads

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux