ESQL/C and threads
Posted in 1996
We are using ONLINE 7.10, ESQL/C 7.10 with Solaris 2.4 on Sparc. Having a problem when trying to open a connection to the database from the thread other than main. ( The way of connecting is TCP/IP sockets, not shared memory). The C-compiler we are using is /opt/SUNWspro/bin/cc, but I don't think this is important). Here is a test program: /* -------------------------------------- */ #include <thread.h> #include <stdio.h> $include sqlca; short make_connection(dbname, connection_name) EXEC SQL BEGIN DECLARE SECTION; PARAMETER char * dbname, * connection_name; EXEC SQL END DECLARE SECTION; { EXEC SQL CONNECT TO $dbname AS $connection_name WITH CONCURRENT TRANSACTION; fprintf(stderr, "sqlcode: %d isamerr: %d\\n", sqlca.sqlcode, sqlca.sqlerrd[1]); return !sqlca.sqlcode; } void *thread_body(args) void * args; { fprintf(stderr, "Trying to connect in other thread...\\n"); make_connection("tst", "conn1"); return 0; } main() { thread_t tid; fprintf(stderr, "Trying to connect in main thread...\\n"); make_connection("tst", "conn0"); thr_create(NULL, 0, thread_body, 0, 0, &tid); thr_join(tid, 0, 0); } /* -------------------------------------- */ This is how we compile it: esql -o tst tst.ec -lthread And this is the program's ouput: ----------------------------------------------- Trying to connect in main thread... sqlcode: 0 isamerr: 0 Trying to connect in other thread... sqlcode: -908 isamerr: 2 ----------------------------------------------- Questions: 1. Does anybody experience the same problem ? It would be great if you could find 10 minutes of your spare time to do the test. The trouble is that Informix tech. support was not supportive at all in this matter. 2. Maybe we just have to upgrade to 7.12, or 7.2 ? Again, I couldn't get the answer from Informix on such (it seems) simple question. I thought they should know. I would greatly appreciate any useful feedback. -- Leonid Ilyevsky NYNEX Science and Technology E-mail: leonid@nynexst.com 500 Westchester Ave. Phone:(914)644-2086 Fax:(914)644-2301 White Plains, NY 10604