Postgres 8.3.5 - ECPG and the use of descriptors and cursors in multi-threaded programs

Поиск
Список
Период
Сортировка
От Leif Jensen
Тема Postgres 8.3.5 - ECPG and the use of descriptors and cursors in multi-threaded programs
Дата
Msg-id 11871028.1725.1306155121693.JavaMail.root@quick
обсуждение исходный текст
Ответы Re: Postgres 8.3.5 - ECPG and the use of descriptors and cursors in multi-threaded programs
Список pgsql-general
Hello Guys,

    In a multi-threaded server program using Postgresql 8.3.5 with ECPG interface for C, we have problems using
descriptors(and possibly cursors). 

    We have created a common database interface module with basically 1 function: SQLExec(). In the 'select' part of
thisfunction we (statically) allocate a descriptor as shown below. 

    This seems to be working most of the time, but looking at the generated C code from the ecpg compiler and the
associatedlibrary functions, we are not sure whether we should put mutex locks around the 'select' part to avoid
severalthreads are using "the same" execdesc at the same time. 

    We have made sure that each thread uses their own and only their own database connection, but are unsure whether
theecpg library functions is able to handle multiple use of the statical name "execdesc" ? 


static int SQLExec( const char *thisDbConn, char *paramStmt )
{
  EXEC SQL BEGIN DECLARE SECTION;
  const char *_thisDbConn = thisDbConn;
  char *stmt = paramStmt;
  EXEC SQL END DECLARE SECTION;

     .
     .
  if( "select" ) {
     .
     .
    EXEC SQL AT :_thisDbConn ALLOCATE DESCRIPTOR execdesc; line = __LINE__;

      EXEC SQL AT :_thisDbConn PREPARE execquery FROM :stmt; line = __LINE__;

      EXEC SQL AT :_thisDbConn DECLARE execcurs CURSOR FOR execquery; line = __LINE__;

      EXEC SQL AT :_thisDbConn OPEN execcurs; line = __LINE__;

    while( ok ) {

      EXEC SQL AT :_thisDbConn FETCH IN execcurs INTO SQL DESCRIPTOR execdesc;
       .
       (handle data per row, using execdesc)
       .
    }
    .
    (deallocation of stuff)
    .
  }
}

   We experience spurious crashes with SIGSEGV and tracebacks of the core dump usually ends within some ecpg library
function,hence this question. 

   Please help,

 Leif

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

Предыдущее
От: Andreas Kretschmer
Дата:
Сообщение: Re: disable seqscan
Следующее
От: Sim Zacks
Дата:
Сообщение: Re: Where are plpy.execute python commands issued?