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

ct.c tuneups from NCBI as of May 2024 #561

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
34 changes: 30 additions & 4 deletions src/ctlib/ct.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ _ct_get_user_api_layer_error(int error)
case 15:
return "Use direction CS_BLK_IN or CS_BLK_OUT for a bulk copy operation.";
break;
case 36:
return "The result is truncated because the"
" conversion/operation resulted in overflow.";
break;
case 51:
return "Exactly one of context and connection must be non-NULL.";
break;
Expand Down Expand Up @@ -2952,12 +2956,26 @@ ct_get_data(CS_COMMAND * cmd, CS_INT item, CS_VOID * buffer, CS_INT buflen, CS_I
if (table_namelen + column_namelen + 2 > sizeof(cmd->iodesc->name))
column_namelen = sizeof(cmd->iodesc->name) - 2 - table_namelen;

sprintf(cmd->iodesc->name, "%*.*s.%*.*s",
(int) table_namelen, (int) table_namelen, tds_dstr_cstr(&curcol->table_name),
(int) column_namelen, (int) column_namelen, tds_dstr_cstr(&curcol->column_name));
if (table_namelen) {
memcpy(cmd->iodesc->name,
tds_dstr_cstr(&curcol->table_name),
table_namelen);
cmd->iodesc->namelen = (CS_INT) table_namelen;
} else {
cmd->iodesc->namelen = 0;
}

cmd->iodesc->name[cmd->iodesc->namelen] = '.';
++cmd->iodesc->namelen;

cmd->iodesc->namelen = strlen(cmd->iodesc->name);
if (column_namelen) {
memcpy(cmd->iodesc->name + cmd->iodesc->namelen,
tds_dstr_cstr(&curcol->column_name),
column_namelen);
cmd->iodesc->namelen += (CS_INT) column_namelen;
}

cmd->iodesc->name[cmd->iodesc->namelen] = '\0';
if (blob && blob->valid_ptr) {
memcpy(cmd->iodesc->timestamp, blob->timestamp, CS_TS_SIZE);
cmd->iodesc->timestamplen = CS_TS_SIZE;
Expand Down Expand Up @@ -4227,6 +4245,14 @@ paraminfoalloc(TDSSOCKET * tds, CS_PARAM * first_param)
pcol->column_prec = p->precision;
pcol->column_scale = p->scale;
if (pcol->column_varint_size) {
if ((pcol->column_varint_size == 2
&& *(p->datalen) > 8000)
|| (pcol->column_varint_size == 1
&& *(p->datalen) > 255)) {
_ctclient_msg(NULL,
(CS_CONNECTION*) tds_get_parent(tds),
"paraminfoalloc", 1, 1, 10, 36, "");
}
if (p->maxlen < 0) {
tds_free_param_results(params);
return NULL;
Expand Down