Changed order of statements and added an additiona MSVC safeguard to make ecpg
thread test cases work on Windows.
This commit is contained in:
parent
2073c641b4
commit
04fbe0e451
|
@ -128,63 +128,65 @@ static void* fn(void* arg)
|
|||
{
|
||||
int i;
|
||||
|
||||
#ifdef WIN32
|
||||
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
|
||||
#endif
|
||||
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
#line 44 "alloc.pgc"
|
||||
#line 40 "alloc.pgc"
|
||||
int value ;
|
||||
|
||||
#line 45 "alloc.pgc"
|
||||
#line 41 "alloc.pgc"
|
||||
char name [ 100 ] ;
|
||||
|
||||
#line 46 "alloc.pgc"
|
||||
#line 42 "alloc.pgc"
|
||||
char ** r = NULL ;
|
||||
/* exec sql end declare section */
|
||||
#line 47 "alloc.pgc"
|
||||
#line 43 "alloc.pgc"
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _MSC_VER /* requires MSVC */
|
||||
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
value = (long)arg;
|
||||
sprintf(name, "Connection: %d", value);
|
||||
|
||||
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , name, 0);
|
||||
#line 52 "alloc.pgc"
|
||||
#line 54 "alloc.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 52 "alloc.pgc"
|
||||
#line 54 "alloc.pgc"
|
||||
|
||||
{ ECPGsetcommit(__LINE__, "on", NULL);
|
||||
#line 53 "alloc.pgc"
|
||||
#line 55 "alloc.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 53 "alloc.pgc"
|
||||
#line 55 "alloc.pgc"
|
||||
|
||||
for (i = 1; i <= REPEATS; ++i)
|
||||
{
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select relname from pg_class where relname = 'pg_class'", ECPGt_EOIT,
|
||||
ECPGt_char,&(r),(long)0,(long)0,(1)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
|
||||
#line 56 "alloc.pgc"
|
||||
#line 58 "alloc.pgc"
|
||||
|
||||
if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
|
||||
#line 56 "alloc.pgc"
|
||||
#line 58 "alloc.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 56 "alloc.pgc"
|
||||
#line 58 "alloc.pgc"
|
||||
|
||||
free(r);
|
||||
r = NULL;
|
||||
}
|
||||
{ ECPGdisconnect(__LINE__, name);
|
||||
#line 60 "alloc.pgc"
|
||||
#line 62 "alloc.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 60 "alloc.pgc"
|
||||
#line 62 "alloc.pgc"
|
||||
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -109,22 +109,24 @@ static void* fn(void* arg)
|
|||
int i;
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _MSC_VER /* requires MSVC */
|
||||
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
for (i = 1; i <= REPEATS; ++i)
|
||||
{
|
||||
ECPGallocate_desc(__LINE__, "mydesc");
|
||||
#line 34 "descriptor.pgc"
|
||||
#line 36 "descriptor.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();
|
||||
#line 34 "descriptor.pgc"
|
||||
#line 36 "descriptor.pgc"
|
||||
|
||||
ECPGdeallocate_desc(__LINE__, "mydesc");
|
||||
#line 35 "descriptor.pgc"
|
||||
#line 37 "descriptor.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();
|
||||
#line 35 "descriptor.pgc"
|
||||
#line 37 "descriptor.pgc"
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -128,73 +128,75 @@ static void* fn(void* arg)
|
|||
{
|
||||
int i;
|
||||
|
||||
#ifdef WIN32
|
||||
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
|
||||
#endif
|
||||
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
#line 44 "prep.pgc"
|
||||
#line 40 "prep.pgc"
|
||||
int value ;
|
||||
|
||||
#line 45 "prep.pgc"
|
||||
#line 41 "prep.pgc"
|
||||
char name [ 100 ] ;
|
||||
|
||||
#line 46 "prep.pgc"
|
||||
#line 42 "prep.pgc"
|
||||
char query [ 256 ] = "INSERT INTO T VALUES ( ? )" ;
|
||||
/* exec sql end declare section */
|
||||
#line 47 "prep.pgc"
|
||||
#line 43 "prep.pgc"
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _MSC_VER /* requires MSVC */
|
||||
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
value = (long)arg;
|
||||
sprintf(name, "Connection: %d", value);
|
||||
|
||||
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , name, 0);
|
||||
#line 52 "prep.pgc"
|
||||
#line 54 "prep.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 52 "prep.pgc"
|
||||
#line 54 "prep.pgc"
|
||||
|
||||
{ ECPGsetcommit(__LINE__, "on", NULL);
|
||||
#line 53 "prep.pgc"
|
||||
#line 55 "prep.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 53 "prep.pgc"
|
||||
#line 55 "prep.pgc"
|
||||
|
||||
for (i = 1; i <= REPEATS; ++i)
|
||||
{
|
||||
{ ECPGprepare(__LINE__, NULL, 0, "i", query);
|
||||
#line 56 "prep.pgc"
|
||||
#line 58 "prep.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 56 "prep.pgc"
|
||||
#line 58 "prep.pgc"
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "i",
|
||||
ECPGt_int,&(value),(long)1,(long)1,sizeof(int),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
|
||||
#line 57 "prep.pgc"
|
||||
#line 59 "prep.pgc"
|
||||
|
||||
if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
|
||||
#line 57 "prep.pgc"
|
||||
#line 59 "prep.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 57 "prep.pgc"
|
||||
#line 59 "prep.pgc"
|
||||
|
||||
}
|
||||
{ ECPGdeallocate(__LINE__, 0, NULL, "i");
|
||||
#line 59 "prep.pgc"
|
||||
#line 61 "prep.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 59 "prep.pgc"
|
||||
#line 61 "prep.pgc"
|
||||
|
||||
{ ECPGdisconnect(__LINE__, name);
|
||||
#line 60 "prep.pgc"
|
||||
#line 62 "prep.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 60 "prep.pgc"
|
||||
#line 62 "prep.pgc"
|
||||
|
||||
|
||||
return 0;
|
||||
|
@ -210,34 +212,34 @@ int main ()
|
|||
#endif
|
||||
|
||||
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
|
||||
#line 74 "prep.pgc"
|
||||
#line 76 "prep.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 74 "prep.pgc"
|
||||
#line 76 "prep.pgc"
|
||||
|
||||
{ ECPGsetcommit(__LINE__, "on", NULL);
|
||||
#line 75 "prep.pgc"
|
||||
#line 77 "prep.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 75 "prep.pgc"
|
||||
#line 77 "prep.pgc"
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table if exists T", ECPGt_EOIT, ECPGt_EORT);
|
||||
#line 76 "prep.pgc"
|
||||
#line 78 "prep.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 76 "prep.pgc"
|
||||
#line 78 "prep.pgc"
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table T ( i int )", ECPGt_EOIT, ECPGt_EORT);
|
||||
#line 77 "prep.pgc"
|
||||
#line 79 "prep.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 77 "prep.pgc"
|
||||
#line 79 "prep.pgc"
|
||||
|
||||
{ ECPGdisconnect(__LINE__, "CURRENT");
|
||||
#line 78 "prep.pgc"
|
||||
#line 80 "prep.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 78 "prep.pgc"
|
||||
#line 80 "prep.pgc"
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
|
|
|
@ -140,23 +140,25 @@ void *test_thread(void *arg)
|
|||
{
|
||||
long threadnum = (long)arg;
|
||||
|
||||
#ifdef WIN32
|
||||
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
|
||||
#endif
|
||||
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
#line 107 "thread.pgc"
|
||||
#line 103 "thread.pgc"
|
||||
int l_i ;
|
||||
|
||||
#line 108 "thread.pgc"
|
||||
#line 104 "thread.pgc"
|
||||
char l_connection [ 128 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 109 "thread.pgc"
|
||||
#line 105 "thread.pgc"
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _MSC_VER /* requires MSVC */
|
||||
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* build up connection name, and connect to database */
|
||||
#ifndef _MSC_VER
|
||||
snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
|
||||
|
@ -164,13 +166,13 @@ void *test_thread(void *arg)
|
|||
_snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
|
||||
#endif
|
||||
/* exec sql whenever sqlerror sqlprint ; */
|
||||
#line 117 "thread.pgc"
|
||||
#line 119 "thread.pgc"
|
||||
|
||||
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , l_connection, 0);
|
||||
#line 118 "thread.pgc"
|
||||
#line 120 "thread.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 118 "thread.pgc"
|
||||
#line 120 "thread.pgc"
|
||||
|
||||
if( sqlca.sqlcode != 0 )
|
||||
{
|
||||
|
@ -178,10 +180,10 @@ if (sqlca.sqlcode < 0) sqlprint();}
|
|||
return( NULL );
|
||||
}
|
||||
{ ECPGtrans(__LINE__, l_connection, "begin");
|
||||
#line 124 "thread.pgc"
|
||||
#line 126 "thread.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 124 "thread.pgc"
|
||||
#line 126 "thread.pgc"
|
||||
|
||||
|
||||
/* insert into test_thread table */
|
||||
|
@ -192,10 +194,10 @@ if (sqlca.sqlcode < 0) sqlprint();}
|
|||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_int,&(l_i),(long)1,(long)1,sizeof(int),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
|
||||
#line 129 "thread.pgc"
|
||||
#line 131 "thread.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 129 "thread.pgc"
|
||||
#line 131 "thread.pgc"
|
||||
|
||||
if( sqlca.sqlcode != 0 )
|
||||
printf("%s: ERROR: insert failed!\n", l_connection);
|
||||
|
@ -203,16 +205,16 @@ if (sqlca.sqlcode < 0) sqlprint();}
|
|||
|
||||
/* all done */
|
||||
{ ECPGtrans(__LINE__, l_connection, "commit");
|
||||
#line 135 "thread.pgc"
|
||||
#line 137 "thread.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 135 "thread.pgc"
|
||||
#line 137 "thread.pgc"
|
||||
|
||||
{ ECPGdisconnect(__LINE__, l_connection);
|
||||
#line 136 "thread.pgc"
|
||||
#line 138 "thread.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 136 "thread.pgc"
|
||||
#line 138 "thread.pgc"
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
|
|
|
@ -141,23 +141,25 @@ void *test_thread(void *arg)
|
|||
{
|
||||
long threadnum = (long)arg;
|
||||
|
||||
#ifdef WIN32
|
||||
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
|
||||
#endif
|
||||
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
#line 108 "thread_implicit.pgc"
|
||||
#line 104 "thread_implicit.pgc"
|
||||
int l_i ;
|
||||
|
||||
#line 109 "thread_implicit.pgc"
|
||||
#line 105 "thread_implicit.pgc"
|
||||
char l_connection [ 128 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 110 "thread_implicit.pgc"
|
||||
#line 106 "thread_implicit.pgc"
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _MSC_VER /* requires MSVC */
|
||||
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* build up connection name, and connect to database */
|
||||
#ifndef _MSC_VER
|
||||
snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
|
||||
|
@ -165,13 +167,13 @@ void *test_thread(void *arg)
|
|||
_snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
|
||||
#endif
|
||||
/* exec sql whenever sqlerror sqlprint ; */
|
||||
#line 118 "thread_implicit.pgc"
|
||||
#line 120 "thread_implicit.pgc"
|
||||
|
||||
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , l_connection, 0);
|
||||
#line 119 "thread_implicit.pgc"
|
||||
#line 121 "thread_implicit.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 119 "thread_implicit.pgc"
|
||||
#line 121 "thread_implicit.pgc"
|
||||
|
||||
if( sqlca.sqlcode != 0 )
|
||||
{
|
||||
|
@ -179,10 +181,10 @@ if (sqlca.sqlcode < 0) sqlprint();}
|
|||
return( NULL );
|
||||
}
|
||||
{ ECPGtrans(__LINE__, NULL, "begin");
|
||||
#line 125 "thread_implicit.pgc"
|
||||
#line 127 "thread_implicit.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 125 "thread_implicit.pgc"
|
||||
#line 127 "thread_implicit.pgc"
|
||||
|
||||
|
||||
/* insert into test_thread table */
|
||||
|
@ -193,10 +195,10 @@ if (sqlca.sqlcode < 0) sqlprint();}
|
|||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_int,&(l_i),(long)1,(long)1,sizeof(int),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
|
||||
#line 130 "thread_implicit.pgc"
|
||||
#line 132 "thread_implicit.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 130 "thread_implicit.pgc"
|
||||
#line 132 "thread_implicit.pgc"
|
||||
|
||||
if( sqlca.sqlcode != 0 )
|
||||
printf("%s: ERROR: insert failed!\n", l_connection);
|
||||
|
@ -204,16 +206,16 @@ if (sqlca.sqlcode < 0) sqlprint();}
|
|||
|
||||
/* all done */
|
||||
{ ECPGtrans(__LINE__, NULL, "commit");
|
||||
#line 136 "thread_implicit.pgc"
|
||||
#line 138 "thread_implicit.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 136 "thread_implicit.pgc"
|
||||
#line 138 "thread_implicit.pgc"
|
||||
|
||||
{ ECPGdisconnect(__LINE__, l_connection);
|
||||
#line 137 "thread_implicit.pgc"
|
||||
#line 139 "thread_implicit.pgc"
|
||||
|
||||
if (sqlca.sqlcode < 0) sqlprint();}
|
||||
#line 137 "thread_implicit.pgc"
|
||||
#line 139 "thread_implicit.pgc"
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
|
|
|
@ -36,16 +36,18 @@ static void* fn(void* arg)
|
|||
{
|
||||
int i;
|
||||
|
||||
#ifdef WIN32
|
||||
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
|
||||
#endif
|
||||
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
int value;
|
||||
char name[100];
|
||||
char **r = NULL;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _MSC_VER /* requires MSVC */
|
||||
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
value = (long)arg;
|
||||
sprintf(name, "Connection: %d", value);
|
||||
|
||||
|
|
|
@ -26,7 +26,9 @@ static void* fn(void* arg)
|
|||
int i;
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _MSC_VER /* requires MSVC */
|
||||
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
for (i = 1; i <= REPEATS; ++i)
|
||||
|
|
|
@ -36,16 +36,18 @@ static void* fn(void* arg)
|
|||
{
|
||||
int i;
|
||||
|
||||
#ifdef WIN32
|
||||
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
|
||||
#endif
|
||||
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
int value;
|
||||
char name[100];
|
||||
char query[256] = "INSERT INTO T VALUES ( ? )";
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _MSC_VER /* requires MSVC */
|
||||
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
value = (long)arg;
|
||||
sprintf(name, "Connection: %d", value);
|
||||
|
||||
|
|
|
@ -99,15 +99,17 @@ void *test_thread(void *arg)
|
|||
{
|
||||
long threadnum = (long)arg;
|
||||
|
||||
#ifdef WIN32
|
||||
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
|
||||
#endif
|
||||
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
int l_i;
|
||||
char l_connection[128];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _MSC_VER /* requires MSVC */
|
||||
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* build up connection name, and connect to database */
|
||||
#ifndef _MSC_VER
|
||||
snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
|
||||
|
|
|
@ -100,15 +100,17 @@ void *test_thread(void *arg)
|
|||
{
|
||||
long threadnum = (long)arg;
|
||||
|
||||
#ifdef WIN32
|
||||
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
|
||||
#endif
|
||||
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
int l_i;
|
||||
char l_connection[128];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _MSC_VER /* requires MSVC */
|
||||
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* build up connection name, and connect to database */
|
||||
#ifndef _MSC_VER
|
||||
snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
|
||||
|
|
Loading…
Reference in New Issue