4 #ifdef TDS_ICONV_ENCODING_TABLES
7 {
"ISO-8859-1", 1, 1, 0},
10 {
"UCS-2BE", 2, 2, 3},
11 {
"ARMSCII-8", 1, 1, 4},
13 {
"BIG5-HKSCS", 1, 2, 6},
15 {
"CHINESE", 1, 1, 8},
18 {
"CN-GB-ISOIR165", 1, 1, 11},
19 {
"CP1133", 1, 1, 12},
20 {
"CP1250", 1, 1, 13},
21 {
"CP1251", 1, 1, 14},
22 {
"CP1252", 1, 1, 15},
23 {
"CP1253", 1, 1, 16},
24 {
"CP1254", 1, 1, 17},
25 {
"CP1255", 1, 1, 18},
26 {
"CP1256", 1, 1, 19},
27 {
"CP1257", 1, 1, 20},
28 {
"CP1258", 1, 1, 21},
29 {
"CP1361", 1, 2, 22},
39 {
"EUC-JP", 1, 3, 32},
40 {
"EUC-KR", 1, 2, 33},
41 {
"EUC-TW", 1, 4, 34},
42 {
"GB18030", 1, 4, 35},
43 {
"GEORGIAN-ACADEMY", 1, 1, 36},
44 {
"GEORGIAN-PS", 1, 1, 37},
46 {
"ISO-2022-CN", 1, 4, 39},
47 {
"ISO-2022-CN-EXT", 1, 4, 40},
48 {
"ISO-2022-JP", 1, 1, 41},
49 {
"ISO-2022-JP-1", 1, 1, 42},
50 {
"ISO-2022-JP-2", 1, 1, 43},
51 {
"ISO-2022-KR", 1, 2, 44},
52 {
"ISO-8859-10", 1, 1, 45},
53 {
"ISO-8859-13", 1, 1, 46},
54 {
"ISO-8859-14", 1, 1, 47},
55 {
"ISO-8859-15", 1, 1, 48},
56 {
"ISO-8859-16", 1, 1, 49},
57 {
"ISO-8859-2", 1, 1, 50},
58 {
"ISO-8859-3", 1, 1, 51},
59 {
"ISO-8859-4", 1, 1, 52},
60 {
"ISO-8859-5", 1, 1, 53},
61 {
"ISO-8859-6", 1, 1, 54},
62 {
"ISO-8859-7", 1, 1, 55},
63 {
"ISO-8859-8", 1, 1, 56},
64 {
"ISO-8859-9", 1, 1, 57},
65 {
"ISO-IR-14", 1, 1, 58},
66 {
"ISO-IR-149", 1, 1, 59},
67 {
"ISO-IR-159", 1, 1, 60},
68 {
"ISO-IR-166", 1, 1, 61},
69 {
"ISO-IR-87", 1, 1, 62},
71 {
"JISX0201-1976", 1, 1, 64},
72 {
"KOI8-R", 1, 1, 65},
73 {
"KOI8-RU", 1, 1, 66},
74 {
"KOI8-T", 1, 1, 67},
75 {
"KOI8-U", 1, 1, 68},
77 {
"MACARABIC", 1, 1, 70},
78 {
"MACCENTRALEUROPE", 1, 1, 71},
79 {
"MACCROATIAN", 1, 1, 72},
80 {
"MACCYRILLIC", 1, 1, 73},
81 {
"MACGREEK", 1, 1, 74},
82 {
"MACHEBREW", 1, 1, 75},
83 {
"MACICELAND", 1, 1, 76},
84 {
"MACROMANIA", 1, 1, 77},
85 {
"MACTHAI", 1, 1, 78},
86 {
"MACTURKISH", 1, 1, 79},
87 {
"MACUKRAINE", 1, 1, 80},
88 {
"MULELAO-1", 1, 1, 81},
89 {
"NEXTSTEP", 1, 1, 82},
90 {
"ROMAN8", 1, 1, 83},
93 {
"UCS-4BE", 4, 4, 86},
94 {
"UCS-4LE", 4, 4, 87},
95 {
"US-ASCII", 1, 1, 88},
96 {
"UTF-16BE", 2, 4, 89},
97 {
"UTF-16LE", 2, 4, 90},
98 {
"UTF-32BE", 4, 4, 91},
99 {
"UTF-32LE", 4, 4, 92},
100 {
"UTF-7", 1, 4, 93},
101 {
"VISCII", 1, 1, 94},
109 {
"ANSI_X3.4-1968", 88 },
110 {
"ANSI_X3.4-1986", 88 },
126 {
"CN-GB-ISOIR165", 11 },
152 {
"CSEUCPKDFMTJAPANESE", 32 },
155 {
"CSHALFWIDTHKATAKANA", 64 },
156 {
"CSHPROMAN8", 83 },
158 {
"CSISO14JISC6220RO", 58 },
159 {
"CSISO159JISX02121990", 60 },
160 {
"CSISO2022CN", 39 },
161 {
"CSISO2022JP", 41 },
162 {
"CSISO2022JP2", 43 },
163 {
"CSISO2022KR", 44 },
164 {
"CSISO57GB1988", 9 },
165 {
"CSISO58GB231280", 8 },
166 {
"CSISO87JISX0208", 62 },
167 {
"CSISOLATIN1", 0 },
168 {
"CSISOLATIN2", 50 },
169 {
"CSISOLATIN3", 51 },
170 {
"CSISOLATIN4", 52 },
171 {
"CSISOLATIN5", 57 },
172 {
"CSISOLATIN6", 45 },
173 {
"CSISOLATINARABIC", 54 },
174 {
"CSISOLATINCYRILLIC", 53 },
175 {
"CSISOLATINGREEK", 55 },
176 {
"CSISOLATINHEBREW", 56 },
178 {
"CSKSC56011987", 59 },
179 {
"CSMACINTOSH", 69 },
180 {
"CSPC850MULTILINGUAL", 24 },
181 {
"CSPC862LATINHEBREW", 25 },
182 {
"CSSHIFTJIS", 84 },
183 {
"CSUNICODE11", 3 },
184 {
"CSUNICODE11UTF7", 93 },
198 {
"EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE", 32 },
204 {
"GEORGIAN-ACADEMY", 36 },
205 {
"GEORGIAN-PS", 37 },
211 {
"HZ-GB-2312", 38 },
212 {
"IBM-CP1133", 12 },
219 {
"ISO-2022-CN", 39 },
220 {
"ISO-2022-CN-EXT", 40 },
221 {
"ISO-2022-JP", 41 },
222 {
"ISO-2022-JP-1", 42 },
223 {
"ISO-2022-JP-2", 43 },
224 {
"ISO-2022-KR", 44 },
226 {
"ISO-8859-10", 45 },
227 {
"ISO-8859-13", 46 },
228 {
"ISO-8859-14", 47 },
229 {
"ISO-8859-15", 48 },
230 {
"ISO-8859-16", 49 },
231 {
"ISO-8859-2", 50 },
232 {
"ISO-8859-3", 51 },
233 {
"ISO-8859-4", 52 },
234 {
"ISO-8859-5", 53 },
235 {
"ISO-8859-6", 54 },
236 {
"ISO-8859-7", 55 },
237 {
"ISO-8859-8", 56 },
238 {
"ISO-8859-9", 57 },
239 {
"ISO-CELTIC", 47 },
241 {
"ISO-IR-101", 50 },
242 {
"ISO-IR-109", 51 },
243 {
"ISO-IR-110", 52 },
244 {
"ISO-IR-126", 55 },
245 {
"ISO-IR-127", 54 },
246 {
"ISO-IR-138", 56 },
248 {
"ISO-IR-144", 53 },
249 {
"ISO-IR-148", 57 },
250 {
"ISO-IR-149", 59 },
251 {
"ISO-IR-157", 45 },
252 {
"ISO-IR-159", 60 },
253 {
"ISO-IR-165", 11 },
254 {
"ISO-IR-166", 61 },
255 {
"ISO-IR-179", 46 },
256 {
"ISO-IR-199", 47 },
257 {
"ISO-IR-203", 48 },
258 {
"ISO-IR-226", 49 },
267 {
"ISO8859-10", 45 },
268 {
"ISO8859-15", 48 },
276 {
"ISO_646.IRV:1991", 88 },
278 {
"ISO_8859-10", 45 },
279 {
"ISO_8859-10:1992", 45 },
280 {
"ISO_8859-13", 46 },
281 {
"ISO_8859-14", 47 },
282 {
"ISO_8859-14:1998", 47 },
283 {
"ISO_8859-15", 48 },
284 {
"ISO_8859-15:1998", 48 },
285 {
"ISO_8859-16", 49 },
286 {
"ISO_8859-16:2000", 49 },
287 {
"ISO_8859-1:1987", 0 },
288 {
"ISO_8859-2", 50 },
289 {
"ISO_8859-2:1987", 50 },
290 {
"ISO_8859-3", 51 },
291 {
"ISO_8859-3:1988", 51 },
292 {
"ISO_8859-4", 52 },
293 {
"ISO_8859-4:1988", 52 },
294 {
"ISO_8859-5", 53 },
295 {
"ISO_8859-5:1988", 53 },
296 {
"ISO_8859-6", 54 },
297 {
"ISO_8859-6:1987", 54 },
298 {
"ISO_8859-7", 55 },
299 {
"ISO_8859-7:1987", 55 },
300 {
"ISO_8859-8", 56 },
301 {
"ISO_8859-8:1988", 56 },
302 {
"ISO_8859-9", 57 },
303 {
"ISO_8859-9:1989", 57 },
306 {
"JISX0201-1976", 64 },
307 {
"JIS_C6220-1969-RO", 58 },
308 {
"JIS_C6226-1983", 62 },
311 {
"JIS_X0208-1983", 62 },
312 {
"JIS_X0208-1990", 62 },
314 {
"JIS_X0212-1990", 60 },
315 {
"JIS_X0212.1990-0", 60 },
324 {
"KS_C_5601-1987", 59 },
325 {
"KS_C_5601-1989", 59 },
344 {
"MACCENTRALEUROPE", 71 },
345 {
"MACCROATIAN", 72 },
346 {
"MACCYRILLIC", 73 },
349 {
"MACICELAND", 76 },
352 {
"MACROMANIA", 77 },
354 {
"MACTURKISH", 79 },
355 {
"MACUKRAINE", 80 },
373 {
"TCVN5712-1", 85 },
374 {
"TCVN5712-1:1993", 85 },
378 {
"TIS620.2529-1", 61 },
379 {
"TIS620.2533-0", 61 },
380 {
"TIS620.2533-1", 61 },
386 {
"UNICODE-1-1", 3 },
387 {
"UNICODE-1-1-UTF-7", 93 },
389 {
"UNICODELITTLE", 2 },
401 {
"VISCII1.1-1", 94 },
402 {
"WINBALTRIM", 20 },
403 {
"WINDOWS-1250", 13 },
404 {
"WINDOWS-1251", 14 },
405 {
"WINDOWS-1252", 15 },
406 {
"WINDOWS-1253", 16 },
407 {
"WINDOWS-1254", 17 },
408 {
"WINDOWS-1255", 18 },
409 {
"WINDOWS-1256", 19 },
410 {
"WINDOWS-1257", 20 },
411 {
"WINDOWS-1258", 21 },
412 {
"WINDOWS-874", 27 },
513 TDS_CHARSET_ISO_8859_1 = 0,
514 TDS_CHARSET_UTF_8 = 1,
515 TDS_CHARSET_UCS_2LE = 2,
516 TDS_CHARSET_UCS_2BE = 3,
517 TDS_CHARSET_ARMSCII_8 = 4,
518 TDS_CHARSET_BIG_5 = 5,
519 TDS_CHARSET_BIG5_HKSCS = 6,
521 TDS_CHARSET_CHINESE = 8,
523 TDS_CHARSET_CN_GB = 10,
524 TDS_CHARSET_CN_GB_ISOIR165 = 11,
525 TDS_CHARSET_CP1133 = 12,
526 TDS_CHARSET_CP1250 = 13,
527 TDS_CHARSET_CP1251 = 14,
528 TDS_CHARSET_CP1252 = 15,
529 TDS_CHARSET_CP1253 = 16,
530 TDS_CHARSET_CP1254 = 17,
531 TDS_CHARSET_CP1255 = 18,
532 TDS_CHARSET_CP1256 = 19,
533 TDS_CHARSET_CP1257 = 20,
534 TDS_CHARSET_CP1258 = 21,
535 TDS_CHARSET_CP1361 = 22,
536 TDS_CHARSET_CP437 = 23,
537 TDS_CHARSET_CP850 = 24,
538 TDS_CHARSET_CP862 = 25,
539 TDS_CHARSET_CP866 = 26,
540 TDS_CHARSET_CP874 = 27,
541 TDS_CHARSET_CP932 = 28,
542 TDS_CHARSET_CP936 = 29,
543 TDS_CHARSET_CP949 = 30,
544 TDS_CHARSET_CP950 = 31,
545 TDS_CHARSET_EUC_JP = 32,
546 TDS_CHARSET_EUC_KR = 33,
547 TDS_CHARSET_EUC_TW = 34,
548 TDS_CHARSET_GB18030 = 35,
549 TDS_CHARSET_GEORGIAN_ACADEMY = 36,
550 TDS_CHARSET_GEORGIAN_PS = 37,
552 TDS_CHARSET_ISO_2022_CN = 39,
553 TDS_CHARSET_ISO_2022_CN_EXT = 40,
554 TDS_CHARSET_ISO_2022_JP = 41,
555 TDS_CHARSET_ISO_2022_JP_1 = 42,
556 TDS_CHARSET_ISO_2022_JP_2 = 43,
557 TDS_CHARSET_ISO_2022_KR = 44,
558 TDS_CHARSET_ISO_8859_10 = 45,
559 TDS_CHARSET_ISO_8859_13 = 46,
560 TDS_CHARSET_ISO_8859_14 = 47,
561 TDS_CHARSET_ISO_8859_15 = 48,
562 TDS_CHARSET_ISO_8859_16 = 49,
563 TDS_CHARSET_ISO_8859_2 = 50,
564 TDS_CHARSET_ISO_8859_3 = 51,
565 TDS_CHARSET_ISO_8859_4 = 52,
566 TDS_CHARSET_ISO_8859_5 = 53,
567 TDS_CHARSET_ISO_8859_6 = 54,
568 TDS_CHARSET_ISO_8859_7 = 55,
569 TDS_CHARSET_ISO_8859_8 = 56,
570 TDS_CHARSET_ISO_8859_9 = 57,
571 TDS_CHARSET_ISO_IR_14 = 58,
572 TDS_CHARSET_ISO_IR_149 = 59,
573 TDS_CHARSET_ISO_IR_159 = 60,
574 TDS_CHARSET_ISO_IR_166 = 61,
575 TDS_CHARSET_ISO_IR_87 = 62,
576 TDS_CHARSET_JAVA = 63,
577 TDS_CHARSET_JISX0201_1976 = 64,
578 TDS_CHARSET_KOI8_R = 65,
579 TDS_CHARSET_KOI8_RU = 66,
580 TDS_CHARSET_KOI8_T = 67,
581 TDS_CHARSET_KOI8_U = 68,
582 TDS_CHARSET_MAC = 69,
583 TDS_CHARSET_MACARABIC = 70,
584 TDS_CHARSET_MACCENTRALEUROPE = 71,
585 TDS_CHARSET_MACCROATIAN = 72,
586 TDS_CHARSET_MACCYRILLIC = 73,
587 TDS_CHARSET_MACGREEK = 74,
588 TDS_CHARSET_MACHEBREW = 75,
589 TDS_CHARSET_MACICELAND = 76,
590 TDS_CHARSET_MACROMANIA = 77,
591 TDS_CHARSET_MACTHAI = 78,
592 TDS_CHARSET_MACTURKISH = 79,
593 TDS_CHARSET_MACUKRAINE = 80,
594 TDS_CHARSET_MULELAO_1 = 81,
595 TDS_CHARSET_NEXTSTEP = 82,
596 TDS_CHARSET_ROMAN8 = 83,
597 TDS_CHARSET_SJIS = 84,
598 TDS_CHARSET_TCVN = 85,
599 TDS_CHARSET_UCS_4BE = 86,
600 TDS_CHARSET_UCS_4LE = 87,
601 TDS_CHARSET_US_ASCII = 88,
602 TDS_CHARSET_UTF_16BE = 89,
603 TDS_CHARSET_UTF_16LE = 90,
604 TDS_CHARSET_UTF_32BE = 91,
605 TDS_CHARSET_UTF_32LE = 92,
606 TDS_CHARSET_UTF_7 = 93,
607 TDS_CHARSET_VISCII = 94,
608 TDS_NUM_CHARSETS = 95
TDS_INT tds_convert(const TDSCONTEXT *tds_ctx, int srctype, const TDS_CHAR *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr)
tds_convert convert a type to another.
Definition: convert.c:1878
DSTR new_password
new password to set (TDS 7.2+)
Definition: tds.h:531
DSTR user_name
account for login
Definition: tds.h:529
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:1112
static char * tds7_build_param_def_from_query(TDSSOCKET *tds, const char *converted_query, size_t converted_query_len, TDSPARAMINFO *params, size_t *out_len)
Return string with parameters definition, useful for TDS7+.
Definition: query.c:923
struct addrinfo * ip_addrs
ip(s) of server
Definition: tds.h:541
DSTR * tds_dstr_setlen(DSTR *s, size_t length)
limit length of string, MUST be <= current length
Definition: tdsstring.c:145
bool bulk_query
true is query sent was a bulk query so we need to switch state to QUERYING
Definition: tds.h:1200
static TDSRET tds7_build_bulk_insert_stmt(TDSSOCKET *tds, TDSPBCB *clause, TDSCOLUMN *bcpcol, int first)
Help to build query to be sent to server.
Definition: bulk.c:216
static char * tds5_fix_dot_query(const char *query, size_t *query_len, TDSPARAMINFO *params)
Substitute ?-style placeholders with named (@param) ones.
Definition: query.c:224
Used by tds_datecrack.
Definition: tds.h:157
TDSRET tds_submit_rollback(TDSSOCKET *tds, int cont)
Send a rollback request.
Definition: query.c:3719
#define TDS_PUT_N_AS_UCS2(tds, s)
Utility to convert a constant ascii string to ucs2 and send to server.
Definition: query.c:107
int(* write)(struct tds_output_stream *stream, size_t len)
write len bytes from buffer, return <0 if error or len
Definition: stream.h:41
static void tds_bcp_row_free(TDSRESULTINFO *result, unsigned char *row)
Free row data allocated in the result set.
Definition: bulk.c:869
static TDS_INT string_to_int(const char *buf, const char *pend, TDS_INT *res)
convert a number in string to TDS_INT
Definition: convert.c:3251
static bool tds_cursor_check_allocated(TDSCONNECTION *conn, TDSCURSOR *cursor)
Check if a cursor is allocated into the server.
Definition: query.c:3063
static const char * parse_numeric(const char *buf, const char *pend, bool *p_negative, size_t *p_digits, size_t *p_decimals)
Parse a string for numbers.
Definition: convert.c:3387
TDS_INT ret_status
return status from store procedure
Definition: tds.h:1203
TDS_CURSOR_STATUS status
cursor parameter
Definition: tds.h:954
DSTR server_charset
charset of server e.g.
Definition: tds.h:518
output stream to write data to a dynamic buffer
Definition: stream.h:99
TDS_INT decimicrosecond
0-9999999
Definition: tds.h:168
TDSRET tds_submit_execute(TDSSOCKET *tds, TDSDYNAMIC *dyn)
Sends a previously prepared dynamic statement to the server.
Definition: query.c:1737
const char * tds_convert_string(TDSSOCKET *tds, TDSICONV *char_conv, const char *s, int len, size_t *out_len)
Convert a string in an allocated buffer.
Definition: query.c:123
static int tds_file_stream_read(TDSINSTREAM *stream, void *ptr, size_t len)
Reads a chunk of data from file stream checking for terminator.
Definition: bulk.c:1012
TDSRET tds_bcp_fread(TDSSOCKET *tds, TDSICONV *char_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:1042
TDS_INT timezone
-840 - 840 minutes from UTC
Definition: tds.h:169
void tds_set_cur_dyn(TDSSOCKET *tds, TDSDYNAMIC *dyn)
Set current dynamic.
Definition: query.c:189
TDS_INT column_size
maximun size of data.
Definition: tds.h:696
static size_t tds_ascii_to_ucs2(char *buffer, const char *buf)
Accept an ASCII string, convert it to UCS2-LE The input is NUL-terminated, but the output does not co...
Definition: query.c:88
static int tds_bcp_add_variable_columns(TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset, TDS_UCHAR *rowbuffer, int start, int *pncols)
Add variable size columns to the row.
Definition: bulk.c:565
size_t tds_fix_column_size(TDSSOCKET *tds, TDSCOLUMN *curcol)
Get column size for wire.
Definition: query.c:1564
TDSRET tds_writetext_end(TDSSOCKET *tds)
Finish sending writetext data.
Definition: bulk.c:1167
TDSRET tds_convert_stream(TDSSOCKET *tds, TDSICONV *char_conv, TDS_ICONV_DIRECTION direction, TDSINSTREAM *istream, TDSOUTSTREAM *ostream)
Reads and writes from a stream converting characters.
Definition: stream.c:71
TDSRET tds_generic_put_info(TDSSOCKET *tds, TDSCOLUMN *col)
Put data information to wire.
Definition: data.c:873
TDS_INT cursor_id
cursor id returned by the server after cursor declare
Definition: tds.h:942
static const char * tds_next_placeholder_ucs2le(const char *start, const char *end, int named)
Found the next placeholder (? or @param) in a string.
Definition: query.c:663
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
@ TDS_DONE_ERROR
error occurred
Definition: tds.h:252
void tdsdump_log(const char *file, unsigned int level_line, const char *fmt,...)
Write a message to the debug log.
Definition: log.c:354
TDSRET tds_datecrack(TDS_INT datetype, const void *di, TDSDATEREC *dr)
Convert from db date format to a structured date format.
Definition: convert.c:3124
DSTR db_filename
database filename to attach (MSSQL)
Definition: tds.h:524
static size_t tds_quote(TDSSOCKET *tds, char *buffer, char quoting, const char *id, size_t len)
Quote a string properly.
Definition: query.c:2224
Store variant informations.
Definition: tds.h:598
TDSINSTREAM stream
common fields, must be the first field
Definition: bulk.c:970
static int tds_bcp_add_fixed_columns(TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset, unsigned char *rowbuffer, int start)
Add fixed size columns to the row.
Definition: bulk.c:480
static size_t tds_dstr_len(const DSTR *s)
Returns the length of the string in bytes.
Definition: string.h:85
static void tds_quote_and_put(TDSSOCKET *tds, const char *s, const char *end)
Send a string to server while quoting it.
Definition: query.c:3151
TDS_TINYINT emulated
this dynamic query cannot be prepared so libTDS have to construct a simple query.
Definition: tds.h:994
TDSRET tds_bcp_init(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
Initialize BCP information.
Definition: bulk.c:82
size_t tds_quote_string(TDSSOCKET *tds, char *buffer, const char *str, int len)
Quote a string.
Definition: query.c:2310
bool tds_set_server(TDSLOGIN *tds_login, const char *server) TDS_WUR
Set the servername in a TDSLOGIN structure.
Definition: login.c:125
void tds_start_query(TDSSOCKET *tds, unsigned char packet_type)
Start query packet of a given type.
Definition: query.c:345
TDSRET tds_submit_rpc(TDSSOCKET *tds, const char *rpc_name, TDSPARAMINFO *params, TDSHEADERS *head)
Calls a RPC from server.
Definition: query.c:2021
TDSCURSOR * cur_cursor
cursor in use
Definition: tds.h:1199
DSTR * tds_dstr_set(DSTR *s, char *src)
set a string from another buffer.
Definition: tdsstring.c:107
void tdsdump_off(void)
Temporarily turn off logging.
Definition: log.c:76
static void unix_to_nt_time(uint64_t *nt, struct timeval *tv)
put a 8 byte filetime from a time_t This takes GMT as input
Definition: challenge.c:556
int tds7_get_instance_port(struct addrinfo *addr, const char *instance)
Get port of given instance.
Definition: net.c:1229
static TDS_INT string_to_uint8(const char *buf, const char *pend, TDS_UINT8 *res)
convert a number in string to TDS_UINT8
Definition: convert.c:3349
TDSRET tds_bcp_send_record(TDSSOCKET *tds, TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error ignored, int offset)
Send one row of data to server.
Definition: bulk.c:334
unsigned int bulk_copy
if bulk copy should be enabled
Definition: tds.h:551
TDSRET tds_flush_packet(TDSSOCKET *tds)
Flush packet to server.
Definition: write.c:285
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:876
int tds_get_size_by_type(TDS_SERVER_TYPE servertype)
Return the number of bytes needed by specified type.
Definition: tds_types.h:9
Holds information for a dynamic (also called prepared) query.
Definition: tds.h:977
@ TDS_DONE_COUNT
count field in packet is valid
Definition: tds.h:255
void tds_staticin_stream_init(TDSSTATICINSTREAM *stream, const void *ptr, size_t len)
Initialize an input stream for read from a static allocated buffer.
Definition: stream.c:286
TDS_TINYINT column_scale
scale for decimal/numeric
Definition: tds.h:706
input stream to read data from tds protocol
Definition: stream.h:63
unsigned int out_buf_max
Maximum size of packet pointed by out_buf.
Definition: tds.h:1167
DSTR * tds_dstr_alloc(DSTR *s, size_t length)
allocate space for length char
Definition: tdsstring.c:165
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:1206
@ TDS_PENDING
cilent is waiting for data
Definition: tds.h:794
TDSAUTHENTICATION * tds_ntlm_get_auth(TDSSOCKET *tds)
Build a NTLMSPP packet to send to server.
Definition: challenge.c:691
TDSDYNAMIC * tds_alloc_dynamic(TDSCONNECTION *conn, const char *id)
Allocate a dynamic statement.
Definition: mem.c:160
TDS_INT date
date, 0 = 1900-01-01
Definition: tds.h:147
bool defer_close
true if dynamic was marker to be closed when connection is idle
Definition: tds.h:998
static int string_to_numeric(const char *instr, const char *pend, CONV_RESULT *cr)
convert a number in string to a TDSNUMERIC
Definition: convert.c:2268
TDS_UINT tds_get_uint(TDSSOCKET *tds)
Get an int32 from the server.
Definition: read.c:131
static TDSRET tds_send_emulated_rpc(TDSSOCKET *tds, const char *rpc_name, TDSPARAMINFO *params)
Send RPC as string query.
Definition: query.c:1965
TDS_STATE tds_set_state(TDSSOCKET *tds, TDS_STATE state)
Set state of TDS connection, with logging and checking.
Definition: util.c:58
void tds_dstr_free(DSTR *s)
free string
Definition: tdsstring.c:62
static TDS_INT string_to_int8(const char *buf, const char *pend, TDS_INT8 *res)
convert a number in string to TDS_INT8
Definition: convert.c:3320
unsigned in_len
input buffer length
Definition: tds.h:1170
define a stream of data used for input
Definition: stream.h:30
static int tds_dstr_isempty(const DSTR *s)
test if string is empty
Definition: string.h:60
TDSRET tds_get_char_data(TDSSOCKET *tds, char *row_buffer, size_t wire_size, TDSCOLUMN *curcol)
Fetch character data the wire.
Definition: read.c:213
TDSICONV * char_conv
refers to previously allocated iconv information
Definition: tds.h:714
void tds_datain_stream_init(TDSDATAINSTREAM *stream, TDSSOCKET *tds, size_t wire_size)
Initialize a data input stream.
Definition: stream.c:204
#define tds_put_tinyint(tds, ti)
Output a tinyint value.
Definition: tds.h:1422
TDS_INT dayofyear
day of year (1-366)
Definition: tds.h:163
static char * tds_dstr_buf(DSTR *s)
Returns a buffer to edit the string.
Definition: string.h:71
const char * tds_skip_quoted(const char *s)
Skip quoting string (like 'sfsf', "dflkdj" or [dfkjd])
Definition: query.c:535
#define TDS_IS_MSSQL(x)
Check if product is Microsft SQL Server.
Definition: tds.h:1623
void tds_set_column_type(TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type)
Set type of column initializing all dependency.
Definition: data.c:227
unsigned char tds_willconvert(int srctype, int desttype)
Test if a conversion is possible.
Definition: convert.c:3058
Structure to hold a string.
Definition: string.h:36
TDSRET tds_bcp_start_copy_in(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
Start bulk copy to server.
Definition: bulk.c:881
static void tds_set_cur_cursor(TDSSOCKET *tds, TDSCURSOR *cursor)
Set current cursor.
Definition: query.c:2322
Metadata about columns in regular and compute rows.
Definition: tds.h:690
TDSRET tds_get_column_declaration(TDSSOCKET *tds, TDSCOLUMN *curcol, char *out)
Return declaration for column (like "varchar(20)").
Definition: query.c:737
input stream to read data from a static buffer
Definition: stream.h:81
size_t tds_iconv(TDSSOCKET *tds, TDSICONV *conv, TDS_ICONV_DIRECTION io, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
Wrapper around iconv(3).
Definition: iconv.c:551
DSTR * tds_dstr_get(TDSSOCKET *tds, DSTR *s, size_t len)
Reads a string from wire and put in a DSTR.
Definition: read.c:311
TDS_INT second
0-59
Definition: tds.h:167
FILE * f
file to read from
Definition: bulk.c:972
char * query
SQL query.
Definition: tds.h:948
TDS_INT day
day of month (1-31)
Definition: tds.h:162
TDS_INT weekday
day of week (0-6, 0 = sunday)
Definition: tds.h:164
#define tds_dstr_empty(s)
Make a string empty.
Definition: string.h:91
int tds_count_placeholders(const char *query)
Count the number of placeholders ('?') in a query.
Definition: query.c:591
DSTR server_name
server name (in freetds.conf)
Definition: tds.h:513
static TDSRET tds_put_data(TDSSOCKET *tds, TDSCOLUMN *curcol)
Write data to wire.
Definition: query.c:276
Holds clause buffer.
Definition: bulk.c:58
bool tds_get_n(TDSSOCKET *tds, void *dest, size_t need)
Get N bytes from the buffer and return them in the already allocated space given to us.
Definition: read.c:248
int tm_min
minutes (0-59)
Definition: convert.c:60
static const char * tds_dstr_cstr(const DSTR *s)
Returns a C version (NUL terminated string) of dstr.
Definition: string.h:78
TDS_USMALLINT tds_version
TDS version.
Definition: tds.h:515
DSTR * tds_dstr_dup(DSTR *s, const DSTR *src)
Duplicate a string from another dynamic string.
Definition: tdsstring.c:134
TDSRET tds_deferred_unprepare(TDSCONNECTION *conn, TDSDYNAMIC *dyn)
Unprepare dynamic on idle.
Definition: query.c:1864
static char * tds7_build_param_def_from_params(TDSSOCKET *tds, const char *query, size_t query_len, TDSPARAMINFO *params, size_t *out_len)
Return string with parameters definition, useful for TDS7+.
Definition: query.c:988
int tm_sec
seconds (0-59)
Definition: convert.c:61
TDSRET tds_dynamic_stream_init(TDSDYNAMICSTREAM *stream, void **ptr, size_t allocated)
Initialize a dynamic output stream.
Definition: stream.c:354
static int stringz_to_numeric(const char *instr, CONV_RESULT *cr)
convert a zero terminated string to NUMERIC
Definition: convert.c:2262
TDS_SMALLINT offset
time offset
Definition: tds.h:148
unsigned char in_flag
input buffer type
Definition: tds.h:1171
TDS_INT tds_numeric_to_string(const TDS_NUMERIC *numeric, char *s)
Definition: numeric.c:95
size_t tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC *dr, int prec)
format a date string according to an "extended" strftime(3) formatting definition.
Definition: convert.c:2970
Hold information for any results.
Definition: tds.h:769
struct tds_file_stream TDSFILESTREAM
input stream to read a file
DSTR * tds_dstr_copy(DSTR *s, const char *src)
copy a string from another
Definition: tdsstring.c:122
TDSDYNAMIC * cur_dyn
dynamic structure in use
Definition: tds.h:1212
TDS_INT ref_count
reference counter so client can retain safely a pointer
Definition: tds.h:940
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:2123
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:363
unsigned int from_malloc
true is buffer came from malloc
Definition: bulk.c:65
static void tds7_put_query_params(TDSSOCKET *tds, const char *query, size_t query_len)
Output params types and query (required by sp_prepare/sp_executesql/sp_prepexec)
Definition: query.c:1102
tds_func_put_info * put_info
Send metadata column information to server.
Definition: tds.h:654
struct tds_blob TDSBLOB
Information about blobs (e.g.
char * pb
buffer
Definition: bulk.c:61
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:394
TDSRET tds_deferred_cursor_dealloc(TDSCONNECTION *conn, TDSCURSOR *cursor)
Deallocate cursor on idle.
Definition: query.c:3129
static TDS_INT parse_int8(const char *buf, const char *pend, TDS_UINT8 *res, bool *p_negative)
convert a number in string to TDS_INT8
Definition: convert.c:3290
TDSRET tds_submit_begin_tran(TDSSOCKET *tds)
Send a rollback request.
Definition: query.c:3691
static TDSRET tds_answer_challenge(TDSSOCKET *tds, TDSLOGIN *login, const unsigned char *challenge, uint32_t *flags, const unsigned char *names_blob, int names_blob_len, TDSANSWER *answer, unsigned char **ntlm_v2_response)
Crypt a given password using schema required for NTLMv1 or NTLM2 authentication.
Definition: challenge.c:291
void tds_set_param_type(TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type)
Set type of column initializing all dependency.
Definition: data.c:249
TDS_TINYINT column_prec
precision for decimal/numeric
Definition: tds.h:705
TDSRET tds_bcp_start(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
Start sending BCP data to server.
Definition: bulk.c:834
Information relevant to libiconv.
Definition: tds.h:612
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:184
static TDSRET tds_put_params(TDSSOCKET *tds, TDSPARAMINFO *info, int flags) TDS_WUR
Send parameters to server.
Definition: query.c:1802
void tdsdump_on(void)
Turn logging back on.
Definition: log.c:88
unsigned int cb
buffer length
Definition: bulk.c:63
int tds_read_packet(TDSSOCKET *tds)
Read in one 'packet' from the server.
Definition: packet.c:531
static void tds_swap_numeric(TDS_NUMERIC *num)
Converts numeric from Microsoft representation to internal one (Sybase).
Definition: data.c:1724
TDSRET tds_cursor_dealloc(TDSSOCKET *tds, TDSCURSOR *cursor)
Send a deallocation request to server.
Definition: query.c:3078
TDSRET tds_submit_execdirect(TDSSOCKET *tds, const char *query, TDSPARAMINFO *params, TDSHEADERS *head)
Submit a prepared query with parameters.
Definition: query.c:1326
TDS_SERVER_TYPE column_type
This type can be different from wire type because conversion (e.g.
Definition: tds.h:698
TDS_INT8 rows_affected
rows updated/deleted/inserted/selected, TDS_NO_COUNT if not valid
Definition: tds.h:1209
Definition: challenge.c:533
this structure is not directed connected to a TDS protocol but keeps any DATE/TIME information.
Definition: tds.h:144
char * left
buffer for store bytes readed that could be the terminator
Definition: bulk.c:980
bool defer_close
true if cursor was marker to be closed when connection is idle
Definition: tds.h:947
int tm_hour
hours (0-23)
Definition: convert.c:59
#define DSTR_INITIALIZER
Initializer, used to initialize string like in the following example.
Definition: string.h:49
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:3415
@ TDS_IDLE
no data expected
Definition: tds.h:791
TDS_INT quarter
quarter (0-3)
Definition: tds.h:160
static TDSRET tds7_send_execute(TDSSOCKET *tds, TDSDYNAMIC *dyn)
Send dynamic request on TDS 7+ to be executed.
Definition: query.c:1700
TDSRET tds_generic_put(TDSSOCKET *tds, TDSCOLUMN *curcol, int bcp7)
Write data to wire.
Definition: data.c:945
@ TDS_SENDING
client would send data
Definition: tds.h:793
unsigned int pending_close
true is connection has pending closing (cursors or dynamic)
Definition: tds.h:1103
unsigned in_pos
current position in in_buf
Definition: tds.h:1168
int(* read)(struct tds_input_stream *stream, void *ptr, size_t len)
read some data Return 0 if end of stream Return <0 if error (actually not defined)
Definition: stream.h:35
TDSRET tds_submit_queryf(TDSSOCKET *tds, const char *queryf,...)
Format and submit a query.
Definition: query.c:487
TDS_INT month
month number (0-11)
Definition: tds.h:161
void tds_release_dynamic(TDSDYNAMIC **pdyn)
Frees dynamic statement.
Definition: mem.c:253
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:1187
bool has_status
true is ret_status is valid
Definition: tds.h:1201
char * cursor_name
name of the cursor
Definition: tds.h:941
TDSRET tds_submit_unprepare(TDSSOCKET *tds, TDSDYNAMIC *dyn)
Send a unprepare request for a prepared query.
Definition: query.c:1887
Definition: challenge.c:64
TDSRET tds_process_login_tokens(TDSSOCKET *tds)
tds_process_login_tokens() is called after sending the login packet to the server.
Definition: token.c:409
int tm_year
year (0=1900)
Definition: convert.c:56
struct tds_pbcb TDSPBCB
Holds clause buffer.
int tm_ns
nanoseconds (0-999999999)
Definition: convert.c:62
TDS_SERVER_TYPE tds_get_null_type(TDS_SERVER_TYPE srctype)
Get same type but nullable.
Definition: convert.c:2915
static int store_monthname(const char *, struct tds_time *)
Test if a string is a month name and store correct month number.
Definition: convert.c:2708
Information about blobs (e.g.
Definition: tds.h:587
TDS_USMALLINT tds_get_usmallint(TDSSOCKET *tds)
Get an int16 from the server.
Definition: read.c:113
static TDSRET tds_put_data_info(TDSSOCKET *tds, TDSCOLUMN *curcol, int flags)
Put data information to wire.
Definition: query.c:1606
static void tds7_put_params_definition(TDSSOCKET *tds, const char *param_definition, size_t param_length)
Send parameters definition to server.
Definition: query.c:1154
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:1210
TDSRESULTINFO * current_results
Current query information.
Definition: tds.h:1194
const char * tds_next_placeholder(const char *start)
Get position of next placeholder.
Definition: query.c:555
char * buffer
write buffer.
Definition: stream.h:50
static TDSRET tds_bcp_start_insert_stmt(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
Prepare the query to be sent to server to request BCP information.
Definition: bulk.c:263
Definition: challenge.c:71
static int tds_put_data_info_length(TDSSOCKET *tds, TDSCOLUMN *curcol, int flags)
Calc information length in bytes (useful for calculating full packet length)
Definition: query.c:1676
static TDS_INT string_to_result(int desttype, const char *s, CONV_RESULT *cr)
Copy a terminated string to result and return len or TDS_CONVERT_NOMEM.
Definition: convert.c:161
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:125
unsigned char * in_buf
Input buffer.
Definition: tds.h:1154
TDS_UINT product_version
version of product (Sybase/MS and full version)
Definition: tds.h:1072
int port
port of database service
Definition: tds.h:514
tds_func_put_data * put_data
Send column data to server.
Definition: tds.h:664
void tds_dstr_zero(DSTR *s)
clear all string filling with zeroes (mainly for security reason)
Definition: tdsstring.c:55
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:1472
int tm_mday
month day (1-31)
Definition: convert.c:58
static const char * tds_skip_quoted_ucs2le(const char *s, const char *end)
Return pointer to end of a quoted string.
Definition: query.c:637
unsigned char tds_get_byte(TDSSOCKET *tds)
Return a single byte from the input buffer.
Definition: read.c:72
TDS_INT hour
0-23
Definition: tds.h:165
int tds_needs_unprepare(TDSCONNECTION *conn, TDSDYNAMIC *dyn)
Check if dynamic request must be unprepared.
Definition: query.c:1842
unsigned char out_flag
output buffer type
Definition: tds.h:1172
int tm_mon
month (0-11)
Definition: convert.c:57
TDSRET tds_generic_get(TDSSOCKET *tds, TDSCOLUMN *curcol)
Read a data from wire.
Definition: data.c:709
TDS_UINT8 time
time, 7 digit precision
Definition: tds.h:146
TDSRET tds_submit_commit(TDSSOCKET *tds, int cont)
Send a commit request.
Definition: query.c:3750
@ TDS_WRITING
client is writing data
Definition: tds.h:792
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:307
TDSRET tds_bcp_done(TDSSOCKET *tds, int *rows_copied)
Tell we finished sending BCP data to server.
Definition: bulk.c:804
DSTR password
password of account login
Definition: tds.h:530
input stream to read a file
Definition: bulk.c:968
#define TDS_SYB_VER(maj, min, x)
Calc a version number for Sybase.
Definition: tds.h:1632
Information for a server connection.
Definition: tds.h:1141
TDS_INT year
year
Definition: tds.h:159
tds_func_put_info_len * put_info_len
Returns metadata column information size.
Definition: tds.h:648
TDSPARAMINFO * params
query parameters.
Definition: tds.h:1008
static TDSRET tds_start_query_head(TDSSOCKET *tds, unsigned char packet_type, TDSHEADERS *head)
Start query packet of a given type.
Definition: query.c:288
TDS_INT num_id
numeric id for mssql7+
Definition: tds.h:982
static int tds_count_placeholders_ucs2le(const char *query, const char *query_end)
Count the number of placeholders ('?') in a query.
Definition: query.c:711
size_t size
size of data inside buffer
Definition: stream.h:106
const char * tds_skip_comment(const char *s)
Skip a comment in a query.
Definition: query.c:510
int tds_put_string(TDSSOCKET *tds, const char *s, int len)
Output a string to wire automatic translate string to unicode if needed.
Definition: write.c:93
void tds_close_socket(TDSSOCKET *tds)
Close current socket.
Definition: net.c:548
TDS_INT type
row fetched from this cursor
Definition: tds.h:957
TDSLOGIN * login
config for login stuff.
Definition: tds.h:1214
static TDS_INT binary_to_result(int desttype, const void *data, size_t len, CONV_RESULT *cr)
Copy binary data to to result and return len or TDS_CONVERT_NOMEM.
Definition: convert.c:179
char id[30]
id of dynamic.
Definition: tds.h:988
const char * tds_prtype(int type)
Returns string representation of the given type.
Definition: token.c:3052
static TDSRET tds7_bcp_send_colmetadata(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
Send BCP metadata to server.
Definition: bulk.c:706
char * query
saved query, we need to know original query if prepare is impossible
Definition: tds.h:1010
int tdsdump_open(const char *filename)
Create and truncate a human readable dump file for the TDS traffic.
Definition: log.c:112
static TDSRET tds_query_flush_packet(TDSSOCKET *tds)
Flush query packet.
Definition: query.c:175
TDS_INT ref_count
reference counter so client can retain safely a pointer
Definition: tds.h:980
TDS_INT cursor_rows
< number of updatable columns
Definition: tds.h:952
const char * terminator
terminator
Definition: bulk.c:975
size_t wire_size
bytes still to read
Definition: stream.h:65
size_t tds_quote_id(TDSSOCKET *tds, char *buffer, const char *id, int idlen)
Quote an id.
Definition: query.c:2266
static TDSRET tds_send_emulated_execute(TDSSOCKET *tds, const char *query, TDSPARAMINFO *params)
Emulate prepared execute traslating to a normal language.
Definition: query.c:3295
TDS_INT minute
0-59
Definition: tds.h:166
void tdsdump_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:256
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:1150
static const char * tds_skip_comment_ucs2le(const char *s, const char *end)
Skip a comment in a query.
Definition: query.c:609
size_t term_len
terminator length in bytes
Definition: bulk.c:977
Holds informations about a cursor.
Definition: tds.h:937
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
static TDSRET tds_put_param_as_string(TDSSOCKET *tds, TDSPARAMINFO *params, int n)
Send a parameter to server.
Definition: query.c:3179
TDSRET tds_submit_query(TDSSOCKET *tds, const char *query)
Sends a language string to the database server for processing.
Definition: query.c:207
TDS_INT column_cur_size
size written in variable (ie: char, text, binary).
Definition: tds.h:737
TDSRET tds_process_tokens(TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag)
process all streams.
Definition: token.c:529
TDS_TINYINT column_varint_size
size of length when reading from wire (0, 1, 2 or 4)
Definition: tds.h:703
TDSRET tds_copy_stream(TDSINSTREAM *istream, TDSOUTSTREAM *ostream)
Reads and writes from a stream to another.
Definition: stream.c:163