Fixed of by one variable size.
authorMichael Meskes
Thu, 24 Aug 2006 10:35:58 +0000 (10:35 +0000)
committerMichael Meskes
Thu, 24 Aug 2006 10:35:58 +0000 (10:35 +0000)
src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/ecpglib/data.c
src/interfaces/ecpg/preproc/preproc.y
src/interfaces/ecpg/test/expected/compat_informix-rnull.c
src/interfaces/ecpg/test/expected/sql-desc.c

index 165ba04f57cd190a24a1504ba8323b26b3229c43..10dda45d763ec1c414c5ce18f0f53bfdbc83f85c 100644 (file)
@@ -2116,5 +2116,9 @@ We 23. Aug 09:32:14 CEST 2006
    - Replaced double-quote-fix with a hopefully better version.
    - Use initializer string length as size for character strings.
    - Added ecpg_config.h file that is created via configure.
+
+Th 24. Aug 11:53:29 CEST 2006
+
+   - Fixed of by one variable size.
    - Set ecpg library version to 5.2.
    - Set ecpg version to 4.2.1.
index 36d54496224d6d560df09cec5897c254abee9905..4f474d3bcf12b73a2f24238a93cecb2979087108 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.33 2006/08/08 11:51:24 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.34 2006/08/24 10:35:58 meskes Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -406,33 +406,33 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
            case ECPGt_unsigned_char:
                if (pval)
                {
-                   if (varcharsize == 0 || varcharsize > strlen(pval))
-                       strncpy((char *) ((long) var + offset * act_tuple), pval, strlen(pval) + 1);
+                   if (varcharsize == 0 || varcharsize > size)
+                       strncpy((char *) ((long) var + offset * act_tuple), pval, size + 1);
                    else
                    {
                        strncpy((char *) ((long) var + offset * act_tuple), pval, varcharsize);
 
-                       if (varcharsize < strlen(pval))
+                       if (varcharsize < size)
                        {
                            /* truncation */
                            switch (ind_type)
                            {
                                case ECPGt_short:
                                case ECPGt_unsigned_short:
-                                   *((short *) (ind + ind_offset * act_tuple)) = strlen(pval);
+                                   *((short *) (ind + ind_offset * act_tuple)) = size;
                                    break;
                                case ECPGt_int:
                                case ECPGt_unsigned_int:
-                                   *((int *) (ind + ind_offset * act_tuple)) = strlen(pval);
+                                   *((int *) (ind + ind_offset * act_tuple)) = size;
                                    break;
                                case ECPGt_long:
                                case ECPGt_unsigned_long:
-                                   *((long *) (ind + ind_offset * act_tuple)) = strlen(pval);
+                                   *((long *) (ind + ind_offset * act_tuple)) = size;
                                    break;
 #ifdef HAVE_LONG_LONG_INT_64
                                case ECPGt_long_long:
                                case ECPGt_unsigned_long_long:
-                                   *((long long int *) (ind + ind_offset * act_tuple)) = strlen(pval);
+                                   *((long long int *) (ind + ind_offset * act_tuple)) = size;
                                    break;
 #endif   /* HAVE_LONG_LONG_INT_64 */
                                default:
@@ -441,7 +441,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
                            sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
                        }
                    }
-                   pval += strlen(pval);
+                   pval += size;
                }
                break;
 
@@ -451,7 +451,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
                    struct ECPGgeneric_varchar *variable =
                    (struct ECPGgeneric_varchar *) ((long) var + offset * act_tuple);
 
-                   variable->len = strlen(pval);
+                   variable->len = size;
                    if (varcharsize == 0)
                        strncpy(variable->arr, pval, variable->len);
                    else
@@ -489,7 +489,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
                            variable->len = varcharsize;
                        }
                    }
-                   pval += strlen(pval);
+                   pval += size;
                }
                break;
 
index da0631b6c650b5ef740d0249b152080f1ad512e6..d49d3795bc703fcc9a0d5a8bde454382adc8c503 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.330 2006/08/23 12:01:52 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.331 2006/08/24 10:35:58 meskes Exp $ */
 
 /* Copyright comment */
 %{
@@ -5422,7 +5422,7 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize
                            /* if we have an initializer but no string size set, let's use the initializer's length */
                            free(length);
                            length = mm_alloc(i+sizeof("sizeof()"));
-                           sprintf(length, "sizeof(%s)+1", $5+2);
+                           sprintf(length, "sizeof(%s)", $5+2);
                        }
                        type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length);
                    }
