Skip to content

Fix garbage in column names on IBM i #61

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

Merged
merged 1 commit into from
Nov 27, 2024
Merged
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
8 changes: 7 additions & 1 deletion ibm_db2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1971,7 +1971,13 @@ static int _php_db2_get_result_set_info(stmt_handle *stmt_res)
return -1;
}
} else {
stmt_res->column_info[i].name = (SQLCHAR *)estrdup(tmp_name);
/*
* CB20241114: In some cases on i (i.e. QP2SHELL w/ CCSID 65535),
* SQL/CLI might not add a null terminator, and garbage can appear
* at the end of column names. However, name_length is still
* correct, so we truncate with that when copying the name.
*/
stmt_res->column_info[i].name = (SQLCHAR *)estrndup(tmp_name, name_length);
}
switch (stmt_res->column_info[i].type) {
/* BIGINT 9223372036854775807 (2^63-1) string convert */
Expand Down
Loading