27 #include <sys/types.h>
40 #include <netinet/in.h>
43 #include <arpa/inet.h>
72 #include <freetds/version.h>
73 #include "tds_sysdep_public.h"
74 #include <freetds/sysdep_private.h>
75 #include <freetds/thread.h>
76 #include <freetds/bool.h>
77 #include "replacements.h"
79 #include <freetds/pushvis.h>
158 #include <freetds/proto.h>
160 #define TDS_INVALID_TYPE ((TDS_SERVER_TYPE) 0)
202 #define TDS_NO_MORE_RESULTS ((TDSRET)1)
203 #define TDS_SUCCESS ((TDSRET)0)
204 #define TDS_FAIL ((TDSRET)-1)
205 #define TDS_CANCELLED ((TDSRET)-2)
206 #define TDS_FAILED(rc) ((rc)<0)
207 #define TDS_SUCCEED(rc) ((rc)>=0)
209 #define TDS_INT_CONTINUE 1
210 #define TDS_INT_CANCEL 2
211 #define TDS_INT_TIMEOUT 3
214 #define TDS_NO_COUNT -1
216 #define TDS_ROW_RESULT 4040
217 #define TDS_PARAM_RESULT 4042
218 #define TDS_STATUS_RESULT 4043
219 #define TDS_MSG_RESULT 4044
220 #define TDS_COMPUTE_RESULT 4045
221 #define TDS_CMD_DONE 4046
222 #define TDS_CMD_SUCCEED 4047
223 #define TDS_CMD_FAIL 4048
224 #define TDS_ROWFMT_RESULT 4049
225 #define TDS_COMPUTEFMT_RESULT 4050
226 #define TDS_DESCRIBE_RESULT 4051
227 #define TDS_DONE_RESULT 4052
228 #define TDS_DONEPROC_RESULT 4053
229 #define TDS_DONEINPROC_RESULT 4054
230 #define TDS_OTHERS_RESULT 4055
246 #define TDS_TOKEN_FLAG(flag) TDS_RETURN_##flag = (1 << (TDS_TOKEN_RES_##flag*2)), TDS_STOPAT_##flag = (2 << (TDS_TOKEN_RES_##flag*2))
344 #define TDS_NULLTERM -9
359 #define TDS_ZERO_FREE(x) do {free((x)); (x) = NULL;} while(0)
360 #define TDS_VECTOR_SIZE(x) (sizeof(x)/sizeof(x[0]))
362 #define TDS_OFFSET(str, field) offsetof(str, field)
364 #define TDS_OFFSET(str, field) (((char*)&((str*)0)->field)-((char*)0))
367 #if defined(__GNUC__) && __GNUC__ >= 3
368 # define TDS_LIKELY(x) __builtin_expect(!!(x), 1)
369 # define TDS_UNLIKELY(x) __builtin_expect(!!(x), 0)
371 # define TDS_LIKELY(x) (x)
372 # define TDS_UNLIKELY(x) (x)
375 #if ENABLE_EXTRA_CHECKS
376 # if defined(__llvm__) \
377 || (defined(__GNUC__) \
378 && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
379 # define TDS_COMPILE_CHECK(name,check) \
380 _Static_assert(check,#name)
381 # elif defined(__GNUC__) && __GNUC__ >= 2
382 # define TDS_COMPILE_CHECK(name,check) \
383 extern int name[(check)?1:-1] __attribute__ ((unused))
385 # define TDS_COMPILE_CHECK(name,check) \
386 extern int name[(check)?1:-1]
388 # define TDS_EXTRA_CHECK(stmt) stmt
390 # define TDS_COMPILE_CHECK(name,check) \
391 extern int disabled_check_##name
392 # define TDS_EXTRA_CHECK(stmt)
395 #if ENABLE_EXTRA_CHECKS && defined(__GNUC__) && __GNUC__ >= 4
396 #define TDS_WUR __attribute__ ((__warn_unused_result__))
406 #define TDS_BYTE_SWAP16(value) \
407 (((((unsigned short)value)<<8) & 0xFF00) | \
408 ((((unsigned short)value)>>8) & 0x00FF))
410 #define TDS_BYTE_SWAP32(value) \
411 (((((unsigned long)value)<<24) & 0xFF000000) | \
412 ((((unsigned long)value)<< 8) & 0x00FF0000) | \
413 ((((unsigned long)value)>> 8) & 0x0000FF00) | \
414 ((((unsigned long)value)>>24) & 0x000000FF))
416 #define is_end_token(x) (x==TDS_DONE_TOKEN || \
417 x==TDS_DONEPROC_TOKEN || \
418 x==TDS_DONEINPROC_TOKEN)
434 extern const unsigned char tds_type_flags_syb[256];
435 extern const char *
const tds_type_names[256];
438 #define is_fixed_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_FIXED) != 0)
439 #define is_nullable_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_NULLABLE) != 0)
440 #define is_variable_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_VARIABLE) != 0)
443 #define is_blob_type(x) ((x)==SYBTEXT || (x)==SYBIMAGE || (x)==SYBNTEXT)
445 #define is_blob_col(x) (is_blob_type((x)->column_type) \
446 || ((x)->column_varint_size == 8) \
447 || ((x)->column_type == SYBVARIANT \
448 && (x)->column_varint_size == 4))
450 #define is_blob_col(x) ((x)->column_varint_size > 2)
454 #define is_numeric_type(x) ((x)==SYBNUMERIC || (x)==SYBDECIMAL)
456 #define is_datetime_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_DATETIME) != 0)
457 #define is_unicode_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_UNICODE) != 0)
458 #define is_collate_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_COLLATE) != 0)
459 #define is_ascii_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_ASCII) != 0)
460 #define is_char_type(x) ((tds_type_flags_ms[x] & (TDS_TYPEFLAG_ASCII|TDS_TYPEFLAG_UNICODE)) != 0)
461 #define is_similar_type(x, y) (is_char_type(x) && is_char_type(y))
469 #define TDS_MAX_CAPABILITY 32
470 #define MAXPRECISION 77
471 #define TDS_MAX_CONN 4096
472 #define TDS_MAX_DYNID_LEN 30
475 #define TDS_DEF_SERVER "SYBASE"
476 #define TDS_DEF_BLKSZ 512
477 #define TDS_DEF_CHARSET "iso_1"
478 #define TDS_DEF_LANG "us_english"
480 #define TDS_DEFAULT_VERSION 0x402
481 #define TDS_DEF_PORT 1433
483 #define TDS_DEFAULT_VERSION 0x406
484 #define TDS_DEF_PORT 4000
486 #define TDS_DEFAULT_VERSION 0x500
487 #define TDS_DEF_PORT 4000
489 #define TDS_DEFAULT_VERSION 0x700
490 #define TDS_DEF_PORT 1433
492 #define TDS_DEFAULT_VERSION 0x701
493 #define TDS_DEF_PORT 1433
495 #define TDS_DEFAULT_VERSION 0x702
496 #define TDS_DEF_PORT 1433
498 #define TDS_DEFAULT_VERSION 0x703
499 #define TDS_DEF_PORT 1433
501 #define TDS_DEFAULT_VERSION 0x704
502 #define TDS_DEF_PORT 1433
504 #define TDS_DEFAULT_VERSION 0x000
505 #define TDS_DEF_PORT 1433
509 #define TDS_STR_VERSION "tds version"
510 #define TDS_STR_BLKSZ "initial block size"
511 #define TDS_STR_SWAPDT "swap broken dates"
512 #define TDS_STR_DUMPFILE "dump file"
513 #define TDS_STR_DEBUGLVL "debug level"
514 #define TDS_STR_DEBUGFLAGS "debug flags"
515 #define TDS_STR_TIMEOUT "timeout"
516 #define TDS_STR_QUERY_TIMEOUT "query timeout"
517 #define TDS_STR_CONNTIMEOUT "connect timeout"
518 #define TDS_STR_HOSTNAME "hostname"
519 #define TDS_STR_HOST "host"
520 #define TDS_STR_PORT "port"
521 #define TDS_STR_TEXTSZ "text size"
523 #define TDS_STR_EMUL_LE "emulate little endian"
524 #define TDS_STR_CHARSET "charset"
525 #define TDS_STR_CLCHARSET "client charset"
526 #define TDS_STR_USE_UTF_16 "use utf-16"
527 #define TDS_STR_LANGUAGE "language"
528 #define TDS_STR_APPENDMODE "dump file append"
529 #define TDS_STR_DATEFMT "date format"
530 #define TDS_STR_INSTANCE "instance"
531 #define TDS_STR_ASA_DATABASE "asa database"
532 #define TDS_STR_DATABASE "database"
533 #define TDS_STR_ENCRYPTION "encryption"
534 #define TDS_STR_USENTLMV2 "use ntlmv2"
535 #define TDS_STR_USELANMAN "use lanman"
537 #define TDS_STR_ENCRYPTION_OFF "off"
538 #define TDS_STR_ENCRYPTION_REQUEST "request"
539 #define TDS_STR_ENCRYPTION_REQUIRE "require"
541 #define TDS_GSSAPI_DELEGATION "enable gssapi delegation"
543 #define TDS_STR_REALM "realm"
545 #define TDS_STR_SPN "spn"
547 #define TDS_STR_CAFILE "ca file"
549 #define TDS_STR_CRLFILE "crl file"
551 #define TDS_STR_CHECKSSLHOSTNAME "check certificate hostname"
553 #define TDS_STR_DBFILENAME "database filename"
555 #define TDS_STR_READONLY_INTENT "read-only intent"
557 #define TLS_STR_OPENSSL_CIPHERS "openssl ciphers"
568 #define TDS_ALIGN_SIZE sizeof(tds_align_struct)
582 #define TDS_MAX_LOGIN_STR_SZ 128
735 #if ENABLE_EXTRA_CHECKS
896 #define TDS_DBG_LOGIN __FILE__, ((__LINE__ << 4) | 11)
897 #define TDS_DBG_HEADER __FILE__, ((__LINE__ << 4) | 10)
898 #define TDS_DBG_FUNC __FILE__, ((__LINE__ << 4) | 7)
899 #define TDS_DBG_INFO2 __FILE__, ((__LINE__ << 4) | 6)
900 #define TDS_DBG_INFO1 __FILE__, ((__LINE__ << 4) | 5)
901 #define TDS_DBG_NETWORK __FILE__, ((__LINE__ << 4) | 4)
902 #define TDS_DBG_WARN __FILE__, ((__LINE__ << 4) | 3)
903 #define TDS_DBG_ERROR __FILE__, ((__LINE__ << 4) | 2)
904 #define TDS_DBG_SEVERE __FILE__, ((__LINE__ << 4) | 1)
906 #define TDS_DBGFLAG_FUNC 0x80
907 #define TDS_DBGFLAG_INFO2 0x40
908 #define TDS_DBGFLAG_INFO1 0x20
909 #define TDS_DBGFLAG_NETWORK 0x10
910 #define TDS_DBGFLAG_WARN 0x08
911 #define TDS_DBGFLAG_ERROR 0x04
912 #define TDS_DBGFLAG_SEVERE 0x02
913 #define TDS_DBGFLAG_ALL 0xfff
914 #define TDS_DBGFLAG_LOGIN 0x0800
915 #define TDS_DBGFLAG_HEADER 0x0400
916 #define TDS_DBGFLAG_PID 0x1000
917 #define TDS_DBGFLAG_TIME 0x2000
918 #define TDS_DBGFLAG_SOURCE 0x4000
919 #define TDS_DBGFLAG_THREAD 0x8000
927 enum TDS_DBG_LOG_STATE
931 , TDS_DBG_API = (1 << 1)
932 , TDS_DBG_ASYNC = (1 << 2)
933 , TDS_DBG_DIAG = (1 << 3)
934 , TDS_DBG_error = (1 << 4)
937 , TDS_DBG_PACKET = (1 << 5)
938 , TDS_DBG_LIBTDS = (1 << 6)
939 , TDS_DBG_CONFIG = (1 << 7)
940 , TDS_DBG_DEFAULT = 0xFE
1172 #if ENABLE_ODBC_MARS
1173 unsigned int mars:1;
1179 unsigned send_pos, recv_pos;
1181 #ifdef TDS_HAVE_MUTEX
1184 #define BUSY_SOCKET ((TDSSOCKET*)(TDS_UINTPTR)1)
1185 #define TDSSOCKET_VALID(tds) (((TDS_UINTPTR)(tds)) > 1)
1187 unsigned num_sessions;
1196 #if defined(HAVE_GNUTLS)
1197 void *tls_credentials;
1198 #elif defined(HAVE_OPENSSL)
1212 #if ENABLE_ODBC_MARS
1245 #if ENABLE_ODBC_MARS
1289 #ifdef TDS_HAVE_MUTEX
1294 #define tds_get_ctx(tds) ((tds)->conn->tds_ctx)
1295 #define tds_set_ctx(tds, val) do { ((tds)->conn->tds_ctx) = (val); } while(0)
1296 #define tds_get_parent(tds) ((tds)->parent)
1297 #define tds_set_parent(tds, val) do { ((tds)->parent) = (val); } while(0)
1298 #define tds_get_s(tds) ((tds)->conn->s)
1299 #define tds_set_s(tds, val) do { ((tds)->conn->s) = (val); } while(0)
1383 const char *
query,
size_t querylen);
1390 #define TDS_RESIZE(p, n_elem) \
1391 tds_realloc((void **) &(p), sizeof(*(p)) * (size_t) (n_elem))
1392 #define tds_new(type, n) ((type *) malloc(sizeof(type) * (n)))
1393 #define tds_new0(type, n) ((type *) calloc(n, sizeof(type)))
1449 const char *s,
ssize_t len,
size_t *out_len);
1451 #if !ENABLE_EXTRA_CHECKS
1452 #define tds_convert_string_free(original, converted) \
1453 do { if (original != converted) free((char*) converted); } while(0)
1504 #define tds_put_tinyint(tds, ti) tds_put_byte(tds,ti)
1515 #define tds_get_smallint(tds) ((TDS_SMALLINT) tds_get_usmallint(tds))
1517 #define tds_get_int(tds) ((TDS_INT) tds_get_uint(tds))
1519 #define tds_get_int8(tds) ((TDS_INT8) tds_get_uint8(tds))
1531 #ifdef ENABLE_DEVELOPING
1542 #include <freetds/popvis.h>
1544 #include <freetds/pushvis.h>
1547 const char *
msg,
const void *
buf,
size_t length);
1550 const char *fmt, ...)
1551 #if defined(__GNUC__) && __GNUC__ >= 2
1552 #if defined(__MINGW32__)
1553 __attribute__ ((__format__ (ms_printf, 3, 4)))
1555 __attribute__ ((__format__ (__printf__, 3, 4)))
1559 #define TDSDUMP_LOG_FAST \
1560 if (TDS_UNLIKELY(tds_write_dump && !tdsdump_elided)) tdsdump_do_log
1561 #define tdsdump_log TDSDUMP_LOG_FAST
1562 #define TDSDUMP_BUF_FAST \
1563 if (TDS_UNLIKELY(tds_write_dump && !tdsdump_elided)) tdsdump_do_dump_buf
1564 #define tdsdump_dump_buf TDSDUMP_BUF_FAST
1586 size_t buflen,
int final);
1587 #define TDSSELREAD POLLIN
1588 #define TDSSELWRITE POLLOUT
1608 #if ENABLE_ODBC_MARS
1684 const char *
terminator,
size_t term_len,
char **
outbuf,
size_t * outbytes);
1694 return (cap->
values[
sizeof(cap->
values)-1-(cap_num>>3)] >> (cap_num&7)) & 1;
1696 #define tds_capability_has_req(conn, cap) \
1697 tds_capability_enabled(&conn->capabilities.types[0], cap)
1699 #define IS_TDS42(x) (x->tds_version==0x402)
1700 #define IS_TDS46(x) (x->tds_version==0x406)
1701 #define IS_TDS50(x) (x->tds_version==0x500)
1702 #define IS_TDS70(x) (x->tds_version==0x700)
1703 #define IS_TDS71(x) (x->tds_version==0x701)
1704 #define IS_TDS72(x) (x->tds_version==0x702)
1705 #define IS_TDS73(x) (x->tds_version==0x703)
1707 #define IS_TDS50_PLUS(x) ((x)->tds_version>=0x500)
1708 #define IS_TDS7_PLUS(x) ((x)->tds_version>=0x700)
1709 #define IS_TDS71_PLUS(x) ((x)->tds_version>=0x701)
1710 #define IS_TDS72_PLUS(x) ((x)->tds_version>=0x702)
1711 #define IS_TDS73_PLUS(x) ((x)->tds_version>=0x703)
1712 #define IS_TDS74_PLUS(x) ((x)->tds_version>=0x704)
1714 #define TDS_MAJOR(x) ((x)->tds_version >> 8)
1715 #define TDS_MINOR(x) ((x)->tds_version & 0xff)
1717 #define IS_TDSDEAD(x) (((x) == NULL) || (x)->state == TDS_DEAD)
1720 #define TDS_IS_SYBASE(x) (!((x)->conn->product_version & 0x80000000u))
1722 #define TDS_IS_MSSQL(x) (((x)->conn->product_version & 0x80000000u)!=0)
1727 #define TDS_MS_VER(maj,min,x) (0x80000000u|((maj)<<24)|((min)<<16)|(x))
1731 #define TDS_SYB_VER(maj,min,x) (((maj)<<24)|((min)<<16)|(x)<<8)
1740 #include <freetds/popvis.h>
1742 #define TDS_PUT_INT(tds,v) tds_put_int((tds), ((TDS_INT)(v)))
1743 #define TDS_PUT_SMALLINT(tds,v) tds_put_smallint((tds), ((TDS_SMALLINT)(v)))
1744 #define TDS_PUT_BYTE(tds,v) tds_put_byte((tds), ((unsigned char)(v)))
static const char si[8][64]
std::ofstream out("events_result.xml")
main entry point for tests
static CS_CONNECTION * conn
static const int timeout_seconds
#define TDS_SP_CURSOROPEN
TDS_OPTION_CMD
options that can be sent with a TDS_OPTIONCMD token
#define TDS_SP_CURSORCLOSE
#define TDS_SP_CURSOREXECUTE
#define TDS_SP_CURSORPREPARE
#define TDS_SP_PREPEXECRPC
#define TDS_SP_CURSORPREPEXEC
#define TDS_SP_CURSORUNPREPARE
#define TDS_SP_CURSORFETCH
#define TDS_SP_CURSOROPTION
#define TDS_SP_EXECUTESQL
int tds_iconv_alloc(TDSCONNECTION *conn)
Allocate iconv stuff.
TDSRET tds_func_get_data(TDSSOCKET *tds, TDSCOLUMN *col)
TDS_SERVER_TYPE tds_get_conversion_type(TDS_SERVER_TYPE srctype, int colsize)
Return type suitable for conversions (convert all nullable types to fixed type)
#define TDS_TOKEN_FLAG(flag)
TDSRET tds_func_put_info(TDSSOCKET *tds, TDSCOLUMN *col)
struct tm * tds_localtime_r(const time_t *timep, struct tm *result)
bool tds_set_user(TDSLOGIN *tds_login, const char *username)
void tdsdump_on(void)
Turn logging back on.
bool tds_set_server(TDSLOGIN *tds_login, const char *server)
Set the servername in a TDSLOGIN structure.
char * tds_strndup(const void *s, TDS_INTPTR len)
Copy a string of length len to a new allocated buffer This function does not read more than len bytes...
TDS_STATE tds_set_state(TDSSOCKET *tds, TDS_STATE state)
Set state of TDS connection, with logging and checking.
enum tds_cursor_operation TDS_CURSOR_OPERATION
tds_sysdep_int32_type TDS_INT
struct tds_compiletime_settings TDS_COMPILETIME_SETTINGS
A structure to hold all the compile-time settings.
int tdsdump_open(const char *filename)
Create and truncate a human readable dump file for the TDS traffic.
struct tds_variant TDSVARIANT
Store variant informations.
bool tds_set_library(TDSLOGIN *tds_login, const char *library)
@ initial_char_conv_count
struct tds_message TDSMESSAGE
static bool tds_capability_enabled(const TDS_CAPABILITY_TYPE *cap, unsigned cap_num)
void tdsdump_close(void)
Close the TDS dump log file.
void tds_set_column_type(TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type)
Set type of column initializing all dependency.
void tdsdump_do_dump_buf(const char *file, unsigned int level_line, const char *msg, const void *buf, size_t length)
Dump the contents of data into the log file in a human readable format.
char * tds_money_to_string(const TDS_MONEY *money, char *s)
struct tds_headers TDSHEADERS
int tds_getservice(const char *name)
Return service port given the name.
struct tdsdaterec TDSDATEREC
Used by tds_datecrack.
const char STD_DATETIME_FMT[]
static void tds_release_cur_dyn(TDSSOCKET *tds)
int tds_write_dump
Tell if TDS debug logging is turned on or off.
struct tds_blob TDSBLOB
Information about blobs (e.g.
int tds_get_size_by_type(TDS_SERVER_TYPE servertype)
Return the number of bytes needed by specified type.
const int tds_numeric_bytes_per_prec[]
The following little table is indexed by precision and will tell us the number of bytes required to s...
char * tds_prwsaerror(int erc)
void(* tds_bcp_null_error)(TDSBCPINFO *bulk, int index, int offset)
static bool is_tds_type_valid(int type)
struct tds_multiple TDSMULTIPLE
tds_sysdep_real64_type TDS_FLOAT
TDSRET tds_bcp_start_copy_in(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
Start bulk copy to server \tds.
int tds_connect_and_login(TDSSOCKET *tds, TDSLOGIN *login)
TDSRESULTINFO TDSPARAMINFO
tds_sysdep_int64_type TDS_INT8
TDS_INT tds_numeric_to_string(const TDS_NUMERIC *numeric, char *s)
tds_sysdep_intptr_type TDS_INTPTR
void(* TDSCONFPARSE)(const char *option, const char *value, void *param)
bool tds_set_app(TDSLOGIN *tds_login, const char *application)
int tds_get_varint_size(TDSCONNECTION *conn, int datatype)
tds_get_varint_size() returns the size of a variable length integer returned in a TDS 7....
void tdsdump_do_log(const char *file, unsigned int level_line, const char *fmt,...)
Write a message to the debug log.
void tds_set_packet(TDSLOGIN *tds_login, int packet_size)
char * tds_get_homedir(void)
Get user home directory.
union tds_option_arg TDS_OPTION_ARG
unsigned tds_func_put_info_len(TDSSOCKET *tds, TDSCOLUMN *col)
@ TDS_CURSOR_FETCH_RELATIVE
@ TDS_CURSOR_FETCH_ABSOLUTE
TDSRET tds_writetext_start(TDSSOCKET *tds, const char *objname, const char *textptr, const char *timestamp, int with_log, TDS_UINT size)
Start writing writetext request.
int tds5_send_optioncmd(TDSSOCKET *tds, TDS_OPTION_CMD tds_command, TDS_OPTION tds_option, TDS_OPTION_ARG *tds_argument, TDS_INT *tds_argsize)
@ TDS_CURSOR_STATE_UNACTIONED
@ TDS_CURSOR_STATE_REQUESTED
@ TDS_CURSOR_STATE_ACTIONED
tds_sysdep_real32_type TDS_REAL
TDSRET tds_bcp_fread(TDSSOCKET *tds, TDSICONV *conv, FILE *stream, const char *terminator, size_t term_len, char **outbuf, size_t *outbytes)
Read a data file, passing the data through iconv().
TDSRET tds_bcp_start(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
Start sending BCP data to server.
int tdsdump_state(void)
Get the logging state.
bool tds_set_host(TDSLOGIN *tds_login, const char *hostname)
void tds_prwsaerror_free(char *s)
unsigned char TDS_TINYINT
void tds_set_param_type(TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type)
Set type of column initializing all dependency.
tds_states
values for tds->state
@ TDS_PENDING
cilent is waiting for data
@ TDS_SENDING
client would send data
@ TDS_READING
client is reading data
@ TDS_WRITING
client is writing data
@ TDS_IDLE
no data expected
TDS_SERVER_TYPE tds_get_cardinal_type(TDS_SERVER_TYPE datatype, int usertype)
tds_sysdep_int16_type TDS_SMALLINT
struct hostent * tds_gethostbyname_r(const char *servername, struct hostent *result, char *buffer, int buflen, int *h_errnop)
char * tds_timestamp_str(char *str, int maxlen)
void tds_set_port(TDSLOGIN *tds_login, int port)
#define tds_convert_string_free(original, converted)
void tds_set_version(TDSLOGIN *tds_login, TDS_TINYINT major_ver, TDS_TINYINT minor_ver)
struct tds_upd_col TDSUPDCOL
TDSRET(* tds_bcp_get_col_data)(TDSBCPINFO *bulk, TDSCOLUMN *bcpcol, int offset)
tds_end
Flags returned in TDS_DONE token.
@ TDS_DONE_CANCELLED
acknowledging an attention command (usually a cancel)
@ TDS_DONE_MORE_RESULTS
more results follow
@ TDS_DONE_SRVERROR
SQL server server error.
@ TDS_DONE_FINAL
final result set, command completed successfully.
@ TDS_DONE_ERROR
error occurred
@ TDS_DONE_INXACT
transaction in progress
@ TDS_DONE_PROC
results are from a stored procedure
@ TDS_DONE_COUNT
count field in packet is valid
tds_sysdep_uint64_type TDS_UINT8
void tdsdump_col(const TDSCOLUMN *col)
Write a column value to the debug log.
TDSSOCKET * tds_alloc_additional_socket(TDSCONNECTION *conn)
TDSRET tds_writetext_continue(TDSSOCKET *tds, const TDS_UCHAR *text, TDS_UINT size)
Send some data in the writetext request started by tds_writetext_start.
TDSRET tds_func_get_info(TDSSOCKET *tds, TDSCOLUMN *col)
int(* err_handler_t)(const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *)
tds_sysdep_uint16_type TDS_USMALLINT
int tdserror(const TDSCONTEXT *tds_ctx, TDSSOCKET *tds, int msgno, int errnum)
Call the client library's error handler (for library-generated errors only)
enum tds_states TDS_STATE
values for tds->state
TDSRET tds_writetext_end(TDSSOCKET *tds)
Finish sending writetext data.
void tdsdump_off(void)
Temporarily turn off logging.
TDSRET tds_bcp_init(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
Initialize BCP information.
enum tds_cursor_fetch TDS_CURSOR_FETCH
const unsigned char tds_type_flags_ms[256]
tds_sysdep_uintptr_type TDS_UINTPTR
TDS_INT tds_numeric_change_prec_scale(TDS_NUMERIC *numeric, unsigned char new_prec, unsigned char new_scale)
TDSRET tds_func_put_data(TDSSOCKET *tds, TDSCOLUMN *col, int bcp7)
TDSAUTHENTICATION * tds_gss_get_auth(TDSSOCKET *tds)
tds_bcp_directions
bcp direction
TDSRET tds_vstrbuild(char *buffer, int buflen, int *resultlen, const char *text, int textlen, const char *formats, int formatlen, va_list ap)
TDSRET tds_bcp_send_record(TDSSOCKET *tds, TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset)
Send one row of data to server \tds.
TDSRET tds_bcp_done(TDSSOCKET *tds, int *rows_copied)
Tell we finished sending BCP data to server \tds.
TDS_INT tds_func_row_len(TDSCOLUMN *col)
struct tds_encoding TDS_ENCODING
Information relevant to libiconv.
tds_sysdep_uint32_type TDS_UINT
void tds_random_buffer(unsigned char *out, int len)
#define TDS_MAX_CAPABILITY
@ TDS_TOKEN_RES_COMPUTEFMT
void tds_getmac(TDS_SYS_SOCKET s, unsigned char mac[6])
static TDS_SYS_SOCKET tds_wakeup_get_fd(const TDSPOLLWAKEUP *wakeup)
int tds_func_check(const TDSCOLUMN *col)
enum tds_operations TDS_OPERATION
bool tds_set_client_charset(TDSLOGIN *tds_login, const char *charset)
TDSLOCALE * tds_get_locale(void)
Get locale information.
void tds_swap_bytes(void *buf, int bytes)
bool tds_set_language(TDSLOGIN *tds_login, const char *language)
void tds_set_bulk(TDSLOGIN *tds_login, TDS_TINYINT enabled)
bool tds_set_passwd(TDSLOGIN *tds_login, const char *password)
enum tds_encryption_level TDS_ENCRYPTION_LEVEL
@ TDS_CUR_ISTAT_UPDATABLE
static SQLCHAR output[256]
static const char * str(char *buf, int n)
static const char * column
static TDSRET convert(TDSSOCKET *tds, TDSICONV *conv, TDS_ICONV_DIRECTION direction, const char *from, size_t from_len, char *dest, size_t *dest_len)
#define tds_sysdep_real32_type
#define tds_sysdep_int16_type
#define tds_sysdep_uintptr_type
#define tds_sysdep_uint16_type
#define tds_sysdep_int64_type
#define tds_sysdep_uint32_type
#define tds_sysdep_int32_type
#define tds_sysdep_uint64_type
#define tds_sysdep_intptr_type
#define tds_sysdep_real64_type
unsigned int tds_gettime_ms(void)
#define tds_append_cancel
TDSAUTHENTICATION * tds5_negotiate_get_auth(TDSSOCKET *tds)
void tds5_negotiate_set_msg_type(TDSSOCKET *tds, TDSAUTHENTICATION *auth, unsigned msg_type)
TDSAUTHENTICATION * tds_ntlm_get_auth(TDSSOCKET *tds)
Build a NTLMSPP packet to send to server.
int tds_read_conf_file(TDSLOGIN *login, const char *server)
Read configuration info for given server return 0 on error.
TDSRET tds_lookup_host_set(const char *servername, struct addrinfo **addr)
void tds_parse_conf_section(const char *option, const char *value, void *param)
TDSRET tds_set_interfaces_file_loc(const char *interfloc)
Set the full name of interface file.
int tds_read_conf_section(FILE *in, const char *section, TDSCONFPARSE tds_conf_parse, void *parse_param)
Read a section of configuration file (INI style file)
const TDS_COMPILETIME_SETTINGS * tds_get_compiletime_settings(void)
Return a structure capturing the compile-time settings provided to the configure script.
TDSLOGIN * tds_read_config_info(TDSSOCKET *tds, TDSLOGIN *login, TDSLOCALE *locale)
tds_read_config_info() will fill the tds connection structure based on configuration information gath...
struct addrinfo * tds_lookup_host(const char *servername)
Get the IP address for a hostname.
int tds_config_boolean(const char *option, const char *value, TDSLOGIN *login)
int tds_parse_boolean(const char *value, int default_value)
void tds_fix_login(TDSLOGIN *login)
Fix configuration after reading it.
TDS_USMALLINT * tds_config_verstr(const char *tdsver, TDSLOGIN *login)
Set TDS version from given string.
TDSRET tds_iconv_open(TDSCONNECTION *conn, const char *charset, int use_utf16)
void tds_iconv_close(TDSCONNECTION *conn)
void tds_srv_charset_changed(TDSCONNECTION *conn, const char *charset)
void tds7_srv_charset_changed(TDSCONNECTION *conn, int sql_collate, int lcid)
void tds_iconv_free(TDSCONNECTION *conn)
TDSICONV * tds_iconv_from_collate(TDSCONNECTION *conn, TDS_UCHAR collate[5])
Get iconv information from a LCID (to support different column encoding under MSSQL2K)
TDSRET tds_datecrack(TDS_INT datetype, const void *di, TDSDATEREC *dr)
Convert from db date format to a structured date format.
const char tds_hex_digits[]
unsigned int
A callback function used to compare two keys in a database.
TDSRESULTINFO * tds_alloc_results(TDS_USMALLINT num_cols)
TDSRET tds_alloc_compute_row(TDSCOMPUTEINFO *res_info)
void tds_free_bcp_column_data(BCPCOLDATA *coldata)
TDSRET tds_alloc_row(TDSRESULTINFO *res_info)
Allocate space for row store return NULL on out of memory.
TDSLOGIN * tds_alloc_login(int use_environment)
void tds_detach_results(TDSRESULTINFO *info)
Detach result info from it current socket.
TDSPACKET * tds_realloc_packet(TDSPACKET *packet, unsigned len)
void * tds_alloc_param_data(TDSCOLUMN *curparam)
Allocate data for a parameter.
TDSLOGIN * tds_init_login(TDSLOGIN *login, TDSLOCALE *locale)
Initialize login structure with locale information and other stuff for connection.
TDSDYNAMIC * tds_alloc_dynamic(TDSCONNECTION *conn, const char *id)
Allocate a dynamic statement.
TDSSOCKET * tds_realloc_socket(TDSSOCKET *tds, unsigned int bufsize)
char * tds_alloc_lookup_sqlstate(TDSSOCKET *tds, int msgno)
TDSPACKET * tds_alloc_packet(void *buf, unsigned len)
TDSCONTEXT * tds_alloc_context(void *parent)
void tds_free_param_results(TDSPARAMINFO *param_info)
void tds_free_param_result(TDSPARAMINFO *param_info)
Delete latest parameter.
TDSLOCALE * tds_alloc_locale(void)
TDSPARAMINFO * tds_alloc_param_result(TDSPARAMINFO *old_param)
Adds a output parameter to TDSPARAMINFO.
void tds_set_current_results(TDSSOCKET *tds, TDSRESULTINFO *info)
void tds_free_all_results(TDSSOCKET *tds)
TDSBCPINFO * tds_alloc_bcpinfo(void)
void * tds_realloc(void **pp, size_t new_size)
Reallocate a pointer and update it if success.
void tds_free_context(TDSCONTEXT *locale)
void tds_release_cursor(TDSCURSOR **pcursor)
void tds_cursor_deallocated(TDSCONNECTION *conn, TDSCURSOR *cursor)
TDSCURSOR * tds_alloc_cursor(TDSSOCKET *tds, const char *name, size_t namelen, const char *query, size_t querylen)
void tds_free_row(TDSRESULTINFO *res_info, unsigned char *row)
BCPCOLDATA * tds_alloc_bcp_column_data(unsigned int column_size)
TDSSOCKET * tds_alloc_socket(TDSCONTEXT *context, unsigned int bufsize)
void tds_free_input_params(TDSDYNAMIC *dyn)
Frees all allocated input parameters of a dynamic statement.
void tds_release_dynamic(TDSDYNAMIC **dyn)
Frees dynamic statement.
void tds_dynamic_deallocated(TDSCONNECTION *conn, TDSDYNAMIC *dyn)
void tds_free_bcpinfo(TDSBCPINFO *bcpinfo)
void tds_free_login(TDSLOGIN *login)
void tds_free_msg(TDSMESSAGE *message)
void tds_free_locale(TDSLOCALE *locale)
char * tds_alloc_client_sqlstate(int msgno)
void tds_deinit_bcpinfo(TDSBCPINFO *bcpinfo)
void tds_free_packets(TDSPACKET *packet)
void tds_free_results(TDSRESULTINFO *res_info)
TDSCOMPUTEINFO ** tds_alloc_compute_results(TDSSOCKET *tds, TDS_USMALLINT num_cols, TDS_USMALLINT by_cols)
void tds_free_socket(TDSSOCKET *tds)
void tds_wakeup_send(TDSPOLLWAKEUP *wakeup, char cancel)
unsigned char tds_get_byte(TDSSOCKET *tds)
Return a single byte from the input buffer \tds.
int tds_put_string(TDSSOCKET *tds, const char *buf, int len)
Output a string to wire automatic translate string to unicode if needed.
unsigned char tds_peek(TDSSOCKET *tds)
Reads a byte from the TDS stream without removing it \tds.
int tds_socket_set_nonblocking(TDS_SYS_SOCKET sock)
Set socket to non-blocking.
ssize_t tds_connection_read(TDSSOCKET *tds, unsigned char *buf, size_t buflen)
void tds_close_socket(TDSSOCKET *tds)
Close current socket.
int tds_read_packet(TDSSOCKET *tds)
Read in one 'packet' from the server.
ssize_t tds_goodread(TDSSOCKET *tds, unsigned char *buf, size_t buflen)
Loops until we have received some characters return -1 on failure.
int tds_put_int8(TDSSOCKET *tds, TDS_INT8 i)
void tds_wakeup_close(TDSPOLLWAKEUP *wakeup)
TDSRET tds_write_packet(TDSSOCKET *tds, unsigned char final)
TDSRET tds_flush_packet(TDSSOCKET *tds)
Flush packet to server.
int tds_wakeup_init(TDSPOLLWAKEUP *wakeup)
int tds_put_buf(TDSSOCKET *tds, const unsigned char *buf, int dsize, int ssize)
int tds_put_n(TDSSOCKET *tds, const void *buf, size_t n)
TDS_UINT8 tds_get_uint8(TDSSOCKET *tds)
Get an uint64 from the server.
TDSRET tds_get_char_data(TDSSOCKET *tds, char *dest, size_t wire_size, TDSCOLUMN *curcol)
Fetch character data the wire.
size_t tds_get_string(TDSSOCKET *tds, size_t string_len, char *dest, size_t dest_size)
Fetch a string from the wire.
int tds7_get_instance_ports(FILE *output, struct addrinfo *addr)
Get port of all instances.
TDS_UINT tds_get_uint(TDSSOCKET *tds)
Get an int32 from the server.
ssize_t tds_connection_write(TDSSOCKET *tds, const unsigned char *buf, size_t buflen, int final)
void tds_socket_flush(TDS_SYS_SOCKET sock)
int tds_put_cancel(TDSSOCKET *tds)
int tds7_get_instance_port(struct addrinfo *addr, const char *instance)
Get port of given instance.
const char * tds_addrinfo2str(struct addrinfo *addr, char *name, int namemax)
TDS_USMALLINT tds_get_usmallint(TDSSOCKET *tds)
Get an int16 from the server.
void tds_unget_byte(TDSSOCKET *tds)
Unget will always work as long as you don't call it twice in a row.
int tds_select(TDSSOCKET *tds, unsigned tds_sel, int timeout_seconds)
Select on a socket until it's available or the timeout expires.
int tds_init_write_buf(TDSSOCKET *tds)
void * tds_get_n(TDSSOCKET *tds, void *dest, size_t n)
Get N bytes from the buffer and return them in the already allocated space given to us.
ssize_t tds_goodwrite(TDSSOCKET *tds, const unsigned char *buffer, size_t buflen)
int tds_put_smallint(TDSSOCKET *tds, TDS_SMALLINT si)
int tds_put_byte(TDSSOCKET *tds, unsigned char c)
int tds_put_int(TDSSOCKET *tds, TDS_INT i)
void tds_connection_close(TDSCONNECTION *conn)
TDSERRNO tds_open_socket(TDSSOCKET *tds, struct addrinfo *ipaddr, unsigned int port, int timeout, int *p_oserr)
DSTR * tds_dstr_get(TDSSOCKET *tds, DSTR *s, size_t len)
Reads a string from wire and put in a DSTR.
int tds_needs_unprepare(TDSCONNECTION *conn, TDSDYNAMIC *dyn)
Check if dynamic request must be unprepared.
TDSRET tds71_submit_prepexec(TDSSOCKET *tds, const char *query, const char *id, TDSDYNAMIC **dyn_out, TDSPARAMINFO *params)
Creates a temporary stored procedure in the server and execute it.
void tds_start_query(TDSSOCKET *tds, unsigned char packet_type)
Start query packet of a given type \tds.
TDSRET tds_send_cancel(TDSSOCKET *tds)
tds_send_cancel() sends an empty packet (8 byte header only) tds_process_cancel should be called dire...
TDSRET tds_multiple_query(TDSSOCKET *tds, TDSMULTIPLE *multiple, const char *query, TDSPARAMINFO *params)
TDSRET tds_cursor_get_cursor_info(TDSSOCKET *tds, TDSCURSOR *cursor, TDS_UINT *row_number, TDS_UINT *row_count)
TDSRET tds_disconnect(TDSSOCKET *tds)
TDSRET tds_submit_execute(TDSSOCKET *tds, TDSDYNAMIC *dyn)
Sends a previously prepared dynamic statement to the server.
size_t tds_fix_column_size(TDSSOCKET *tds, TDSCOLUMN *curcol)
Get column size for wire.
TDSRET tds_get_column_declaration(TDSSOCKET *tds, TDSCOLUMN *curcol, char *out)
Return declaration for column (like "varchar(20)").
TDSRET tds_submit_commit(TDSSOCKET *tds, int cont)
Send a commit request.
TDSRET tds_deferred_cursor_dealloc(TDSCONNECTION *conn, TDSCURSOR *cursor)
Deallocate cursor on idle.
TDSRET tds_submit_query(TDSSOCKET *tds, const char *query)
Sends a language string to the database server for processing.
const char * tds_skip_quoted(const char *s)
Skip quoting string (like 'sfsf', "dflkdj" or [dfkjd])
TDSRET tds_submit_rpc(TDSSOCKET *tds, const char *rpc_name, TDSPARAMINFO *params, TDSHEADERS *head)
Calls a RPC from server.
const char * tds_next_placeholder(const char *start)
Get position of next placeholder.
size_t tds_quote_id(TDSSOCKET *tds, char *buffer, const char *id, ssize_t idlen)
Quote an id.
TDSRET tds_submit_prepare(TDSSOCKET *tds, const char *query, const char *id, TDSDYNAMIC **dyn_out, TDSPARAMINFO *params)
Creates a temporary stored procedure in the server.
TDSRET tds_submit_begin_tran(TDSSOCKET *tds)
Send a rollback request.
TDSRET tds_cursor_declare(TDSSOCKET *tds, TDSCURSOR *cursor, TDSPARAMINFO *params, int *send)
size_t tds_quote_string(TDSSOCKET *tds, char *buffer, const char *str, ssize_t len)
Quote a string.
TDSRET tds_submit_query_params(TDSSOCKET *tds, const char *query, TDSPARAMINFO *params, TDSHEADERS *head)
Sends a language string to the database server for processing.
TDSRET tds_submit_rollback(TDSSOCKET *tds, int cont)
Send a rollback request.
TDSRET tds_deferred_unprepare(TDSCONNECTION *conn, TDSDYNAMIC *dyn)
Unprepare dynamic on idle.
const char * tds_convert_string(TDSSOCKET *tds, TDSICONV *char_conv, const char *s, ssize_t len, size_t *out_len)
Convert a string in an allocated buffer.
int tds_count_placeholders(const char *query)
Count the number of placeholders ('?') in a query.
const char * tds_skip_comment(const char *s)
Skip a comment in a query.
TDSRET tds_cursor_dealloc(TDSSOCKET *tds, TDSCURSOR *cursor)
Send a deallocation request to server.
TDSRET tds_cursor_setrows(TDSSOCKET *tds, TDSCURSOR *cursor, int *send)
TDSRET tds_submit_queryf(TDSSOCKET *tds, const char *queryf,...)
Format and submit a query \tds.
TDSRET tds_cursor_setname(TDSSOCKET *tds, TDSCURSOR *cursor)
TDSRET tds_cursor_close(TDSSOCKET *tds, TDSCURSOR *cursor)
TDSRET tds_multiple_execute(TDSSOCKET *tds, TDSMULTIPLE *multiple, TDSDYNAMIC *dyn)
TDSRET tds_multiple_init(TDSSOCKET *tds, TDSMULTIPLE *multiple, TDS_MULTIPLE_TYPE type, TDSHEADERS *head)
TDSRET tds_submit_execdirect(TDSSOCKET *tds, const char *query, TDSPARAMINFO *params, TDSHEADERS *head)
Submit a prepared query with parameters.
TDSRET tds_multiple_done(TDSSOCKET *tds, TDSMULTIPLE *multiple)
TDSRET tds_cursor_update(TDSSOCKET *tds, TDSCURSOR *cursor, TDS_CURSOR_OPERATION op, TDS_INT i_row, TDSPARAMINFO *params)
void tds_set_cur_dyn(TDSSOCKET *tds, TDSDYNAMIC *dyn)
Set current dynamic.
TDSRET tds_submit_optioncmd(TDSSOCKET *tds, TDS_OPTION_CMD command, TDS_OPTION option, TDS_OPTION_ARG *param, TDS_INT param_size)
Send option commands to server.
TDSRET tds_cursor_open(TDSSOCKET *tds, TDSCURSOR *cursor, TDSPARAMINFO *params, int *send)
TDSRET tds_submit_unprepare(TDSSOCKET *tds, TDSDYNAMIC *dyn)
Send a unprepare request for a prepared query.
const char * tds_prtype(int token)
Returns string representation of the given type.
TDSDYNAMIC * tds_lookup_dynamic(TDSCONNECTION *conn, const char *id)
Finds a dynamic given string id.
int determine_adjusted_size(const TDSICONV *char_conv, int size)
Allow for maximum possible size of converted data, while being careful about integer division truncat...
TDSRET tds_process_login_tokens(TDSSOCKET *tds)
tds_process_login_tokens() is called after sending the login packet to the server.
int tds_get_token_size(int marker)
tds_get_token_size() returns the size of a fixed length token used by tds_process_cancel() to determi...
TDSRET tds_process_tokens(TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag)
process all streams.
TDSRET tds_process_simple_query(TDSSOCKET *tds)
Process results for simple query as "SET TEXTSIZE" or "USE dbname" If the statement returns results,...
TDSRET tds_process_cancel(TDSSOCKET *tds)
static void text(MDB_val *v)
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
std::istream & in(std::istream &in_, double &x_)
static const char * locale
static PCRE2_SIZE bufsize
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
#define row(bind, expected)
this structure is not directed connected to a TDS protocol but keeps any DATE/TIME information.
TDS_USMALLINT _tds_reserved
TDS_INT date
date, 0 = 1900-01-01
TDS_SMALLINT offset
time offset
TDS_UINT8 time
time, 7 digit precision
TDSRET(* free)(TDSCONNECTION *conn, struct tds_authentication *auth)
TDSRET(* handle_next)(TDSSOCKET *tds, struct tds_authentication *auth, size_t len)
TDS_INT identity_insert_on
Information about blobs (e.g.
TDS_CAPABILITY_TYPE types[2]
unsigned char values[32/2-2]
tds_func_get_info * get_info
tds_func_row_len * row_len
tds_func_put_info * put_info
Send metadata column information to server.
tds_func_put_info_len * put_info_len
Returns metadata column information size.
tds_func_get_data * get_data
tds_func_put_data * put_data
Send column data to server.
Metadata about columns in regular and compute rows.
TDS_INT bcp_prefix_len
The length, in bytes, of any length prefix this column may have.
TDS_TINYINT column_varint_size
size of length when reading from wire (0, 1, 2 or 4)
TDS_TINYINT column_operator
TDS_INT column_size
maximun size of data.
TDS_SMALLINT column_operand
unsigned int column_hasdefault
TDS_SMALLINT * column_nullbind
unsigned int column_timestamp
BCPCOLDATA * bcp_column_data
TDS_UCHAR column_collation[5]
void(* column_data_free)(struct tds_column *column)
const TDSCOLUMNFUNCS * funcs
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
TDSICONV * char_conv
refers to previously allocated iconv information
TDS_SMALLINT column_bindfmt
TDS_CHAR column_text_sqlputdatainfo
unsigned int column_nullable
TDS_TINYINT column_scale
scale for decimal/numeric
unsigned char * column_data
unsigned int column_output
struct tds_column::@124 on_server
TDS_CHAR * column_varaddr
unsigned char * column_default
TDS_INT column_cur_size
size written in variable (ie: char, text, binary).
TDS_CHAR * bcp_terminator
TDS_INT column_text_sqlgetdatapos
unsigned int column_hidden
A structure to hold all the compile-time settings.
const char * freetds_version
TDSENV env
environment is shared between all sessions
TDS_SYS_SOCKET s
tcp socket, INVALID_SOCKET if not connected
unsigned num_cached_packets
TDS_UINT product_version
version of product (Sybase/MS and full version)
TDSCURSOR * cursors
linked list of cursors allocated for this connection contains only cursors allocated on the server
unsigned int encrypt_single_packet
unsigned int pending_close
true is connection has pending closing (cursors or dynamic)
TDS_UCHAR tds72_transaction[8]
const TDSCONTEXT * tds_ctx
TDSDYNAMIC * dyns
list of dynamic allocated for this connection contains only dynamic allocated on the server
TDS_USMALLINT tds_version
TDSAUTHENTICATION * authentication
TDS_CAPABILITIES capabilities
unsigned int emul_little_endian
int(* msg_handler)(const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *)
int(* err_handler)(const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *)
int(* int_handler)(void *)
TDS_CURSOR_STATE cursor_row
Holds informations about a cursor.
TDS_TINYINT options
read only|updatable TODO use it
char * cursor_name
name of the cursor
TDS_INT ref_count
reference counter so client can retain safely a pointer
TDS_TINYINT defer_close
true if cursor was marker to be closed when connection is idle
TDS_INT cursor_id
cursor id returned by the server after cursor declare
TDS_INT cursor_rows
< number of updatable columns
TDS_INT type
row fetched from this cursor
TDS_CURSOR_STATUS status
cursor parameter
struct tds_cursor * next
next in linked list, keep first
Structure to hold a string.
Holds information for a dynamic (also called prepared) query.
TDS_TINYINT defer_close
true if dynamic was marker to be closed when connection is idle
struct tds_dynamic * next
next in linked list, keep first
TDS_INT ref_count
reference counter so client can retain safely a pointer
char * query
saved query, we need to know original query if prepare is impossible
TDSPARAMINFO * params
query parameters.
TDSPARAMINFO * res_info
query results
TDS_TINYINT emulated
this dynamic query cannot be prepared so libTDS have to construct a simple query.
TDS_INT num_id
numeric id for mssql7+
Information relevant to libiconv.
unsigned char max_bytes_per_char
const char * name
name of the encoding (ie UTF-8)
unsigned char min_bytes_per_char
unsigned char canonic
internal numeric index into array of all encodings
Current environment as reported by the server.
char * charset
character set encoding
int block_size
packet size (512-65535)
char * database
database name
unsigned int use_new_password
DSTR crlfile
certificate revocation file
unsigned int check_ssl_hostname
DSTR server_realm_name
server realm name (in freetds.conf)
DSTR user_name
account for login
unsigned int gssapi_use_delegation
struct addrinfo * ip_addrs
ip(s) of server
DSTR password
password of account login
DSTR db_filename
database filename to attach (MSSQL)
TDS_CAPABILITIES capabilities
unsigned int readonly_intent
TDS_TINYINT encryption_level
unsigned char option_flag2
unsigned int valid_configuration
DSTR server_name
server name (in freetds.conf)
DSTR server_charset
charset of server e.g.
TDS_USMALLINT tds_version
TDS version.
DSTR new_password
new password to set (TDS 7.2+)
struct addrinfo * connected_addr
unsigned int suppress_language
unsigned int emul_little_endian
unsigned int bulk_copy
if bulk copy should be enabled
DSTR cafile
certificate authorities file
DSTR server_spn
server SPN (in freetds.conf)
TDS_USMALLINT routing_port
int port
port of database service
TDS_TINYINT priv_msg_type
TDS_SYS_SOCKET s_signaled
Hold information for any results.
unsigned char * current_row
void(* row_free)(struct tds_result_info *result, unsigned char *row)
Information for a server connection.
void(* env_chg_func)(TDSSOCKET *tds, int type, char *oldval, char *newval)
unsigned in_len
input buffer length
TDSCOMPUTEINFO ** comp_info
TDS_INT ret_status
return status from store procedure
TDSLOGIN * login
config for login stuff.
unsigned out_pos
current position in out_buf
TDSCURSOR * cur_cursor
cursor in use
unsigned char * out_buf
Output buffer.
TDS_TINYINT has_status
true is ret_status is valid
unsigned char in_flag
input buffer type
TDS_INT8 rows_affected
rows updated/deleted/inserted/selected, TDS_NO_COUNT if not valid
TDSPACKET * send_packet
packet we are preparing to send
unsigned char * in_buf
Input buffer.
TDS_TINYINT bulk_query
true is query sent was a bulk query so we need to switch state to QUERYING
TDSDYNAMIC * cur_dyn
dynamic structure in use
unsigned char out_flag
output buffer type
unsigned in_pos
current position in in_buf
bool in_row
true if we are getting rows
TDSRESULTINFO * current_results
Current query information.
volatile unsigned char in_cancel
indicate we are waiting a cancel reply; discard tokens till acknowledge; 1 mean we have to send cance...
unsigned int out_buf_max
Maximum size of packet pointed by out_buf.
TDSPARAMINFO * param_info
struct tds_upd_col * next
Store variant informations.
TDS_INT dayofyear
day of year (1-366)
TDS_INT weekday
day of week (0-6, 0 = sunday)
TDS_INT timezone
-840 - 840 minutes from UTC
TDS_INT day
day of month (1-31)
TDS_INT decimicrosecond
0-9999999
TDS_INT quarter
quarter (0-3)
TDS_INT month
month number (0-11)
uchar outbuf[(1000000+1000000)]
static CS_CONTEXT * context