index fd6128a62e21e63bf917a2e03ec183e7b06d94c8..74fcfc74a71e19fb82e6a4ee41160e981b3b0e48 100644 (file)
@@ -119,7 +119,7 @@ if (sqlca.sqlcode < 0) sqlprint (  );}
 
 
    { ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id  , c  , s  , i  , b  , f  , l  , dbl  ) values( 1 ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ) ", 
-   ECPGt_char,(c),(long)sizeof("abc       ")+1,(long)1,(sizeof("abc       ")+1)*sizeof(char), 
+   ECPGt_char,(c),(long)sizeof("abc       "),(long)1,(sizeof("abc       "))*sizeof(char), 
    ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
    ECPGt_short,&(s),(long)1,(long)1,sizeof(short), 
    ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
@@ -157,7 +157,7 @@ if (sqlca.sqlcode < 0) sqlprint (  );}
    rsetnull(CDTIMETYPE, (char *) &tmp);
 
    { ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id  , c  , s  , i  , b  , f  , l  , dbl  , dec  , dat  , tmp  ) values( 2 ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ) ", 
-   ECPGt_char,(c),(long)sizeof("abc       ")+1,(long)1,(sizeof("abc       ")+1)*sizeof(char), 
+   ECPGt_char,(c),(long)sizeof("abc       "),(long)1,(sizeof("abc       "))*sizeof(char), 
    ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
    ECPGt_short,&(s),(long)1,(long)1,sizeof(short), 
    ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
@@ -192,7 +192,7 @@ if (sqlca.sqlcode < 0) sqlprint (  );}
    printf("first select\n");
 
    { ECPGdo(__LINE__, 1, 0, NULL, "select  c , s , i , b , f , l , dbl , dec , dat , tmp  from test where id = 1  ", ECPGt_EOIT, 
-   ECPGt_char,(c),(long)sizeof("abc       ")+1,(long)1,(sizeof("abc       ")+1)*sizeof(char), 
+   ECPGt_char,(c),(long)sizeof("abc       "),(long)1,(sizeof("abc       "))*sizeof(char), 
    ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
    ECPGt_short,&(s),(long)1,(long)1,sizeof(short), 
    ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
@@ -232,7 +232,7 @@ if (sqlca.sqlcode < 0) sqlprint (  );}
    printf("second select\n");
 
    { ECPGdo(__LINE__, 1, 0, NULL, "select  c , s , i , b , f , l , dbl , dec , dat , tmp  from test where id = 2  ", ECPGt_EOIT, 
-   ECPGt_char,(c),(long)sizeof("abc       ")+1,(long)1,(sizeof("abc       ")+1)*sizeof(char), 
+   ECPGt_char,(c),(long)sizeof("abc       "),(long)1,(sizeof("abc       "))*sizeof(char), 
    ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
    ECPGt_short,&(s),(long)1,(long)1,sizeof(short), 
    ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
index 2fc9eff1a68f37df2f9f4f9701d34c391a15af29..2ca755b3a0b55ddab4ca4a106ed61acf9bb452b2 100644 (file)
@@ -228,7 +228,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 
    { ECPGget_desc(__LINE__, "outdesc", 1,ECPGd_data,
-   ECPGt_char,(val2output),(long)sizeof("AAA")+1,(long)1,(sizeof("AAA")+1)*sizeof(char), ECPGd_EODT);
+   ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), ECPGd_EODT);
 
 #line 51 "desc.pgc"
 
@@ -254,7 +254,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
    { ECPGdo(__LINE__, 0, 1, NULL, "fetch next from c1", ECPGt_EOIT, 
    ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int), 
    ECPGt_int,&(ind1),(long)1,(long)1,sizeof(int), 
-   ECPGt_char,(val2output),(long)sizeof("AAA")+1,(long)1,(sizeof("AAA")+1)*sizeof(char), 
+   ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), 
    ECPGt_int,&(ind2),(long)1,(long)1,sizeof(int), ECPGt_EORT);
 #line 57 "desc.pgc"
 
@@ -304,7 +304,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
    { ECPGdo(__LINE__, 0, 1, NULL, "fetch next from c2", ECPGt_EOIT, 
    ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int), 
    ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_char,(val2output),(long)sizeof("AAA")+1,(long)1,(sizeof("AAA")+1)*sizeof(char), 
+   ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), 
    ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGt_EORT);
 #line 69 "desc.pgc"
 
@@ -323,7 +323,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
    { ECPGdo(__LINE__, 0, 1, NULL, "select  *  from test1 where a = 3  ", ECPGt_EOIT, 
    ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int), 
    ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_char,(val2output),(long)sizeof("AAA")+1,(long)1,(sizeof("AAA")+1)*sizeof(char), 
+   ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), 
    ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGt_EORT);
 #line 74 "desc.pgc"