]> granicus.if.org Git - postgresql/commitdiff
Changed order of statements and added an additiona MSVC safeguard to make ecpg
authorMichael Meskes <meskes@postgresql.org>
Sat, 26 Aug 2017 17:07:25 +0000 (19:07 +0200)
committerMichael Meskes <meskes@postgresql.org>
Wed, 13 Sep 2017 22:47:08 +0000 (00:47 +0200)
thread test cases work on Windows.

src/interfaces/ecpg/test/expected/thread-alloc.c
src/interfaces/ecpg/test/expected/thread-descriptor.c
src/interfaces/ecpg/test/expected/thread-prep.c
src/interfaces/ecpg/test/expected/thread-thread.c
src/interfaces/ecpg/test/expected/thread-thread_implicit.c
src/interfaces/ecpg/test/thread/alloc.pgc
src/interfaces/ecpg/test/thread/descriptor.pgc
src/interfaces/ecpg/test/thread/prep.pgc
src/interfaces/ecpg/test/thread/thread.pgc
src/interfaces/ecpg/test/thread/thread_implicit.pgc

index 1a605765332cf9c94322668f3761bae5a914dd75..e7b69b387f71f165ae261b73a6d679d16141c0e1 100644 (file)
@@ -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;
index d1c20b147e1ed2c2873dbe0e03d8bf9377035755..03cebad603a98c43e6a629b0c870c8f80ffebd32 100644 (file)
@@ -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"
 
        }
 
index ff872f08b593cad47f01d75bdf4a290e0af82a87..94e02933cd84ad60ee4e4164e0a9c8a11df49807 100644 (file)
@@ -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
index 470fbb252ddb395d40d40f505484f803725a1fee..6e809d60fbc2cc2f728a22443086406033417893 100644 (file)
@@ -140,22 +140,24 @@ 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
@@ -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 );
 }
index 854549e27d85b6e698cb9cfc19945c2a22bcc50f..b42c5566338419624bf5dcb55de234ca8527f210 100644 (file)
@@ -141,22 +141,24 @@ 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
@@ -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 );
 }
index 8e6d042d89136e9a4060502cb768f0c3af256f38..b13bcb860b23b6978ee6ce14fef7d729de53c5f5 100644 (file)
@@ -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);
 
index c88c05a8a5dc5583c01aca630e32436f28315d64..3f28c6d329a703d7b6c9feb7b988e5920b0711a0 100644 (file)
@@ -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)
index 1ec96767af9bf9a2526ef82e6b06d7ceb6f4e8bf..3a2467c9abbcdd20c38e62506ea0566051779b94 100644 (file)
@@ -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);
 
index f08aacdee5fd68dd857cb0379331dea57dad4509..c5fbe928d9fbf8bd33d97ac9e743ce158d3b6f7a 100644 (file)
@@ -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);
index aab758ed92c2fec98135ff5f3b13f4a0636231be..d65f17c07367c9216906b13eb47582318fcb16ec 100644 (file)
@@ -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);