@@ -107,7 +107,7 @@ char *mapFuncs[][2] = {
107
107
{"DAYNAME" , "to_char($1, 'Day')" },
108
108
{"DAYOFMONTH" , "cast(extract(day from $1) as integer)" },
109
109
{"DAYOFWEEK" , "(cast(extract(dow from $1) as integer) + 1)" },
110
- {"DAYOFYEAR" , "cast(extract(doy from $1) as integer)" },
110
+ {"DAYOFYEAR" , "cast(extract(doy from $1) as integer)" },
111
111
{"HOUR" , "cast(extract(hour from $1) as integer)" },
112
112
{"MINUTE" , "cast(extract(minute from $1) as integer)" },
113
113
{"MONTH" , "cast(extract(month from $1) as integer)" },
@@ -161,7 +161,9 @@ timestamp2stime(const char *str, SIMPLE_TIME *st, BOOL *bZone, int *zone)
161
161
* ptr ;
162
162
int scnt ,
163
163
i ;
164
+ #if defined(WIN32 ) || defined(HAVE_INT_TIMEZONE )
164
165
long timediff ;
166
+ #endif
165
167
BOOL withZone = * bZone ;
166
168
167
169
* bZone = FALSE;
@@ -402,7 +404,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
402
404
else
403
405
{
404
406
stmt -> errornumber = STMT_RETURN_NULL_WITHOUT_INDICATOR ;
405
- stmt -> errormsg = "StrLen_or_IndPtr was a null pointer and NULL data was retrieved" ;
407
+ stmt -> errormsg = "StrLen_or_IndPtr was a null pointer and NULL data was retrieved" ;
406
408
SC_log_error (func , "" , stmt );
407
409
return SQL_ERROR ;
408
410
}
@@ -757,7 +759,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
757
759
if (cbValueMax < 2 * (SDWORD ) ucount )
758
760
result = COPY_RESULT_TRUNCATED ;
759
761
len = ucount * 2 ;
760
- free (str );
762
+ free (str );
761
763
}
762
764
else
763
765
{
@@ -1431,7 +1433,8 @@ copy_statement_with_parameters(StatementClass *stmt)
1431
1433
*/
1432
1434
else if (oldchar == '{' )
1433
1435
{
1434
- char * begin = & old_statement [opos ], * end ;
1436
+ char * begin = & old_statement [opos ];
1437
+ const char * end ;
1435
1438
1436
1439
/* procedure calls */
1437
1440
if (stmt -> statement_type == STMT_TYPE_PROCCALL )
@@ -1463,8 +1466,8 @@ copy_statement_with_parameters(StatementClass *stmt)
1463
1466
proc_no_param = FALSE;
1464
1467
continue ;
1465
1468
}
1466
- if (convert_escape (begin , stmt , & npos , & new_stsize , & end
1467
- ) != CONVERT_ESCAPE_OK )
1469
+ if (convert_escape (begin , stmt , & npos , & new_stsize , & end ) !=
1470
+ CONVERT_ESCAPE_OK )
1468
1471
{
1469
1472
stmt -> errormsg = "ODBC escape convert error" ;
1470
1473
stmt -> errornumber = STMT_EXEC_ERROR ;
@@ -1604,7 +1607,7 @@ copy_statement_with_parameters(StatementClass *stmt)
1604
1607
buffer += (bind_size * current_row );
1605
1608
else if (ctypelen = ctype_length (stmt -> parameters [param_number ].CType ), ctypelen > 0 )
1606
1609
buffer += current_row * ctypelen ;
1607
- else
1610
+ else
1608
1611
buffer += current_row * stmt -> parameters [param_number ].buflen ;
1609
1612
}
1610
1613
if (stmt -> parameters [param_number ].used )
@@ -2080,7 +2083,7 @@ mapFunction(const char *func, int param_count)
2080
2083
if (mapFuncs [i ][0 ][0 ] == '%' )
2081
2084
{
2082
2085
if (mapFuncs [i ][0 ][1 ] - '0' == param_count &&
2083
- !stricmp (mapFuncs [i ][0 ] + 2 , func ))
2086
+ !stricmp (mapFuncs [i ][0 ] + 2 , func ))
2084
2087
return mapFuncs [i ][1 ];
2085
2088
}
2086
2089
else if (!stricmp (mapFuncs [i ][0 ], func ))
@@ -2098,7 +2101,7 @@ static int processParameters(const ConnectionClass *conn, const char *value, cha
2098
2101
* inner_convert_escape()
2099
2102
* work with embedded escapes sequences
2100
2103
*/
2101
-
2104
+
2102
2105
static
2103
2106
int inner_convert_escape (const ConnectionClass * conn , const char * value ,
2104
2107
char * result , UInt4 maxLen , const char * * input_resume ,
@@ -2111,7 +2114,7 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
2111
2114
const char * valptr ;
2112
2115
UInt4 vlen , prtlen , input_consumed , param_consumed , extra_len ;
2113
2116
Int4 param_pos [16 ][2 ];
2114
-
2117
+
2115
2118
valptr = value ;
2116
2119
if (* valptr == '{' ) /* skip the first { */
2117
2120
valptr ++ ;
@@ -2123,7 +2126,7 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
2123
2126
valptr ++ ;
2124
2127
while ((* valptr != '\0' ) && isspace ((unsigned char ) * valptr ))
2125
2128
valptr ++ ;
2126
-
2129
+
2127
2130
if (end = my_strchr (conn , valptr , '}' ), NULL == end )
2128
2131
{
2129
2132
mylog ("%s couldn't find the ending }\n" ,func );
@@ -2135,7 +2138,7 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
2135
2138
valnts [vlen ] = '\0' ;
2136
2139
* input_resume = valptr + vlen ; /* resume from the last } */
2137
2140
mylog ("%s: key='%s', val='%s'\n" , func , key , valnts );
2138
-
2141
+
2139
2142
extra_len = 0 ;
2140
2143
if (isalnum (result [-1 ])) /* Avoid the concatenation of the function name with the previous word. Aceto */
2141
2144
{
@@ -2172,7 +2175,7 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
2172
2175
{
2173
2176
/* Literal; return the escape part as-is */
2174
2177
strncpy (result , valnts , maxLen );
2175
- prtlen = vlen ;
2178
+ prtlen = vlen ;
2176
2179
}
2177
2180
else if (strcmp (key , "fn" ) == 0 )
2178
2181
{
@@ -2183,7 +2186,7 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
2183
2186
char * funcEnd = valnts ;
2184
2187
char svchar ;
2185
2188
const char * mapExpr ;
2186
-
2189
+
2187
2190
params [sizeof (params )- 1 ] = '\0' ;
2188
2191
2189
2192
while ((* funcEnd != '\0' ) && (* funcEnd != '(' ) &&
@@ -2197,7 +2200,7 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
2197
2200
funcEnd ++ ;
2198
2201
2199
2202
/*
2200
- * We expect left parenthesis here, else return fn body as-is
2203
+ * We expect left parenthesis here, else return fn body as-is
2201
2204
* since it is one of those "function constants".
2202
2205
*/
2203
2206
if (* funcEnd != '(' )
@@ -2213,7 +2216,7 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
2213
2216
*/
2214
2217
2215
2218
valptr += (UInt4 )(funcEnd - valnts );
2216
- if (subret = processParameters (conn , valptr , params , sizeof (params ) - 1 , & input_consumed , & param_consumed , param_pos ), CONVERT_ESCAPE_OK != subret )
2219
+ if (subret = processParameters (conn , valptr , params , sizeof (params ) - 1 , & input_consumed , & param_consumed , param_pos ), CONVERT_ESCAPE_OK != subret )
2217
2220
return CONVERT_ESCAPE_ERROR ;
2218
2221
2219
2222
for (param_count = 0 ;; param_count ++ )
@@ -2222,9 +2225,9 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
2222
2225
break ;
2223
2226
}
2224
2227
if (param_count == 1 &&
2225
- param_pos [0 ][1 ] < param_pos [0 ][0 ])
2228
+ param_pos [0 ][1 ] < param_pos [0 ][0 ])
2226
2229
param_count = 0 ;
2227
-
2230
+
2228
2231
mapExpr = mapFunction (key , param_count );
2229
2232
if (mapExpr == NULL )
2230
2233
prtlen = snprintf (result , maxLen , "%s%s" , key , params );
@@ -2256,7 +2259,7 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
2256
2259
{
2257
2260
pidx = * mapptr - '0' - 1 ;
2258
2261
if (pidx < 0 ||
2259
- param_pos [pidx ][0 ] < 0 )
2262
+ param_pos [pidx ][0 ] < 0 )
2260
2263
{
2261
2264
qlog ("%s %dth param not found for the expression %s\n" , pidx + 1 , mapExpr );
2262
2265
return CONVERT_ESCAPE_ERROR ;
@@ -2291,7 +2294,7 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
2291
2294
/* Bogus key, leave untranslated */
2292
2295
return CONVERT_ESCAPE_ERROR ;
2293
2296
}
2294
-
2297
+
2295
2298
if (count )
2296
2299
* count = prtlen + extra_len ;
2297
2300
if (prtlen < 0 || prtlen >= maxLen ) /* buffer overflow */
@@ -2301,12 +2304,12 @@ int inner_convert_escape(const ConnectionClass *conn, const char *value,
2301
2304
}
2302
2305
return CONVERT_ESCAPE_OK ;
2303
2306
}
2304
-
2307
+
2305
2308
/*
2306
2309
* processParameters()
2307
2310
* Process function parameters and work with embedded escapes sequences.
2308
2311
*/
2309
-
2312
+
2310
2313
static
2311
2314
int processParameters (const ConnectionClass * conn , const char * value ,
2312
2315
char * result , UInt4 maxLen , UInt4 * input_consumed ,
@@ -2321,7 +2324,7 @@ int processParameters(const ConnectionClass *conn, const char *value,
2321
2324
#ifdef MULTIBYTE
2322
2325
encoded_str encstr ;
2323
2326
#endif /* MULTIBYTE */
2324
-
2327
+
2325
2328
buf [sizeof (buf )- 1 ] = '\0' ;
2326
2329
innerParenthesis = 0 ;
2327
2330
in_quote = in_dquote = in_escape = leadingSpace = FALSE;
@@ -2400,7 +2403,7 @@ int processParameters(const ConnectionClass *conn, const char *value,
2400
2403
}
2401
2404
innerParenthesis ++ ;
2402
2405
break ;
2403
-
2406
+
2404
2407
case ')' :
2405
2408
innerParenthesis -- ;
2406
2409
if (0 == innerParenthesis )
@@ -2411,18 +2414,18 @@ int processParameters(const ConnectionClass *conn, const char *value,
2411
2414
param_pos [param_count ][1 ] = -1 ;
2412
2415
}
2413
2416
break ;
2414
-
2417
+
2415
2418
case '}' :
2416
2419
stop = TRUE;
2417
2420
break ;
2418
-
2421
+
2419
2422
case '{' :
2420
2423
if (subret = inner_convert_escape (conn , valptr , buf , sizeof (buf ) - 1 , & valptr , & inner_count ), CONVERT_ESCAPE_OK != subret )
2421
2424
return CONVERT_ESCAPE_ERROR ;
2422
-
2425
+
2423
2426
if (inner_count + count >= maxLen )
2424
2427
return CONVERT_ESCAPE_OVERFLOW ;
2425
- memcpy (& result [count ], buf , inner_count );
2428
+ memcpy (& result [count ], buf , inner_count );
2426
2429
count += inner_count ;
2427
2430
ipos = (UInt4 ) (valptr - value );
2428
2431
continue ;
@@ -2442,14 +2445,15 @@ int processParameters(const ConnectionClass *conn, const char *value,
2442
2445
* output_count = count ;
2443
2446
return CONVERT_ESCAPE_OK ;
2444
2447
}
2445
-
2448
+
2446
2449
/*
2447
2450
* convert_escape()
2448
2451
* This function returns a pointer to static memory!
2449
2452
*/
2450
-
2453
+
2451
2454
int
2452
- convert_escape (const char * value , StatementClass * stmt , int * npos , int * stsize , const char * * val_resume )
2455
+ convert_escape (const char * value , StatementClass * stmt , int * npos , int * stsize ,
2456
+ const char * * val_resume )
2453
2457
{
2454
2458
int ret , pos = * npos ;
2455
2459
UInt4 count ;
0 commit comments