Re: regarding isolation between threads

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: regarding isolation between threads
Дата
Msg-id 42FB3941.9080006@archonet.com
обсуждение исходный текст
Ответ на regarding isolation between threads  ("Surabhi Ahuja " <surabhi.ahuja@iiitb.ac.in>)
Список 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

В списке pgsql-general по дате отправления:

Предыдущее
От: "Surabhi Ahuja "
Дата:
Сообщение: regarding isolation between threads
Следующее
От: Jeff Boes
Дата:
Сообщение: Re: World-wide Stop Order on PERL,Python,Java::->> Use