Skip to content

Commit 0bc94e9

Browse files
authored
Allow some statement attributes be used for a connection (#213)
* allow some statment attrs be used for a connection Allow two statment attributes be used on a connection handle. This is in support of some 2.x applications that can make use of them. - SQL_ATTR_MAX_ROWS: the value is reset to 0 if different, which is the same behavior the driver has when the attribute is set on a statement; - SQL_ATTR_QUERY_TIMEOUT: the attribute is applied; any statement belonging to the affected connection can subsequently override the value, so the support is safe. * comment better the code Rephrase comment to reflect extra case inclusion and justify lack of a "break;".
1 parent 8b045b1 commit 0bc94e9

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

driver/connect.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3255,7 +3255,9 @@ SQLRETURN EsSQLSetConnectAttrW(
32553255
RET_HDIAGS(dbc, SQL_STATE_HY092);
32563256
break;
32573257

3258-
/* coalesce login and connection timeouts for a REST req. */
3258+
/* coalesce login, connection and query timeouts for a REST req. */
3259+
case SQL_ATTR_QUERY_TIMEOUT: /* stmt attr -- 2.x */
3260+
WARNH(dbc, "applying a statement as connection attribute (2.x?)");
32593261
case SQL_ATTR_CONNECTION_TIMEOUT:
32603262
case SQL_ATTR_LOGIN_TIMEOUT:
32613263
INFOH(dbc, "setting login/connection timeout: %lu",
@@ -3302,10 +3304,17 @@ SQLRETURN EsSQLSetConnectAttrW(
33023304
RET_HDIAGS(DBCH(ConnectionHandle), SQL_STATE_HY092);
33033305
#endif
33043306

3307+
case SQL_ATTR_MAX_ROWS: /* stmt attr -- 2.x app */
3308+
WARNH(dbc, "applying a statement as connection attribute (2.x?)");
3309+
DBGH(dbc, "setting max rows: %llu.", (SQLULEN)Value);
3310+
if ((SQLULEN)Value != 0) {
3311+
WARNH(dbc, "requested max_rows substituted with 0.");
3312+
RET_HDIAGS(dbc, SQL_STATE_01S02);
3313+
}
3314+
break;
3315+
33053316
default:
33063317
ERRH(dbc, "unknown Attribute: %d.", Attribute);
3307-
// FIXME: add the other attributes
3308-
FIXME;
33093318
RET_HDIAGS(dbc, SQL_STATE_HY092);
33103319
}
33113320

0 commit comments

Comments
 (0)