FreeTDS API

stdint.h
1 #include <inttypes.h>
tds_dynamic
Holds information for a dynamic (also called prepared) query.
Definition: tds.h:977
tds_socket::bulk_query
bool bulk_query
true is query sent was a bulk query so we need to switch state to QUERYING
Definition: tds.h:1244
tds_submit_unprepare
TDSRET tds_submit_unprepare(TDSSOCKET *tds, TDSDYNAMIC *dyn)
Send a unprepare request for a prepared query.
Definition: query.c:1797
tds_process_param_result
static TDSRET tds_process_param_result(TDSSOCKET *tds, TDSPARAMINFO **info)
process output parameters of a stored procedure.
Definition: token.c:1302
tds_env::charset
char * charset
character set encoding
Definition: tds.h:968
tds5_process_result
static TDSRET tds5_process_result(TDSSOCKET *tds)
tds5_process_result() is the TDS 5.0 result set processing routine.
Definition: token.c:1734
tds_dynamic::defer_close
bool defer_close
true if dynamic was marker to be closed when connection is idle
Definition: tds.h:997
ptw32_mcs_node_t_
Definition: ptw32_MCS_lock.c:98
tds_pr_op
static const char * tds_pr_op(int op)
Returns string representation for a given operation.
Definition: token.c:3023
tds_set_state
TDS_STATE tds_set_state(TDSSOCKET *tds, TDS_STATE state)
Set state of TDS connection, with logging and checking.
Definition: util.c:58
TDS_READING
@ TDS_READING
client is reading data
Definition: tds.h:794
tds_cursor::status
TDS_CURSOR_STATUS status
cursor parameter
Definition: tds.h:953
tds_dstr_cstr
static const char * tds_dstr_cstr(const DSTR *s)
Returns a C version (NUL terminated string) of dstr.
Definition: string.h:78
tds_connection::cursors
TDSCURSOR * cursors
linked list of cursors allocated for this connection contains only cursors allocated on the server
Definition: tds.h:1107
tds_socket::has_status
bool has_status
true is ret_status is valid
Definition: tds.h:1245
TDS_DONE_COUNT
@ TDS_DONE_COUNT
count field in packet is valid
Definition: tds.h:256
tds7_process_compute_result
static TDSRET tds7_process_compute_result(TDSSOCKET *tds)
tds7_process_compute_result() processes compute result sets for TDS 7/8.
Definition: token.c:2837
tds_raw_mutex
Definition: thread.h:250
tds_prtype
const char * tds_prtype(int type)
Returns string representation of the given type.
Definition: token.c:3056
tds_socket::in_pos
unsigned in_pos
current position in in_buf
Definition: tds.h:1192
tds.h
Main include file for libtds.
tds_connection::env
TDSENV env
environment is shared between all sessions
Definition: tds.h:1101
tds5_process_optioncmd
static TDSRET tds5_process_optioncmd(TDSSOCKET *tds)
Process option cmd results.
Definition: token.c:2972
tds_dstr_isempty
static int tds_dstr_isempty(const DSTR *s)
test if string is empty
Definition: string.h:60
tds_staticin_stream
input stream to read data from a static buffer
Definition: stream.h:81
tds_socket::login
TDSLOGIN * login
config for login stuff.
Definition: tds.h:1258
tds_unget_byte
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
tds_dataout_stream
output stream to write data to tds protocol
Definition: stream.h:72
tds_encoding::canonic
unsigned char canonic
internal numeric index into array of all encodings
Definition: tds.h:624
tds_cursor
Holds informations about a cursor.
Definition: tds.h:937
tds_socket::out_buf
unsigned char * out_buf
Output buffer.
Definition: tds.h:1185
tds_set_cur_dyn
void tds_set_cur_dyn(TDSSOCKET *tds, TDSDYNAMIC *dyn)
Set current dynamic.
Definition: query.c:192
string_linked_list
Definition: vstrbuild.c:37
tds_connection::product_version
TDS_UINT product_version
version of product (Sybase/MS and full version)
Definition: tds.h:1093
tds_cursor::cursor_id
TDS_INT cursor_id
cursor id returned by the server after cursor declare
Definition: tds.h:941
tds_process_col_fmt
static TDSRET tds_process_col_fmt(TDSSOCKET *tds)
tds_process_col_fmt() is the other half of result set processing under TDS 4.2.
Definition: token.c:1052
tds_socket::rows_affected
TDS_INT8 rows_affected
rows updated/deleted/inserted/selected, TDS_NO_COUNT if not valid
Definition: tds.h:1254
tds_column::column_prec
TDS_TINYINT column_prec
precision for decimal/numeric
Definition: tds.h:703
tds_socket::in_buf
unsigned char * in_buf
Input buffer.
Definition: tds.h:1177
tds_socket::cur_cursor
TDSCURSOR * cur_cursor
cursor in use
Definition: tds.h:1243
tds_close_socket
void tds_close_socket(TDSSOCKET *tds)
Close current socket.
Definition: net.c:548
pollfd
Definition: poll.h:52
tds_connection::dyns
TDSDYNAMIC * dyns
list of dynamic allocated for this connection contains only dynamic allocated on the server
Definition: tds.h:1112
tds_alloc_row
TDSRET tds_alloc_row(TDSRESULTINFO *res_info)
Allocate space for row store return NULL on out of memory.
Definition: mem.c:524
namelist
Holds list of names.
Definition: token.c:914
tds_token_name
static const char * tds_token_name(unsigned char marker)
Returns string representation for a given token type.
Definition: token.c:3130
tds_goodread
int tds_goodread(TDSSOCKET *tds, unsigned char *buf, int buflen)
Loops until we have received some characters return -1 on failure.
Definition: net.c:914
MD5Context
Definition: md5.h:8
tds_cursor_dealloc
TDSRET tds_cursor_dealloc(TDSSOCKET *tds, TDSCURSOR *cursor)
Send a deallocation request to server.
Definition: query.c:3006
tds_socket::in_row
bool in_row
true if we are getting rows
Definition: tds.h:1246
tds_iconv_get_info
TDSICONV * tds_iconv_get_info(TDSCONNECTION *conn, int canonic_client, int canonic_server)
Get a iconv info structure, allocate and initialize if needed.
Definition: iconv.c:758
tds_process_compute
static TDSRET tds_process_compute(TDSSOCKET *tds)
tds_process_compute() processes compute rows and places them in the row buffer.
Definition: token.c:1903
poll.h
Provide poll call where missing.
adjust_character_column_size
static void adjust_character_column_size(TDSSOCKET *tds, TDSCOLUMN *curcol)
Adjust column size according to client's encoding.
Definition: token.c:3226
tds_dynamic::emulated
TDS_TINYINT emulated
this dynamic query cannot be prepared so libTDS have to construct a simple query.
Definition: tds.h:993
tds_process_cancel
TDSRET tds_process_cancel(TDSSOCKET *tds)
Definition: token.c:2554
tds_process_auth
static TDSRET tds_process_auth(TDSSOCKET *tds)
Process authentication token.
Definition: token.c:457
tds_process_simple_query
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:881
tds_get_token_size
int tds_get_token_size(int marker)
tds_get_token_size() returns the size of a fixed length token used by tds_process_cancel() to determi...
Definition: token.c:2754
tds_dstr_copyn
DSTR * tds_dstr_copyn(DSTR *s, const char *src, size_t length)
Set string to a given buffer of characters.
Definition: tdsstring.c:77
tds_dstr_dup
DSTR * tds_dstr_dup(DSTR *s, const DSTR *src)
Duplicate a string from another dynamic string.
Definition: tdsstring.c:134
tds_process_row
static TDSRET tds_process_row(TDSSOCKET *tds)
tds_process_row() processes rows and places them in the row buffer.
Definition: token.c:1942
tds_peek
unsigned char tds_peek(TDSSOCKET *tds)
Reads a byte from the TDS stream without removing it.
Definition: read.c:100
tds_lookup_dynamic
TDSDYNAMIC * tds_lookup_dynamic(TDSCONNECTION *conn, const char *id)
Finds a dynamic given string id.
Definition: token.c:2587
tds_dstr_setlen
DSTR * tds_dstr_setlen(DSTR *s, size_t length)
limit length of string, MUST be <= current length
Definition: tdsstring.c:145
tds_str_empty
const struct tds_dstr tds_str_empty
Internal representation for an empty string.
Definition: tdsstring.c:45
tds_get_data_info
static TDSRET tds_get_data_info(TDSSOCKET *tds, TDSCOLUMN *curcol, int is_param)
Reads data metadata from wire.
Definition: token.c:1646
tds_message
Definition: tds.h:876
tds_dstr_set
DSTR * tds_dstr_set(DSTR *s, char *src)
set a string from another buffer.
Definition: tdsstring.c:107
tds_process_colinfo
static TDSRET tds_process_colinfo(TDSSOCKET *tds, char **names, int num_names)
Reads column information.
Definition: token.c:1237
MD4Context
Definition: md4.h:9
tds_column
Metadata about columns in regular and compute rows.
Definition: tds.h:689
tdsiconvinfo
Definition: iconv.h:92
tds_cursor::next
struct tds_cursor * next
next in linked list, keep first
Definition: tds.h:938
tds_encoding::name
const char * name
name of the encoding (ie UTF-8)
Definition: tds.h:620
tds_connection
Definition: tds.h:1091
tds_cursor::ref_count
TDS_INT ref_count
reference counter so client can retain safely a pointer
Definition: tds.h:939
tds_get_byte
unsigned char tds_get_byte(TDSSOCKET *tds)
Return a single byte from the input buffer.
Definition: read.c:72
tds_process_col_name
static TDSRET tds_process_col_name(TDSSOCKET *tds)
tds_process_col_name() is one half of the result set under TDS 4.2 it contains all the column names,...
Definition: token.c:1004
tds_dstr_get
DSTR * tds_dstr_get(TDSSOCKET *tds, DSTR *s, size_t len)
Reads a string from wire and put in a DSTR.
Definition: read.c:293
tds_socket::out_flag
unsigned char out_flag
output buffer type
Definition: tds.h:1196
tds_goodwrite
int tds_goodwrite(TDSSOCKET *tds, const unsigned char *buffer, size_t buflen)
Definition: net.c:985
tds_process_tabname
static TDSRET tds_process_tabname(TDSSOCKET *tds)
Process list of table from network.
Definition: token.c:1188
tds_dynamic::next
struct tds_dynamic * next
next in linked list, keep first
Definition: tds.h:978
dlist_ring
Definition: dlist.h:23
tds_socket::in_cancel
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:1248
tds_get_string
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
tds_cursor::defer_close
bool defer_close
true if cursor was marker to be closed when connection is idle
Definition: tds.h:946
tds_dynamic::ref_count
TDS_INT ref_count
reference counter so client can retain safely a pointer
Definition: tds.h:979
tds_condition
Definition: thread.h:278
TDS_SENDING
@ TDS_SENDING
client would send data
Definition: tds.h:792
tds_process_login_tokens
TDSRET tds_process_login_tokens(TDSSOCKET *tds)
tds_process_login_tokens() is called after sending the login packet to the server.
Definition: token.c:411
tds_read_packet
int tds_read_packet(TDSSOCKET *tds)
Read in one 'packet' from the server.
Definition: packet.c:527
tds_dstr
Structure to hold a string.
Definition: string.h:36
tds_result_info
Hold information for any results.
Definition: tds.h:769
tds_alloc_param_result
TDSPARAMINFO * tds_alloc_param_result(TDSPARAMINFO *old_param)
Adds a output parameter to TDSPARAMINFO.
Definition: mem.c:284
tds_socket::cur_dyn
TDSDYNAMIC * cur_dyn
dynamic structure in use
Definition: tds.h:1256
tds7_get_data_info
static TDSRET tds7_get_data_info(TDSSOCKET *tds, TDSCOLUMN *curcol)
Reads data information from wire.
Definition: token.c:1514
tds_socket::current_results
TDSRESULTINFO * current_results
Current query information.
Definition: tds.h:1238
tds_alloc_param_data
void * tds_alloc_param_data(TDSCOLUMN *curparam)
Allocate data for a parameter.
Definition: mem.c:364
tds_alloc_get_string
static int tds_alloc_get_string(TDSSOCKET *tds, char **string, size_t len)
Reads a string from wire in a new allocated buffer.
Definition: token.c:2527
tds_login::server_name
DSTR server_name
server name (in freetds.conf)
Definition: tds.h:518
tds_socket::in_len
unsigned in_len
input buffer length
Definition: tds.h:1194
tds_process_param_result_tokens
static TDSRET tds_process_param_result_tokens(TDSSOCKET *tds)
Process parameters from networks.
Definition: token.c:1358
tds_socket::out_pos
unsigned out_pos
current position in out_buf
Definition: tds.h:1193
tds_column::column_size
TDS_INT column_size
maximun size of data.
Definition: tds.h:694
tds_dstr_alloc
DSTR * tds_dstr_alloc(DSTR *s, size_t length)
allocate space for length char
Definition: tdsstring.c:165
namelist::name
char * name
string name
Definition: token.c:916
tds_socket::ret_status
TDS_INT ret_status
return status from store procedure
Definition: tds.h:1250
tds_convert_stream
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
tds_process_info
static TDSRET tds_process_info(TDSSOCKET *tds, int marker)
tds_process_info() is called for INFO, ERR, or EED tokens and is responsible for calling the CLI's me...
Definition: token.c:2332
tds_column::column_cur_size
TDS_INT column_cur_size
size written in variable (ie: char, text, binary).
Definition: tds.h:736
tds_column::char_conv
TDSICONV * char_conv
refers to previously allocated iconv information
Definition: tds.h:712
tds_column::column_varint_size
TDS_TINYINT column_varint_size
size of length when reading from wire (0, 1, 2 or 4)
Definition: tds.h:701
tds_process_compute_result
static TDSRET tds_process_compute_result(TDSSOCKET *tds)
tds_process_compute_result() processes compute result sets.
Definition: token.c:1414
tds_staticin_stream_init
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_IS_MSSQL
#define TDS_IS_MSSQL(x)
Check if product is Microsft SQL Server.
Definition: tds.h:1722
tds_dstr_free
void tds_dstr_free(DSTR *s)
free string
Definition: tdsstring.c:62
tds_dstr_copy
DSTR * tds_dstr_copy(DSTR *s, const char *src)
copy a string from another
Definition: tdsstring.c:122
tds_process_dynamic
static TDSDYNAMIC * tds_process_dynamic(TDSSOCKET *tds)
tds_process_dynamic() finds the element of the dyns array for the id
Definition: token.c:2607
tds_put_string
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:97
tds_process_env_chg
static TDSRET tds_process_env_chg(TDSSOCKET *tds)
tds_process_env_chg() when ever certain things change on the server, such as database,...
Definition: token.c:2195
tdserror
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:321
tds_quote_id
size_t tds_quote_id(TDSSOCKET *tds, char *buffer, const char *id, int idlen)
Quote an id.
Definition: query.c:2171
tdsdump_dump_buf
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:293
tds_process_params_result_token
static TDSRET tds_process_params_result_token(TDSSOCKET *tds)
tds_process_params_result_token() processes params on TDS5.
Definition: token.c:1388
tds_column::column_scale
TDS_TINYINT column_scale
scale for decimal/numeric
Definition: tds.h:704
tds_dynamic::res_info
TDSPARAMINFO * res_info
query results
Definition: tds.h:999
tds_free_namelist
static void tds_free_namelist(struct namelist *head)
Frees list of names.
Definition: token.c:926
TDS_DEAD
@ TDS_DEAD
no connection
Definition: tds.h:795
tds_strndup
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:406
tds_release_dynamic
void tds_release_dynamic(TDSDYNAMIC **pdyn)
Frees dynamic statement.
Definition: mem.c:253
tds_env::database
char * database
database name
Definition: tds.h:970
tds_process_cursor_tokens
static TDSRET tds_process_cursor_tokens(TDSSOCKET *tds)
Reads cursor command results.
Definition: token.c:2929
tds_login::crlfile
DSTR crlfile
certificate revocation file
Definition: tds.h:531
determine_adjusted_size
static int determine_adjusted_size(const TDSICONV *char_conv, int size)
Allow for maximum possible size of converted data, while being careful about integer division truncat...
Definition: token.c:3294
tds71_read_table_names
static int tds71_read_table_names(TDSSOCKET *tds, int remainder, struct namelist **p_head)
Reads table names for TDS 7.1+.
Definition: token.c:1105
tds5_process_dyn_result2
static TDSRET tds5_process_dyn_result2(TDSSOCKET *tds)
Process new TDS 5.0 token for describing output parameters.
Definition: token.c:2685
tds5_process_result2
static TDSRET tds5_process_result2(TDSSOCKET *tds)
tds5_process_result2() is the new TDS 5.0 result set processing routine.
Definition: token.c:1781
tds_dynamic::id
char id[30]
id of dynamic.
Definition: tds.h:987
tds_authentication
Definition: tds.h:1047
tds_process_default_tokens
static TDSRET tds_process_default_tokens(TDSSOCKET *tds, int marker)
tds_process_default_tokens() is a catch all function that is called to process tokens not known to ot...
Definition: token.c:122
tds_read_namelist
static int tds_read_namelist(TDSSOCKET *tds, int remainder, struct namelist **p_head, int large)
Reads list of names (usually table names)
Definition: token.c:946
tds_process_end
static TDSRET tds_process_end(TDSSOCKET *tds, int marker, int *flags_parm)
tds_process_end() processes any of the DONE, DONEPROC, or DONEINPROC tokens.
Definition: token.c:2082
tds_connection::pending_close
unsigned int pending_close
true is connection has pending closing (cursors or dynamic)
Definition: tds.h:1123
tds_get_n
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:230
tds_process_pending_closes
static void tds_process_pending_closes(TDSSOCKET *tds)
Attempt to close all deferred closes (dynamics and cursors).
Definition: token.c:2018
TDS_IDLE
@ TDS_IDLE
no data expected
Definition: tds.h:790
tds_socket
Information for a server connection.
Definition: tds.h:1163
tds_capability_type
Definition: tds.h:504
namelist::next
struct namelist * next
next element in the list
Definition: token.c:918
des_key
Definition: des.h:16
tds_encoding
Information relevant to libiconv.
Definition: tds.h:618
tds_dataout_stream_init
void tds_dataout_stream_init(TDSDATAOUTSTREAM *stream, TDSSOCKET *tds)
Initialize a data output stream.
Definition: stream.c:244
TDS_SYB_VER
#define TDS_SYB_VER(maj, min, x)
Calc a version number for Sybase.
Definition: tds.h:1731
tds_socket::out_buf_max
unsigned int out_buf_max
Maximum size of packet pointed by out_buf.
Definition: tds.h:1191
tds_process_dyn_result
static TDSRET tds_process_dyn_result(TDSSOCKET *tds)
Process results from dynamic.
Definition: token.c:2643
TDS_DONE_CANCELLED
@ TDS_DONE_CANCELLED
acknowledging an attention command (usually a cancel)
Definition: tds.h:257
TDS_DONE_ERROR
@ TDS_DONE_ERROR
error occurred
Definition: tds.h:253
tds_flush_packet
TDSRET tds_flush_packet(TDSSOCKET *tds)
Flush packet to server.
Definition: write.c:224
tds7_process_result
static TDSRET tds7_process_result(TDSSOCKET *tds)
tds7_process_result() is the TDS 7.0 result set processing routine.
Definition: token.c:1571
tds_process_compute_names
static TDSRET tds_process_compute_names(TDSSOCKET *tds)
tds_process_compute_names() processes compute result sets.
Definition: token.c:2777
tds_process_tokens
TDSRET tds_process_tokens(TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag)
process all streams.
Definition: token.c:531
tds_dynamic::num_id
TDS_INT num_id
numeric id for mssql7+
Definition: tds.h:981
TDS_PENDING
@ TDS_PENDING
cilent is waiting for data
Definition: tds.h:793
tds_column::column_type
TDS_SERVER_TYPE column_type
This type can be different from wire type because conversion (e.g.
Definition: tds.h:696
tds_write_dump
int tds_write_dump
Tell if TDS debug logging is turned on or off.
Definition: log.c:58
tds_get_uint
TDS_UINT tds_get_uint(TDSSOCKET *tds)
Get an int32 from the server.
Definition: read.c:127
tds_get_usmallint
TDS_USMALLINT tds_get_usmallint(TDSSOCKET *tds)
Get an int16 from the server.
Definition: read.c:113
tds_login::cafile
DSTR cafile
certificate authorities file
Definition: tds.h:530
TDS_DONE_MORE_RESULTS
@ TDS_DONE_MORE_RESULTS
more results follow
Definition: tds.h:252
tds_process_nbcrow
static TDSRET tds_process_nbcrow(TDSSOCKET *tds)
tds_process_nbcrow() processes rows and places them in the row buffer.
Definition: token.c:1966
tds_free_param_result
void tds_free_param_result(TDSPARAMINFO *param_info)
Delete latest parameter.
Definition: mem.c:320
tds_dstr_zero
void tds_dstr_zero(DSTR *s)
clear all string filling with zeroes (mainly for security reason)
Definition: tdsstring.c:55
tdsdump_log
void tdsdump_log(const char *file, unsigned int level_line, const char *fmt,...)
Write a message to the debug log.
Definition: log.c:396
tdsdump_col
void tdsdump_col(const TDSCOLUMN *col)
Write a column value to the debug log.
Definition: log.c:455