25 #include <freetds/time.h>
52 #include <freetds/tds.h>
53 #include <freetds/thread.h>
54 #include <freetds/convert.h>
56 #include <freetds/data.h>
57 #include <replacements.h>
193 #ifdef TDS_HAVE_MUTEX
224 const int list_size =
ctx->connection_list_size_represented;
228 while (i < list_size && ctx->connection_list[
i])
230 if (
i == list_size) {
243 const int list_size =
ctx->connection_list_size;
247 while (i < list_size && ctx->connection_list[
i] !=
tds)
249 if (
i == list_size) {
276 const static char date_format[] =
278 "%b %e %Y %I:%M:%S:%z%p";
280 "%b %d %Y %I:%M:%S:%z%p";
311 if (strlen(oldval) == 1 && *oldval == 1)
389 if (
info->computeid == computeid)
393 if (column < 1 || column >
info->num_cols) {
524 assert(0 ==
"no such datatype");
583 memcpy(varaddr, pnullrep->
bindval, pnullrep->
len);
591 if (pnullrep->
bindval && (varlen <= 0 || (
size_t)varlen >= pnullrep->
len)) {
592 memcpy(varaddr, pnullrep->
bindval, pnullrep->
len);
606 varlen = pnullrep->
len;
614 case SENSITIVITYBIND:
619 if (varlen < (
long)pnullrep->
len) {
621 varaddr, varlen, (
unsigned long int) pnullrep->
len);
626 varaddr, varlen, (
unsigned long int) pnullrep->
len);
636 varaddr += pnullrep->
len;
637 varlen -= (
int)pnullrep->
len;
641 memset(varaddr,
' ', varlen);
644 memset(varaddr,
' ', varlen);
645 varaddr[varlen-1] =
'\0';
651 memset(varaddr, 0, varlen);
657 assert(!
"unknown bindtype");
776 const char *value_nonull =
value ?
value :
"";
861 #if defined(DBLIB_UNIMPLEMENTED)
1009 while (*strp !=
NULL) {
1010 strp = &((*strp)->strnext);
1016 (*strp)->strtotlen = (
DBINT)strlen(p);
1022 memcpy((*strp)->strtext, p, (*strp)->strtotlen);
1023 (*strp)->strnext =
NULL;
1056 if (dbstr ==
NULL) {
1062 if (i < dbstr->strtotlen) {
1078 if (dbstr ==
NULL) {
1088 memcpy(cp,
next->strtext,
next->strtotlen);
1089 cp +=
next->strtotlen;
1124 "transaction isolation level",
1127 "no_identity_column",
1128 "cnv_date2char_short",
1179 char *tdsdump = getenv(
"TDSDUMP");
1180 if (tdsdump && *tdsdump) {
1191 if ((server = getenv(
"TDSQUERY")) ==
NULL)
1192 if ((server = getenv(
"DSQUERY")) ==
NULL)
1303 char *temp_filename =
NULL;
1313 free(temp_filename);
1379 size_t cmd_len, buf_len, newsz;
1396 cmd_len = strlen(cmdstring);
1397 newsz = buf_len + cmd_len + 1;
1402 memcpy(
dbproc->
dbbuf + buf_len, cmdstring, cmd_len);
1467 strcpy(
query,
"use ");
1469 if (name[0] ==
'[' && name[strlen(name)-1] ==
']')
1563 int i, list_size, count = 1;
1576 for (
i = 0;
i < list_size;
i++) {
1614 sprintf(
buf,
"oops: %u ??", retcode);
1623 case REG_ROW:
return "REG_ROW/MORE_ROWS";
1627 case SUCCEED:
return "SUCCEED";
1628 case FAIL:
return "FAIL";
1630 sprintf(
buf,
"oops: %u ??", retcode);
1644 sprintf(
buf,
"oops: %u ??", retcode);
1652 switch(result_type) {
1669 sprintf(
buf,
"oops: %u ??", result_type);
1719 int result_type = 0, done_flags;
1755 switch (result_type) {
2010 case SENSITIVITYBIND:
2027 memcpy(pval, bindval, bindlen);
2129 bool rows_set =
false;
2326 if (typeinfo ==
NULL) {
2344 if (src ==
NULL || srclen == 0) {
2369 srclen = (
int)strlen((
const char *) src);
2380 if (srclen > destlen && destlen >= 0) {
2384 memcpy(dest, src, srclen);
2385 if (srclen < destlen)
2386 memset(dest + srclen, 0, destlen - srclen);
2396 srclen = (
int)strlen((
const char *) src);
2403 while (srclen && src[srclen - 1] ==
' ') {
2408 memcpy(dest, src, srclen);
2409 dest[srclen] =
'\0';
2418 if (srclen > destlen) {
2422 memcpy(dest, src, srclen);
2423 for (
i = srclen;
i < destlen;
i++)
2448 memcpy(dest, src, ret);
2456 memcpy(dest, src, ret);
2472 if (src && dest && srclen > 0 && destlen >= srclen) {
2473 memcpy(dest, src, srclen);
2492 if (
len > destlen && destlen >= 0) {
2496 memcpy(dest, dres.
ib,
len);
2498 memset(dest +
len, 0, destlen -
len);
2526 memcpy(dest, &(dres.
ti),
len);
2542 for (
i =
len - 1;
i >= 0 && dres.
c[
i] ==
' '; --
i) {
2545 memcpy(dest, dres.
c,
len);
2550 memcpy(dest, dres.
c,
len);
2560 srclen, srctype, desttype, destlen,
len);
2563 if (
len > destlen) {
2568 memcpy(dest, dres.
c,
len);
2569 for (
i =
len;
i < destlen;
i++)
2605 int srctype,
const BYTE * src,
DBINT srclen,
int desttype,
BYTE * dest,
DBINT destlen)
2651 tdsdump_log(
TDS_DBG_FUNC,
"dbbind(%p, %d, %d, %d, %p)\n",
dbproc,
column, vartype, varlen, varaddr);
2725 if (filename ==
NULL) {
2992 tdsdump_log(
TDS_DBG_FUNC,
"dbcolinfo(%p, %d, %d, %d, %p)\n",
dbproc,
type,
column, computeid, pdbcol);
3035 if (
info->computeid == computeid)
3040 if (column < 1 || column >
info->num_cols)
3320 len += collen > namlen ? collen : namlen;
3359 size_t padlen, collen, namlen;
3363 if (buf_len <=
len) {
3387 padlen = (collen > namlen ? collen : namlen) -
len;
3391 for (; padlen > 0; padlen--) {
3431 size_t collen, namlen,
len;
3433 int desttype, srctype;
3441 const char *opname, *p;
3444 DBINT computeid, num_cols, colid;
3455 free(col_printlens);
3463 if (col_printlens ==
NULL) {
3470 for (col = 0; col < resinfo->
num_cols; col++) {
3471 colinfo = resinfo->
columns[col];
3474 strcpy(dest,
"NULL");
3483 desttype, (
BYTE *) dest,
sizeof(dest));
3487 p = memchr(dest,
'\0',
len);
3488 fwrite(dest, 1, p ==
NULL ?
len : (p - dest),
3492 padlen = (collen > namlen ? collen : namlen) -
len;
3495 for (; c > -1 && padlen > 0; padlen--) {
3499 if ((col + 1) < resinfo->
num_cols) {
3505 col_printlens[col] = collen;
3512 }
else if (col_printlens ==
NULL) {
3520 free(col_printlens);
3535 for (selcol = col = 1; col <= num_cols; col++) {
3542 while (selcol < colid) {
3543 for (
i = 0;
i < col_printlens[selcol - 1];
i++) {
3555 printf(
"%s", opname);
3557 i < (col_printlens[selcol - 1]
3558 - (
int) strlen(opname));
3564 if ((colid + 1) < num_cols) {
3576 for (selcol = col = 1; col <= num_cols; col++) {
3579 while (selcol < colid) {
3580 for (
i = 0;
i < col_printlens[selcol - 1];
i++) {
3594 for (
i = 0;
i < col_printlens[colid - 1];
i++)
3597 if ((colid + 1) < num_cols) {
3609 for (selcol = col = 1; col <= num_cols; col++) {
3610 colinfo = resinfo->
columns[col - 1];
3620 (
BYTE *) dest,
sizeof(dest));
3627 while (selcol < colid) {
3628 for (
i = 0;
i < col_printlens[selcol - 1];
i++) {
3637 p = memchr(dest,
'\0',
len);
3638 fwrite(dest, 1, p ==
NULL ?
len : (p - dest),
3642 padlen = (collen > namlen ? collen : namlen) -
len;
3646 for (; padlen > 0; padlen--) {
3650 if ((colid + 1) < num_cols) {
3664 free(col_printlens);
3736 size_t i, col,
len, collen, namlen;
3746 for (col = 0; col < resinfo->
num_cols; col++) {
3747 colinfo = resinfo->
columns[col];
3750 len = collen > namlen ? collen : namlen;
3751 for (
i = 0;
i <
len;
i++) {
3758 if ((col + 1) < resinfo->
num_cols) {
3794 int i, collen, namlen;
3806 for (col = 0; col < resinfo->
num_cols; col++) {
3807 colinfo = resinfo->
columns[col];
3810 padlen = (collen > namlen ? collen : namlen) - namlen;
3811 if (buf_len < namlen) {
3820 for (; padlen > 0; padlen--) {
3827 if ((col + 1) < resinfo->
num_cols) {
3859 size_t i, col,
len, collen, namlen;
3868 if (resinfo ==
NULL) {
3871 for (col = 0; col < resinfo->
num_cols; col++) {
3872 colinfo = resinfo->
columns[col];
3875 padlen = (collen > namlen ? collen : namlen) - namlen;
3882 for (; padlen > 0; padlen--) {
3886 if ((col + 1) < resinfo->
num_cols) {
3899 for (col = 0; col < resinfo->
num_cols; col++) {
3900 colinfo = resinfo->
columns[col];
3903 len = collen > namlen ? collen : namlen;
3904 for (
i = 0;
i <
len;
i++)
3906 if ((col + 1) < resinfo->
num_cols) {
3942 #if defined(DBLIB_UNIMPLEMENTED)
3953 dbsetdeflang(
char *language)
4016 old_list[
i] = old_list[j];
4105 tds[
i]->query_timeout = seconds;
4283 tdsdump_log(
TDS_DBG_FUNC,
"dbaltbind(%p, %d, %d, %d, %d, %p)\n",
dbproc, computeid,
column, vartype, varlen, varaddr);
4456 i = atoi(char_param);
4457 if (i < 0 || i > 2147483647)
4483 nrows = atoi(char_param);
4485 nrows = (nrows < 0 )? 100 : nrows;
4487 if( 1 < nrows && nrows <= 2147483647 ) {
4512 i = atoi(char_param);
4645 if (!param_info || !param_info->
columns || retnum < 1 || retnum > param_info->
num_cols)
4671 if (!param_info || !param_info->
columns || retnum < 1 || retnum > param_info->
num_cols)
4700 if (!param_info || !param_info->
columns || retnum < 1 || retnum > param_info->
num_cols)
4704 if (
column->column_cur_size < 0)
4707 return column->column_cur_size;
4776 switch (result_type) {
4824 __FILE__, __LINE__, result_type);
4860 compute_id = computeid;
4866 if (
info->computeid == compute_id)
4870 return info->num_cols;
4927 if (
info->computeid == computeid)
4939 if (
info->by_cols > 0 &&
info->bycolumns[0] != byte_flag) {
4946 for (
n = 0;
n <
info->by_cols; ++
n)
4947 p[
sizeof(
info->bycolumns[0]) +
n] =
info->bycolumns[
n] > 255 ? 255 :
info->bycolumns[
n];
4952 return (
BYTE *) (&
info->bycolumns[1]);
5003 tdsdump_log(
TDS_DBG_FUNC,
"default_err_handler %p, %d, %d, %d, %p, %p",
dbproc, severity, dberr, oserr, dberrstr, oserrstr);
5059 #if defined(DBLIB_UNIMPLEMENTED)
5197 #if defined(DBLIB_UNIMPLEMENTED)
5260 amount->
mnylow = 0xFFFFFFFFlu;
5261 amount->
mnyhigh = 0x7FFFFFFFl;
5282 amount->
mnyhigh = -0x7FFFFFFFL - 1;
5286 #if defined(DBLIB_UNIMPLEMENTED)
5378 if (amount->
mnylow != 0xFFFFFFFFlu) {
5382 if (amount->
mnyhigh == 0x7FFFFFFFl)
5406 if (amount->
mnylow != 0) {
5410 if (amount->
mnyhigh == -0x7FFFFFFFL - 1)
5412 amount->
mnylow = 0xFFFFFFFFlu;
5511 if (((m1->
mny4 < 0) && (m2->
mny4 < 0) && (sum->
mny4 >= 0))
5512 || ((m1->
mny4 > 0) && (m2->
mny4 > 0) && (sum->
mny4 <= 0))) {
5543 if (((m1->
mny4 <= 0) && (m2->
mny4 > 0) && (diff->
mny4 > 0))
5544 || ((m1->
mny4 >= 0) && (m2->
mny4 < 0) && (diff->
mny4 < 0))) {
5552 #if defined(DBLIB_UNIMPLEMENTED)
5688 if (d1->
dtdays > 2958463) {
5690 if (d2->
dtdays > 2958463)
5696 if (d2->
dtdays < 2958463)
5707 tdsdump_log(
TDS_DBG_FUNC,
"dblib_datecrack(%p, %d, %p, %d, %p)\n",
dbproc, nano_precision,
output,
type,
data);
5782 #if defined(DBLIB_UNIMPLEMENTED)
5812 dbrpwset(
LOGINREC *
login,
char *srvname,
char *password,
int pwlen)
6268 if (numbytes < -1) {
6278 memcpy(dest, (
char *) &
dbproc->
dbbuf[start], numbytes);
6279 dest[numbytes] =
'\0';
6307 tdsdump_log(
TDS_DBG_FUNC,
"dbsafestr(%p, %s, %d, %s, %d, %d)\n",
dbproc, src, srclen, dest, destlen, quotetype);
6312 if (srclen < -1 || destlen < -1)
6316 srclen = (
int)strlen(src);
6324 if (!dquote && !squote)
6328 for (
i = 0;
i < srclen;
i++) {
6332 if (destlen >= 0 && j >= destlen)
6335 if (squote && src[
i] ==
'\'')
6337 else if (dquote && src[
i] ==
'\"')
6340 if (destlen >= 0 && j >= destlen)
6346 if (destlen >= 0 && j >= destlen)
6513 char textptr_string[35];
6514 char timestamp_string[19];
6518 dbproc, objname, textptr, textptrlen, timestamp,
log);
6536 (
BYTE *) timestamp_string, -1);
6552 textptr_string, timestamp_string, (
log ==
TRUE),
size)))
6589 int cpbytes, bytes_avail;
6694 if (filename ==
NULL) {
6768 #if defined(DBLIB_UNIMPLEMENTED)
6839 tdsdump_log(
TDS_DBG_FUNC,
"dbregparam(%p, %s, %d, %d, %p)\n",
dbproc, param_name,
type, datalen,
data);
6882 static const char shortmon[][4] = {
6883 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
6885 static const char longmon[][12] = {
6886 "January",
"February",
"March",
"April",
"May",
"June",
6887 "July",
"August",
"September",
"October",
"November",
"December"
6894 if (monthnum < 1 || monthnum > 12)
6896 return (shortform) ? shortmon[monthnum - 1] : longmon[monthnum - 1];
7094 #if defined(DBLIB_UNIMPLEMENTED)
7229 tdsdump_log(
TDS_DBG_FUNC,
"dbstrbuild(%p, %s, %d, %s, %s, ...)\n",
dbproc, charbuf,
bufsize,
text, formats);
7234 va_start(ap, formats);
7236 charbuf[resultlen] =
'\0';
7244 time_t currtime = time(
NULL);
7248 strcpy(timestr, asctime(gmtime(&currtime)));
7249 timestr[strlen(timestr) - 1] =
'\0';
7262 if (!resinfo || column < 1 || column > resinfo->
num_cols)
7276 case SYBCHAR:
return "SYBCHAR";
7278 case SYBINTN:
return "SYBINTN";
7279 case SYBINT1:
return "SYBINT1";
7280 case SYBINT2:
return "SYBINT2";
7281 case SYBINT4:
return "SYBINT4";
7282 case SYBINT8:
return "SYBINT8";
7283 case SYBFLT8:
return "SYBFLT8";
7285 case SYBBIT:
return "SYBBIT";
7286 case SYBTEXT:
return "SYBTEXT";
7292 case SYBREAL:
return "SYBREAL";
7294 case SYBVOID:
return "SYBVOID";
7297 case SYBBITN:
return "SYBBITN";
7300 case SYBFLTN:
return "SYBFLTN";
7321 case SYBDATE:
return "SYBDATE";
7322 case SYBTIME:
return "SYBTIME";
7333 case SYBXML:
return "SYBXML";
7341 int bindtype,
DBINT *indicator)
7346 DBINT indicator_value = 0;
7348 int limited_dest_space = 0;
7353 CHECK_NULP(src,
"copy_data_to_host_var", 3, );
7354 CHECK_NULP(dest,
"copy_data_to_host_var", 6, );
7362 limited_dest_space = 1;
7392 }
else if ((srctype == desttype) ||
7400 if (srclen > destlen && destlen >= 0) {
7403 memcpy(dest, src, srclen);
7404 if (srclen < destlen)
7405 memset(dest + srclen, 0, destlen - srclen);
7415 while (srclen && src[srclen - 1] ==
' ') {
7418 if (limited_dest_space) {
7419 if (srclen + 1 > destlen) {
7421 indicator_value = srclen + 1;
7422 srclen = destlen - 1;
7425 memcpy(dest, src, srclen);
7426 dest[srclen] =
'\0';
7429 if (limited_dest_space) {
7430 if (srclen + 1 > destlen) {
7432 indicator_value = srclen + 1;
7433 srclen = destlen - 1;
7438 memcpy(dest, src, srclen);
7439 for (
i = srclen;
i < destlen - 1;
i++)
7444 if (limited_dest_space) {
7445 if (srclen > destlen) {
7447 indicator_value = srclen;
7453 memcpy(dest, src, srclen);
7454 for (
i = srclen;
i < destlen;
i++)
7458 if (limited_dest_space) {
7459 if (srclen > destlen) {
7461 indicator_value = srclen;
7488 memcpy(dest, src, ret);
7496 memcpy(dest, src, ret);
7503 *indicator = indicator_value;
7523 if (limited_dest_space) {
7526 indicator_value =
len;
7533 if (
len > destlen && destlen >= 0) {
7536 memcpy(dest, dres.
ib,
len);
7538 memset(dest +
len, 0, destlen -
len);
7566 memcpy(dest, &(dres.
ti),
len);
7574 while (
len && dres.
c[
len - 1] ==
' ') {
7577 if (limited_dest_space) {
7578 if (
len + 1 > destlen) {
7583 memcpy(dest, dres.
c,
len);
7587 if (limited_dest_space) {
7588 if (
len + 1 > destlen) {
7595 memcpy(dest, dres.
c,
len);
7596 for (
i =
len;
i < destlen - 1;
i++)
7601 if (limited_dest_space) {
7602 if (
len > destlen) {
7604 indicator_value =
len;
7610 memcpy(dest, dres.
c,
len);
7611 for (
i =
len;
i < destlen;
i++)
7615 if (limited_dest_space) {
7618 indicator_value =
len;
7635 *indicator = indicator_value;
7663 "server character set '%2!'\0%s %s" }
7664 , {
SYBEICONVO,
EXCONVERSION,
"Error converting characters into server's character set. Some character(s) could "
7665 "not be converted\0" }
7666 , {
SYBEICONVI,
EXCONVERSION,
"Some character(s) could not be converted into client's character set. Unconverted "
7667 "bytes were changed to question marks ('?')\0" }
7673 , {
SYBEAAMT,
EXPROGRAM,
"User attempted a dbaltbind with mismatched column and variable types\0" }
7674 , {
SYBEABMT,
EXPROGRAM,
"User attempted a dbbind with mismatched column and variable types\0" }
7678 , {
SYBEACNV,
EXCONVERSION,
"Attempt to do data-conversion with NULL destination variable.\0" }
7679 , {
SYBEADST,
EXCONSISTENCY,
"International Release: Error in attempting to determine the size of a pair of "
7680 "translation tables\0" }
7681 , {
SYBEAICF,
EXCONSISTENCY,
"International Release: Error in attempting to install custom format\0" }
7682 , {
SYBEALTT,
EXCONSISTENCY,
"International Release: Error in attempting to load a pair of translation tables\0" }
7683 , {
SYBEAOLF,
EXRESOURCE,
"International Release: Error in attempting to open a localization file\0" }
7684 , {
SYBEAPCT,
EXCONSISTENCY,
"International Release: Error in attempting to perform a character set translation\0" }
7686 , {
SYBEARDI,
EXRESOURCE,
"International Release: Error in attempting to read datetime information from a "
7687 "localization file\0" }
7688 , {
SYBEARDL,
EXRESOURCE,
"International Release: Error in attempting to read the dblib.loc localization file\0" }
7689 , {
SYBEASEC,
EXPROGRAM,
"Attempt to send an empty command buffer to the server\0" }
7693 , {
SYBEAUTN,
EXPROGRAM,
"Attempt to update the timestamp of a table that has no timestamp column\0" }
7694 , {
SYBEBADPK,
EXINFO,
"Packet size of %1! not supported -- size of %2! used instead!\0%d %d" }
7695 , {
SYBEBBCI,
EXINFO,
"Batch successfully bulk copied to the server\0" }
7697 , {
SYBEBCBC,
EXPROGRAM,
"bcp_columns must be called before bcp_colfmt and bcp_colfmt_ps\0" }
7699 "and no terminator should be specified\0" }
7700 , {
SYBEBCBNTYP,
EXPROGRAM,
"bcp_bind: if varaddr is NULL and varlen greater than 0, the table column type "
7701 "must be SYBTEXT or SYBIMAGE and the program variable type must be SYBTEXT, SYBCHAR, "
7702 "SYBIMAGE or SYBBINARY\0" }
7704 , {
SYBEBCFO,
EXUSER,
"bcp host files must contain at least one column\0" }
7706 , {
SYBEBCIS,
EXCONSISTENCY,
"Attempt to bulk copy an illegally-sized column value to the server\0" }
7707 , {
SYBEBCIT,
EXPROGRAM,
"It is illegal to use BCP terminators with program variables other than SYBCHAR, "
7708 "SYBBINARY, SYBTEXT, or SYBIMAGE\0" }
7711 , {
SYBEBCMTXT,
EXPROGRAM,
"bcp_moretext may be used only when there is at least one text or image column in "
7712 "the server table\0" }
7714 , {
SYBEBCNN,
EXUSER,
"Attempt to bulk copy a NULL value into a Server column "
7715 "which does not accept null values\0" }
7716 , {
SYBEBCNT,
EXUSER,
"Attempt to use Bulk Copy with a non-existent Server table\0" }
7718 , {
SYBEBCPB,
EXPROGRAM,
"bcp_bind, bcp_moretext and bcp_sendrow may not be used after bcp_init has been "
7719 "passed a non-NULL input file name\0" }
7721 , {
SYBEBCPI,
EXPROGRAM,
"bcp_init must be called before any other bcp routines\0" }
7722 , {
SYBEBCPN,
EXPROGRAM,
"bcp_bind, bcp_collen, bcp_colptr, bcp_moretext and bcp_sendrow may be used only "
7723 "after bcp_init has been called with the copy direction set to DB_IN\0" }
7727 , {
SYBEBCRO,
EXINFO,
"The BCP hostfile '%1!' contains only %2! rows. It was impossible to read the "
7728 "requested %3! rows\0%s %d %d" }
7729 , {
SYBEBCSA,
EXUSER,
"The BCP hostfile '%1!' contains only %2! rows. "
7730 "Skipping all of these rows is not allowed\0%s %d" }
7732 , {
SYBEBCSI,
EXPROGRAM,
"Host-file columns may be skipped only when copying into the Server\0" }
7733 , {
SYBEBCSNDROW,
EXPROGRAM,
"bcp_sendrow may not be called unless all text data for the previous row has been "
7734 "sent using bcp_moretext\0" }
7735 , {
SYBEBCSNTYP,
EXPROGRAM,
"column number %1!: if varaddr is NULL and varlen greater than 0, the table column "
7736 "type must be SYBTEXT or SYBIMAGE and the program variable type must be SYBTEXT, "
7737 "SYBCHAR, SYBIMAGE or SYBBINARY\0%d" }
7740 , {
SYBEBCVH,
EXPROGRAM,
"bcp_exec may be called only after bcp_init has been passed a valid host file\0" }
7743 , {
SYBEBDIO,
EXPROGRAM,
"Bad bulk copy direction. Must be either IN or OUT\0" }
7745 , {
SYBEBIHC,
EXPROGRAM,
"Incorrect host-column number found in bcp format file\0" }
7746 , {
SYBEBIVI,
EXPROGRAM,
"bcp_columns, bcp_colfmt and bcp_colfmt_ps may be used only after bcp_init has been "
7747 "passed a valid input file\0" }
7748 , {
SYBEBNCR,
EXPROGRAM,
"Attempt to bind user variable to a non-existent compute row\0" }
7750 , {
SYBEBPKS,
EXPROGRAM,
"In DBSETLPACKET, the packet size parameter must be between 0 and 999999\0" }
7754 "columns received\0" }
7762 "defaults received\0" }
7765 , {
SYBEBTMT,
EXPROGRAM,
"Attempt to send too much text data via the bcp_moretext call\0" }
7766 , {
SYBEBTOK,
EXCOMM,
"Bad token from the server: Datastream processing out of sync\0" }
7778 , {
SYBECAP,
EXCOMM,
"DB-Library capabilities not accepted by the Server\0" }
7779 , {
SYBECAPTYP,
EXCOMM,
"Unexpected capability type in CAPABILITY datastream\0" }
7780 , {
SYBECDNS,
EXCONSISTENCY,
"Datastream indicates that a compute column is derived from a non-existent select "
7789 , {
SYBECONN,
EXCOMM,
"Unable to connect: Adaptive Server is unavailable or does not exist\0" }
7790 , {
SYBECRNC,
EXPROGRAM,
"The current row is not a result of compute clause %1!, so it is illegal to attempt "
7791 "to extract that data from this row\0%d" }
7792 , {
SYBECRSAGR,
EXPROGRAM,
"Aggregate functions are not allowed in a cursor statement\0" }
7793 , {
SYBECRSBROL,
EXPROGRAM,
"Backward scrolling cannot be used in a forward scrolling cursor\0" }
7794 , {
SYBECRSBSKEY,
EXPROGRAM,
"Keyset cannot be scrolled backward in mixed cursors with a previous fetch type\0" }
7796 , {
SYBECRSDIS,
EXPROGRAM,
"Cursor statement contains one of the disallowed phrases compute, union, for "
7797 "browse, or select into\0" }
7799 , {
SYBECRSFRAND,
EXPROGRAM,
"Fetch types RANDOM and RELATIVE can only be used within the keyset of keyset "
7800 "driven cursors\0" }
7805 , {
SYBECRSMROWS,
EXRESOURCE,
"Multiple rows are returned, only one is expected while retrieving dbname\0" }
7808 "when doing updates or deletes with dbcursor\0" }
7809 , {
SYBECRSNOFREE,
EXPROGRAM,
"The DBNOAUTOFREE option should not be turned on when using cursor APIs\0" }
7810 , {
SYBECRSNOIND,
EXPROGRAM,
"One of the tables involved in the cursor statement does not have a unique index\0" }
7821 , {
SYBECRSORD,
EXPROGRAM,
"Only fully keyset driven cursors can have order by, group by, or having phrases\0" }
7822 , {
SYBECRSRO,
EXPROGRAM,
"Data locking or modifications cannot be made in a READONLY cursor\0" }
7824 , {
SYBECRSTAB,
EXPROGRAM,
"Table name must be determined in operations involving data locking or modifications\0" }
7826 , {
SYBECRSVIEW,
EXPROGRAM,
"A view cannot be joined with another table or a view in a cursor statement\0" }
7827 , {
SYBECRSVIIND,
EXPROGRAM,
"The view used in the cursor statement does not include all the unique index "
7828 "columns of the underlying tables\0" }
7829 , {
SYBECRSUPDNB,
EXPROGRAM,
"Update or insert operations cannot use bind variables when binding type is NOBIND\0" }
7830 , {
SYBECRSUPDTAB,
EXPROGRAM,
"Update or insert operations using bind variables require single table cursors\0" }
7831 , {
SYBECSYN,
EXCONVERSION,
"Attempt to convert data stopped by syntax error in source field\0" }
7836 , {
SYBEDIVZ,
EXUSER,
"Attempt to divide by $0.00 in function %1!\0%s" }
7837 , {
SYBEDNTI,
EXPROGRAM,
"Attempt to use dbtxtsput to put a new text timestamp into a column whose datatype "
7838 "is neither SYBTEXT nor SYBIMAGE\0" }
7841 , {
SYBEECAN,
EXINFO,
"Attempted to cancel unrequested event notification\0" }
7843 , {
SYBEETD,
EXPROGRAM,
"Failure to send the expected amount of TEXT or IMAGE data via dbmoretext\0" }
7844 , {
SYBEEUNR,
EXCOMM,
"Unsolicited event notification received\0" }
7845 , {
SYBEEVOP,
EXINFO,
"Called dbregwatch with a bad options parameter\0" }
7846 , {
SYBEEVST,
EXINFO,
"Must initiate a transaction before calling dbregparam\0" }
7849 , {
SYBEFSHD,
EXRESOURCE,
"Error in attempting to find the Sybase home directory\0" }
7850 , {
SYBEFUNC,
EXPROGRAM,
"Functionality not supported at the specified version level\0" }
7852 , {
SYBEIDCL,
EXCONSISTENCY,
"Illegal datetime column length returned by Adaptive Server. Legal datetime lengths "
7853 "are 4 and 8 bytes\0" }
7855 , {
SYBEIFCL,
EXCONSISTENCY,
"Illegal floating-point column length returned by Adaptive Server. Legal "
7856 "floating-point lengths are 4 and 8 bytes\0" }
7858 , {
SYBEIICL,
EXCONSISTENCY,
"Illegal integer column length returned by Adaptive Server. Legal integer lengths "
7859 "are 1, 2, and 4 bytes\0" }
7860 , {
SYBEIMCL,
EXCONSISTENCY,
"Illegal money column length returned by Adaptive Server. Legal money lengths are 4 "
7862 , {
SYBEINLN,
EXUSER,
"Interface file: unexpected end-of-line\0" }
7863 , {
SYBEINTF,
EXUSER,
"Server name not found in configuration files\0" }
7865 , {
SYBEIPV,
EXINFO,
"%1! is an illegal value for the %2! parameter of %3!\0%d %s %s" }
7872 , {
SYBEKBCO,
EXINFO,
"1000 rows successfully bulk copied to host file\0" }
7874 , {
SYBEMOV,
EXUSER,
"Money arithmetic resulted in overflow in function %1!\0%s" }
7875 , {
SYBEMPLL,
EXUSER,
"Attempt to set maximum number of DBPROCESSes lower than 1\0" }
7877 , {
SYBENBUF,
EXINFO,
"Called dbsendpassthru with a NULL buf parameter\0" }
7879 , {
SYBENDC,
EXPROGRAM,
"Cannot have negative component in date in numeric form\0" }
7882 , {
SYBENHAN,
EXINFO,
"Called dbrecvpassthru with a NULL handle parameter\0" }
7884 , {
SYBENOEV,
EXINFO,
"DBPOLL can not be called when registered procedure notifications have been disabled\0" }
7888 , {
SYBENTTN,
EXPROGRAM,
"Attempt to use dbtxtsput to put a new text timestamp into a non-existent data row\0" }
7889 , {
SYBENULL,
EXINFO,
"NULL DBPROCESS pointer passed to DB-Library\0" }
7891 , {
SYBENXID,
EXNONFATAL,
"The Server did not grant us a distributed-transaction ID\0" }
7893 , {
SYBEOOB,
EXCOMM,
"Error in sending out-of-band data to the server\0" }
7896 , {
SYBEOREN,
EXINFO,
"International Release: Warning: an out-of-range error-number was encountered in "
7897 "dblib.loc. The maximum permissible error-number is defined as DBERRCOUNT in sybdb.h\0" }
7898 , {
SYBEORPF,
EXUSER,
"Attempt to set remote password would overflow "
7899 "the login record's remote password field\0" }
7901 , {
SYBEPRTF,
EXINFO,
"dbtracestring may only be called from a printfunc\0" }
7906 , {
SYBERESP,
EXPROGRAM,
"Response function address passed to dbresponse must be non-NULL\0" }
7907 , {
SYBERPCS,
EXINFO,
"Must call dbrpcinit before dbrpcparam or dbrpcsend\0" }
7908 , {
SYBERPIL,
EXPROGRAM,
"It is illegal to pass -1 to dbrpcparam for the datalen of parameters which are of "
7909 "type SYBCHAR, SYBVARCHAR, SYBBINARY, or SYBVARBINARY\0" }
7910 , {
SYBERPNA,
EXNONFATAL,
"The RPC facility is available only when using a server whose version number is 4.0 "
7912 , {
SYBERPND,
EXPROGRAM,
"Attempt to initiate a new Adaptive Server operation with results pending\0" }
7913 , {
SYBERPNULL,
EXPROGRAM,
"value parameter for dbrpcparam can be NULL, only if the datalen parameter is 0\0" }
7915 , {
SYBERPUL,
EXPROGRAM,
"When passing a SYBINTN, SYBDATETIMN, SYBMONEYN, or SYBFLTN parameter via "
7916 "dbrpcparam, it is necessary to specify the parameter's maximum or actual length so "
7917 "that DB-Library can recognize it as a SYINT1, SYBINT2, SYBINT4, SYBMONEY, SYBMONEY4, "
7919 , {
SYBERTCC,
EXPROGRAM,
"dbreadtext may not be used to receive the results of a query that contains a "
7920 "COMPUTE clause\0" }
7921 , {
SYBERTSC,
EXPROGRAM,
"dbreadtext may be used only to receive the results of a query that contains a "
7922 "single result column\0" }
7923 , {
SYBERXID,
EXNONFATAL,
"The Server did not recognize our distributed-transaction ID\0" }
7925 , {
SYBESEFA,
EXPROGRAM,
"DBSETNOTIFS cannot be called if connections are present\0" }
7927 , {
SYBESFOV,
EXPROGRAM,
"International Release: dbsafestr overflowed its destination buffer\0" }
7928 , {
SYBESMSG,
EXSERVER,
"General Adaptive Server error: Check messages from the server\0" }
7931 , {
SYBESYNC,
EXCOMM,
"Read attempted while out of synchronization with Adaptive Server\0" }
7932 , {
SYBETEXS,
EXINFO,
"Called dbmoretext with a bad size parameter\0" }
7934 , {
SYBETMCF,
EXPROGRAM,
"Attempt to install too many custom formats via dbfmtinstall\0" }
7935 , {
SYBETMTD,
EXPROGRAM,
"Attempt to send too much TEXT data via the dbmoretext call\0" }
7937 , {
SYBETPTN,
EXUSER,
"Syntax error: only two periods are permitted in table names\0" }
7938 , {
SYBETRAC,
EXINFO,
"Attempted to turn off a trace flag that was not on\0" }
7939 , {
SYBETRAN,
EXINFO,
"DBPROCESS is being used for another transaction\0" }
7940 , {
SYBETRAS,
EXINFO,
"DB-Library internal error - trace structure not found\0" }
7941 , {
SYBETRSN,
EXINFO,
"Bad numbytes parameter passed to dbtracestring\0" }
7942 , {
SYBETSIT,
EXINFO,
"Attempt to call dbtsput with an invalid timestamp\0" }
7943 , {
SYBETTS,
EXUSER,
"The table which bulk copy is attempting to copy to a host file is shorter than the "
7944 "number of rows which bulk copy was instructed to skip\0" }
7945 , {
SYBETYPE,
EXINFO,
"Invalid argument type given to Hyper/DB-Library\0" }
7946 , {
SYBEUCPT,
EXUSER,
"Unrecognized custom-format parameter-type encountered in dbstrbuild\0" }
7947 , {
SYBEUCRR,
EXCONSISTENCY,
"Internal software error: Unknown connection result reported by dbpasswd\0" }
7949 , {
SYBEUFDS,
EXUSER,
"Unrecognized format encountered in dbstrbuild\0" }
7953 , {
SYBEUNAM,
EXFATAL,
"Unable to get current user name from operating system\0" }
7955 , {
SYBEUNT,
EXUSER,
"Unknown network type found in interface file\0" }
7956 , {
SYBEURCI,
EXRESOURCE,
"International Release: Unable to read copyright information from the DB-Library "
7957 "localization file\0" }
7958 , {
SYBEUREI,
EXRESOURCE,
"International Release: Unable to read error information from the DB-Library "
7959 "localization file\0" }
7960 , {
SYBEUREM,
EXRESOURCE,
"International Release: Unable to read error mnemonic from the DB-Library "
7961 "localization file\0" }
7962 , {
SYBEURES,
EXRESOURCE,
"International Release: Unable to read error string from the DB-Library "
7963 "localization file. 401 Error severities\0" }
7964 , {
SYBEURMI,
EXRESOURCE,
"International Release: Unable to read money-format information from the DB-Library "
7965 "localization file\0" }
7967 , {
SYBEUTDS,
EXCOMM,
"Unrecognized TDS version received from the server\0" }
7968 , {
SYBEUVBF,
EXPROGRAM,
"Attempt to read an unknown version of bcp format file\0" }
7970 , {
SYBEVDPT,
EXUSER,
"For bulk copy, all variable-length data must have either a length-prefix or a "
7971 "terminator specified\0" }
7974 , {
SYBEXOCI,
EXNONFATAL,
"International Release: A character-set translation overflowed its destination "
7975 "buffer while using bcp to copy data from a host-file to the server\0" }
7976 , {
SYBEXTDN,
EXPROGRAM,
"Warning: the xlt_todisp parameter to dbfree_xlate was NULL. The space associated "
7977 "with the xlt_tosrv parameter has been freed\0" }
7978 , {
SYBEXTN,
EXPROGRAM,
"The xlt_tosrv and xlt_todisp parameters to dbfree_xlate were NULL\0" }
7979 , {
SYBEXTSN,
EXPROGRAM,
"Warning: the xlt_tosrv parameter to dbfree_xlate was NULL. The space associated "
7980 "with the xlt_todisp parameter has been freed\0" }
7981 , {
SYBEZTXT,
EXINFO,
"Attempt to send zero length TEXT or IMAGE to dataserver via dbwritetext\0" }
7983 , { 50000,
EXCONVERSION,
"Data is truncated during conversion\0" }
7984 , { 50001,
EXPROGRAM,
"Max connections reached, increase value of TDS_MAX_CONN\0" }
8041 static const char int_exit_text[] =
"FreeTDS: db-lib: exiting because client error handler returned %s for msgno %d\n";
8042 static const char int_invalid_text[] =
"%s (%d) received from client-installed error handler for nontimeout for error %d."
8043 " Treating as INT_EXIT\n";
8049 const char *os_msgtext =
strerror((
int)errnum),
8050 *rc_name =
"logic error";
8065 if (os_msgtext ==
NULL)
8066 os_msgtext =
"no OS error";
8081 const char * pformats = ptext + strlen(ptext) + 1;
8083 assert(*(pformats - 1) ==
'\0');
8084 if(*pformats !=
'\0') {
8091 va_start(ap, errnum);
8101 msg = &constructed_message;
8116 msg = &constructed_message;
8126 (
char*) msg->
msgtext, (
char*) os_msgtext);
8129 rc_name =
"INT_EXIT";
8132 rc_name =
"INT_CONTINUE";
8135 rc_name =
"INT_CANCEL";
8138 rc_name =
"INT_TIMEOUT";
8141 rc_name =
"invalid";
8144 tdsdump_log(
TDS_DBG_FUNC,
"dbperror: dblib_err_handler for msgno = %d; msg->msgtext = \"%s\" -- returns %d (%s)\n",
8145 msgno, msg->
msgtext, rc, rc_name);
8182 sprintf(rc_buf,
"%d", rc);
void(*)(CSeq_entry_Handle seh, IWorkbench *wb, const CSerialObject &obj) handler
static void buffer_alloc(DBPROCESS *dbproc)
static void buffer_delete_rows(DBPROC_ROWBUF *buf, int count)
Deleting a row from the buffer doesn't affect memory allocation.
static int buffer_is_full(const DBPROC_ROWBUF *buf)
Can the buffer be written to?
static int buffer_count(const DBPROC_ROWBUF *buf)
A few words on the buffering design.
static DBINT buffer_idx2row(const DBPROC_ROWBUF *buf, int idx)
Convert an index to a row number.
static void buffer_set_capacity(DBPROCESS *dbproc, int nrows)
static int buffer_add_row(DBPROCESS *dbproc, TDSRESULTINFO *resinfo)
Called by dbnextrow Returns a row buffer index, or -1 to indicate the buffer is full.
static void buffer_free(DBPROC_ROWBUF *buf)
static void buffer_transfer_bound_data(DBPROC_ROWBUF *buf, TDS_INT res_type, TDS_INT compute_id, DBPROCESS *dbproc, int idx)
static int buffer_row2idx(const DBPROC_ROWBUF *buf, int row_number)
Convert a row number to an index.
static RETCODE buffer_save_row(DBPROCESS *dbproc)
static int buffer_current_index(const DBPROCESS *dbproc)
Return the current row buffer index.
int dbcurcmd(DBPROCESS *dbproc)
static const DBSMALLINT null_SMALLINT
RETCODE dbsetlbool(LOGINREC *login, int value, int which)
static TDSCOLUMN * dbcolptr(DBPROCESS *dbproc, int column)
static const DBTINYINT null_TINYINT
DBINT dblastrow(DBPROCESS *dbproc)
RETCODE dbcmdrow(DBPROCESS *dbproc)
EHANDLEFUNC _dblib_err_handler
static TDSCOLUMN * dbacolptr(DBPROCESS *dbproc, int computeid, int column, int is_bind)
DBPROCESS * tdsdbopen(LOGINREC *login, const char *server, int msdblib)
static char * dbstring_get(DBSTRING *dbstr)
STATUS dbnextrow(DBPROCESS *dbproc)
static int _get_printable_size(TDSCOLUMN *colinfo)
int dbperror(DBPROCESS *dbproc, DBINT msgno, long errnum,...)
static const char * prresult_type(int result_type, prbuf_t buf)
static BYTE * _dbcoldata(TDSCOLUMN *colinfo)
static const DBINT null_INT
static RETCODE dbstring_concat(DBSTRING **dbstrp, const char *p)
static const DBLIB_ERROR_MESSAGE dblib_error_messages[]
void copy_data_to_host_var(DBPROCESS *, TDS_SERVER_TYPE, const BYTE *, int, BYTE *, DBINT, int, DBINT *)
static const DBREAL null_REAL
RETCODE dbrows(DBPROCESS *dbproc)
static const char * prretcode(int retcode, prbuf_t buf)
static int _dbnullable(DBPROCESS *dbproc, int column)
void dbsetavail(DBPROCESS *dbproc)
static const char * prdbresults_state(int retcode, prbuf_t buf)
static const DBFLT8 null_FLT8
int dbiowdesc(DBPROCESS *dbproc)
static const DBMONEY4 null_SMALLMONEY
static DBOPTION * init_dboptions(void)
static const DBBIT null_BIT
static int g_dblib_version
static const DBBIGINT null_BIGINT
static const DBCHAR null_CHAR
static TDS_SERVER_TYPE dblib_bound_type(int bindtype)
static const DBNUMERIC null_NUMERIC
static NULLREP default_null_representations[MAXBINDTYPES]
int dbtds(DBPROCESS *dbproc)
struct _dblib_error_message DBLIB_ERROR_MESSAGE
struct dblib_context DBLIBCONTEXT
static int dbbindtype(int datatype)
RETCODE dbcolinfo(DBPROCESS *dbproc, CI_TYPE type, DBINT column, DBINT computeid, DBCOL *pdbcol)
Get a bunch of column attributes with a single call (Microsoft-compatibility feature).
DBINT dbcurrow(DBPROCESS *dbproc)
static const char * dbcoltablename(DBPROCESS *dbproc, int column)
static char * _dbprdate(char *timestr)
STATUS dbrowtype(DBPROCESS *dbproc)
static const char * prdbretcode(RETCODE retcode, prbuf_t buf)
static void dbstring_free(DBSTRING **dbstrp)
static int g_dbsetversion_called
MHANDLEFUNC _dblib_msg_handler
int dbiordesc(DBPROCESS *dbproc)
static const DBDATETIME4 null_SMALLDATETIME
static int dblib_add_connection(DBLIBCONTEXT *ctx, TDSSOCKET *tds)
static const DBVARYCHAR null_VARYCHAR
RETCODE dbsetllong(LOGINREC *login, long value, int which)
static void dblib_del_connection(DBLIBCONTEXT *ctx, TDSSOCKET *tds)
static const char * tds_prdatatype(int datatype_token)
Returns type in string.
static void dblib_release_tds_ctx(int count)
static int default_err_handler(DBPROCESS *dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr)
static TDSCONTEXT * dblib_get_tds_ctx(void)
static DBLIBCONTEXT g_dblib_ctx
static const DBDATETIME null_DATETIME
static DBINT dbstring_length(DBSTRING *dbstr)
static RETCODE dblib_datecrack(DBPROCESS *dbproc, BOOL nano_precision, DBDATEREC *output, int type, const void *data)
static void db_env_chg(TDSSOCKET *tds, int type, char *oldval, char *newval)
RETCODE dbsetlname(LOGINREC *login, const char *value, int which)
static const char *const opttext[DBNUMOPTIONS]
RETCODE dbgetnull(DBPROCESS *dbproc, int bindtype, int varlen, BYTE *varaddr)
DBBOOL dbdead(DBPROCESS *dbproc)
static const DBMONEY null_MONEY
DBBOOL dbisavail(DBPROCESS *dbproc)
static const TDS_DATETIMEALL null_DATETIMEALL
static RETCODE dbstring_assign(DBSTRING **dbstrp, const char *p)
static int dbstring_getchar(DBSTRING *dbstr, ssize_t i)
static DBPROCESS * dbproc
static int hndlintr(DBPROCESS *dbproc)
static int chkintr(DBPROCESS *dbproc)
#define DBPERROR_RETURN(x, msg)
#define CHECK_PARAMETER_NOPROC(x, msg)
#define CHECK_NULP(x, func, param_num, ret)
@ _DB_RES_NO_MORE_RESULTS
@ _DB_RES_RESULTSET_EMPTY
#define CHECK_PARAMETER(x, msg, ret)
static DLIST_TYPE *DLIST_NAME() next(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
#define is_numeric_type(x)
#define TDS_DONEPROC_RESULT
#define TDS_ROWFMT_RESULT
tds_sysdep_int32_type TDS_INT
#define tds_get_parent(tds)
#define TDS_NO_MORE_RESULTS
#define TDS_COMPUTEFMT_RESULT
#define is_datetime_type(x)
return true if type is a datetime (but not date or time)
#define TDS_OTHERS_RESULT
static bool is_tds_type_valid(int type)
tds_sysdep_int64_type TDS_INT8
#define TDS_DESCRIBE_RESULT
#define TDS_COMPUTE_RESULT
unsigned char TDS_TINYINT
@ TDS_PENDING
cilent is waiting for data
tds_sysdep_int16_type TDS_SMALLINT
#define TDS_VECTOR_SIZE(x)
#define tds_new0(type, n)
#define is_nullable_type(x)
@ TDS_DONE_MORE_RESULTS
more results follow
@ TDS_DONE_ERROR
error occurred
tds_sysdep_uint16_type TDS_USMALLINT
#define TDS_STATUS_RESULT
#define TDS_RESIZE(p, n_elem)
#define tds_set_parent(tds, val)
#define TDS_MAX_LOGIN_STR_SZ
tds_sysdep_uint32_type TDS_UINT
#define is_similar_type(x, y)
#define TDS_DONEINPROC_RESULT
#define tds_mutex_lock(x)
#define tds_mutex_unlock(x)
static SQLCHAR output[256]
static const char * str(char *buf, int n)
static const char * column
RETCODE dbsetlshort(LOGINREC *login, int value, int which)
#define DBTDS_UNKNOWN
DBTDS_xxx are returned by DBTDS() The integer values of the constants are poorly chosen.
int(* DB_DBCHKINTR_FUNC)(void *dbproc)
#define SYBMSDATETIMEOFFSET
RETCODE dbmnysub(DBPROCESS *dbproc, DBMONEY *m1, DBMONEY *m2, DBMONEY *diff)
int(* EHANDLEFUNC)(DBPROCESS *dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr)
#define SMALLDATETIMEBIND
int(* DB_DBHNDLINTR_FUNC)(void *dbproc)
#define DBVERSION_UNKNOWN
DBVERSION_xxx are used with dbsetversion()
int(* MHANDLEFUNC)(DBPROCESS *dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *proc, int line)
RETCODE dbsetdefcharset(char *charset)
#define _dblib_handle_info_message
#define _dblib_check_and_handle_interrupt
#define _dblib_handle_err_message
#define dbnextrow_pivoted
#define tds_read_config_info
#define tds_writetext_end
#define tds_get_size_by_type
#define tds_writetext_continue
#define tds_connect_and_login
#define tds_set_interfaces_file_loc
#define tds_get_column_declaration
#define tds_alloc_context
#define tds_process_cancel
#define tds_set_client_charset
#define tds_get_conversion_type
#define tds_writetext_start
#define tds_process_tokens
static tds_mutex dblib_mutex
#define TDS_MUTEX_INITIALIZER
#define _dblib_convert_err
void dbclrbuf(DBPROCESS *dbproc, DBINT n)
Clear n rows from the row buffer.
LOGINREC * dblogin(void)
Allocate a LOGINREC structure.
DBTYPEINFO * dbcoltypeinfo(DBPROCESS *dbproc, int column)
Get precision and scale information for a regular result column.
void dbfreebuf(DBPROCESS *dbproc)
Erase the command buffer, in case DBNOAUTOFREE was set with dbsetopt().
BYTE * dbdata(DBPROCESS *dbproc, int column)
Get address of data in a regular result column.
int dbstrlen(DBPROCESS *dbproc)
Get size of the command buffer, in bytes.
BYTE * dbadata(DBPROCESS *dbproc, int computeid, int column)
Get address of compute column data.
int dbspid(DBPROCESS *dbproc)
Get server process ID for a DBPROCESS.
DBBINARY * dbtxtimestamp(DBPROCESS *dbproc, int column)
Get text timestamp for a column in the current row.
BYTE * dbbylist(DBPROCESS *dbproc, int computeid, int *size)
Get bylist for a compute row.
#define DBDEAD(x)
Sybase macro mapping to the Microsoft (lower-case) function.
char * dbservcharset(DBPROCESS *dbproc)
Get syscharset name of the server character set.
DBINT dbspr1rowlen(DBPROCESS *dbproc)
Determine size buffer required to hold the results returned by dbsprhead(), dbsprline(),...
DBINT dbconvert(DBPROCESS *dbproc, int srctype, const BYTE *src, DBINT srclen, int desttype, BYTE *dest, DBINT destlen)
cf.
DBINT dbadlen(DBPROCESS *dbproc, int computeid, int column)
Get size of data in a compute column.
void dbsetinterrupt(DBPROCESS *dbproc, DB_DBCHKINTR_FUNC chkintr, DB_DBHNDLINTR_FUNC hndlintr)
Set interrupt handler for db-lib to use while blocked against a read from the server.
RETCODE dbsetnull(DBPROCESS *dbproc, int bindtype, int bindlen, BYTE *bindval)
Define substitution values to be used when binding null values.
char * dbcolname(DBPROCESS *dbproc, int column)
Return name of a regular result column.
RETCODE dbfcmd(DBPROCESS *dbproc, const char *fmt,...)
printf-like way to form SQL to send to the server.
RETCODE dbdatecrack(DBPROCESS *dbproc, DBDATEREC *di, DBDATETIME *datetime)
Break a DBDATETIME value into useful pieces.
RETCODE dbresults(DBPROCESS *dbproc)
Set up query results.
RETCODE dbwritetext(DBPROCESS *dbproc, char *objname, DBBINARY *textptr, DBTINYINT textptrlen, DBBINARY *timestamp, DBBOOL log, DBINT size, BYTE *text)
Send text or image data to the server.
RETCODE dbcanquery(DBPROCESS *dbproc)
Cancel the query currently being retrieved, discarding all pending rows.
RETCODE dbinit(void)
Initialize db-lib.
DBINT dbvarylen(DBPROCESS *dbproc, int column)
Determine whether a column can vary in size.
RETCODE dbcancel(DBPROCESS *dbproc)
Cancel the current command batch.
RETCODE dbsetlogintime(int seconds)
Set maximum seconds db-lib waits for a server response to a login attempt.
RETCODE dbgetrow(DBPROCESS *dbproc, DBINT row)
Read a row from the row buffer.
int dbcoltype(DBPROCESS *dbproc, int column)
Get the datatype of a regular result set column.
void dbsetifile(char *filename)
set name and location of the interfaces file FreeTDS should use to look up a servername.
const char * dbversion()
See which version of db-lib is in use.
RETCODE dbuse(DBPROCESS *dbproc, const char *name)
Change current database.
int dbnumalts(DBPROCESS *dbproc, int computeid)
Get count of columns in a compute row.
BOOL dbiscount(DBPROCESS *dbproc)
Indicates whether or not the count returned by dbcount is real (Microsoft-compatibility feature).
int dbgettime(void)
Get maximum seconds db-lib waits for a server response to query.
RETCODE dbmoretext(DBPROCESS *dbproc, DBINT size, const BYTE text[])
Send chunk of a text/image value to the server.
const char * dbprtype(int token)
Print a token value's name to a buffer.
char * dbcolsource(DBPROCESS *dbproc, int column)
Get base database column name for a result set column.
char * dbchange(DBPROCESS *dbproc)
See if a command caused the current database to change.
RETCODE dbnullbind(DBPROCESS *dbproc, int column, DBINT *indicator)
Tie a null-indicator to a regular result column.
RETCODE dbbind(DBPROCESS *dbproc, int column, int vartype, DBINT varlen, BYTE *varaddr)
Tie a host variable to a resultset column.
RETCODE dbcmd(DBPROCESS *dbproc, const char cmdstring[])
Append SQL to the command buffer.
DBINT dbcollen(DBPROCESS *dbproc, int column)
Get size of a regular result column.
DBINT dbconvert_ps(DBPROCESS *dbproc, int db_srctype, const BYTE *src, DBINT srclen, int db_desttype, BYTE *dest, DBINT destlen, DBTYPEINFO *typeinfo)
Convert one datatype to another.
char * dbgetchar(DBPROCESS *dbproc, int pos)
Get address of a position in the command buffer.
RETCODE dbanullbind(DBPROCESS *dbproc, int computeid, int column, DBINT *indicator)
Tie a null-indicator to a compute result column.
RETCODE dbclropt(DBPROCESS *dbproc, int option, const char param[])
Reset an option.
DBINT dbcount(DBPROCESS *dbproc)
Get count of rows processed.
int dbaltop(DBPROCESS *dbproc, int computeid, int column)
Get aggregation operator for a compute column.
RETCODE dbtablecolinfo(DBPROCESS *dbproc, DBINT column, DBCOL *pdbcol)
describe table column attributes with a single call (Freetds-only API function modelled on dbcolinfo)
DBINT dbaltlen(DBPROCESS *dbproc, int computeid, int column)
Get size of data in compute column.
RETCODE dbsetopt(DBPROCESS *dbproc, int option, const char *char_param, int int_param)
Set db-lib or server option.
void dbprhead(DBPROCESS *dbproc)
Print result set headings to stdout.
RETCODE dbsetlversion(LOGINREC *login, BYTE version)
Set TDS version for future connections.
RETCODE dbprrow(DBPROCESS *dbproc)
Print a result set to stdout.
char * dbname(DBPROCESS *dbproc)
Get name of current database.
int dbalttype(DBPROCESS *dbproc, int computeid, int column)
Get datatype for a compute column.
RETCODE dbsprhead(DBPROCESS *dbproc, char *buffer, DBINT buf_len)
Print result set headings to a buffer.
RETCODE dbsqlexec(DBPROCESS *dbproc)
send the SQL command to the server and wait for an answer.
DBBOOL dbwillconvert(int srctype, int desttype)
Test whether or not a datatype can be converted to another datatype.
int dbcolutype(DBPROCESS *dbproc, int column)
Get user-defined datatype of a regular result column.
RETCODE dbstrbuild(DBPROCESS *dbproc, char *charbuf, int bufsize, char *text, char *formats,...)
Build a printable string from text containing placeholders for variables.
EHANDLEFUNC dberrhandle(EHANDLEFUNC handler)
Set an error handler, for messages from db-lib.
RETCODE dbsetversion(DBINT version)
Specify a db-lib version level.
int dbgetpacket(DBPROCESS *dbproc)
Get TDS packet size for the connection.
void dbrecftos(const char filename[])
Record to a file all SQL commands sent to the server.
BYTE * dbgetuserdata(DBPROCESS *dbproc)
Get address of user-allocated data from a DBPROCESS.
void dbsetuserdata(DBPROCESS *dbproc, BYTE *ptr)
Associate client-allocated (and defined) data with a DBPROCESS.
DBINT dbprcollen(DBPROCESS *dbproc, int column)
Get size of a result column needed to print column.
void dbloginfree(LOGINREC *login)
free the LOGINREC
RETCODE dbmorecmds(DBPROCESS *dbproc)
See if more commands are to be processed.
DBBOOL dbisopt(DBPROCESS *dbproc, int option, const char param[])
Get value of an option.
int dbnumcompute(DBPROCESS *dbproc)
Get count of COMPUTE clauses for a result set.
RETCODE dbsqlsend(DBPROCESS *dbproc)
Transmit the command buffer to the server.
RETCODE dbsprline(DBPROCESS *dbproc, char *buffer, DBINT buf_len, DBCHAR line_char)
Get formatted string for underlining dbsprhead() column names.
void dbexit()
Close server connections and free all related structures.
RETCODE dbsafestr(DBPROCESS *dbproc, const char *src, DBINT srclen, char *dest, DBINT destlen, int quotetype)
safely quotes character values in SQL text.
int dbaltcolid(DBPROCESS *dbproc, int computeid, int column)
Get column ID of a compute column.
RETCODE dbanydatecrack(DBPROCESS *dbproc, DBDATEREC2 *di, int type, const void *data)
Break any kind of date or time value into useful pieces.
RETCODE dbsettime(int seconds)
Set maximum seconds db-lib waits for a server response to query.
int dbnumcols(DBPROCESS *dbproc)
Return number of regular columns in a result set.
int dbgetmaxprocs(void)
get maximum simultaneous connections db-lib will open to the server.
DBBINARY * dbtxptr(DBPROCESS *dbproc, int column)
Get text pointer for a column in the current row.
MHANDLEFUNC dbmsghandle(MHANDLEFUNC handler)
Set a message handler, for messages from the server.
STATUS dbreadtext(DBPROCESS *dbproc, void *buf, DBINT bufsize)
Fetch part of a text or image value from the server.
RETCODE dbsqlok(DBPROCESS *dbproc)
Wait for results of a query from the server.
DBINT dbdatlen(DBPROCESS *dbproc, int column)
Get size of current row's data in a regular result column.
STATUS dbsetrow(DBPROCESS *dbproc, DBINT row)
Make a buffered row "current" without fetching it into bound variables.
void dbclose(DBPROCESS *dbproc)
Close a connection to the server and free associated resources.
RETCODE dbstrcpy(DBPROCESS *dbproc, int start, int numbytes, char *dest)
Get a copy of a chunk of the command buffer.
static RETCODE _dbresults(DBPROCESS *dbproc)
DBINT dbaltutype(DBPROCESS *dbproc, int computeid, int column)
Get user-defined datatype of a compute column.
RETCODE dbsetmaxprocs(int maxprocs)
Set maximum simultaneous connections db-lib will open to the server.
DBINT dbfirstrow(DBPROCESS *dbproc)
See if a server response has arrived.
RETCODE dbspr1row(DBPROCESS *dbproc, char *buffer, DBINT buf_len)
Print a regular result row to a buffer.
RETCODE dbaltbind(DBPROCESS *dbproc, int computeid, int column, int vartype, DBINT varlen, BYTE *varaddr)
Bind a compute column to a program variable.
int dbdatecmp(DBPROCESS *dbproc, DBDATETIME *d1, DBDATETIME *d2)
Compare DBDATETIME values, similar to strcmp(3).
const char * dbmonthname(DBPROCESS *dbproc, char *language, int monthnum, DBBOOL shortform)
Get name of a month, in some human language.
RETCODE dbmny4zero(DBPROCESS *dbproc, DBMONEY4 *dest)
Zero a DBMONEY4 value.
RETCODE dbmny4add(DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2, DBMONEY4 *sum)
Add two DBMONEY4 values.
int dbmny4cmp(DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2)
Compare two DBMONEY4 values.
RETCODE dbmnymaxpos(DBPROCESS *dbproc, DBMONEY *amount)
Get maximum positive DBMONEY value supported.
RETCODE dbmny4minus(DBPROCESS *dbproc, DBMONEY4 *src, DBMONEY4 *dest)
Negate a DBMONEY4 value.
RETCODE dbmnyminus(DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest)
Negate a DBMONEY value.
RETCODE dbmny4sub(DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2, DBMONEY4 *diff)
Subtract two DBMONEY4 values.
RETCODE dbmnyzero(DBPROCESS *dbproc, DBMONEY *dest)
Set a DBMONEY value to zero.
RETCODE dbmnycopy(DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest)
Copy a DBMONEY value.
RETCODE dbmny4copy(DBPROCESS *dbproc, DBMONEY4 *src, DBMONEY4 *dest)
Copy a DBMONEY4 value.
RETCODE dbmnymaxneg(DBPROCESS *dbproc, DBMONEY *amount)
Get maximum negative DBMONEY value supported.
RETCODE dbmnydec(DBPROCESS *dbproc, DBMONEY *amount)
Subtract $0.0001 from a DBMONEY value.
RETCODE dbmnyinc(DBPROCESS *dbproc, DBMONEY *amount)
Add $0.0001 to a DBMONEY value.
int dbmnycmp(DBPROCESS *dbproc, DBMONEY *m1, DBMONEY *m2)
Compare two DBMONEY values.
DBINT dbretstatus(DBPROCESS *dbproc)
Fetch status value returned by query or remote procedure call.
BYTE * dbretdata(DBPROCESS *dbproc, int retnum)
Get value of an output parameter filled by a stored procedure.
char * dbretname(DBPROCESS *dbproc, int retnum)
Get name of an output parameter filled by a stored procedure.
DBBOOL dbhasretstat(DBPROCESS *dbproc)
Determine if query generated a return status number.
int dbrettype(DBPROCESS *dbproc, int retnum)
Get datatype of a stored procedure's return parameter.
int dbretlen(DBPROCESS *dbproc, int retnum)
Get size of an output parameter filled by a stored procedure.
int dbnumrets(DBPROCESS *dbproc)
Get count of output parameters filled by a stored procedure.
static const char * tds_dstr_cstr(DSTR *s)
Returns a C version (NUL terminated string) of dstr.
static char * tds_dstr_buf(DSTR *s)
Returns a buffer to edit the string.
DSTR * tds_dstr_copy(DSTR *s, const char *src) TDS_WUR
copy a string from another
static int tds_dstr_isempty(DSTR *s)
test if string is empty
static size_t tds_dstr_len(DSTR *s)
Returns the length of the string in bytes.
unsigned int
A callback function used to compare two keys in a database.
if(yy_accept[yy_current_state])
static void text(MDB_val *v)
constexpr bool empty(list< Ts... >) noexcept
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
#define TRUE
bool replacment for C indicating true.
#define FALSE
bool replacment for C indicating false.
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
double f(double x_, const double &y_)
static pcre_uint8 * buffer
#define row(bind, expected)
BCP_HOSTCOLINFO ** host_columns
DBCHAR ServerTypeDeclaration[256]
DBCHAR TableName[MAXCOLNAMELEN+2]
DBCHAR ActualName[MAXCOLNAMELEN+2]
DBCHAR Name[MAXCOLNAMELEN+2]
this structure is not directed connected to a TDS protocol but keeps any DATE/TIME information.
int login_timeout
not used unless positive
int ref_count
reference count, time dbinit called
TDSCONTEXT * tds_ctx
libTDS context
int query_timeout
not used unless positive
TDSSOCKET ** connection_list
int connection_list_size_represented
int tds_ctx_ref_count
libTDS context reference counter
struct dbstring * strnext
Information about blobs (e.g.
Metadata about columns in regular and compute rows.
TDS_TINYINT column_operator
TDS_INT column_size
maximun size of data.
TDS_SMALLINT column_operand
TDS_SMALLINT * column_nullbind
TDS_SMALLINT column_bindtype
unsigned int column_writeable
TDS_TINYINT column_prec
precision for decimal/numeric
TDS_SERVER_TYPE column_type
This type can be different from wire type because conversion (e.g.
unsigned int column_identity
unsigned int column_nullable
TDS_TINYINT column_scale
scale for decimal/numeric
unsigned char * column_data
struct tds_column::@124 on_server
TDS_CHAR * column_varaddr
TDS_INT column_cur_size
size written in variable (ie: char, text, binary).
TDSENV env
environment is shared between all sessions
TDS_USMALLINT tds_version
int(* msg_handler)(const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *)
int(* err_handler)(const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *)
int(* int_handler)(void *)
NULLREP nullreps[MAXBINDTYPES]
default null values
char dbcurdb[DBMAXNAME+1]
BCP_HOSTFILEINFO * hostfileinfo
DB_DBCHKINTR_FUNC chkintr
DB_DBHNDLINTR_FUNC hndlintr
char servcharset[DBMAXNAME+1]
DB_RESULT_STATE dbresults_state
DBUSMALLINT envchange_rcv
int msdblib
boolean use ms behaviour
Structure to hold a string.
int block_size
packet size (512-65535)
unsigned int readonly_intent
unsigned char option_flag2
DSTR server_name
server name (in freetds.conf)
TDS_USMALLINT tds_version
TDS version.
Hold information for any results.
Information for a server connection.
void(* env_chg_func)(TDSSOCKET *tds, int type, char *oldval, char *newval)
TDSCOMPUTEINFO ** comp_info
TDS_INT ret_status
return status from store procedure
TDSLOGIN * login
config for login stuff.
TDS_TINYINT has_status
true is ret_status is valid
TDS_INT8 rows_affected
rows updated/deleted/inserted/selected, TDS_NO_COUNT if not valid
TDSRESULTINFO * current_results
Current query information.
TDSPARAMINFO * param_info