Changeset: 236a9e2b0231 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=236a9e2b0231 Modified Files: clients/odbc/driver/SQLColAttribute.c clients/odbc/driver/SQLColAttributes.c clients/odbc/driver/SQLGetConnectAttr.c clients/odbc/driver/SQLGetDescField.c clients/odbc/driver/SQLGetInfo.c Branch: Oct2014 Log Message:
Try making fewer calls for wide character interface. diffs (232 lines): diff --git a/clients/odbc/driver/SQLColAttribute.c b/clients/odbc/driver/SQLColAttribute.c --- a/clients/odbc/driver/SQLColAttribute.c +++ b/clients/odbc/driver/SQLColAttribute.c @@ -377,13 +377,7 @@ SQLColAttributeW(SQLHSTMT StatementHandl case SQL_DESC_SCHEMA_NAME: /* SQL_COLUMN_OWNER_NAME */ case SQL_DESC_TABLE_NAME: /* SQL_COLUMN_TABLE_NAME */ case SQL_DESC_TYPE_NAME: /* SQL_COLUMN_TYPE_NAME */ - rc = MNDBColAttribute(stmt, ColumnNumber, FieldIdentifier, - NULL, 0, &n, NumericAttributePtr); - if (!SQL_SUCCEEDED(rc)) - return rc; - clearStmtErrors(stmt); - n++; /* account for NUL byte */ - ptr = (SQLPOINTER) malloc(n); + ptr = malloc(BufferLength); if (ptr == NULL) { /* Memory allocation error */ addStmtError(stmt, "HY001", NULL, 0); @@ -408,7 +402,6 @@ SQLColAttributeW(SQLHSTMT StatementHandl case SQL_DESC_UNNAMED: case SQL_DESC_UNSIGNED: case SQL_DESC_UPDATABLE: - n = BufferLength; ptr = CharacterAttributePtr; break; default: @@ -418,9 +411,22 @@ SQLColAttributeW(SQLHSTMT StatementHandl } rc = MNDBColAttribute(stmt, ColumnNumber, FieldIdentifier, ptr, - n, &n, NumericAttributePtr); + BufferLength, &n, NumericAttributePtr); if (ptr != CharacterAttributePtr) { + if (rc == SQL_SUCCESS_WITH_INFO) { + clearStmtErrors(stmt); + free(ptr); + ptr = malloc(++n); /* add one for NULL byte */ + if (ptr == NULL) { + /* Memory allocation error */ + addStmtError(stmt, "HY001", NULL, 0); + return SQL_ERROR; + } + rc = MNDBColAttribute(stmt, ColumnNumber, + FieldIdentifier, ptr, n, &n, + NumericAttributePtr); + } if (SQL_SUCCEEDED(rc)) { fixWcharOut(rc, ptr, n, CharacterAttributePtr, BufferLength, StringLengthPtr, 2, diff --git a/clients/odbc/driver/SQLColAttributes.c b/clients/odbc/driver/SQLColAttributes.c --- a/clients/odbc/driver/SQLColAttributes.c +++ b/clients/odbc/driver/SQLColAttributes.c @@ -191,13 +191,7 @@ SQLColAttributesW(SQLHSTMT StatementHand case SQL_DESC_SCHEMA_NAME: /* SQL_COLUMN_OWNER_NAME */ case SQL_DESC_TABLE_NAME: /* SQL_COLUMN_TABLE_NAME */ case SQL_DESC_TYPE_NAME: /* SQL_COLUMN_TYPE_NAME */ - rc = MNDBColAttributes(stmt, ColumnNumber, FieldIdentifier, - NULL, 0, &n, NumericAttributePtr); - if (!SQL_SUCCEEDED(rc)) - return rc; - clearStmtErrors(stmt); - n++; /* account for NUL byte */ - ptr = (SQLPOINTER) malloc(n); + ptr = malloc(BufferLength); if (ptr == NULL) { /* Memory allocation error */ addStmtError(stmt, "HY001", NULL, 0); @@ -205,15 +199,27 @@ SQLColAttributesW(SQLHSTMT StatementHand } break; default: - n = BufferLength; ptr = CharacterAttributePtr; break; } rc = MNDBColAttributes(stmt, ColumnNumber, FieldIdentifier, ptr, - n, &n, NumericAttributePtr); + BufferLength, &n, NumericAttributePtr); if (ptr != CharacterAttributePtr) { + if (rc == SQL_SUCCESS_WITH_INFO) { + clearStmtErrors(stmt); + free(ptr); + ptr = malloc(++n); /* add one for NULL byte */ + if (ptr == NULL) { + /* Memory allocation error */ + addStmtError(stmt, "HY001", NULL, 0); + return SQL_ERROR; + } + rc = MNDBColAttributes(stmt, ColumnNumber, + FieldIdentifier, ptr, n, &n, + NumericAttributePtr); + } if (SQL_SUCCEEDED(rc)) { fixWcharOut(rc, ptr, n, CharacterAttributePtr, BufferLength, StringLengthPtr, 2, diff --git a/clients/odbc/driver/SQLGetConnectAttr.c b/clients/odbc/driver/SQLGetConnectAttr.c --- a/clients/odbc/driver/SQLGetConnectAttr.c +++ b/clients/odbc/driver/SQLGetConnectAttr.c @@ -214,12 +214,7 @@ SQLGetConnectAttrW(SQLHDBC ConnectionHan switch (Attribute) { /* all string attributes */ case SQL_ATTR_CURRENT_CATALOG: - rc = MNDBGetConnectAttr(dbc, Attribute, NULL, 0, &n); - if (!SQL_SUCCEEDED(rc)) - return rc; - clearDbcErrors(dbc); - n++; /* account for NUL byte */ - ptr = (SQLPOINTER) malloc(n); + ptr = malloc(BufferLength); if (ptr == NULL) { /* Memory allocation error */ addDbcError(dbc, "HY001", NULL, 0); @@ -227,14 +222,24 @@ SQLGetConnectAttrW(SQLHDBC ConnectionHan } break; default: - n = BufferLength; ptr = ValuePtr; break; } - rc = MNDBGetConnectAttr(dbc, Attribute, ptr, n, &n); + rc = MNDBGetConnectAttr(dbc, Attribute, ptr, BufferLength, &n); if (ptr != ValuePtr) { + if (rc == SQL_SUCCESS_WITH_INFO) { + clearDbcErrors(dbc); + free(ptr); + ptr = malloc(++n); /* add one for NULL byte */ + if (ptr == NULL) { + /* Memory allocation error */ + addDbcError(dbc, "HY001", NULL, 0); + return SQL_ERROR; + } + rc = MNDBGetConnectAttr(dbc, Attribute, ptr, n, &n); + } if (SQL_SUCCEEDED(rc)) { SQLSMALLINT nn = (SQLSMALLINT) n; diff --git a/clients/odbc/driver/SQLGetDescField.c b/clients/odbc/driver/SQLGetDescField.c --- a/clients/odbc/driver/SQLGetDescField.c +++ b/clients/odbc/driver/SQLGetDescField.c @@ -361,13 +361,7 @@ SQLGetDescFieldW(SQLHDESC DescriptorHand case SQL_DESC_SCHEMA_NAME: case SQL_DESC_TABLE_NAME: case SQL_DESC_TYPE_NAME: - rc = MNDBGetDescField(desc, RecordNumber, FieldIdentifier, - NULL, 0, &n); - if (!SQL_SUCCEEDED(rc)) - return rc; - clearDescErrors(desc); - n++; /* account for NUL byte */ - ptr = (SQLPOINTER) malloc(n); + ptr = (SQLPOINTER) malloc(BufferLength); if (ptr == NULL) { /* Memory allocation error */ addDescError(desc, "HY001", NULL, 0); @@ -375,14 +369,26 @@ SQLGetDescFieldW(SQLHDESC DescriptorHand } break; default: - n = BufferLength; ptr = ValuePtr; break; } - rc = MNDBGetDescField(desc, RecordNumber, FieldIdentifier, ptr, n, &n); + rc = MNDBGetDescField(desc, RecordNumber, FieldIdentifier, ptr, + BufferLength, &n); if (ptr != ValuePtr) { + if (rc == SQL_SUCCESS_WITH_INFO) { + clearDescErrors(desc); + free(ptr); + ptr = malloc(++n); /* add one for NULL byte */ + if (ptr == NULL) { + /* Memory allocation error */ + addDescError(desc, "HY001", NULL, 0); + return SQL_ERROR; + } + rc = MNDBGetDescField(desc, RecordNumber, + FieldIdentifier, ptr, n, &n); + } if (SQL_SUCCEEDED(rc)) { SQLSMALLINT nn = (SQLSMALLINT) n; diff --git a/clients/odbc/driver/SQLGetInfo.c b/clients/odbc/driver/SQLGetInfo.c --- a/clients/odbc/driver/SQLGetInfo.c +++ b/clients/odbc/driver/SQLGetInfo.c @@ -1671,12 +1671,7 @@ SQLGetInfoW(SQLHDBC ConnectionHandle, case SQL_TABLE_TERM: case SQL_USER_NAME: case SQL_XOPEN_CLI_YEAR: - rc = MNDBGetInfo(dbc, InfoType, NULL, 0, &n); - if (!SQL_SUCCEEDED(rc)) - return rc; - clearDbcErrors(dbc); - n++; /* account for NUL byte */ - ptr = (SQLPOINTER) malloc(n); + ptr = malloc(BufferLength); if (ptr == NULL) { /* Memory allocation error */ addDbcError(dbc, "HY001", NULL, 0); @@ -1684,14 +1679,23 @@ SQLGetInfoW(SQLHDBC ConnectionHandle, } break; default: - n = BufferLength; ptr = InfoValuePtr; break; } - rc = MNDBGetInfo(dbc, InfoType, ptr, n, &n); + rc = MNDBGetInfo(dbc, InfoType, ptr, BufferLength, &n); if (ptr != InfoValuePtr) { + if (rc == SQL_SUCCESS_WITH_INFO) { + clearDbcErrors(dbc); + ptr = malloc(++n); /* add one for NULL byte */ + if (ptr == NULL) { + /* Memory allocation error */ + addDbcError(dbc, "HY001", NULL, 0); + return SQL_ERROR; + } + rc = MNDBGetInfo(dbc, InfoType, ptr, n, &n); + } if (SQL_SUCCEEDED(rc)) { fixWcharOut(rc, ptr, n, InfoValuePtr, BufferLength, StringLengthPtr, 2, addDbcError, dbc); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list