From: Philip Yarra <philip@utiba.com>
To: pgsql-interfaces@postgresql.org
Subject: ECPG thread-safety test-case
Date: Thu, 8 May 2003 17:30:28 +1000
Message-ID: <200305081730.28422.philip@utiba.com> (raw)
Hi all, as per conversations around about 2003-04-22, I have put together a
quick app to test the thread-safety issue in ECPG that we hit. I've run this
against 7.3.2 with Lee's patch applied, and I still get problems with threads
locking up.
Would anyone care to give it a try? It would help me to ascertain if the
problem still exists, or if it's something I am doing wrong.
Regards, Philip Yarra.
Attachments:cn.pgc (text/x-csrc, 1.3K) download
/* on linux, you can compile with:
ecpg cn.pgc&& gcc -I/usr/local/pgsql/include -L/usr/local/pgsql/lib -lecpg -lpthread cn.c
and you'll need this table:
CREATE TABLE foo (
message character(40)
);
*/
#include <pthread.h>
int main();
void ins1();
void ins2();
int main()
{
pthread_t thread1, thread2;
pthread_create(&thread1, NULL, (void *) ins1, NULL);
pthread_create(&thread2, NULL, (void *) ins2, NULL);
pthread_join(thread1, NULL);
pthread_join(thread2, NULL);
printf("Done!");
return 0;
}
void ins1()
{
int i;
EXEC SQL BEGIN DECLARE SECTION;
char* cs = "test@somehost";
char* bar = "one!";
EXEC SQL END DECLARE SECTION;
EXEC SQL WHENEVER sqlerror sqlprint;
EXEC SQL CONNECT TO :cs AS test1;
EXEC SQL SET AUTOCOMMIT TO ON;
for (i = 0; i < 5; i++)
{
printf("thread1 inserting\n");
EXEC SQL INSERT INTO foo VALUES(:bar);
printf("==>thread1 insert done\n");
}
EXEC SQL DISCONNECT test1;
printf("done!\n");
}
void ins2()
{
int i;
EXEC SQL BEGIN DECLARE SECTION;
char* cs = "test@somehost";
char* bar = "two!";
EXEC SQL END DECLARE SECTION;
EXEC SQL WHENEVER sqlerror sqlprint;
EXEC SQL CONNECT TO :cs AS test2;
EXEC SQL SET AUTOCOMMIT TO ON;
for (i = 0; i < 5; i++)
{
printf("thread2 inserting\n");
EXEC SQL INSERT INTO foo VALUES(:bar);
printf("==>thread2 insert done\n");
}
EXEC SQL DISCONNECT test2;
printf("done!\n");
}
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: philip@utiba.com
Subject: Re: ECPG thread-safety test-case
In-Reply-To: <200305081730.28422.philip@utiba.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox