Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init all record fields #111

Merged
merged 1 commit into from
Feb 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions driver/odbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,12 +898,12 @@ SQLRETURN SQL_API SQLFetchScroll(SQLHSTMT StatementHandle,
SQLSMALLINT FetchOrientation, SQLLEN FetchOffset)
{
SQLRETURN ret;
TRACE(_IN, StatementHandle, "phz", StatementHandle,
TRACE3(_IN, StatementHandle, "phz", StatementHandle,
FetchOrientation, FetchOffset);
HND_LOCK(StatementHandle);
ret = EsSQLFetchScroll(StatementHandle, FetchOrientation, FetchOffset);
HND_UNLOCK(StatementHandle);
TRACE(_OUT, StatementHandle, "dphz", ret, StatementHandle,
TRACE4(_OUT, StatementHandle, "dphz", ret, StatementHandle,
FetchOrientation, FetchOffset);
return ret;
}
Expand Down
13 changes: 11 additions & 2 deletions driver/queries.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ static SQLRETURN attach_columns(esodbc_stmt_st *stmt, UJObject columns)
MK_WPTR(JSON_ANSWER_COL_NAME),
MK_WPTR(JSON_ANSWER_COL_TYPE)
};
static const wstr_st EMPTY_WSTR = WSTR_INIT("");

ird = stmt->ird;
dbc = stmt->hdr.dbc;
Expand Down Expand Up @@ -180,15 +181,23 @@ static SQLRETURN attach_columns(esodbc_stmt_st *stmt, UJObject columns)
/* "If a base column name does not exist (as in the case of columns
* that are expressions), then this variable contains an empty
* string." */
rec->base_column_name = MK_WSTR("");
rec->base_column_name = EMPTY_WSTR;
/* "If a column does not have a label, the column name is returned. If
* the column is unlabeled and unnamed, an empty string is ret" */
rec->label = rec->name.cnt ? rec->name : MK_WSTR("");
rec->label = rec->name.cnt ? rec->name : EMPTY_WSTR;

assert(rec->name.str && rec->label.str);
rec->unnamed = (rec->name.cnt || rec->label.cnt) ?
SQL_NAMED : SQL_UNNAMED;

/* All rec fields must be init'ed to a valid string in case their value
* is requested (and written with write_wstr()). The values would
* normally be provided by the data source, this is not the case here
* (yet), though. */
rec->base_table_name = EMPTY_WSTR;
rec->catalog_name = EMPTY_WSTR;
rec->schema_name = EMPTY_WSTR;
rec->table_name = EMPTY_WSTR;
#ifndef NDEBUG
//dump_record(rec);
#endif /* NDEBUG */
Expand Down
1 change: 1 addition & 0 deletions driver/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ SQLRETURN write_wstr(SQLHANDLE hnd, SQLWCHAR *dest, wstr_st *src,
LWSTR(src), src->cnt, wide_avail);
RET_HDIAGS(hnd, SQL_STATE_01004);
} else {
assert(src->str);
wcsncpy(dest, src->str, src->cnt + /* 0-term */1);
}
} else {
Expand Down