NCBI C++ ToolKit
tds.h
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns
3  * Copyright (C) 2010, 2011 Frediano Ziglio
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20 
21 #ifndef _tds_h_
22 #define _tds_h_
23 
24 #ifndef _freetds_config_h_
25 #error should include config.h before
26 #endif
27 
28 #include <stdarg.h>
29 #include <stdio.h>
30 #include <time.h>
31 
32 #ifdef HAVE_STDDEF_H
33 #include <stddef.h>
34 #endif
35 
36 #if HAVE_NETDB_H
37 #include <netdb.h>
38 #endif /* HAVE_NETDB_H */
39 
40 #if HAVE_NETINET_IN_H
41 #include <netinet/in.h>
42 #endif /* HAVE_NET_INET_IN_H */
43 #if HAVE_ARPA_INET_H
44 #include <arpa/inet.h>
45 #endif /* HAVE_ARPA_INET_H */
46 
47 #if HAVE_SYS_SOCKET_H
48 #include <sys/socket.h>
49 #endif /* HAVE_SYS_SOCKET_H */
50 
51 /* forward declaration */
52 typedef struct tdsiconvinfo TDSICONV;
53 typedef struct tds_connection TDSCONNECTION;
54 typedef struct tds_socket TDSSOCKET;
55 typedef struct tds_column TDSCOLUMN;
56 typedef struct tds_bcpinfo TDSBCPINFO;
57 /* More, to address "declared with greater visibility" warnings. */
58 struct tds5_colinfo;
59 struct tds_authentication;
60 struct tds_bcpcoldata;
61 struct tds_capabilities;
62 struct tds_capability_type;
63 struct tds_column_funcs;
64 struct tds_context;
65 struct tds_cursor;
66 struct tds_cursor_status;
67 struct tds_dynamic;
68 struct tds_env;
69 struct tds_locale;
70 struct tds_login;
71 struct tds_packet;
72 struct tds_poll_wakeup;
73 struct tds_result_info;
74 
75 #include <freetds/version.h>
76 #include <freetds/sysdep_private.h>
77 #include <freetds/sysdep_types.h>
78 #include <freetds/thread.h>
79 #include <freetds/bool.h>
80 #include <freetds/macros.h>
81 #include <freetds/utils/string.h>
82 #include <freetds/replacements.h>
83 
84 #include <freetds/pushvis.h>
85 
86 #ifdef __cplusplus
87 extern "C"
88 {
89 #if 0
90 }
91 #endif
92 #endif
93 
94 /**
95  * A structure to hold all the compile-time settings.
96  * This structure is returned by tds_get_compiletime_settings
97  */
98 
99 typedef struct tds_compiletime_settings
100 {
101  const char *freetds_version; /* release version of FreeTDS */
102  const char *sysconfdir; /* location of freetds.conf */
103  const char *last_update; /* latest software_version date among the modules */
104  const char *tdsver; /* TDS protocol version (4.2/4.6/5.0/7.0/7.1) 5.0 */
105  bool msdblib; /* for MS style dblib */
106  bool sybase_compat; /* enable increased Open Client binary compatibility */
107  bool threadsafe; /* compile for thread safety default=no */
108  bool libiconv; /* search for libiconv in DIR/include and DIR/lib */
109  bool iodbc; /* build odbc driver against iODBC in DIR */
110  bool unixodbc; /* build odbc driver against unixODBC in DIR */
111  bool openssl; /* build against OpenSSL */
112  bool gnutls; /* build against GnuTLS */
113  bool mars; /* MARS enabled */
114  bool sspi; /* SSPI enabled */
115  bool kerberos; /* Kerberos enabled */
117 
118 /**
119  * @file tds.h
120  * Main include file for libtds
121  */
122 
123 /**
124  * \defgroup libtds LibTDS API
125  * Callable functions in \c libtds.
126  *
127  * The \c libtds library is for use internal to \em FreeTDS. It is not
128  * intended for use by applications. Although any use is \em permitted, you're
129  * encouraged to use one of the established public APIs instead, because their
130  * interfaces are stable and documented by the vendors.
131  */
132 
133 /*
134  * All references to data that touch the wire should use the following typedefs.
135  *
136  * If you have problems on 64-bit machines and the code is
137  * using a native datatype, please change it to use
138  * these. (In the TDS layer only, the API layers have their
139  * own typedefs which equate to these).
140  */
141 typedef char TDS_CHAR; /* 8-bit char */
142 typedef uint8_t TDS_UCHAR; /* 8-bit uchar */
143 typedef uint8_t TDS_TINYINT; /* 8-bit unsigned */
144 typedef int16_t TDS_SMALLINT; /* 16-bit int */
145 typedef uint16_t TDS_USMALLINT; /* 16-bit unsigned */
146 typedef int32_t TDS_INT; /* 32-bit int */
147 typedef uint32_t TDS_UINT; /* 32-bit unsigned */
148 typedef int64_t TDS_INT8; /* 64-bit integer */
149 typedef uint64_t TDS_UINT8; /* 64-bit unsigned */
150 typedef tds_sysdep_real32_type TDS_REAL; /* 32-bit real */
151 typedef tds_sysdep_real64_type TDS_FLOAT; /* 64-bit real */
152 
153 #include <freetds/proto.h>
154 
155 #define TDS_INVALID_TYPE ((TDS_SERVER_TYPE) 0)
156 
157 /**
158  * this structure is not directed connected to a TDS protocol but
159  * keeps any DATE/TIME information.
160  */
161 typedef struct
162 {
163  TDS_UINT8 time; /**< time, 7 digit precision */
164  TDS_INT date; /**< date, 0 = 1900-01-01 */
165  TDS_SMALLINT offset; /**< time offset */
166  TDS_USMALLINT time_prec:3;
167  TDS_USMALLINT _tds_reserved:10;
168  TDS_USMALLINT has_time:1;
169  TDS_USMALLINT has_date:1;
170  TDS_USMALLINT has_offset:1;
172 
173 /** Used by tds_datecrack */
174 typedef struct tdsdaterec
175 {
176  TDS_INT year; /**< year */
177  TDS_INT quarter; /**< quarter (0-3) */
178  TDS_INT month; /**< month number (0-11) */
179  TDS_INT day; /**< day of month (1-31) */
180  TDS_INT dayofyear; /**< day of year (1-366) */
181  TDS_INT weekday; /**< day of week (0-6, 0 = sunday) */
182  TDS_INT hour; /**< 0-23 */
183  TDS_INT minute; /**< 0-59 */
184  TDS_INT second; /**< 0-59 */
185  TDS_INT decimicrosecond; /**< 0-9999999 */
186  TDS_INT timezone; /**< -840 - 840 minutes from UTC */
188 
189 /**
190  * The following little table is indexed by precision and will
191  * tell us the number of bytes required to store the specified
192  * precision.
193  */
194 extern const int tds_numeric_bytes_per_prec[];
195 
196 typedef int TDSRET;
197 #define TDS_NO_MORE_RESULTS ((TDSRET)1)
198 #define TDS_SUCCESS ((TDSRET)0)
199 #define TDS_FAIL ((TDSRET)-1)
200 #define TDS_CANCELLED ((TDSRET)-2)
201 #define TDS_FAILED(rc) ((rc)<0)
202 #define TDS_SUCCEED(rc) ((rc)>=0)
203 #define TDS_PROPAGATE(rc) \
204  do { TDSRET _tds_ret = (rc); if (TDS_FAILED(_tds_ret)) return _tds_ret; } while(0)
205 
206 #define TDS_INT_CONTINUE 1
207 #define TDS_INT_CANCEL 2
208 #define TDS_INT_TIMEOUT 3
209 
210 
211 #define TDS_NO_COUNT -1
212 
213 #define TDS_ROW_RESULT 4040
214 #define TDS_PARAM_RESULT 4042
215 #define TDS_STATUS_RESULT 4043
216 #define TDS_MSG_RESULT 4044
217 #define TDS_COMPUTE_RESULT 4045
218 #define TDS_CMD_DONE 4046
219 #define TDS_CMD_SUCCEED 4047
220 #define TDS_CMD_FAIL 4048
221 #define TDS_ROWFMT_RESULT 4049
222 #define TDS_COMPUTEFMT_RESULT 4050
223 #define TDS_DESCRIBE_RESULT 4051
224 #define TDS_DONE_RESULT 4052
225 #define TDS_DONEPROC_RESULT 4053
226 #define TDS_DONEINPROC_RESULT 4054
227 #define TDS_OTHERS_RESULT 4055
228 
230 {
241 };
242 
243 #define TDS_TOKEN_FLAG(flag) TDS_RETURN_##flag = (1 << (TDS_TOKEN_RES_##flag*2)), TDS_STOPAT_##flag = (2 << (TDS_TOKEN_RES_##flag*2))
244 
246 {
248  TDS_TOKEN_FLAG(OTHERS),
249  TDS_TOKEN_FLAG(ROWFMT),
250  TDS_TOKEN_FLAG(COMPUTEFMT),
251  TDS_TOKEN_FLAG(PARAMFMT),
254  TDS_TOKEN_FLAG(COMPUTE),
260 };
261 
262 /**
263  * Flags returned in TDS_DONE token
264  */
266 {
267  TDS_DONE_FINAL = 0x00 /**< final result set, command completed successfully. */
268  , TDS_DONE_MORE_RESULTS = 0x01 /**< more results follow */
269  , TDS_DONE_ERROR = 0x02 /**< error occurred */
270  , TDS_DONE_INXACT = 0x04 /**< transaction in progress */
271  , TDS_DONE_PROC = 0x08 /**< results are from a stored procedure */
272  , TDS_DONE_COUNT = 0x10 /**< count field in packet is valid */
273  , TDS_DONE_CANCELLED = 0x20 /**< acknowledging an attention command (usually a cancel) */
274  , TDS_DONE_EVENT = 0x40 /* part of an event notification. */
275  , TDS_DONE_SRVERROR = 0x100 /**< SQL server server error */
276 
277  /* after the above flags, a TDS_DONE packet has a field describing the state of the transaction */
278  , TDS_DONE_NO_TRAN = 0 /* No transaction in effect */
279  , TDS_DONE_TRAN_SUCCEED = 1 /* Transaction completed successfully */
280  , TDS_DONE_TRAN_PROGRESS= 2 /* Transaction in progress */
281  , TDS_DONE_STMT_ABORT = 3 /* A statement aborted */
282  , TDS_DONE_TRAN_ABORT = 4 /* Transaction aborted */
283 };
284 
285 
286 /*
287  * TDSERRNO is emitted by libtds to the client library's error handler
288  * (which may in turn call the client's error handler).
289  * These match the db-lib msgno, because the same values have the same meaning
290  * in db-lib and ODBC. ct-lib maps them to ct-lib numbers (todo).
291  */
292 typedef enum { TDSEOK = TDS_SUCCESS,
293  TDSEVERDOWN = 100,
295  TDSEICONVIU = 2400,
296  TDSEICONVAVAIL = 2401,
297  TDSEICONVO = 2402,
298  TDSEICONVI = 2403,
301  TDSESYNC = 20001,
302  TDSEFCON = 20002,
303  TDSETIME = 20003,
304  TDSEREAD = 20004,
305  TDSEWRIT = 20006,
306  TDSESOCK = 20008,
307  TDSECONN = 20009,
308  TDSEMEM = 20010,
309  TDSEINTF = 20012, /* Server name not found in interface file */
310  TDSEUHST = 20013, /* Unknown host machine name. */
311  TDSEPWD = 20014,
312  TDSESEOF = 20017,
313  TDSERPND = 20019,
314  TDSEBTOK = 20020,
315  TDSEOOB = 20022,
316  TDSECLOS = 20056,
317  TDSEUSCT = 20058,
318  TDSEUTDS = 20146,
319  TDSEEUNR = 20185,
320  TDSECAP = 20203,
321  TDSENEG = 20210,
322  TDSEUMSG = 20212,
323  TDSECAPTYP = 20213,
324  TDSECONF = 20214,
325  TDSEBPROBADTYP = 20250,
326  TDSECLOSEIN = 20292
328 
329 
330 enum {
338  TDS_CUR_ISTAT_DEALLOC = 0x40
339 };
340 
341 /* string types */
342 #define TDS_NULLTERM -9
343 
344 
345 typedef union tds_option_arg
346 {
347  TDS_TINYINT ti;
348  TDS_INT i;
349  TDS_CHAR *c;
351 
352 
353 typedef enum tds_encryption_level {
359 
360 /*
361  * TODO use system macros for optimization
362  * See mcrypt for reference and linux kernel source for optimization
363  * check if unaligned access and use fast write/read when implemented
364  */
365 #define TDS_BYTE_SWAP16(value) \
366  (((((uint16_t)value)<<8) & 0xFF00u) | \
367  ((((uint16_t)value)>>8) & 0x00FFu))
368 
369 #define TDS_BYTE_SWAP32(value) \
370  (((((uint32_t)value)<<24) & 0xFF000000u)| \
371  ((((uint32_t)value)<< 8) & 0x00FF0000u)| \
372  ((((uint32_t)value)>> 8) & 0x0000FF00u)| \
373  ((((uint32_t)value)>>24) & 0x000000FFu))
374 
375 #define is_end_token(x) ((x) >= TDS_DONE_TOKEN && (x) <= TDS_DONEINPROC_TOKEN)
376 
377 enum {
389 };
390 
391 extern const uint16_t tds_type_flags_ms[256];
392 #if 0
393 extern const uint16_t tds_type_flags_syb[256];
394 extern const char *const tds_type_names[256];
395 #endif
396 
397 #define is_fixed_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_FIXED) != 0)
398 #define is_nullable_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_NULLABLE) != 0)
399 #define is_variable_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_VARIABLE) != 0)
400 #define is_variant_inner_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_VARIANT) != 0)
401 
402 
403 #define is_blob_type(x) ((x)==SYBTEXT || (x)==SYBIMAGE || (x)==SYBNTEXT)
404 #if 1
405 #define is_blob_col(x) (is_blob_type((x)->column_type) \
406  || ((x)->column_varint_size == 8) \
407  || ((x)->column_type == SYBVARIANT \
408  && (x)->column_varint_size == 4))
409 #else
410 #define is_blob_col(x) ((x)->column_varint_size > 2)
411 #endif
412 /* large type means it has a two byte size field */
413 /* define is_large_type(x) (x>128) */
414 #define is_numeric_type(x) ((x)==SYBNUMERIC || (x)==SYBDECIMAL)
415 /** return true if type is a datetime (but not date or time) */
416 #define is_datetime_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_DATETIME) != 0)
417 #define is_unicode_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_UNICODE) != 0)
418 #define is_collate_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_COLLATE) != 0)
419 #define is_ascii_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_ASCII) != 0)
420 #define is_binary_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_BINARY) != 0)
421 #define is_char_type(x) ((tds_type_flags_ms[x] & (TDS_TYPEFLAG_ASCII|TDS_TYPEFLAG_UNICODE)) != 0)
422 #define is_similar_type(x, y) (is_char_type(x) && is_char_type(y))
423 static inline
425 {
426  return (unsigned) type < 256u && tds_type_flags_ms[type] != 0;
427 }
428 
429 
430 #define TDS_MAX_CAPABILITY 32
431 #define MAXPRECISION 77
432 #define TDS_MAX_CONN 4096
433 #define TDS_MAX_DYNID_LEN 30
434 
435 /* defaults to use if no others are found */
436 #define TDS_DEF_SERVER "SYBASE"
437 #define TDS_DEF_BLKSZ 512
438 #define TDS_DEF_CHARSET "iso_1"
439 #define TDS_DEF_LANG "us_english"
440 #if TDS50
441 #define TDS_DEFAULT_VERSION 0x500
442 #define TDS_DEF_PORT 4000
443 #elif TDS71
444 #define TDS_DEFAULT_VERSION 0x701
445 #define TDS_DEF_PORT 1433
446 #elif TDS72
447 #define TDS_DEFAULT_VERSION 0x702
448 #define TDS_DEF_PORT 1433
449 #elif TDS73
450 #define TDS_DEFAULT_VERSION 0x703
451 #define TDS_DEF_PORT 1433
452 #elif TDS74
453 #define TDS_DEFAULT_VERSION 0x704
454 #define TDS_DEF_PORT 1433
455 #else
456 #define TDS_DEFAULT_VERSION 0x000
457 #define TDS_DEF_PORT 1433
458 #endif
459 
460 /* normalized strings from freetds.conf file */
461 #define TDS_STR_VERSION "tds version"
462 #define TDS_STR_BLKSZ "initial block size"
463 #define TDS_STR_SWAPDT "swap broken dates"
464 #define TDS_STR_DUMPFILE "dump file"
465 #define TDS_STR_DEBUGLVL "debug level"
466 #define TDS_STR_DEBUGFLAGS "debug flags"
467 #define TDS_STR_TIMEOUT "timeout"
468 #define TDS_STR_QUERY_TIMEOUT "query timeout"
469 #define TDS_STR_CONNTIMEOUT "connect timeout"
470 #define TDS_STR_HOSTNAME "hostname"
471 #define TDS_STR_HOST "host"
472 #define TDS_STR_PORT "port"
473 #define TDS_STR_TEXTSZ "text size"
474 /* for big endian hosts, obsolete, ignored */
475 #define TDS_STR_EMUL_LE "emulate little endian"
476 #define TDS_STR_CHARSET "charset"
477 #define TDS_STR_CLCHARSET "client charset"
478 #define TDS_STR_USE_UTF_16 "use utf-16"
479 #define TDS_STR_LANGUAGE "language"
480 #define TDS_STR_APPENDMODE "dump file append"
481 #define TDS_STR_DATETIMEFMT "date format"
482 #define TDS_STR_DATEFMT "date-only format"
483 #define TDS_STR_TIMEFMT "time-only format"
484 #define TDS_STR_INSTANCE "instance"
485 #define TDS_STR_ASA_DATABASE "asa database"
486 #define TDS_STR_DATABASE "database"
487 #define TDS_STR_ENCRYPTION "encryption"
488 #define TDS_STR_USENTLMV2 "use ntlmv2"
489 #define TDS_STR_USELANMAN "use lanman"
490 /* conf values */
491 #define TDS_STR_ENCRYPTION_OFF "off"
492 #define TDS_STR_ENCRYPTION_REQUEST "request"
493 #define TDS_STR_ENCRYPTION_REQUIRE "require"
494 /* Defines to enable optional GSSAPI delegation */
495 #define TDS_GSSAPI_DELEGATION "enable gssapi delegation"
496 /* Mutual authentication */
497 #define TDS_STR_MUTUAL_AUTHENTICATION "mutual authentication"
498 /* Kerberos realm name */
499 #define TDS_STR_REALM "realm"
500 /* Kerberos SPN */
501 #define TDS_STR_SPN "spn"
502 /* CA file */
503 #define TDS_STR_CAFILE "ca file"
504 /* CRL file */
505 #define TDS_STR_CRLFILE "crl file"
506 /* check SSL hostname */
507 #define TDS_STR_CHECKSSLHOSTNAME "check certificate hostname"
508 /* database filename to attach on login (MSSQL) */
509 #define TDS_STR_DBFILENAME "database filename"
510 /* Application Intent MSSQL 2012 support */
511 #define TDS_STR_READONLY_INTENT "read-only intent"
512 /* configurable cipher suite to send to openssl's SSL_set_cipher_list() function */
513 #define TLS_STR_OPENSSL_CIPHERS "openssl ciphers"
514 /* enable old TLS v1, required for instance if you are using a really old Windows XP */
515 #define TDS_STR_ENABLE_TLS_V1 "enable tls v1"
516 
517 
518 /* TODO do a better check for alignment than this */
519 typedef union
520 {
521  void *p;
522  int i;
525 
526 #define TDS_ALIGN_SIZE sizeof(tds_align_struct)
527 
528 typedef struct tds_capability_type
529 {
530  unsigned char type;
531  unsigned char len; /* always sizeof(values) */
532  unsigned char values[TDS_MAX_CAPABILITY/2-2];
534 
535 typedef struct tds_capabilities
536 {
539 
540 #define TDS_MAX_LOGIN_STR_SZ 128
541 typedef struct tds_login
542 {
543  DSTR server_name; /**< server name (in freetds.conf) */
544  int port; /**< port of database service */
545  TDS_USMALLINT tds_version; /**< TDS version */
546  int block_size;
547  DSTR language; /* e.g. us-english */
548  DSTR server_charset; /**< charset of server e.g. iso_1 */
552  DSTR server_realm_name; /**< server realm name (in freetds.conf) */
553  DSTR server_spn; /**< server SPN (in freetds.conf) */
554  DSTR db_filename; /**< database filename to attach (MSSQL) */
555  DSTR cafile; /**< certificate authorities file */
556  DSTR crlfile; /**< certificate revocation file */
558  DSTR app_name;
559  DSTR user_name; /**< account for login */
560  DSTR password; /**< password of account login */
561  DSTR new_password; /**< new password to set (TDS 7.2+) */
562 
563  DSTR library; /* Ct-Library, DB-Library, TDS-Library or ODBC */
565 
569  DSTR database;
570 
571  struct addrinfo *ip_addrs; /**< ip(s) of server */
573  DSTR dump_file;
574  int debug_flags;
575  int text_size;
578 
579  unsigned char option_flag2;
580 
581  unsigned int bulk_copy:1; /**< if bulk copy should be enabled */
582  unsigned int suppress_language:1;
583  unsigned int gssapi_use_delegation:1;
584  unsigned int mutual_authentication:1;
585  unsigned int use_ntlmv2:1;
586  unsigned int use_ntlmv2_specified:1;
587  unsigned int use_lanman:1;
588  unsigned int mars:1;
589  unsigned int use_utf16:1;
590  unsigned int use_new_password:1;
591  unsigned int valid_configuration:1;
592  unsigned int check_ssl_hostname:1;
593  unsigned int readonly_intent:1;
594  unsigned int enable_tls_v1:1;
595  unsigned int enable_tls_v1_specified:1;
596  unsigned int server_is_valid:1;
598 
599 typedef struct tds_headers
600 {
601  const char *qn_options;
602  const char *qn_msgtext;
604  /* TDS 7.4+: trace activity ID char[20] */
606 
607 typedef struct tds_locale
608 {
609  char *language;
610  char *server_charset;
612  char *date_fmt;
613  char *time_fmt;
615 
616 /**
617  * Information about blobs (e.g. text or image).
618  * current_row contains this structure.
619  */
620 typedef struct tds_blob
621 {
623  TDS_CHAR textptr[16];
624  TDS_CHAR timestamp[8];
625  bool valid_ptr;
627 
628 /**
629  * Store variant informations
630  */
631 typedef struct tds_variant
632 {
633  /* this MUST have same position and place of textvalue in tds_blob */
634  TDS_CHAR *data;
635  TDS_INT size;
638  TDS_UCHAR collation[5];
640 
641 /**
642  * Information relevant to libiconv. The name is an iconv name, not
643  * the same as found in master..syslanguages.
644  */
645 typedef struct tds_encoding
646 {
647  /** name of the encoding (ie UTF-8) */
648  const char *name;
649  unsigned char min_bytes_per_char;
650  unsigned char max_bytes_per_char;
651  /** internal numeric index into array of all encodings */
652  unsigned char canonic;
654 
655 typedef struct tds_bcpcoldata
656 {
657  TDS_UCHAR *data;
659  bool is_null;
661 
662 
667 typedef TDSRET tds_func_put_data(TDSSOCKET *tds, TDSCOLUMN *col, int bcp7);
668 typedef int tds_func_check(const TDSCOLUMN *col);
669 
670 typedef struct tds_column_funcs
671 {
675  /**
676  * Send metadata column information to server.
677  * \tds
678  * \param col column to send
679  */
681  /**
682  * Send column data to server.
683  * Usually send parameters unless bcp7 is specified, in
684  * this case send BCP for TDS7+ (Sybase use a completely
685  * different format for BCP)
686  * \tds
687  * \param col column to send
688  * \param bcp7 1 to send BCP column on TDS7+
689  */
691 #if ENABLE_EXTRA_CHECKS
692  /**
693  * Check column is valid.
694  * Some things should be checked:
695  * - column_type and on_server.column_type;
696  * - column_size and on_server.column_size;
697  * - column_cur_size;
698  * - column_prec and column_scale;
699  * - is_XXXX_type macros/functions (nullable/fixed/blob/variable);
700  * - tds_get_size_by_type;
701  * - tds_get_conversion_type.
702  *
703  * \tds
704  * \param col column to check
705  */
707 #endif
708 #if 0
709  TDSRET (*convert)(TDSSOCKET *tds, TDSCOLUMN *col);
710 #endif
712 
713 /**
714  * Metadata about columns in regular and compute rows
715  */
716 struct tds_column
717 {
718  const TDSCOLUMNFUNCS *funcs;
721 
722  TDS_INT column_size; /**< maximun size of data. For fixed is the size. */
723 
724  TDS_SERVER_TYPE column_type; /**< This type can be different from wire type because
725  * conversion (e.g. UCS-2->Ascii) can be applied.
726  * I'm beginning to wonder about the wisdom of this, however.
727  * April 2003 jkl
728  */
729  TDS_TINYINT column_varint_size; /**< size of length when reading from wire (0, 1, 2 or 4) */
730 
731  TDS_TINYINT column_prec; /**< precision for decimal/numeric */
732  TDS_TINYINT column_scale; /**< scale for decimal/numeric */
733 
734  struct
735  {
736  TDS_SERVER_TYPE column_type; /**< type of data, saved from wire */
739 
740  TDSICONV *char_conv; /**< refers to previously allocated iconv information */
741 
745 
746  unsigned char *column_data;
747  void (*column_data_free)(struct tds_column *column);
748  unsigned char column_nullable:1;
749  unsigned char column_writeable:1;
750  unsigned char column_identity:1;
751  unsigned char column_key:1;
752  unsigned char column_hidden:1;
753  unsigned char column_output:1;
754  unsigned char column_timestamp:1;
755  unsigned char column_computed:1;
757 
758  /* additional fields flags for compute results */
761 
762  /* FIXME this is data related, not column */
763  /** size written in variable (ie: char, text, binary). -1 if NULL. */
765 
766  /* related to binding or info stored by client libraries */
767  /* FIXME find a best place to store these data, some are unused */
777  unsigned char column_iconv_left;
779 
781  /**
782  * The length, in bytes, of any length prefix this column may have.
783  * For example, strings in some non-C programming languages are
784  * made up of a one-byte length prefix, followed by the string
785  * data itself.
786  * If the data do not have a length prefix, set prefixlen to 0.
787  * Currently not very used in code, however do not remove.
788  */
792 };
793 
794 
795 /** Hold information for any results */
796 typedef struct tds_result_info
797 {
798  /* TODO those fields can became a struct */
799  TDSCOLUMN **columns;
804  unsigned char *current_row;
805  void (*row_free)(struct tds_result_info* result, unsigned char *row);
807 
811  /* TODO remove ?? used only in dblib */
814 
815 /** values for tds->state */
816 typedef enum tds_states
817 {
818  TDS_IDLE, /**< no data expected */
819  TDS_WRITING, /**< client is writing data */
820  TDS_SENDING, /**< client would send data */
821  TDS_PENDING, /**< cilent is waiting for data */
822  TDS_READING, /**< client is reading data */
823  TDS_DEAD /**< no connection */
825 
826 typedef enum tds_operations
827 {
829 
830  /* mssql operations */
846 
847  /* sybase operations */
850 
851 #define TDS_DBG_LOGIN __FILE__, ((__LINE__ << 4) | 11)
852 #define TDS_DBG_HEADER __FILE__, ((__LINE__ << 4) | 10)
853 #define TDS_DBG_FUNC __FILE__, ((__LINE__ << 4) | 7)
854 #define TDS_DBG_INFO2 __FILE__, ((__LINE__ << 4) | 6)
855 #define TDS_DBG_INFO1 __FILE__, ((__LINE__ << 4) | 5)
856 #define TDS_DBG_NETWORK __FILE__, ((__LINE__ << 4) | 4)
857 #define TDS_DBG_WARN __FILE__, ((__LINE__ << 4) | 3)
858 #define TDS_DBG_ERROR __FILE__, ((__LINE__ << 4) | 2)
859 #define TDS_DBG_SEVERE __FILE__, ((__LINE__ << 4) | 1)
860 
861 #define TDS_DBGFLAG_FUNC 0x80
862 #define TDS_DBGFLAG_INFO2 0x40
863 #define TDS_DBGFLAG_INFO1 0x20
864 #define TDS_DBGFLAG_NETWORK 0x10
865 #define TDS_DBGFLAG_WARN 0x08
866 #define TDS_DBGFLAG_ERROR 0x04
867 #define TDS_DBGFLAG_SEVERE 0x02
868 #define TDS_DBGFLAG_ALL 0xfff
869 #define TDS_DBGFLAG_LOGIN 0x0800
870 #define TDS_DBGFLAG_HEADER 0x0400
871 #define TDS_DBGFLAG_PID 0x1000
872 #define TDS_DBGFLAG_TIME 0x2000
873 #define TDS_DBGFLAG_SOURCE 0x4000
874 #define TDS_DBGFLAG_THREAD 0x8000
875 
876 #if 0
877 /**
878  * An attempt at better logging.
879  * Using these bitmapped values, various logging features can be turned on and off.
880  * It can be especially helpful to turn packet data on/off for security reasons.
881  */
882 enum TDS_DBG_LOG_STATE
883 {
884  TDS_DBG_LOGIN = (1 << 0) /**< for diagnosing login problems;
885  otherwise the username/password information is suppressed. */
886  , TDS_DBG_API = (1 << 1) /**< Log calls to client libraries */
887  , TDS_DBG_ASYNC = (1 << 2) /**< Log asynchronous function starts or completes. */
888  , TDS_DBG_DIAG = (1 << 3) /**< Log client- and server-generated messages */
889  , TDS_DBG_error = (1 << 4)
890  /* TODO: ^^^^^ make upper case when old #defines (above) are removed */
891  /* Log FreeTDS runtime/logic error occurs. */
892  , TDS_DBG_PACKET = (1 << 5) /**< Log hex dump of packets to/from the server. */
893  , TDS_DBG_LIBTDS = (1 << 6) /**< Log calls to (and in) libtds */
894  , TDS_DBG_CONFIG = (1 << 7) /**< replaces TDSDUMPCONFIG */
895  , TDS_DBG_DEFAULT = 0xFE /**< all above except login packets */
896 };
897 #endif
898 
899 typedef struct tds_result_info TDSCOMPUTEINFO;
900 
902 
903 typedef struct tds_message
904 {
905  TDS_CHAR *server;
906  TDS_CHAR *message;
909  TDS_INT msgno;
911  /* -1 .. 255 */
915  /* for library-generated errors */
916  int oserr;
917  TDS_CHAR *osstr;
919 
920 typedef struct tds_upd_col
921 {
922  struct tds_upd_col *next;
924  char * columnname;
926 
927 typedef enum {
928  TDS_CURSOR_STATE_UNACTIONED = 0 /* initial value */
929  , TDS_CURSOR_STATE_REQUESTED = 1 /* called by ct_cursor */
930  , TDS_CURSOR_STATE_SENT = 2 /* sent to server */
931  , TDS_CURSOR_STATE_ACTIONED = 3 /* acknowledged by server */
933 
934 typedef struct tds_cursor_status
935 {
943 
945 {
951 
952 typedef enum tds_cursor_fetch
953 {
961 
962 /**
963  * Holds informations about a cursor
964  */
965 typedef struct tds_cursor
966 {
967  struct tds_cursor *next; /**< next in linked list, keep first */
968  TDS_INT ref_count; /**< reference counter so client can retain safely a pointer */
969  char *cursor_name; /**< name of the cursor */
970  TDS_INT cursor_id; /**< cursor id returned by the server after cursor declare */
971  TDS_TINYINT options; /**< read only|updatable TODO use it */
972  /**
973  * true if cursor was marker to be closed when connection is idle
974  */
976  char *query; /**< SQL query */
977  /* TODO for updatable columns */
978  /* TDS_TINYINT number_upd_cols; */ /**< number of updatable columns */
979  /* TDSUPDCOL *cur_col_list; */ /**< updatable column list */
980  TDS_INT cursor_rows; /**< number of cursor rows to fetch */
981  /* TDSPARAMINFO *params; */ /** cursor parameter */
984  TDSRESULTINFO *res_info; /** row fetched from this cursor */
987 
988 /**
989  * Current environment as reported by the server
990  */
991 typedef struct tds_env
992 {
993  /** packet size (512-65535) */
994  int block_size;
995  char *language;
996  /** character set encoding */
997  char *charset;
998  /** database name */
999  char *database;
1001 
1002 /**
1003  * Holds information for a dynamic (also called prepared) query.
1004  */
1005 typedef struct tds_dynamic
1006 {
1007  struct tds_dynamic *next; /**< next in linked list, keep first */
1008  TDS_INT ref_count; /**< reference counter so client can retain safely a pointer */
1009  /** numeric id for mssql7+*/
1010  TDS_INT num_id;
1011  /**
1012  * id of dynamic.
1013  * Usually this id correspond to server one but if not specified
1014  * is generated automatically by libTDS
1015  */
1016  char id[30];
1017  /**
1018  * this dynamic query cannot be prepared so libTDS have to construct a simple query.
1019  * This can happen for instance is tds protocol doesn't support dynamics or trying
1020  * to prepare query under Sybase that have BLOBs as parameters.
1021  */
1023  /**
1024  * true if dynamic was marker to be closed when connection is idle
1025  */
1027  /* int dyn_state; */ /* TODO use it */
1028  TDSPARAMINFO *res_info; /**< query results */
1029  /**
1030  * query parameters.
1031  * Mostly used executing query however is a good idea to prepare query
1032  * again if parameter type change in an incompatible way (ie different
1033  * types or larger size). Is also better to prepare a query knowing
1034  * parameter types earlier.
1035  */
1037  /** saved query, we need to know original query if prepare is impossible */
1038  char *query;
1040 
1041 typedef enum {
1046 
1047 typedef struct tds_multiple
1048 {
1050  unsigned int flags;
1052 
1053 /* forward declaration */
1054 typedef struct tds_context TDSCONTEXT;
1055 typedef int (*err_handler_t) (const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *);
1056 
1057 struct tds_context
1058 {
1059  TDSLOCALE *locale;
1060  void *parent;
1061  /* handlers */
1062  int (*msg_handler) (const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *);
1063  int (*err_handler) (const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *);
1064  int (*int_handler) (void *);
1066 };
1067 
1069 {
1070  client2ucs2
1072  , initial_char_conv_count /* keep last */
1073 };
1074 
1075 typedef struct tds_authentication
1076 {
1078  int packet_len;
1079  /* TDS_MSG_TOKEN type, for TDS5 */
1081  TDSRET (*free)(TDSCONNECTION* conn, struct tds_authentication * auth);
1082  TDSRET (*handle_next)(TDSSOCKET * tds, struct tds_authentication * auth, size_t len);
1084 
1085 typedef struct tds_packet
1086 {
1087  struct tds_packet *next;
1089 
1090 #if ENABLE_ODBC_MARS
1091  /**
1092  * Data before TDS data, currently can be 0 or sizeof(TDS72_SMP_HEADER)
1093  */
1094  uint8_t data_start;
1095 #endif
1096 
1097  /**
1098  * data length, this does not account SMP header, only TDS part
1099  */
1100  unsigned data_len;
1101  unsigned capacity;
1102  unsigned char buf[1];
1104 
1105 #if ENABLE_ODBC_MARS
1106 #define tds_packet_zero_data_start(pkt) do { (pkt)->data_start = 0; } while(0)
1107 #define tds_packet_get_data_start(pkt) ((pkt)->data_start)
1108 #else
1109 #define tds_packet_zero_data_start(pkt) do { } while(0)
1110 #define tds_packet_get_data_start(pkt) 0
1111 #endif
1112 
1113 typedef struct tds_poll_wakeup
1114 {
1117 
1118 /* field related to connection */
1119 struct tds_connection
1120 {
1122  TDS_UINT product_version; /**< version of product (Sybase/MS and full version) */
1123  char *product_name;
1124 
1125  TDS_SYS_SOCKET s; /**< tcp socket, INVALID_SOCKET if not connected */
1127  const TDSCONTEXT *tds_ctx;
1128 
1129  /** environment is shared between all sessions */
1130  TDSENV env;
1131 
1132  /**
1133  * linked list of cursors allocated for this connection
1134  * contains only cursors allocated on the server
1135  */
1136  TDSCURSOR *cursors;
1137  /**
1138  * list of dynamic allocated for this connection
1139  * contains only dynamic allocated on the server
1140  */
1141  TDSDYNAMIC *dyns;
1142 
1143  int char_conv_count;
1144  TDSICONV **char_convs;
1145 
1146  TDS_UCHAR collation[5];
1148 
1150  unsigned int use_iconv:1;
1151  unsigned int tds71rev1:1;
1152  unsigned int pending_close:1; /**< true is connection has pending closing (cursors or dynamic) */
1153  unsigned int encrypt_single_packet:1;
1154 #if ENABLE_ODBC_MARS
1155  unsigned int mars:1;
1156 
1157  TDSSOCKET *in_net_tds;
1158  TDSPACKET *packets;
1159  TDSPACKET *recv_packet;
1160  TDSPACKET *send_packets;
1161  unsigned send_pos, recv_pos;
1162 
1163 #define BUSY_SOCKET ((TDSSOCKET*)(TDS_UINTPTR)1)
1164 #define TDSSOCKET_VALID(tds) (((TDS_UINTPTR)(tds)) > 1)
1165  struct tds_socket **sessions;
1166  unsigned num_sessions;
1167 #endif
1169 
1172 
1173  int spid;
1174  int client_spid;
1175 
1176  /**
1177  * Ratio between bytes allocated for a NCHAR type and type length (Sybase).
1178  * For instance in case a NVARCHAR(3) takes 9 bytes it's 3.
1179  */
1181 
1182  /**
1183  * Ratio between bytes allocated for a UNICHAR type and type length (Sybase).
1184  * For instance in case a UNIVARCHAR(2) takes 4 bytes it's 2.
1185  * It really should be only 2.
1186  */
1188 
1189  void *tls_session;
1190 #if defined(HAVE_GNUTLS)
1191  void *tls_credentials;
1192 #elif defined(HAVE_OPENSSL)
1193  void *tls_ctx;
1194 #else
1195  void *tls_dummy;
1196 #endif
1198  char *server;
1199 };
1200 
1201 /**
1202  * Information for a server connection
1203  */
1204 struct tds_socket
1205 {
1206 #if ENABLE_ODBC_MARS
1208 #else
1209  TDSCONNECTION conn[1];
1210 #endif
1211 
1212  void *parent;
1213 
1214  /** Input buffer.
1215  * Points to receiving packet buffer.
1216  * As input buffer contains just the raw packet actually this pointer
1217  * is the address of recv_packet->buf.
1218  */
1219  unsigned char *in_buf;
1220 
1221  /** Output buffer.
1222  * Points to sending packet buffer.
1223  * Output buffer can contain additional data before the raw TDS packet
1224  * so this buffer can point some bytes after send_packet->buf.
1225  * Specifically this will point to send_packet->buf + send_packet->data_start.
1226  */
1227  unsigned char *out_buf;
1228 
1229  /** Maximum size of packet pointed by out_buf.
1230  * The buffer is actually a bit larger to make possible to do some
1231  * optimizations (at least TDS_ADDITIONAL_SPACE bytes).
1232  */
1233  unsigned int out_buf_max;
1234  unsigned in_pos; /**< current position in in_buf */
1235  unsigned out_pos; /**< current position in out_buf */
1236  unsigned in_len; /**< input buffer length */
1237  unsigned char in_flag; /**< input buffer type */
1238  unsigned char out_flag; /**< output buffer type */
1239 
1240  unsigned frozen;
1241  /**
1242  * list of packets frozen, points to first one.
1243  * send_packet is the last packet in the list.
1244  */
1246 
1247 #if ENABLE_ODBC_MARS
1248  /** SID of MARS session.
1249  * ==0 Not in a MARS session or first session
1250  * >0 SID of MARS session valid.
1251  */
1252  uint16_t sid;
1253 
1254  /**
1255  * This condition will be signaled by the network thread on packet
1256  * received or sent for this session
1257  */
1258  tds_condition packet_cond;
1259 
1260  /**
1261  * Packet we are trying to send to network.
1262  * This field should be protected by conn->list_mtx
1263  */
1264  TDSPACKET *sending_packet;
1265  TDS_UINT recv_seq;
1266  TDS_UINT send_seq;
1267  TDS_UINT recv_wnd;
1268  TDS_UINT send_wnd;
1269 #endif
1270  /* packet we received */
1272  /** packet we are preparing to send */
1274 
1275  /**
1276  * Current query information.
1277  * Contains information in process, both normal and compute results.
1278  * This pointer shouldn't be freed; it's just an alias to another structure.
1279  */
1285  TDSCURSOR *cur_cursor; /**< cursor in use */
1286  bool bulk_query; /**< true is query sent was a bulk query so we need to switch state to QUERYING */
1287  bool has_status; /**< true is ret_status is valid */
1288  bool in_row; /**< true if we are getting rows */
1289  volatile
1290  unsigned char in_cancel; /**< indicate we are waiting a cancel reply; discard tokens till acknowledge;
1291  1 mean we have to send cancel packet, 2 already sent. */
1292  TDS_INT ret_status; /**< return status from store procedure */
1293  TDS_STATE state;
1294 
1296  TDS_INT8 rows_affected; /**< rows updated/deleted/inserted/selected, TDS_NO_COUNT if not valid */
1297 
1298  TDSDYNAMIC *cur_dyn; /**< dynamic structure in use */
1299 
1300  TDSLOGIN *login; /**< config for login stuff. After login this field is NULL */
1301 
1302  void (*env_chg_func) (TDSSOCKET * tds, int type, char *oldval, char *newval);
1304 
1305  int option_value;
1307 };
1308 
1309 #define tds_get_ctx(tds) ((tds)->conn->tds_ctx)
1310 #define tds_set_ctx(tds, val) do { ((tds)->conn->tds_ctx) = (val); } while(0)
1311 #define tds_get_parent(tds) ((tds)->parent)
1312 #define tds_set_parent(tds, val) do { ((tds)->parent) = (val); } while(0)
1313 #define tds_get_s(tds) ((tds)->conn->s)
1314 #define tds_set_s(tds, val) do { ((tds)->conn->s) = (val); } while(0)
1315 
1316 typedef struct tds_tvp_row
1317 {
1321 
1322 typedef struct tds_tvp
1323 {
1324  char *schema;
1325  char *name;
1329 
1330 
1331 /* config.c */
1333 typedef void (*TDSCONFPARSE) (const char *option, const char *value, void *param);
1334 bool tds_read_conf_section(FILE * in, const char *section, TDSCONFPARSE tds_conf_parse, void *parse_param);
1335 bool tds_read_conf_file(TDSLOGIN * login, const char *server);
1336 void tds_parse_conf_section(const char *option, const char *value, void *param);
1339 TDS_USMALLINT * tds_config_verstr(const char *tdsver, TDSLOGIN* login);
1340 struct addrinfo *tds_lookup_host(const char *servername);
1341 TDSRET tds_lookup_host_set(const char *servername, struct addrinfo **addr);
1342 const char *tds_addrinfo2str(struct addrinfo *addr, char *name, int namemax);
1343 char *tds_get_home_file(const char *file);
1344 
1345 TDSRET tds_set_interfaces_file_loc(const char *interfloc);
1346 extern const char STD_DATETIME_FMT[];
1347 int tds_parse_boolean(const char *value, int default_value);
1348 int tds_config_boolean(const char *option, const char *value, TDSLOGIN * login);
1349 
1350 TDSLOCALE *tds_get_locale(void);
1351 TDSRET tds_alloc_row(TDSRESULTINFO * res_info);
1353 BCPCOLDATA * tds_alloc_bcp_column_data(unsigned int column_size);
1354 TDSDYNAMIC *tds_lookup_dynamic(TDSCONNECTION * conn, const char *id);
1355 /*@observer@*/ const char *tds_prtype(int token);
1356 int tds_get_varint_size(TDSCONNECTION * conn, int datatype);
1357 TDS_SERVER_TYPE tds_get_cardinal_type(TDS_SERVER_TYPE datatype, int usertype);
1358 
1359 
1360 /* iconv.c */
1361 TDSRET tds_iconv_open(TDSCONNECTION * conn, const char *charset, int use_utf16);
1363 void tds_srv_charset_changed(TDSCONNECTION * conn, const char *charset);
1368 
1369 
1370 /* mem.c */
1371 void tds_free_socket(TDSSOCKET * tds);
1373 void tds_free_results(TDSRESULTINFO * res_info);
1374 void tds_free_param_results(TDSPARAMINFO * param_info);
1375 void tds_free_param_result(TDSPARAMINFO * param_info);
1376 void tds_free_msg(TDSMESSAGE * message);
1378 void tds_release_cursor(TDSCURSOR **pcursor);
1379 void tds_free_bcp_column_data(BCPCOLDATA * coldata);
1382 TDSCONTEXT *tds_alloc_context(void * parent);
1385 void tds_free_input_params(TDSDYNAMIC * dyn);
1386 void tds_release_dynamic(TDSDYNAMIC ** dyn);
1387 static inline
1389 {
1391 }
1395 char *tds_alloc_client_sqlstate(int msgno);
1396 char *tds_alloc_lookup_sqlstate(TDSSOCKET * tds, int msgno);
1397 TDSLOGIN *tds_alloc_login(int use_environment);
1398 TDSDYNAMIC *tds_alloc_dynamic(TDSCONNECTION * conn, const char *id);
1399 void tds_free_login(TDSLOGIN * login);
1402 void *tds_alloc_param_data(TDSCOLUMN * curparam);
1404 TDSCURSOR * tds_alloc_cursor(TDSSOCKET * tds, const char *name, size_t namelen,
1405  const char *query, size_t querylen);
1406 void tds_free_row(TDSRESULTINFO * res_info, unsigned char *row);
1411 void * tds_realloc(void **pp, size_t new_size);
1412 #define TDS_RESIZE(p, n_elem) \
1413  tds_realloc((void **) &(p), sizeof(*(p)) * (size_t) (n_elem))
1414 #define tds_new(type, n) ((type *) malloc(sizeof(type) * (n)))
1415 #define tds_new0(type, n) ((type *) calloc(n, sizeof(type)))
1416 
1417 TDSPACKET *tds_alloc_packet(void *buf, unsigned len);
1418 TDSPACKET *tds_realloc_packet(TDSPACKET *packet, unsigned len);
1419 void tds_free_packets(TDSPACKET *packet);
1421 void tds_free_bcpinfo(TDSBCPINFO *bcpinfo);
1422 void tds_deinit_bcpinfo(TDSBCPINFO *bcpinfo);
1424 
1425 
1426 /* login.c */
1427 void tds_set_packet(TDSLOGIN * tds_login, int packet_size);
1428 void tds_set_port(TDSLOGIN * tds_login, int port);
1429 bool tds_set_passwd(TDSLOGIN * tds_login, const char *password) TDS_WUR;
1430 void tds_set_bulk(TDSLOGIN * tds_login, bool enabled);
1431 bool tds_set_user(TDSLOGIN * tds_login, const char *username) TDS_WUR;
1432 bool tds_set_app(TDSLOGIN * tds_login, const char *application) TDS_WUR;
1433 bool tds_set_host(TDSLOGIN * tds_login, const char *hostname) TDS_WUR;
1434 bool tds_set_library(TDSLOGIN * tds_login, const char *library) TDS_WUR;
1435 bool tds_set_server(TDSLOGIN * tds_login, const char *server) TDS_WUR;
1436 bool tds_set_client_charset(TDSLOGIN * tds_login, const char *charset) TDS_WUR;
1437 bool tds_set_language(TDSLOGIN * tds_login, const char *language) TDS_WUR;
1438 void tds_set_version(TDSLOGIN * tds_login, TDS_TINYINT major_ver, TDS_TINYINT minor_ver);
1440 
1441 
1442 /* query.c */
1443 void tds_start_query(TDSSOCKET *tds, unsigned char packet_type);
1444 
1445 TDSRET tds_submit_query(TDSSOCKET * tds, const char *query);
1447 TDSRET tds_submit_queryf(TDSSOCKET * tds, const char *queryf, ...);
1448 TDSRET tds_submit_prepare(TDSSOCKET * tds, const char *query, const char *id, TDSDYNAMIC ** dyn_out, TDSPARAMINFO * params);
1450 TDSRET tds71_submit_prepexec(TDSSOCKET * tds, const char *query, const char *id, TDSDYNAMIC ** dyn_out, TDSPARAMINFO * params);
1453 const char *tds_next_placeholder(const char *start);
1454 int tds_count_placeholders(const char *query);
1458 TDSRET tds_submit_rpc(TDSSOCKET * tds, const char *rpc_name, TDSPARAMINFO * params, TDSHEADERS * head);
1462 TDSRET tds_submit_commit(TDSSOCKET *tds, bool cont);
1464 size_t tds_quote_id(TDSSOCKET * tds, char *buffer, const char *id,
1465  ssize_t idlen);
1466 size_t tds_quote_id_rpc(TDSSOCKET * tds, char *buffer, const char *id,
1467  ssize_t idlen);
1468 size_t tds_quote_string(TDSSOCKET * tds, char *buffer, const char *str,
1469  ssize_t len);
1470 const char *tds_skip_comment(const char *s);
1471 const char *tds_skip_quoted(const char *s);
1472 size_t tds_fix_column_size(TDSSOCKET * tds, TDSCOLUMN * curcol);
1473 const char *tds_convert_string(TDSSOCKET * tds, TDSICONV * char_conv,
1474  const char *s, ssize_t len, size_t *out_len);
1475 void tds_convert_string_free(const char *original, const char *converted);
1476 #if !ENABLE_EXTRA_CHECKS
1477 #define tds_convert_string_free(original, converted) \
1478  do { if (original != converted) free((char*) converted); } while(0)
1479 #endif
1481 
1482 TDSRET tds_cursor_declare(TDSSOCKET * tds, TDSCURSOR * cursor, TDSPARAMINFO *params, int *send);
1483 TDSRET tds_cursor_setrows(TDSSOCKET * tds, TDSCURSOR * cursor, int *send);
1484 TDSRET tds_cursor_open(TDSSOCKET * tds, TDSCURSOR * cursor, TDSPARAMINFO *params, int *send);
1485 TDSRET tds_cursor_fetch(TDSSOCKET * tds, TDSCURSOR * cursor, TDS_CURSOR_FETCH fetch_type, TDS_INT i_row);
1486 TDSRET tds_cursor_get_cursor_info(TDSSOCKET * tds, TDSCURSOR * cursor, TDS_UINT * row_number, TDS_UINT * row_count);
1492 
1495 TDSRET tds_multiple_query(TDSSOCKET *tds, TDSMULTIPLE *multiple, const char *query, TDSPARAMINFO * params);
1497 
1498 
1499 /* token.c */
1503 int tds5_send_optioncmd(TDSSOCKET * tds, TDS_OPTION_CMD tds_command, TDS_OPTION tds_option, TDS_OPTION_ARG * tds_argument,
1504  TDS_INT * tds_argsize);
1505 TDSRET tds_process_tokens(TDSSOCKET * tds, /*@out@*/ TDS_INT * result_type, /*@out@*/ int *done_flags, unsigned flag);
1506 
1507 
1508 /* data.c */
1511 #ifdef WORDS_BIGENDIAN
1512 void tds_swap_datatype(int coltype, void *b);
1513 #endif
1514 
1515 
1516 /* tds_convert.c */
1517 TDSRET tds_datecrack(TDS_INT datetype, const void *di, TDSDATEREC * dr);
1519 extern const char tds_hex_digits[];
1520 
1521 
1522 /* write.c */
1524 int tds_put_n(TDSSOCKET * tds, const void *buf, size_t n);
1525 int tds_put_string(TDSSOCKET * tds, const char *buf, int len);
1529 /** Output a tinyint value */
1530 #define tds_put_tinyint(tds, ti) tds_put_byte(tds,ti)
1531 int tds_put_byte(TDSSOCKET * tds, unsigned char c);
1533 int tds_put_buf(TDSSOCKET * tds, const unsigned char *buf, int dsize, int ssize);
1534 
1535 
1536 /* read.c */
1537 unsigned char tds_get_byte(TDSSOCKET * tds);
1538 void tds_unget_byte(TDSSOCKET * tds);
1539 unsigned char tds_peek(TDSSOCKET * tds);
1541 #define tds_get_smallint(tds) ((TDS_SMALLINT) tds_get_usmallint(tds))
1543 #define tds_get_int(tds) ((TDS_INT) tds_get_uint(tds))
1545 #define tds_get_int8(tds) ((TDS_INT8) tds_get_uint8(tds))
1546 size_t tds_get_string(TDSSOCKET * tds, size_t string_len, char *dest, size_t dest_size);
1547 TDSRET tds_get_char_data(TDSSOCKET * tds, char *dest, size_t wire_size, TDSCOLUMN * curcol);
1548 bool tds_get_n(TDSSOCKET * tds, /*@out@*/ /*@null@*/ void *dest, size_t n);
1549 int tds_get_size_by_type(TDS_SERVER_TYPE servertype);
1550 DSTR* tds_dstr_get(TDSSOCKET * tds, DSTR * s, size_t len);
1551 
1552 
1553 /* util.c */
1554 int tdserror (const TDSCONTEXT * tds_ctx, TDSSOCKET * tds, int msgno, int errnum);
1556 void tds_swap_bytes(void *buf, int bytes);
1557 unsigned int tds_gettime_ms(void);
1558 char *tds_strndup(const void *s, TDS_INTPTR len);
1559 
1560 
1561 /* log.c */
1562 typedef struct tdsdump_off_item {
1566 void tdsdump_off(TDSDUMP_OFF_ITEM *off_item);
1567 void tdsdump_on(TDSDUMP_OFF_ITEM *off_item);
1568 int tdsdump_isopen(void);
1569 #include <freetds/popvis.h>
1570 int tdsdump_open(const char *filename);
1571 #include <freetds/pushvis.h>
1572 void tdsdump_close(void);
1573 void tdsdump_do_dump_buf(const char* file, unsigned int level_line,
1574  const char *msg, const void *buf, size_t length);
1575 void tdsdump_col(const TDSCOLUMN *col);
1576 #undef tdsdump_log
1577 void tdsdump_do_log(const char* file, unsigned int level_line,
1578  const char *fmt, ...)
1579 #if defined(__GNUC__) && __GNUC__ >= 2
1580 #if defined(__MINGW32__)
1581  __attribute__ ((__format__ (ms_printf, 3, 4)))
1582 #else
1583  __attribute__ ((__format__ (__printf__, 3, 4)))
1584 #endif
1585 #endif
1586 ;
1587 #define TDSDUMP_LOG_FAST if (TDS_UNLIKELY(tds_write_dump)) tdsdump_do_log
1588 #define tdsdump_log TDSDUMP_LOG_FAST
1589 #define TDSDUMP_BUF_FAST if (TDS_UNLIKELY(tds_write_dump)) tdsdump_do_dump_buf
1590 #define tdsdump_dump_buf TDSDUMP_BUF_FAST
1591 
1592 extern int tds_write_dump;
1593 extern int tds_debug_flags;
1594 extern int tds_g_append_mode;
1595 
1596 
1597 /* net.c */
1598 TDSERRNO tds_open_socket(TDSSOCKET * tds, struct addrinfo *ipaddr, unsigned int port, int timeout, int *p_oserr);
1600 int tds7_get_instance_ports(FILE *output, struct addrinfo *addr);
1601 int tds7_get_instance_port(struct addrinfo *addr, const char *instance);
1602 char *tds_prwsaerror(int erc);
1603 void tds_prwsaerror_free(char *s);
1604 ssize_t tds_connection_read(TDSSOCKET * tds, unsigned char *buf,
1605  size_t buflen);
1606 ssize_t tds_connection_write(TDSSOCKET *tds, const unsigned char *buf,
1607  size_t buflen, int final);
1608 #define TDSSELREAD POLLIN
1609 #define TDSSELWRITE POLLOUT
1610 int tds_select(TDSSOCKET * tds, unsigned tds_sel, int timeout_seconds);
1612 ssize_t tds_goodread(TDSSOCKET * tds, unsigned char *buf, size_t buflen);
1613 ssize_t tds_goodwrite(TDSSOCKET * tds, const unsigned char *buffer,
1614  size_t buflen);
1615 void tds_socket_flush(TDS_SYS_SOCKET sock);
1617 int tds_wakeup_init(TDSPOLLWAKEUP *wakeup);
1618 void tds_wakeup_close(TDSPOLLWAKEUP *wakeup);
1619 void tds_wakeup_send(TDSPOLLWAKEUP *wakeup, char cancel);
1620 static inline TDS_SYS_SOCKET tds_wakeup_get_fd(const TDSPOLLWAKEUP *wakeup)
1621 {
1622  return wakeup->s_signaled;
1623 }
1624 
1625 
1626 /* packet.c */
1628 TDSRET tds_write_packet(TDSSOCKET * tds, unsigned char final);
1629 #if ENABLE_ODBC_MARS
1633 #else
1635 #endif
1636 
1637 typedef struct tds_freeze {
1638  /** which socket we refer to */
1640  /** first packet frozen */
1642  /** position in pkt */
1643  unsigned pkt_pos;
1644  /** length size (0, 1, 2 or 4) */
1645  unsigned size_len;
1647 
1648 void tds_freeze(TDSSOCKET *tds, TDSFREEZE *freeze, unsigned size_len);
1649 unsigned int tds_freeze_written(TDSFREEZE *freeze);
1653 
1654 static void inline
1656 {
1657  tds->send_packet = pkt;
1658  tds->out_buf = pkt->buf + tds_packet_get_data_start(pkt);
1659 }
1660 
1661 /* Macros to allow some indentation of the packets.
1662  *
1663  * The 3 nested fake loops require some explanation:
1664  * - first is to allows to declare variables;
1665  * - second is to force using brackets;
1666  * - third is to avoids that a break inside will skip the close.
1667  */
1668 #define TDS_START_LEN_GENERIC(tds_socket, len) do { \
1669  TDSFREEZE current_freeze[1]; \
1670  tds_freeze((tds_socket), current_freeze, (len)); do { do
1671 #define TDS_END_LEN while(0); } while(tds_freeze_close(current_freeze), 0); } while(0);
1672 
1673 #define TDS_START_LEN_TINYINT(tds_socket) TDS_START_LEN_GENERIC(tds_socket, 1)
1674 #define TDS_START_LEN_USMALLINT(tds_socket) TDS_START_LEN_GENERIC(tds_socket, 2)
1675 #define TDS_START_LEN_UINT(tds_socket) TDS_START_LEN_GENERIC(tds_socket, 4)
1676 
1677 /* vstrbuild.c */
1678 TDSRET tds_vstrbuild(char *buffer, int buflen, int *resultlen, const char *text, int textlen, const char *formats, int formatlen,
1679  va_list ap);
1680 
1681 
1682 /* numeric.c */
1683 char *tds_money_to_string(const TDS_MONEY * money, char *s, bool use_2_digits);
1684 TDS_INT tds_numeric_to_string(const TDS_NUMERIC * numeric, char *s);
1685 TDS_INT tds_numeric_change_prec_scale(TDS_NUMERIC * numeric, unsigned char new_prec, unsigned char new_scale);
1686 
1687 
1688 /* getmac.c */
1689 void tds_getmac(TDS_SYS_SOCKET s, unsigned char mac[6]);
1690 
1691 
1692 /* challenge.c */
1693 #ifndef HAVE_SSPI
1696 #else
1697 TDSAUTHENTICATION * tds_sspi_get_auth(TDSSOCKET * tds);
1698 #endif
1700 
1701 
1702 /* random.c */
1703 void tds_random_buffer(unsigned char *out, int len);
1704 
1705 
1706 /* sec_negotiate.c */
1708 static inline
1709 void tds5_negotiate_set_msg_type(TDSAUTHENTICATION * tds_auth, unsigned msg_type)
1710 {
1711  if (tds_auth)
1712  tds_auth->msg_type = msg_type;
1713 }
1714 
1715 
1716 /* bulk.c */
1717 
1718 /** bcp direction */
1720 {
1723  TDS_BCP_QUERYOUT = 3
1724 };
1725 
1726 typedef struct tds5_colinfo
1727 {
1733 
1737 
1738 struct tds_bcpinfo
1739 {
1740  const char *hint;
1741  void *parent;
1742  DSTR tablename;
1752  TDS_INT next_col;
1755 };
1756 
1758 typedef TDSRET (*tds_bcp_get_col_data) (TDSBCPINFO *bulk, TDSCOLUMN *bcpcol, int offset);
1759 typedef void (*tds_bcp_null_error) (TDSBCPINFO *bulk, int index, int offset);
1761 TDSRET tds_bcp_done(TDSSOCKET *tds, int *rows_copied);
1764 
1765 TDSRET tds_bcp_fread(TDSSOCKET * tds, TDSICONV * conv, FILE * stream,
1766  const char *terminator, size_t term_len, char **outbuf, size_t * outbytes);
1767 
1768 TDSRET tds_writetext_start(TDSSOCKET *tds, const char *objname, const char *textptr, const char *timestamp, int with_log, TDS_UINT size);
1771 
1772 
1773 static inline
1774 bool tds_capability_enabled(const TDS_CAPABILITY_TYPE *cap, unsigned cap_num)
1775 {
1776  return (cap->values[sizeof(cap->values)-1-(cap_num>>3)] >> (cap_num&7)) & 1;
1777 }
1778 #define tds_capability_has_req(conn, cap) \
1779  tds_capability_enabled(&conn->capabilities.types[0], cap)
1780 #define tds_capability_has_res(conn, cap) \
1781  tds_capability_enabled(&conn->capabilities.types[1], cap)
1782 
1783 #define IS_TDS42(x) (x->tds_version==0x402)
1784 #define IS_TDS46(x) (x->tds_version==0x406)
1785 #define IS_TDS50(x) (x->tds_version==0x500)
1786 #define IS_TDS70(x) (x->tds_version==0x700)
1787 #define IS_TDS71(x) (x->tds_version==0x701)
1788 #define IS_TDS72(x) (x->tds_version==0x702)
1789 #define IS_TDS73(x) (x->tds_version==0x703)
1790 
1791 #define IS_TDS50_PLUS(x) ((x)->tds_version>=0x500)
1792 #define IS_TDS7_PLUS(x) ((x)->tds_version>=0x700)
1793 #define IS_TDS71_PLUS(x) ((x)->tds_version>=0x701)
1794 #define IS_TDS72_PLUS(x) ((x)->tds_version>=0x702)
1795 #define IS_TDS73_PLUS(x) ((x)->tds_version>=0x703)
1796 #define IS_TDS74_PLUS(x) ((x)->tds_version>=0x704)
1797 
1798 #define TDS_MAJOR(x) ((x)->tds_version >> 8)
1799 #define TDS_MINOR(x) ((x)->tds_version & 0xff)
1800 
1801 #define IS_TDSDEAD(x) (((x) == NULL) || (x)->state == TDS_DEAD)
1802 
1803 /** Check if product is Sybase (such as Adaptive Server Enterrprice). x should be a TDSSOCKET*. */
1804 #define TDS_IS_SYBASE(x) (!((x)->conn->product_version & 0x80000000u))
1805 /** Check if product is Microsft SQL Server. x should be a TDSSOCKET*. */
1806 #define TDS_IS_MSSQL(x) (((x)->conn->product_version & 0x80000000u)!=0)
1807 
1808 /** Calc a version number for mssql. Use with TDS_MS_VER(7,0,842).
1809  * For test for a range of version you can use check like
1810  * if (tds->product_version >= TDS_MS_VER(7,0,0) && tds->product_version < TDS_MS_VER(8,0,0)) */
1811 #define TDS_MS_VER(maj,min,x) (0x80000000u|((maj)<<24)|((min)<<16)|(x))
1812 
1813 /* TODO test if not similar to ms one*/
1814 /** Calc a version number for Sybase. */
1815 #define TDS_SYB_VER(maj,min,x) (((maj)<<24)|((min)<<16)|(x)<<8)
1816 
1817 #ifdef __cplusplus
1818 #if 0
1819 {
1820 #endif
1821 }
1822 #endif
1823 
1824 #include <freetds/popvis.h>
1825 
1826 #define TDS_PUT_INT(tds,v) tds_put_int((tds), ((TDS_INT)(v)))
1827 #define TDS_PUT_SMALLINT(tds,v) tds_put_smallint((tds), ((TDS_SMALLINT)(v)))
1828 #define TDS_PUT_BYTE(tds,v) tds_put_byte((tds), ((unsigned char)(v)))
1829 
1830 #endif /* _tds_h_ */
#define head
Definition: ct_nlmzip_i.h:138
static const char si[8][64]
Definition: des.c:146
std::ofstream out("events_result.xml")
main entry point for tests
static CS_CONNECTION * conn
Definition: ct_dynamic.c:25
static const int timeout_seconds
Definition: timeout.c:13
#define TDS_SP_CURSOROPEN
Definition: proto.h:140
#define TDS_SP_PREPEXEC
Definition: proto.h:151
TDS_OPTION_CMD
options that can be sent with a TDS_OPTIONCMD token
Definition: proto.h:263
#define TDS_SP_UNPREPARE
Definition: proto.h:153
#define TDS_SP_CURSORCLOSE
Definition: proto.h:147
TDS_SERVER_TYPE
Definition: proto.h:161
#define TDS_SP_CURSOREXECUTE
Definition: proto.h:142
#define TDS_SP_CURSOR
Definition: proto.h:139
#define TDS_SP_CURSORPREPARE
Definition: proto.h:141
#define TDS_SP_PREPEXECRPC
Definition: proto.h:152
TDS_OPTION
Definition: proto.h:271
#define TDS_SP_CURSORPREPEXEC
Definition: proto.h:143
#define TDS_SP_EXECUTE
Definition: proto.h:150
#define TDS_SP_PREPARE
Definition: proto.h:149
#define TDS_SP_CURSORUNPREPARE
Definition: proto.h:144
#define TDS_SP_CURSORFETCH
Definition: proto.h:145
#define TDS_SP_CURSOROPTION
Definition: proto.h:146
#define TDS_SP_EXECUTESQL
Definition: proto.h:148
int TDS_SYS_SOCKET
#define TDS_WUR
Definition: tds.h:398
int tds_iconv_alloc(TDSCONNECTION *conn)
Allocate iconv stuff.
Definition: iconv.c:286
TDSRET tds_func_get_data(TDSSOCKET *tds, TDSCOLUMN *col)
Definition: tds.h:701
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)
Definition: tds_types.h:124
TDSRET tds_func_put_info(TDSSOCKET *tds, TDSCOLUMN *col)
Definition: tds.h:704
bool tds_set_user(TDSLOGIN *tds_login, const char *username)
Definition: login.c:100
void tdsdump_on(void)
Turn logging back on.
Definition: log.c:93
bool tds_set_server(TDSLOGIN *tds_login, const char *server)
Set the servername in a TDSLOGIN structure.
Definition: login.c:129
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...
Definition: util.c:414
struct tds_capability_type TDS_CAPABILITY_TYPE
Definition: tds.h:56
tds_operations
Definition: tds.h:872
@ TDS_OP_CURSORPREPARE
Definition: tds.h:878
@ TDS_OP_CURSORFETCH
Definition: tds.h:882
@ TDS_OP_EXECUTESQL
Definition: tds.h:885
@ TDS_OP_DYN_DEALLOC
Definition: tds.h:893
@ TDS_OP_CURSOROPEN
Definition: tds.h:877
@ TDS_OP_PREPEXECRPC
Definition: tds.h:889
@ TDS_OP_PREPEXEC
Definition: tds.h:888
@ TDS_OP_UNPREPARE
Definition: tds.h:890
@ TDS_OP_CURSORCLOSE
Definition: tds.h:884
@ TDS_OP_CURSOREXECUTE
Definition: tds.h:879
@ TDS_OP_CURSOROPTION
Definition: tds.h:883
@ TDS_OP_CURSOR
Definition: tds.h:876
@ TDS_OP_CURSORPREPEXEC
Definition: tds.h:880
@ TDS_OP_CURSORUNPREPARE
Definition: tds.h:881
@ TDS_OP_NONE
Definition: tds.h:873
@ TDS_OP_PREPARE
Definition: tds.h:886
@ TDS_OP_EXECUTE
Definition: tds.h:887
TDS_STATE tds_set_state(TDSSOCKET *tds, TDS_STATE state)
Set state of TDS connection, with logging and checking.
Definition: util.c:65
struct tds_bcpcoldata BCPCOLDATA
Definition: tds.h:54
enum tds_cursor_operation TDS_CURSOR_OPERATION
tds_sysdep_int32_type TDS_INT
Definition: tds.h:149
struct tds_compiletime_settings TDS_COMPILETIME_SETTINGS
A structure to hold all the compile-time settings.
int tds_g_append_mode
Definition: log.c:54
struct tds_result_info TDSRESULTINFO
Definition: tds.h:69
tds_token_flags
Definition: tds.h:249
@ TDS_RETURN_ROWFMT
Definition: tds.h:252
@ TDS_STOPAT_COMPUTEFMT
Definition: tds.h:253
@ TDS_STOPAT_ROW
Definition: tds.h:256
@ TDS_HANDLE_ALL
Definition: tds.h:250
@ TDS_TOKEN_TRAILING
Definition: tds.h:262
@ TDS_STOPAT_OTHERS
Definition: tds.h:251
@ TDS_STOPAT_MSG
Definition: tds.h:259
@ TDS_STOPAT_ROWFMT
Definition: tds.h:252
@ TDS_TOKEN_RESULTS
Definition: tds.h:261
@ TDS_RETURN_PROC
Definition: tds.h:258
@ TDS_RETURN_DONE
Definition: tds.h:255
@ TDS_RETURN_COMPUTEFMT
Definition: tds.h:253
@ TDS_STOPAT_COMPUTE
Definition: tds.h:257
int tdsdump_open(const char *filename)
Create and truncate a human readable dump file for the TDS traffic.
Definition: log.c:126
struct tds_variant TDSVARIANT
Store variant informations.
bool tds_set_library(TDSLOGIN *tds_login, const char *library)
Definition: login.c:156
@ TDS_TYPEFLAG_UNICODE
Definition: tds.h:427
@ TDS_TYPEFLAG_INVALID
Definition: tds.h:421
@ TDS_TYPEFLAG_NULLABLE
Definition: tds.h:422
@ TDS_TYPEFLAG_FIXED
Definition: tds.h:423
@ TDS_TYPEFLAG_ASCII
Definition: tds.h:426
@ TDS_TYPEFLAG_VARIABLE
Definition: tds.h:424
@ TDS_TYPEFLAG_COLLATE
Definition: tds.h:425
@ TDS_TYPEFLAG_DATETIME
Definition: tds.h:429
@ TDS_TYPEFLAG_NUMERIC
Definition: tds.h:428
TDS_ICONV_ENTRY
Definition: tds.h:1108
@ client2server_chardata
Definition: tds.h:1110
@ client2ucs2
Definition: tds.h:1109
@ initial_char_conv_count
Definition: tds.h:1111
struct tds_message TDSMESSAGE
void tdsdump_close(void)
Close the TDS dump log file.
Definition: log.c:207
tds_cursor_operation
Definition: tds.h:986
@ TDS_CURSOR_DELETE
Definition: tds.h:989
@ TDS_CURSOR_INSERT
Definition: tds.h:990
@ TDS_CURSOR_POSITION
Definition: tds.h:987
@ TDS_CURSOR_UPDATE
Definition: tds.h:988
void tds_set_column_type(TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type)
Set type of column initializing all dependency.
Definition: data.c:225
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.
Definition: log.c:270
char * tds_money_to_string(const TDS_MONEY *money, char *s)
Definition: numeric.c:64
struct tds_headers TDSHEADERS
struct tdsdaterec TDSDATEREC
Used by tds_datecrack.
const char STD_DATETIME_FMT[]
Definition: config.c:93
struct tds_env TDSENV
Definition: tds.h:63
struct tds_capabilities TDS_CAPABILITIES
Definition: tds.h:55
int tds_write_dump
Tell if TDS debug logging is turned on or off.
Definition: log.c:57
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.
Definition: tds_types.h:9
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...
Definition: numeric.c:41
char * tds_prwsaerror(int erc)
void(* tds_bcp_null_error)(TDSBCPINFO *bulk, int index, int offset)
Definition: tds.h:1677
struct tds_locale TDSLOCALE
Definition: tds.h:64
struct tds_cursor_status TDS_CURSOR_STATUS
Definition: tds.h:60
struct tds_multiple TDSMULTIPLE
tds_sysdep_real64_type TDS_FLOAT
Definition: tds.h:152
TDSRET tds_bcp_start_copy_in(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
Start bulk copy to server \tds.
Definition: bulk.c:980
int tds_connect_and_login(TDSSOCKET *tds, TDSLOGIN *login)
Definition: login.c:657
TDSRESULTINFO TDSPARAMINFO
Definition: tds.h:70
tds_sysdep_int64_type TDS_INT8
Definition: tds.h:153
TDS_INT tds_numeric_to_string(const TDS_NUMERIC *numeric, char *s)
Definition: numeric.c:94
tds_sysdep_intptr_type TDS_INTPTR
Definition: tds.h:155
unsigned char TDS_UCHAR
Definition: tds.h:145
struct tds_poll_wakeup TDSPOLLWAKEUP
Definition: tds.h:67
void(* TDSCONFPARSE)(const char *option, const char *value, void *param)
Definition: tds.h:1304
bool tds_set_app(TDSLOGIN *tds_login, const char *application)
Definition: login.c:112
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....
Definition: tds_types.h:57
void tdsdump_do_log(const char *file, unsigned int level_line, const char *fmt,...)
Write a message to the debug log.
Definition: log.c:370
void tds_set_packet(TDSLOGIN *tds_login, int packet_size)
Definition: login.c:73
union tds_option_arg TDS_OPTION_ARG
tds_cursor_fetch
Definition: tds.h:994
@ TDS_CURSOR_FETCH_RELATIVE
Definition: tds.h:1000
@ TDS_CURSOR_FETCH_PREV
Definition: tds.h:996
@ TDS_CURSOR_FETCH_NEXT
Definition: tds.h:995
@ TDS_CURSOR_FETCH_FIRST
Definition: tds.h:997
@ TDS_CURSOR_FETCH_LAST
Definition: tds.h:998
@ TDS_CURSOR_FETCH_ABSOLUTE
Definition: tds.h:999
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.
Definition: bulk.c:1211
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
Definition: tds.h:968
@ TDS_CURSOR_STATE_UNACTIONED
Definition: tds.h:969
@ TDS_CURSOR_STATE_REQUESTED
Definition: tds.h:970
@ TDS_CURSOR_STATE_ACTIONED
Definition: tds.h:972
@ TDS_CURSOR_STATE_SENT
Definition: tds.h:971
tds_sysdep_real32_type TDS_REAL
Definition: tds.h:151
int tds_debug_flags
Definition: log.c:53
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().
Definition: bulk.c:1141
TDSRET tds_bcp_start(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
Start sending BCP data to server.
Definition: bulk.c:928
bool tds_set_host(TDSLOGIN *tds_login, const char *hostname)
Definition: login.c:106
struct tds_dynamic TDSDYNAMIC
Definition: tds.h:62
void tds_prwsaerror_free(char *s)
unsigned char TDS_TINYINT
Definition: tds.h:146
void tds_set_param_type(TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type)
Set type of column initializing all dependency.
Definition: data.c:247
tds_states
values for tds->state
Definition: tds.h:862
@ TDS_PENDING
cilent is waiting for data
Definition: tds.h:866
@ TDS_SENDING
client would send data
Definition: tds.h:865
@ TDS_READING
client is reading data
Definition: tds.h:867
@ TDS_WRITING
client is writing data
Definition: tds.h:864
@ TDS_IDLE
no data expected
Definition: tds.h:863
@ TDS_DEAD
no connection
Definition: tds.h:868
TDS_SERVER_TYPE tds_get_cardinal_type(TDS_SERVER_TYPE datatype, int usertype)
Definition: data.c:351
tds_sysdep_int16_type TDS_SMALLINT
Definition: tds.h:147
TDSERRNO
Definition: tds.h:295
@ TDSEICONVO
Definition: tds.h:299
@ TDSEOOB
Definition: tds.h:317
@ TDSEICONVI
Definition: tds.h:300
@ TDSEFCON
Definition: tds.h:304
@ TDSEICONV2BIG
Definition: tds.h:301
@ TDSESYNC
Definition: tds.h:303
@ TDSEUMSG
Definition: tds.h:324
@ TDSEICONVAVAIL
Definition: tds.h:298
@ TDSECAPTYP
Definition: tds.h:325
@ TDSEBTOK
Definition: tds.h:316
@ TDSEPORTINSTANCE
Definition: tds.h:302
@ TDSEVERDOWN
Definition: tds.h:296
@ TDSECONF
Definition: tds.h:326
@ TDSEPWD
Definition: tds.h:313
@ TDSEBPROBADTYP
Definition: tds.h:327
@ TDSESEOF
Definition: tds.h:314
@ TDSEUTDS
Definition: tds.h:320
@ TDSEEUNR
Definition: tds.h:321
@ TDSECONN
Definition: tds.h:309
@ TDSEREAD
Definition: tds.h:306
@ TDSECLOSEIN
Definition: tds.h:328
@ TDSECLOS
Definition: tds.h:318
@ TDSETIME
Definition: tds.h:305
@ TDSESOCK
Definition: tds.h:308
@ TDSEINTF
Definition: tds.h:311
@ TDSEICONVIU
Definition: tds.h:297
@ TDSEMEM
Definition: tds.h:310
@ TDSEOK
Definition: tds.h:295
@ TDSEUHST
Definition: tds.h:312
@ TDSEWRIT
Definition: tds.h:307
@ TDSECAP
Definition: tds.h:322
@ TDSENEG
Definition: tds.h:323
@ TDSEUSCT
Definition: tds.h:319
@ TDSERPND
Definition: tds.h:315
void tds_set_port(TDSLOGIN *tds_login, int port)
Definition: login.c:79
struct tds_packet TDSPACKET
Definition: tds.h:66
void tds_set_version(TDSLOGIN *tds_login, TDS_TINYINT major_ver, TDS_TINYINT minor_ver)
Definition: login.c:67
struct tds_upd_col TDSUPDCOL
struct tds_login TDSLOGIN
Definition: tds.h:65
TDSRET(* tds_bcp_get_col_data)(TDSBCPINFO *bulk, TDSCOLUMN *bcpcol, int offset)
Definition: tds.h:1676
char TDS_CHAR
Definition: tds.h:144
tds_end
Flags returned in TDS_DONE token.
Definition: tds.h:269
@ TDS_DONE_TRAN_ABORT
Definition: tds.h:285
@ TDS_DONE_CANCELLED
acknowledging an attention command (usually a cancel)
Definition: tds.h:276
@ TDS_DONE_STMT_ABORT
Definition: tds.h:284
@ TDS_DONE_TRAN_PROGRESS
Definition: tds.h:283
@ TDS_DONE_MORE_RESULTS
more results follow
Definition: tds.h:271
@ TDS_DONE_TRAN_SUCCEED
Definition: tds.h:282
@ TDS_DONE_NO_TRAN
Definition: tds.h:281
@ TDS_DONE_SRVERROR
SQL server server error.
Definition: tds.h:278
@ TDS_DONE_FINAL
final result set, command completed successfully.
Definition: tds.h:270
@ TDS_DONE_ERROR
error occurred
Definition: tds.h:272
@ TDS_DONE_EVENT
Definition: tds.h:277
@ TDS_DONE_INXACT
transaction in progress
Definition: tds.h:273
@ TDS_DONE_PROC
results are from a stored procedure
Definition: tds.h:274
@ TDS_DONE_COUNT
count field in packet is valid
Definition: tds.h:275
tds_sysdep_uint64_type TDS_UINT8
Definition: tds.h:154
void tdsdump_col(const TDSCOLUMN *col)
Write a column value to the debug log.
Definition: log.c:424
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.
Definition: bulk.c:1249
TDSRET tds_func_get_info(TDSSOCKET *tds, TDSCOLUMN *col)
Definition: tds.h:700
int(* err_handler_t)(const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *)
Definition: tds.h:1095
int TDSRET
Definition: tds.h:201
tds_encryption_level
Definition: tds.h:355
@ TDS_ENCRYPTION_REQUEST
Definition: tds.h:356
@ TDS_ENCRYPTION_OFF
Definition: tds.h:356
@ TDS_ENCRYPTION_REQUIRE
Definition: tds.h:356
tds_sysdep_uint16_type TDS_USMALLINT
Definition: tds.h:148
int tdserror(const TDSCONTEXT *tds_ctx, TDSSOCKET *tds, int msgno, int errnum)
Call the client library's error handler (for library-generated errors only)
Definition: util.c:322
int tdsdump_isopen(void)
Definition: log.c:111
enum tds_states TDS_STATE
values for tds->state
TDSRET tds_writetext_end(TDSSOCKET *tds)
Finish sending writetext data.
Definition: bulk.c:1266
void tdsdump_off(void)
Temporarily turn off logging.
Definition: log.c:81
TDSRET tds_bcp_init(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
Initialize BCP information.
Definition: bulk.c:88
enum tds_cursor_fetch TDS_CURSOR_FETCH
const unsigned char tds_type_flags_ms[256]
Definition: tds_types.h:189
struct tds_authentication TDSAUTHENTICATION
Definition: tds.h:53
TDS_INT tds_numeric_change_prec_scale(TDS_NUMERIC *numeric, unsigned char new_prec, unsigned char new_scale)
Definition: numeric.c:241
TDSRET tds_func_put_data(TDSSOCKET *tds, TDSCOLUMN *col, int bcp7)
Definition: tds.h:705
TDSAUTHENTICATION * tds_gss_get_auth(TDSSOCKET *tds)
TDS_MULTIPLE_TYPE
Definition: tds.h:1082
@ TDS_MULTIPLE_EXECUTE
Definition: tds.h:1084
@ TDS_MULTIPLE_RPC
Definition: tds.h:1085
@ TDS_MULTIPLE_QUERY
Definition: tds.h:1083
tds_bcp_directions
bcp direction
Definition: tds.h:1653
@ TDS_BCP_OUT
Definition: tds.h:1655
@ TDS_BCP_IN
Definition: tds.h:1654
@ TDS_BCP_QUERYOUT
Definition: tds.h:1656
TDSRET tds_vstrbuild(char *buffer, int buflen, int *resultlen, const char *text, int textlen, const char *formats, int formatlen, va_list ap)
Definition: vstrbuild.c:80
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.
Definition: bulk.c:344
TDSRET tds_bcp_done(TDSSOCKET *tds, int *rows_copied)
Tell we finished sending BCP data to server \tds.
Definition: bulk.c:898
TDS_INT tds_func_row_len(TDSCOLUMN *col)
Definition: tds.h:702
struct tds_encoding TDS_ENCODING
Information relevant to libiconv.
tds_sysdep_uint32_type TDS_UINT
Definition: tds.h:150
void tds_random_buffer(unsigned char *out, int len)
Definition: random.c:40
struct tds_column_funcs TDSCOLUMNFUNCS
Definition: tds.h:57
tds_token_results
Definition: tds.h:233
@ TDS_TOKEN_RES_COMPUTE
Definition: tds.h:240
@ TDS_TOKEN_RES_OTHERS
Definition: tds.h:234
@ TDS_TOKEN_RES_PARAMFMT
Definition: tds.h:237
@ TDS_TOKEN_RES_ROWFMT
Definition: tds.h:235
@ TDS_TOKEN_RES_PROC
Definition: tds.h:241
@ TDS_TOKEN_RES_ENV
Definition: tds.h:243
@ TDS_TOKEN_RES_COMPUTEFMT
Definition: tds.h:236
@ TDS_TOKEN_RES_DONE
Definition: tds.h:238
@ TDS_TOKEN_RES_MSG
Definition: tds.h:242
@ TDS_TOKEN_RES_ROW
Definition: tds.h:239
void tds_getmac(TDS_SYS_SOCKET s, unsigned char mac[6])
Definition: getmac.c:45
int tds_func_check(const TDSCOLUMN *col)
Definition: tds.h:706
enum tds_operations TDS_OPERATION
bool tds_set_client_charset(TDSLOGIN *tds_login, const char *charset)
Definition: login.c:162
TDSLOCALE * tds_get_locale(void)
Get locale information.
Definition: locale.c:50
void tds_swap_bytes(void *buf, int bytes)
Definition: util.c:185
bool tds_set_language(TDSLOGIN *tds_login, const char *language)
Definition: login.c:168
void tds_set_bulk(TDSLOGIN *tds_login, TDS_TINYINT enabled)
Definition: login.c:94
bool tds_set_passwd(TDSLOGIN *tds_login, const char *password)
Definition: login.c:85
enum tds_encryption_level TDS_ENCRYPTION_LEVEL
struct tds_cursor TDSCURSOR
Definition: tds.h:59
@ TDS_CUR_ISTAT_ROWCNT
Definition: tds.h:339
@ TDS_CUR_ISTAT_UNUSED
Definition: tds.h:333
@ TDS_CUR_ISTAT_CLOSED
Definition: tds.h:336
@ TDS_CUR_ISTAT_DEALLOC
Definition: tds.h:340
@ TDS_CUR_ISTAT_UPDATABLE
Definition: tds.h:338
@ TDS_CUR_ISTAT_RDONLY
Definition: tds.h:337
@ TDS_CUR_ISTAT_OPEN
Definition: tds.h:335
@ TDS_CUR_ISTAT_DECLARED
Definition: tds.h:334
int tds_thread_id
Definition: thread.h:277
#define check(s)
Definition: describecol2.c:21
static int type
Definition: getdata.c:31
static SQLCHAR output[256]
Definition: print.c:5
static const char * str(char *buf, int n)
Definition: stats.c:84
static const char * column
Definition: stats.c:23
int offset
Definition: replacements.h:160
#define addrinfo
Definition: replacements.h:98
#define option
static TDSICONV * conv
Definition: charconv.c:168
static TDSRET convert(TDSSOCKET *tds, TDSICONV *conv, TDS_ICONV_DIRECTION direction, const char *from, size_t from_len, char *dest, size_t *dest_len)
Definition: charconv.c:57
static TDSSOCKET * tds
Definition: collations.c:37
static TDSLOGIN * login
Definition: dataread.c:31
#define tds_sysdep_real32_type
#define tds_sysdep_real64_type
#define TDS_DBG_LOGIN
Definition: tds.h:851
#define TDS_TOKEN_FLAG(flag)
Definition: tds.h:243
struct tds_tvp_row TDS_TVP_ROW
struct tds5_colinfo TDS5COLINFO
static bool tds_capability_enabled(const TDS_CAPABILITY_TYPE *cap, unsigned cap_num)
Definition: tds.h:1774
static void tds_release_cur_dyn(TDSSOCKET *tds)
Definition: tds.h:1388
#define tds_packet_get_data_start(pkt)
Definition: tds.h:1110
static bool is_tds_type_valid(int type)
Definition: tds.h:424
unsigned int tds_gettime_ms(void)
Definition: util.c:209
struct tds_freeze TDSFREEZE
static void tds_set_current_send_packet(TDSSOCKET *tds, TDSPACKET *pkt)
Definition: tds.h:1655
struct tdsdump_off_item TDSDUMP_OFF_ITEM
@ TDSEINPROGRESS
Definition: tds.h:294
#define tds_convert_string_free(original, converted)
Definition: tds.h:1477
@ TDS_TYPEFLAG_VARIANT
Definition: tds.h:388
@ TDS_TYPEFLAG_BINARY
Definition: tds.h:385
TDSRET tds5_gss_send(TDSSOCKET *tds)
@ TDS_ENCRYPTION_DEFAULT
Definition: tds.h:354
struct tds_tvp TDS_TVP
#define TDS_SUCCESS
Definition: tds.h:198
#define TDS_MAX_CAPABILITY
Definition: tds.h:430
static TDS_SYS_SOCKET tds_wakeup_get_fd(const TDSPOLLWAKEUP *wakeup)
Definition: tds.h:1620
char * tds_get_home_file(const char *file)
Return filename from HOME directory.
Definition: config.c:325
#define tds_mutex
Definition: thread.h:336
Uint8 uint64_t
Int4 int32_t
Int2 int16_t
Int8 int64_t
unsigned char uint8_t
Uint2 uint16_t
Uint4 uint32_t
#define tds_append_syn
#define tds_append_cancel
#define tds_append_fin
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.
Definition: challenge.c:726
int tds_read_conf_file(TDSLOGIN *login, const char *server)
Read configuration info for given server return 0 on error.
Definition: config.c:346
TDSRET tds_lookup_host_set(const char *servername, struct addrinfo **addr)
Definition: config.c:1014
void tds_parse_conf_section(const char *option, const char *value, void *param)
Definition: config.c:593
TDSRET tds_set_interfaces_file_loc(const char *interfloc)
Set the full name of interface file.
Definition: config.c:968
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)
Definition: config.c:503
const TDS_COMPILETIME_SETTINGS * tds_get_compiletime_settings(void)
Return a structure capturing the compile-time settings provided to the configure script.
Definition: config.c:1310
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...
Definition: config.c:138
struct addrinfo * tds_lookup_host(const char *servername)
Get the IP address for a hostname.
Definition: config.c:994
int tds_config_boolean(const char *option, const char *value, TDSLOGIN *login)
Definition: config.c:460
int tds_parse_boolean(const char *value, int default_value)
Definition: config.c:448
void tds_fix_login(TDSLOGIN *login)
Fix configuration after reading it.
Definition: config.c:285
TDS_USMALLINT * tds_config_verstr(const char *tdsver, TDSLOGIN *login)
Set TDS version from given string.
Definition: config.c:930
TDSRET tds_iconv_open(TDSCONNECTION *conn, const char *charset, int use_utf16)
Definition: iconv.c:364
void tds_iconv_close(TDSCONNECTION *conn)
Definition: iconv.c:535
void tds_srv_charset_changed(TDSCONNECTION *conn, const char *charset)
Definition: iconv.c:850
void tds7_srv_charset_changed(TDSCONNECTION *conn, int sql_collate, int lcid)
Definition: iconv.c:840
void tds_iconv_free(TDSCONNECTION *conn)
Definition: iconv.c:546
TDSICONV * tds_iconv_from_collate(TDSCONNECTION *conn, TDS_UCHAR collate[5])
Get iconv information from a LCID (to support different column encoding under MSSQL2K)
Definition: iconv.c:1256
TDSRET tds_datecrack(TDS_INT datetype, const void *di, TDSDATEREC *dr)
Convert from db date format to a structured date format.
Definition: convert.c:3195
const char tds_hex_digits[]
Definition: convert.c:155
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
TDSRESULTINFO * tds_alloc_results(TDS_USMALLINT num_cols)
Definition: mem.c:461
TDSRET tds_alloc_compute_row(TDSCOMPUTEINFO *res_info)
Definition: mem.c:575
void tds_free_bcp_column_data(BCPCOLDATA *coldata)
Definition: mem.c:1844
TDSRET tds_alloc_row(TDSRESULTINFO *res_info)
Allocate space for row store return NULL on out of memory.
Definition: mem.c:533
TDSLOGIN * tds_alloc_login(int use_environment)
Definition: mem.c:983
void tds_detach_results(TDSRESULTINFO *info)
Detach result info from it current socket.
Definition: mem.c:497
TDSPACKET * tds_realloc_packet(TDSPACKET *packet, unsigned len)
Definition: mem.c:1095
void * tds_alloc_param_data(TDSCOLUMN *curparam)
Allocate data for a parameter.
Definition: mem.c:373
TDSLOGIN * tds_init_login(TDSLOGIN *login, TDSLOCALE *locale)
Initialize login structure with locale information and other stuff for connection.
Definition: mem.c:809
void tds_deinit_tvp(TDS_TVP *table)
Definition: mem.c:1930
TDSDYNAMIC * tds_alloc_dynamic(TDSCONNECTION *conn, const char *id)
Allocate a dynamic statement.
Definition: mem.c:160
TDSSOCKET * tds_realloc_socket(TDSSOCKET *tds, unsigned int bufsize)
Definition: mem.c:1350
char * tds_alloc_lookup_sqlstate(TDSSOCKET *tds, int msgno)
Definition: mem.c:1528
TDSPACKET * tds_alloc_packet(void *buf, unsigned len)
Definition: mem.c:1077
TDSCONTEXT * tds_alloc_context(void *parent)
Definition: mem.c:719
void tds_free_param_results(TDSPARAMINFO *param_info)
Definition: mem.c:581
void tds_free_param_result(TDSPARAMINFO *param_info)
Delete latest parameter.
Definition: mem.c:320
TDSLOCALE * tds_alloc_locale(void)
Definition: mem.c:741
TDSPARAMINFO * tds_alloc_param_result(TDSPARAMINFO *old_param)
Adds a output parameter to TDSPARAMINFO.
Definition: mem.c:284
void tds_set_current_results(TDSSOCKET *tds, TDSRESULTINFO *info)
Definition: mem.c:482
void tds_free_all_results(TDSSOCKET *tds)
Definition: mem.c:663
TDSBCPINFO * tds_alloc_bcpinfo(void)
Definition: mem.c:1783
void * tds_realloc(void **pp, size_t new_size)
Reallocate a pointer and update it if success.
Definition: mem.c:1908
void tds_free_context(TDSCONTEXT *locale)
Definition: mem.c:742
void tds_release_cursor(TDSCURSOR **pcursor)
Definition: mem.c:955
void tds_cursor_deallocated(TDSCONNECTION *conn, TDSCURSOR *cursor)
Definition: mem.c:927
TDSCURSOR * tds_alloc_cursor(TDSSOCKET *tds, const char *name, size_t namelen, const char *query, size_t querylen)
Definition: mem.c:888
void tds_free_row(TDSRESULTINFO *res_info, unsigned char *row)
Definition: mem.c:612
BCPCOLDATA * tds_alloc_bcp_column_data(unsigned int column_size)
Definition: mem.c:1827
TDSSOCKET * tds_alloc_socket(TDSCONTEXT *context, unsigned int bufsize)
Definition: mem.c:1332
void tds_free_input_params(TDSDYNAMIC *dyn)
Frees all allocated input parameters of a dynamic statement.
Definition: mem.c:206
void tds_release_dynamic(TDSDYNAMIC **dyn)
Frees dynamic statement.
Definition: mem.c:253
void tds_dynamic_deallocated(TDSCONNECTION *conn, TDSDYNAMIC *dyn)
Definition: mem.c:221
void tds_free_bcpinfo(TDSBCPINFO *bcpinfo)
Definition: mem.c:1893
void tds_free_login(TDSLOGIN *login)
Definition: mem.c:1040
void tds_free_msg(TDSMESSAGE *message)
Definition: mem.c:1484
void tds_free_locale(TDSLOCALE *locale)
Definition: mem.c:1459
char * tds_alloc_client_sqlstate(int msgno)
Definition: mem.c:1502
void tds_deinit_bcpinfo(TDSBCPINFO *bcpinfo)
Definition: mem.c:1868
void tds_free_packets(TDSPACKET *packet)
Definition: mem.c:1106
void tds_free_results(TDSRESULTINFO *res_info)
Definition: mem.c:622
TDSCOMPUTEINFO ** tds_alloc_compute_results(TDSSOCKET *tds, TDS_USMALLINT num_cols, TDS_USMALLINT by_cols)
Definition: mem.c:431
void tds_free_socket(TDSSOCKET *tds)
Definition: mem.c:1418
void tds_wakeup_send(TDSPOLLWAKEUP *wakeup, char cancel)
Definition: net.c:850
unsigned char tds_get_byte(TDSSOCKET *tds)
Return a single byte from the input buffer \tds.
Definition: read.c:72
unsigned int tds_freeze_written(TDSFREEZE *freeze)
Compute how many bytes has been written from freeze.
Definition: packet.c:935
int tds_put_string(TDSSOCKET *tds, const char *buf, int len)
Output a string to wire automatic translate string to unicode if needed.
Definition: write.c:97
unsigned char tds_peek(TDSSOCKET *tds)
Reads a byte from the TDS stream without removing it \tds.
Definition: read.c:100
TDSRET tds_freeze_close_len(TDSFREEZE *freeze, int32_t size)
Stop keeping data for this specific freeze.
Definition: packet.c:1031
int tds_socket_set_nonblocking(TDS_SYS_SOCKET sock)
Set socket to non-blocking.
Definition: net.c:168
ssize_t tds_connection_read(TDSSOCKET *tds, unsigned char *buf, size_t buflen)
Definition: net.c:973
void tds_close_socket(TDSSOCKET *tds)
Close current socket.
Definition: net.c:548
int tds_read_packet(TDSSOCKET *tds)
Read in one 'packet' from the server.
Definition: packet.c:527
ssize_t tds_goodread(TDSSOCKET *tds, unsigned char *buf, size_t buflen)
Loops until we have received some characters return -1 on failure.
Definition: net.c:923
int tds_put_int8(TDSSOCKET *tds, TDS_INT8 i)
Definition: write.c:161
void tds_wakeup_close(TDSPOLLWAKEUP *wakeup)
Definition: net.c:840
TDSRET tds_write_packet(TDSSOCKET *tds, unsigned char final)
Definition: packet.c:740
TDSRET tds_flush_packet(TDSSOCKET *tds)
Flush packet to server.
Definition: write.c:225
int tds_wakeup_init(TDSPOLLWAKEUP *wakeup)
Definition: net.c:809
TDSRET tds_freeze_close(TDSFREEZE *freeze)
Stop keeping data for this specific freeze.
Definition: packet.c:996
void tds_freeze(TDSSOCKET *tds, TDSFREEZE *freeze, unsigned size_len)
Stop writing to server and cache every packet not sending them to server.
Definition: packet.c:907
int tds_put_buf(TDSSOCKET *tds, const unsigned char *buf, int dsize, int ssize)
Definition: write.c:149
TDSRET tds_freeze_abort(TDSFREEZE *freeze)
Discard all data written after the freeze.
Definition: packet.c:961
int tds_put_n(TDSSOCKET *tds, const void *buf, size_t n)
Definition: write.c:63
TDS_UINT8 tds_get_uint8(TDSSOCKET *tds)
Get an uint64 from the server.
Definition: read.c:140
TDSRET tds_get_char_data(TDSSOCKET *tds, char *dest, size_t wire_size, TDSCOLUMN *curcol)
Fetch character data the wire.
Definition: read.c:195
size_t tds_get_string(TDSSOCKET *tds, size_t string_len, char *dest, size_t dest_size)
Fetch a string from the wire.
Definition: read.c:166
int tds7_get_instance_ports(FILE *output, struct addrinfo *addr)
Get port of all instances.
Definition: net.c:1102
TDS_UINT tds_get_uint(TDSSOCKET *tds)
Get an int32 from the server.
Definition: read.c:127
ssize_t tds_connection_write(TDSSOCKET *tds, const unsigned char *buf, size_t buflen, int final)
Definition: net.c:1060
void tds_socket_flush(TDS_SYS_SOCKET sock)
Definition: net.c:1048
int tds_put_cancel(TDSSOCKET *tds)
Definition: packet.c:815
int tds7_get_instance_port(struct addrinfo *addr, const char *instance)
Get port of given instance.
Definition: net.c:1238
const char * tds_addrinfo2str(struct addrinfo *addr, char *name, int namemax)
Definition: net.c:200
TDS_USMALLINT tds_get_usmallint(TDSSOCKET *tds)
Get an int16 from the server.
Definition: read.c:113
void tds_unget_byte(TDSSOCKET *tds)
Unget will always work as long as you don't call it twice in a row.
Definition: read.c:89
int tds_select(TDSSOCKET *tds, unsigned tds_sel, int timeout_seconds)
Select on a socket until it's available or the timeout expires.
Definition: net.c:610
int tds_init_write_buf(TDSSOCKET *tds)
Definition: write.c:213
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.
Definition: read.c:232
ssize_t tds_goodwrite(TDSSOCKET *tds, const unsigned char *buffer, size_t buflen)
Definition: net.c:995
int tds_put_smallint(TDSSOCKET *tds, TDS_SMALLINT si)
Definition: write.c:190
int tds_put_byte(TDSSOCKET *tds, unsigned char c)
Definition: write.c:204
int tds_put_int(TDSSOCKET *tds, TDS_INT i)
Definition: write.c:176
void tds_connection_close(TDSCONNECTION *conn)
Definition: net.c:578
TDSERRNO tds_open_socket(TDSSOCKET *tds, struct addrinfo *ipaddr, unsigned int port, int timeout, int *p_oserr)
Definition: net.c:371
DSTR * tds_dstr_get(TDSSOCKET *tds, DSTR *s, size_t len)
Reads a string from wire and put in a DSTR.
Definition: read.c:300
size_t tds_quote_id_rpc(TDSSOCKET *tds, char *buffer, const char *id, ssize_t idlen)
Quote an id for a RPC call.
Definition: query.c:2274
int tds_needs_unprepare(TDSCONNECTION *conn, TDSDYNAMIC *dyn)
Check if dynamic request must be unprepared.
Definition: query.c:1812
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.
Definition: query.c:1457
void tds_start_query(TDSSOCKET *tds, unsigned char packet_type)
Start query packet of a given type \tds.
Definition: query.c:335
TDSRET tds_send_cancel(TDSSOCKET *tds)
tds_send_cancel() sends an empty packet (8 byte header only) tds_process_cancel should be called dire...
Definition: query.c:2087
TDSRET tds_multiple_query(TDSSOCKET *tds, TDSMULTIPLE *multiple, const char *query, TDSPARAMINFO *params)
Definition: query.c:3403
TDSRET tds_cursor_get_cursor_info(TDSSOCKET *tds, TDSCURSOR *cursor, TDS_UINT *row_number, TDS_UINT *row_count)
Definition: query.c:2692
TDSRET tds_disconnect(TDSSOCKET *tds)
Definition: query.c:3809
TDSRET tds_submit_execute(TDSSOCKET *tds, TDSDYNAMIC *dyn)
Sends a previously prepared dynamic statement to the server.
Definition: query.c:1690
size_t tds_fix_column_size(TDSSOCKET *tds, TDSCOLUMN *curcol)
Get column size for wire.
Definition: query.c:1547
TDSRET tds_get_column_declaration(TDSSOCKET *tds, TDSCOLUMN *curcol, char *out)
Return declaration for column (like "varchar(20)").
Definition: query.c:743
TDSRET tds_submit_commit(TDSSOCKET *tds, int cont)
Send a commit request.
Definition: query.c:3797
TDSRET tds_deferred_cursor_dealloc(TDSCONNECTION *conn, TDSCURSOR *cursor)
Deallocate cursor on idle.
Definition: query.c:3116
TDSRET tds_submit_query(TDSSOCKET *tds, const char *query)
Sends a language string to the database server for processing.
Definition: query.c:213
const char * tds_skip_quoted(const char *s)
Skip quoting string (like 'sfsf', "dflkdj" or [dfkjd])
Definition: query.c:520
TDSRET tds_submit_rpc(TDSSOCKET *tds, const char *rpc_name, TDSPARAMINFO *params, TDSHEADERS *head)
Calls a RPC from server.
Definition: query.c:1990
const char * tds_next_placeholder(const char *start)
Get position of next placeholder.
Definition: query.c:540
size_t tds_quote_id(TDSSOCKET *tds, char *buffer, const char *id, ssize_t idlen)
Quote an id.
Definition: query.c:2229
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.
Definition: query.c:1180
TDSRET tds_submit_begin_tran(TDSSOCKET *tds)
Send a rollback request.
Definition: query.c:3724
TDSRET tds_cursor_declare(TDSSOCKET *tds, TDSCURSOR *cursor, TDSPARAMINFO *params, int *send)
Definition: query.c:2320
size_t tds_quote_string(TDSSOCKET *tds, char *buffer, const char *str, ssize_t len)
Quote a string.
Definition: query.c:2299
TDSRET tds_submit_query_params(TDSSOCKET *tds, const char *query, TDSPARAMINFO *params, TDSHEADERS *head)
Sends a language string to the database server for processing.
Definition: query.c:353
TDSRET tds_submit_rollback(TDSSOCKET *tds, int cont)
Send a rollback request.
Definition: query.c:3766
TDSRET tds_deferred_unprepare(TDSCONNECTION *conn, TDSDYNAMIC *dyn)
Unprepare dynamic on idle.
Definition: query.c:1834
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.
Definition: query.c:126
int tds_count_placeholders(const char *query)
Count the number of placeholders ('?') in a query.
Definition: query.c:576
const char * tds_skip_comment(const char *s)
Skip a comment in a query.
Definition: query.c:495
TDSRET tds_cursor_dealloc(TDSSOCKET *tds, TDSCURSOR *cursor)
Send a deallocation request to server.
Definition: query.c:3065
TDSRET tds_cursor_setrows(TDSSOCKET *tds, TDSCURSOR *cursor, int *send)
Definition: query.c:2510
TDSRET tds_submit_queryf(TDSSOCKET *tds, const char *queryf,...)
Format and submit a query \tds.
Definition: query.c:472
TDSRET tds_cursor_setname(TDSSOCKET *tds, TDSCURSOR *cursor)
Definition: query.c:2867
TDSRET tds_cursor_close(TDSSOCKET *tds, TDSCURSOR *cursor)
Definition: query.c:2808
TDSRET tds_multiple_execute(TDSSOCKET *tds, TDSMULTIPLE *multiple, TDSDYNAMIC *dyn)
Definition: query.c:3415
TDSRET tds_multiple_init(TDSSOCKET *tds, TDSMULTIPLE *multiple, TDS_MULTIPLE_TYPE type, TDSHEADERS *head)
Definition: query.c:3369
TDSRET tds_submit_execdirect(TDSSOCKET *tds, const char *query, TDSPARAMINFO *params, TDSHEADERS *head)
Submit a prepared query with parameters.
Definition: query.c:1312
TDSRET tds_multiple_done(TDSSOCKET *tds, TDSMULTIPLE *multiple)
Definition: query.c:3395
TDSRET tds_cursor_update(TDSSOCKET *tds, TDSCURSOR *cursor, TDS_CURSOR_OPERATION op, TDS_INT i_row, TDSPARAMINFO *params)
Definition: query.c:2934
void tds_set_cur_dyn(TDSSOCKET *tds, TDSDYNAMIC *dyn)
Set current dynamic.
Definition: query.c:195
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.
Definition: query.c:3448
TDSRET tds_cursor_open(TDSSOCKET *tds, TDSCURSOR *cursor, TDSPARAMINFO *params, int *send)
Definition: query.c:2366
TDSRET tds_submit_unprepare(TDSSOCKET *tds, TDSDYNAMIC *dyn)
Send a unprepare request for a prepared query.
Definition: query.c:1857
const char * tds_prtype(int token)
Returns string representation of the given type.
Definition: token.c:3059
TDSDYNAMIC * tds_lookup_dynamic(TDSCONNECTION *conn, const char *id)
Finds a dynamic given string id.
Definition: token.c:2589
TDSRET tds_process_login_tokens(TDSSOCKET *tds)
tds_process_login_tokens() is called after sending the login packet to the server.
Definition: token.c:413
TDSRET tds_process_tokens(TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag)
process all streams.
Definition: token.c:533
TDSRET tds_process_simple_query(TDSSOCKET *tds)
Process results for simple query as "SET TEXTSIZE" or "USE dbname" If the statement returns results,...
Definition: token.c:883
TDSRET tds_process_cancel(TDSSOCKET *tds)
Definition: token.c:2556
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
FILE * file
char * buf
int i
yy_size_t n
int len
static void text(MDB_val *v)
Definition: mdb_dump.c:62
static MDB_envinfo info
Definition: mdb_load.c:37
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
int ssize_t
Definition: ncbiconf_msvc.h:93
const char * command
static char terminator
Definition: njn_ioutil.cpp:56
std::istream & in(std::istream &in_, double &x_)
static int bufsize
Definition: pcregrep.c:162
static char * locale
Definition: pcregrep.c:149
static pcre_uint8 * buffer
Definition: pcretest.c:1051
#define row(bind, expected)
Definition: string_bind.c:73
this structure is not directed connected to a TDS protocol but keeps any DATE/TIME information.
Definition: tds.h:167
static string query
TDS_TINYINT dflt
Definition: tds.h:1732
TDS_SMALLINT offset
Definition: tds.h:1730
TDS_INT dflt_size
Definition: tds.h:1734
TDS_INT length
Definition: tds.h:1731
TDS_TINYINT status
Definition: tds.h:1729
TDS_TINYINT type
Definition: tds.h:1728
TDS_UCHAR * dflt_value
Definition: tds.h:1735
uint8_t * packet
Definition: tds.h:1077
TDSRET(* free)(TDSCONNECTION *conn, struct tds_authentication *auth)
Definition: tds.h:1118
uint16_t msg_type
Definition: tds.h:1080
TDSRET(* handle_next)(TDSSOCKET *tds, struct tds_authentication *auth, size_t len)
Definition: tds.h:1119
TDS_UCHAR * data
Definition: tds.h:694
bool is_null
Definition: tds.h:659
TDS_INT datalen
Definition: tds.h:695
const char * hint
Definition: tds.h:1661
TDSRESULTINFO * bindinfo
Definition: tds.h:1669
TDS_INT blob_cols
Definition: tds.h:1672
TDS_CHAR * insert_stmt
Definition: tds.h:1664
TDS_INT sybase_count
Definition: tds.h:1750
void * parent
Definition: tds.h:1662
TDS_INT rows_sent
Definition: tds.h:1754
TDS_INT text_sent
Definition: tds.h:1670
TDS_INT identity_insert_on
Definition: tds.h:1666
TDS_INT xfer_init
Definition: tds.h:1667
TDS_INT next_col
Definition: tds.h:1671
DSTR tablename
Definition: tds.h:1663
TDS5COLINFO * sybase_colinfo
Definition: tds.h:1749
TDS_INT direction
Definition: tds.h:1665
TDS_INT bind_count
Definition: tds.h:1668
Information about blobs (e.g.
Definition: tds.h:658
bool valid_ptr
Definition: tds.h:625
TDS_CHAR * textvalue
Definition: tds.h:659
TDS_CHAR textptr[16]
Definition: tds.h:660
TDS_CHAR timestamp[8]
Definition: tds.h:661
TDS_CAPABILITY_TYPE types[2]
Definition: tds.h:579
unsigned char type
Definition: tds.h:572
unsigned char len
Definition: tds.h:573
unsigned char values[32/2-2]
Definition: tds.h:574
tds_func_get_info * get_info
Definition: tds.h:710
tds_func_row_len * row_len
Definition: tds.h:712
tds_func_put_info * put_info
Send metadata column information to server.
Definition: tds.h:724
tds_func_get_data * get_data
Definition: tds.h:711
tds_func_put_data * put_data
Send column data to server.
Definition: tds.h:734
Metadata about columns in regular and compute rows.
Definition: tds.h:761
TDS_INT bcp_prefix_len
The length, in bytes, of any length prefix this column may have.
Definition: tds.h:834
unsigned char column_nullable
Definition: tds.h:748
unsigned char column_iconv_left
Definition: tds.h:777
TDS_TINYINT column_varint_size
size of length when reading from wire (0, 1, 2 or 4)
Definition: tds.h:773
TDS_INT bcp_term_len
Definition: tds.h:835
TDS_TINYINT column_operator
Definition: tds.h:806
TDS_INT column_textpos
Definition: tds.h:821
TDS_INT column_size
maximun size of data.
Definition: tds.h:766
TDS_SMALLINT column_operand
Definition: tds.h:807
TDS_SMALLINT * column_nullbind
Definition: tds.h:818
char column_iconv_buf[9]
Definition: tds.h:778
DSTR column_name
Definition: tds.h:787
TDS_UINT column_bindlen
Definition: tds.h:817
BCPCOLDATA * bcp_column_data
Definition: tds.h:825
TDS_UCHAR column_collation[5]
Definition: tds.h:803
void(* column_data_free)(struct tds_column *column)
Definition: tds.h:794
unsigned char column_timestamp
Definition: tds.h:754
const TDSCOLUMNFUNCS * funcs
Definition: tds.h:762
TDS_SMALLINT column_bindtype
Definition: tds.h:815
unsigned char column_computed
Definition: tds.h:755
unsigned char column_output
Definition: tds.h:753
unsigned char column_writeable
Definition: tds.h:749
DSTR table_column_name
Definition: tds.h:788
TDS_TINYINT column_prec
precision for decimal/numeric
Definition: tds.h:775
TDS_SERVER_TYPE column_type
This type can be different from wire type because conversion (e.g.
Definition: tds.h:768
TDSICONV * char_conv
refers to previously allocated iconv information
Definition: tds.h:784
unsigned char column_key
Definition: tds.h:751
unsigned char column_identity
Definition: tds.h:750
TDS_SMALLINT column_bindfmt
Definition: tds.h:816
TDS_CHAR column_text_sqlputdatainfo
Definition: tds.h:823
DSTR table_name
Definition: tds.h:786
unsigned char column_hidden
Definition: tds.h:752
TDS_TINYINT column_scale
scale for decimal/numeric
Definition: tds.h:776
unsigned char * column_data
Definition: tds.h:793
TDS_INT * column_lenbind
Definition: tds.h:820
struct tds_column::@124 on_server
TDS_CHAR * column_varaddr
Definition: tds.h:819
TDS_INT column_flags
Definition: tds.h:764
TDS_INT column_cur_size
size written in variable (ie: char, text, binary).
Definition: tds.h:811
TDS_INT column_usertype
Definition: tds.h:763
TDS_CHAR * bcp_terminator
Definition: tds.h:836
TDS_INT column_text_sqlgetdatapos
Definition: tds.h:822
A structure to hold all the compile-time settings.
Definition: tds.h:95
const char * freetds_version
Definition: tds.h:96
const char * sysconfdir
Definition: tds.h:97
const char * tdsver
Definition: tds.h:103
const char * last_update
Definition: tds.h:98
int char_conv_count
Definition: tds.h:1160
TDSENV env
environment is shared between all sessions
Definition: tds.h:1147
uint8_t unicharsize
Ratio between bytes allocated for a UNICHAR type and type length (Sybase).
Definition: tds.h:1187
unsigned int tds71rev1
Definition: tds.h:1169
int client_spid
Definition: tds.h:1193
char * server
Definition: tds.h:1204
tds_mutex list_mtx
Definition: tds.h:1168
TDSPOLLWAKEUP wakeup
Definition: tds.h:1143
char * product_name
Definition: tds.h:1140
TDS_SYS_SOCKET s
tcp socket, INVALID_SOCKET if not connected
Definition: tds.h:1142
TDS_UCHAR collation[5]
Definition: tds.h:1163
unsigned num_cached_packets
Definition: tds.h:1170
TDSICONV ** char_convs
Definition: tds.h:1161
TDS_UINT product_version
version of product (Sybase/MS and full version)
Definition: tds.h:1139
TDSCURSOR * cursors
linked list of cursors allocated for this connection contains only cursors allocated on the server
Definition: tds.h:1153
unsigned int encrypt_single_packet
Definition: tds.h:1171
unsigned int pending_close
true is connection has pending closing (cursors or dynamic)
Definition: tds.h:1170
TDS_UCHAR tds72_transaction[8]
Definition: tds.h:1164
const TDSCONTEXT * tds_ctx
Definition: tds.h:1144
int spid
Definition: tds.h:1192
void * tls_session
Definition: tds.h:1195
TDSDYNAMIC * dyns
list of dynamic allocated for this connection contains only dynamic allocated on the server
Definition: tds.h:1158
TDS_USMALLINT tds_version
Definition: tds.h:1138
uint8_t ncharsize
Ratio between bytes allocated for a NCHAR type and type length (Sybase).
Definition: tds.h:1180
TDSPACKET * packet_cache
Definition: tds.h:1171
TDSAUTHENTICATION * authentication
Definition: tds.h:1203
TDS_CAPABILITIES capabilities
Definition: tds.h:1166
void * tls_dummy
Definition: tds.h:1201
unsigned int use_iconv
Definition: tds.h:1168
void * parent
Definition: tds.h:1100
TDSLOCALE * locale
Definition: tds.h:1099
int(* msg_handler)(const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *)
Definition: tds.h:1102
int(* err_handler)(const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *)
Definition: tds.h:1103
int(* int_handler)(void *)
Definition: tds.h:1104
bool money_use_2_digits
Definition: tds.h:1065
TDS_CURSOR_STATE close
Definition: tds.h:981
TDS_CURSOR_STATE open
Definition: tds.h:979
TDS_CURSOR_STATE declare
Definition: tds.h:977
TDS_CURSOR_STATE dealloc
Definition: tds.h:982
TDS_CURSOR_STATE fetch
Definition: tds.h:980
TDS_CURSOR_STATE cursor_row
Definition: tds.h:978
Holds informations about a cursor.
Definition: tds.h:1007
char * query
SQL query.
Definition: tds.h:1017
TDS_TINYINT options
read only|updatable TODO use it
Definition: tds.h:1012
bool defer_close
true if cursor was marker to be closed when connection is idle
Definition: tds.h:975
char * cursor_name
name of the cursor
Definition: tds.h:1010
TDS_INT ref_count
reference counter so client can retain safely a pointer
Definition: tds.h:1009
TDS_INT cursor_id
cursor id returned by the server after cursor declare
Definition: tds.h:1011
TDS_INT cursor_rows
< number of updatable columns
Definition: tds.h:1021
TDS_INT type
row fetched from this cursor
Definition: tds.h:1026
TDS_INT concurrency
Definition: tds.h:1026
TDS_CURSOR_STATUS status
cursor parameter
Definition: tds.h:1023
TDSRESULTINFO * res_info
Definition: tds.h:1025
struct tds_cursor * next
next in linked list, keep first
Definition: tds.h:1008
TDS_USMALLINT srv_status
Definition: tds.h:1024
Structure to hold a string.
Definition: tds.h:116
Holds information for a dynamic (also called prepared) query.
Definition: tds.h:1047
struct tds_dynamic * next
next in linked list, keep first
Definition: tds.h:1048
TDS_INT ref_count
reference counter so client can retain safely a pointer
Definition: tds.h:1049
bool defer_close
true if dynamic was marker to be closed when connection is idle
Definition: tds.h:1026
char * query
saved query, we need to know original query if prepare is impossible
Definition: tds.h:1079
TDSPARAMINFO * params
query parameters.
Definition: tds.h:1077
TDSPARAMINFO * res_info
query results
Definition: tds.h:1069
TDS_TINYINT emulated
this dynamic query cannot be prepared so libTDS have to construct a simple query.
Definition: tds.h:1063
TDS_INT num_id
numeric id for mssql7+
Definition: tds.h:1051
Information relevant to libiconv.
Definition: tds.h:683
unsigned char max_bytes_per_char
Definition: tds.h:687
const char * name
name of the encoding (ie UTF-8)
Definition: tds.h:685
unsigned char min_bytes_per_char
Definition: tds.h:686
unsigned char canonic
internal numeric index into array of all encodings
Definition: tds.h:689
Current environment as reported by the server.
Definition: tds.h:1033
char * charset
character set encoding
Definition: tds.h:1038
int block_size
packet size (512-65535)
Definition: tds.h:1035
char * database
database name
Definition: tds.h:1040
char * language
Definition: tds.h:1036
TDSSOCKET * tds
which socket we refer to
Definition: tds.h:1639
unsigned pkt_pos
position in pkt
Definition: tds.h:1643
unsigned size_len
length size (0, 1, 2 or 4)
Definition: tds.h:1645
TDSPACKET * pkt
first packet frozen
Definition: tds.h:1641
const char * qn_msgtext
Definition: tds.h:641
TDS_INT qn_timeout
Definition: tds.h:642
const char * qn_options
Definition: tds.h:640
char * date_fmt
Definition: tds.h:650
char * server_charset
Definition: tds.h:649
char * datetime_fmt
Definition: tds.h:611
char * language
Definition: tds.h:648
char * time_fmt
Definition: tds.h:613
Definition: tds.h:584
unsigned int use_ntlmv2
Definition: tds.h:628
unsigned int use_new_password
Definition: tds.h:632
TDS_INT query_timeout
Definition: tds.h:608
DSTR crlfile
certificate revocation file
Definition: tds.h:598
unsigned int check_ssl_hostname
Definition: tds.h:634
DSTR server_realm_name
server realm name (in freetds.conf)
Definition: tds.h:594
unsigned int server_is_valid
Definition: tds.h:596
DSTR database
Definition: tds.h:611
DSTR client_charset
Definition: tds.h:610
DSTR user_name
account for login
Definition: tds.h:601
TDS_INT connect_timeout
Definition: tds.h:591
unsigned int gssapi_use_delegation
Definition: tds.h:627
struct addrinfo * ip_addrs
ip(s) of server
Definition: tds.h:613
DSTR password
password of account login
Definition: tds.h:602
DSTR db_filename
database filename to attach (MSSQL)
Definition: tds.h:596
TDS_CAPABILITIES capabilities
Definition: tds.h:609
DSTR routing_address
Definition: tds.h:619
unsigned int readonly_intent
Definition: tds.h:635
TDS_TINYINT encryption_level
Definition: tds.h:606
unsigned char option_flag2
Definition: tds.h:622
unsigned int use_ntlmv2_specified
Definition: tds.h:586
DSTR client_host_name
Definition: tds.h:592
DSTR dump_file
Definition: tds.h:616
unsigned int valid_configuration
Definition: tds.h:633
DSTR server_name
server name (in freetds.conf)
Definition: tds.h:585
DSTR instance_name
Definition: tds.h:615
DSTR server_charset
charset of server e.g.
Definition: tds.h:590
DSTR language
Definition: tds.h:589
int debug_flags
Definition: tds.h:617
unsigned int mutual_authentication
Definition: tds.h:584
TDS_USMALLINT tds_version
TDS version.
Definition: tds.h:587
DSTR new_password
new password to set (TDS 7.2+)
Definition: tds.h:603
unsigned int use_utf16
Definition: tds.h:631
unsigned int use_lanman
Definition: tds.h:629
unsigned int suppress_language
Definition: tds.h:625
int text_size
Definition: tds.h:618
unsigned int enable_tls_v1
Definition: tds.h:594
DSTR server_host_name
Definition: tds.h:593
unsigned int enable_tls_v1_specified
Definition: tds.h:595
DSTR openssl_ciphers
Definition: tds.h:599
unsigned int bulk_copy
if bulk copy should be enabled
Definition: tds.h:624
DSTR cafile
certificate authorities file
Definition: tds.h:597
unsigned int mars
Definition: tds.h:630
uint16_t routing_port
Definition: tds.h:577
DSTR server_spn
server SPN (in freetds.conf)
Definition: tds.h:595
int port
port of database service
Definition: tds.h:586
int block_size
Definition: tds.h:588
DSTR library
Definition: tds.h:605
DSTR app_name
Definition: tds.h:600
TDS_CHAR * sql_state
Definition: tds.h:949
TDS_CHAR * message
Definition: tds.h:947
TDS_INT msgno
Definition: tds.h:950
TDS_CHAR * proc_name
Definition: tds.h:948
TDS_CHAR * osstr
Definition: tds.h:958
TDS_INT line_number
Definition: tds.h:951
TDS_CHAR * server
Definition: tds.h:946
int oserr
Definition: tds.h:957
TDS_TINYINT priv_msg_type
Definition: tds.h:954
TDS_TINYINT severity
Definition: tds.h:955
TDS_SMALLINT state
Definition: tds.h:953
TDS_MULTIPLE_TYPE type
Definition: tds.h:1090
unsigned int flags
Definition: tds.h:1091
uint16_t sid
Definition: tds.h:1088
unsigned char buf[1]
Definition: tds.h:1127
unsigned data_len
data length, this does not account SMP header, only TDS part
Definition: tds.h:1100
struct tds_packet * next
Definition: tds.h:1124
unsigned capacity
Definition: tds.h:1126
TDS_SYS_SOCKET s_signaled
Definition: tds.h:1132
TDS_SYS_SOCKET s_signal
Definition: tds.h:1132
Hold information for any results.
Definition: tds.h:842
bool rows_exist
Definition: tds.h:810
unsigned char * current_row
Definition: tds.h:849
TDS_SMALLINT * bycolumns
Definition: tds.h:853
TDS_USMALLINT computeid
Definition: tds.h:846
TDSCOLUMN ** columns
Definition: tds.h:844
TDS_USMALLINT num_cols
Definition: tds.h:845
TDS_INT ref_count
Definition: tds.h:847
bool more_results
Definition: tds.h:812
TDS_USMALLINT by_cols
Definition: tds.h:854
void(* row_free)(struct tds_result_info *result, unsigned char *row)
Definition: tds.h:850
TDS_INT row_size
Definition: tds.h:851
TDSSOCKET * attached_to
Definition: tds.h:848
Information for a server connection.
Definition: tds.h:1211
void(* env_chg_func)(TDSSOCKET *tds, int type, char *oldval, char *newval)
Definition: tds.h:1285
unsigned in_len
input buffer length
Definition: tds.h:1239
TDSPACKET * frozen_packets
list of packets frozen, points to first one.
Definition: tds.h:1245
TDSCOMPUTEINFO ** comp_info
Definition: tds.h:1266
TDS_INT ret_status
return status from store procedure
Definition: tds.h:1272
TDSLOGIN * login
config for login stuff.
Definition: tds.h:1283
unsigned out_pos
current position in out_buf
Definition: tds.h:1238
TDSCURSOR * cur_cursor
cursor in use
Definition: tds.h:1268
void * parent
Definition: tds.h:1243
unsigned char * out_buf
Output buffer.
Definition: tds.h:1230
unsigned char in_flag
input buffer type
Definition: tds.h:1240
tds_mutex wire_mtx
Definition: tds.h:1306
TDS_INT8 rows_affected
rows updated/deleted/inserted/selected, TDS_NO_COUNT if not valid
Definition: tds.h:1278
TDSPACKET * send_packet
packet we are preparing to send
Definition: tds.h:1256
unsigned char * in_buf
Input buffer.
Definition: tds.h:1223
TDSDYNAMIC * cur_dyn
dynamic structure in use
Definition: tds.h:1281
unsigned char out_flag
output buffer type
Definition: tds.h:1241
unsigned in_pos
current position in in_buf
Definition: tds.h:1237
TDS_STATE state
Definition: tds.h:1273
bool in_row
true if we are getting rows
Definition: tds.h:1271
TDSCONNECTION conn[1]
Definition: tds.h:1215
int option_value
Definition: tds.h:1288
TDSPACKET * recv_packet
Definition: tds.h:1254
bool bulk_query
true is query sent was a bulk query so we need to switch state to QUERYING
Definition: tds.h:1286
TDSRESULTINFO * current_results
Current query information.
Definition: tds.h:1263
bool has_status
true is ret_status is valid
Definition: tds.h:1287
TDSRESULTINFO * res_info
Definition: tds.h:1264
unsigned frozen
Definition: tds.h:1240
TDS_UINT num_comp_info
Definition: tds.h:1265
volatile unsigned char in_cancel
indicate we are waiting a cancel reply; discard tokens till acknowledge; 1 mean we have to send cance...
Definition: tds.h:1275
unsigned int out_buf_max
Maximum size of packet pointed by out_buf.
Definition: tds.h:1236
TDS_INT query_timeout
Definition: tds.h:1279
TDSPARAMINFO * param_info
Definition: tds.h:1267
TDS_OPERATION current_op
Definition: tds.h:1286
struct tds_tvp_row * next
Definition: tds.h:1319
TDSPARAMINFO * params
Definition: tds.h:1318
Definition: tds.h:1323
TDSPARAMINFO * metadata
Definition: tds.h:1326
TDS_TVP_ROW * row
Definition: tds.h:1327
char * name
Definition: tds.h:1325
char * schema
Definition: tds.h:1324
char * columnname
Definition: tds.h:965
struct tds_upd_col * next
Definition: tds.h:963
TDS_INT colnamelength
Definition: tds.h:964
Store variant informations.
Definition: tds.h:669
TDS_SERVER_TYPE type
Definition: tds.h:674
TDS_UCHAR collation[5]
Definition: tds.h:675
TDS_CHAR * data
Definition: tds.h:671
TDS_INT data_len
Definition: tds.h:673
TDS_INT size
Definition: tds.h:672
Used by tds_datecrack.
Definition: tds.h:180
TDS_INT dayofyear
day of year (1-366)
Definition: tds.h:185
TDS_INT weekday
day of week (0-6, 0 = sunday)
Definition: tds.h:186
TDS_INT year
year
Definition: tds.h:181
TDS_INT timezone
-840 - 840 minutes from UTC
Definition: tds.h:191
TDS_INT minute
0-59
Definition: tds.h:188
TDS_INT day
day of month (1-31)
Definition: tds.h:184
TDS_INT decimicrosecond
0-9999999
Definition: tds.h:190
TDS_INT second
0-59
Definition: tds.h:189
TDS_INT quarter
quarter (0-3)
Definition: tds.h:182
TDS_INT hour
0-23
Definition: tds.h:187
TDS_INT month
month number (0-11)
Definition: tds.h:183
tds_thread_id thread_id
Definition: tds.h:1564
struct tdsdump_off_item * next
Definition: tds.h:1563
Definition: type.c:6
else result
Definition: token2.c:20
int64_t ui
Definition: tds.h:523
TDS_TINYINT ti
Definition: tds.h:349
TDS_CHAR * c
Definition: tds.h:351
TDS_INT i
Definition: tds.h:350
Definition: proto.h:39
uchar outbuf[(1000000+1000000)]
Definition: unzcrash.c:41
static CS_CONTEXT * context
Definition: will_convert.c:21
@ DONE
Definition: inflate.h:49
Modified on Fri Jul 12 16:24:22 2024 by modify_doxy.py rev. 669887