FreeTDS API

stdint.h
1 #include <inttypes.h>
namelist::name
char * name
string name
Definition: token.c:911
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:2328
tds.h
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_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:1200
tds_write_dump
int tds_write_dump
Tell if TDS debug logging is turned on or off.
Definition: log.c:58
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:2189
tds_socket::ret_status
TDS_INT ret_status
return status from store procedure
Definition: tds.h:1203
tds_process_colinfo
static TDSRET tds_process_colinfo(TDSSOCKET *tds, char **names, int num_names)
Reads column information.
Definition: token.c:1232
tds_cursor::status
TDS_CURSOR_STATUS status
cursor parameter
Definition: tds.h:954
tds_free_param_result
void tds_free_param_result(TDSPARAMINFO *param_info)
Delete latest parameter.
Definition: mem.c:320
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:916
tds_set_cur_dyn
void tds_set_cur_dyn(TDSSOCKET *tds, TDSDYNAMIC *dyn)
Set current dynamic.
Definition: query.c:189
tds_column::column_size
TDS_INT column_size
maximun size of data.
Definition: tds.h:696
tds_free_namelist
static void tds_free_namelist(struct namelist *head)
Frees list of names.
Definition: token.c:921
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
tdsdump_col
void tdsdump_col(const TDSCOLUMN *col)
Write a column value to the debug log.
Definition: log.c:408
tds_cursor::cursor_id
TDS_INT cursor_id
cursor id returned by the server after cursor declare
Definition: tds.h:942
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:1728
TDS_DONE_ERROR
@ TDS_DONE_ERROR
error occurred
Definition: tds.h:252
TDS_DONE_CANCELLED
@ TDS_DONE_CANCELLED
acknowledging an attention command (usually a cancel)
Definition: tds.h:256
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:354
dlist_ring
Definition: dlist.h:23
tds_login::crlfile
DSTR crlfile
certificate revocation file
Definition: tds.h:526
tds_process_pending_closes
static void tds_process_pending_closes(TDSSOCKET *tds)
Attempt to close all deferred closes (dynamics and cursors).
Definition: token.c:2012
tds_alloc_param_result
TDSPARAMINFO * tds_alloc_param_result(TDSPARAMINFO *old_param)
Adds a output parameter to TDSPARAMINFO.
Definition: mem.c:284
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
tds_dynamic::emulated
TDS_TINYINT emulated
this dynamic query cannot be prepared so libTDS have to construct a simple query.
Definition: tds.h:994
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:1640
tds_socket::cur_cursor
TDSCURSOR * cur_cursor
cursor in use
Definition: tds.h:1199
tds_dstr_set
DSTR * tds_dstr_set(DSTR *s, char *src)
set a string from another buffer.
Definition: tdsstring.c:107
tds5_process_optioncmd
static TDSRET tds5_process_optioncmd(TDSSOCKET *tds)
Process option cmd results.
Definition: token.c:2968
namelist::next
struct namelist * next
next element in the list
Definition: token.c:913
tds_flush_packet
TDSRET tds_flush_packet(TDSSOCKET *tds)
Flush packet to server.
Definition: write.c:285
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:876
tds_dynamic
Holds information for a dynamic (also called prepared) query.
Definition: tds.h:977
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:1565
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_DONE_COUNT
@ TDS_DONE_COUNT
count field in packet is valid
Definition: tds.h:255
tds_column::column_scale
TDS_TINYINT column_scale
scale for decimal/numeric
Definition: tds.h:706
tds_socket::out_buf_max
unsigned int out_buf_max
Maximum size of packet pointed by out_buf.
Definition: tds.h:1167
namelist
Holds list of names.
Definition: token.c:908
tds_dstr_alloc
DSTR * tds_dstr_alloc(DSTR *s, size_t length)
allocate space for length char
Definition: tdsstring.c:165
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:1206
TDS_PENDING
@ TDS_PENDING
cilent is waiting for data
Definition: tds.h:794
tdsiconvinfo
Definition: iconv.h:91
tds_dynamic::defer_close
bool defer_close
true if dynamic was marker to be closed when connection is idle
Definition: tds.h:998
tds_get_uint
TDS_UINT tds_get_uint(TDSSOCKET *tds)
Get an int32 from the server.
Definition: read.c:131
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_str_empty
const struct tds_dstr tds_str_empty
Internal representation for an empty string.
Definition: tdsstring.c:45
tds_dstr_free
void tds_dstr_free(DSTR *s)
free string
Definition: tdsstring.c:62
tds_socket::in_len
unsigned in_len
input buffer length
Definition: tds.h:1170
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:1960
tds_dstr_isempty
static int tds_dstr_isempty(const DSTR *s)
test if string is empty
Definition: string.h:60
tds_column::char_conv
TDSICONV * char_conv
refers to previously allocated iconv information
Definition: tds.h:714
pollfd
Definition: poll.h:52
tds_message
Definition: tds.h:876
TDS_IS_MSSQL
#define TDS_IS_MSSQL(x)
Check if product is Microsft SQL Server.
Definition: tds.h:1623
tds_login::cafile
DSTR cafile
certificate authorities file
Definition: tds.h:525
tds_dstr
Structure to hold a string.
Definition: string.h:36
tds_column
Metadata about columns in regular and compute rows.
Definition: tds.h:690
tds_staticin_stream
input stream to read data from a static buffer
Definition: stream.h:81
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:311
tds_socket::out_pos
unsigned out_pos
current position in out_buf
Definition: tds.h:1169
tds_goodwrite
int tds_goodwrite(TDSSOCKET *tds, const unsigned char *buffer, size_t buflen)
Definition: net.c:987
tds_connection::env
TDSENV env
environment is shared between all sessions
Definition: tds.h:1080
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:2750
TDS_DEAD
@ TDS_DEAD
no connection
Definition: tds.h:796
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:1100
TDS_READING
@ TDS_READING
client is reading data
Definition: tds.h:795
tds_login::server_name
DSTR server_name
server name (in freetds.conf)
Definition: tds.h:513
tds_socket::in_row
bool in_row
true if we are getting rows
Definition: tds.h:1202
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:941
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:2076
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:248
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_pr_op
static const char * tds_pr_op(int op)
Returns string representation for a given operation.
Definition: token.c:3019
tds_dstr_dup
DSTR * tds_dstr_dup(DSTR *s, const DSTR *src)
Duplicate a string from another dynamic string.
Definition: tdsstring.c:134
MD4Context
Definition: md4.h:8
tds_connection::cursors
TDSCURSOR * cursors
linked list of cursors allocated for this connection contains only cursors allocated on the server
Definition: tds.h:1086
tds_result_info
Hold information for any results.
Definition: tds.h:769
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:2523
MD5Context
Definition: md5.h:8
tds_dstr_copy
DSTR * tds_dstr_copy(DSTR *s, const char *src)
copy a string from another
Definition: tdsstring.c:122
tds_socket::cur_dyn
TDSDYNAMIC * cur_dyn
dynamic structure in use
Definition: tds.h:1212
tds_cursor::ref_count
TDS_INT ref_count
reference counter so client can retain safely a pointer
Definition: tds.h:940
tds_process_dyn_result
static TDSRET tds_process_dyn_result(TDSSOCKET *tds)
Process results from dynamic.
Definition: token.c:2639
tds_process_param_result_tokens
static TDSRET tds_process_param_result_tokens(TDSSOCKET *tds)
Process parameters from networks.
Definition: token.c:1353
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_process_compute_names
static TDSRET tds_process_compute_names(TDSSOCKET *tds)
tds_process_compute_names() processes compute result sets.
Definition: token.c:2773
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:1936
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:1047
tds_lookup_dynamic
TDSDYNAMIC * tds_lookup_dynamic(TDSCONNECTION *conn, const char *id)
Finds a dynamic given string id.
Definition: token.c:2583
tds_column::column_prec
TDS_TINYINT column_prec
precision for decimal/numeric
Definition: tds.h:705
tds_encoding
Information relevant to libiconv.
Definition: tds.h:612
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:184
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:1775
tds_read_packet
int tds_read_packet(TDSSOCKET *tds)
Read in one 'packet' from the server.
Definition: packet.c:531
TDS_DONE_MORE_RESULTS
@ TDS_DONE_MORE_RESULTS
more results follow
Definition: tds.h:251
tds_cursor_dealloc
TDSRET tds_cursor_dealloc(TDSSOCKET *tds, TDSCURSOR *cursor)
Send a deallocation request to server.
Definition: query.c:3078
tds_socket::out_buf
unsigned char * out_buf
Output buffer.
Definition: tds.h:1161
tds_column::column_type
TDS_SERVER_TYPE column_type
This type can be different from wire type because conversion (e.g.
Definition: tds.h:698
tds_socket::rows_affected
TDS_INT8 rows_affected
rows updated/deleted/inserted/selected, TDS_NO_COUNT if not valid
Definition: tds.h:1209
tds_cursor::defer_close
bool defer_close
true if cursor was marker to be closed when connection is idle
Definition: tds.h:947
tds_token_name
static const char * tds_token_name(unsigned char marker)
Returns string representation for a given token type.
Definition: token.c:3126
tds_authentication
Definition: tds.h:1047
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:1383
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:3222
TDS_IDLE
@ TDS_IDLE
no data expected
Definition: tds.h:791
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:999
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:1897
TDS_SENDING
@ TDS_SENDING
client would send data
Definition: tds.h:793
tds_dynamic::next
struct tds_dynamic * next
next in linked list, keep first
Definition: tds.h:979
tds_connection::pending_close
unsigned int pending_close
true is connection has pending closing (cursors or dynamic)
Definition: tds.h:1103
tds_dynamic::res_info
TDSPARAMINFO * res_info
query results
Definition: tds.h:1000
tds_socket::in_pos
unsigned in_pos
current position in in_buf
Definition: tds.h:1168
tds_release_dynamic
void tds_release_dynamic(TDSDYNAMIC **pdyn)
Frees dynamic statement.
Definition: mem.c:253
tds_socket::has_status
bool has_status
true is ret_status is valid
Definition: tds.h:1201
tds_process_auth
static TDSRET tds_process_auth(TDSSOCKET *tds)
Process authentication token.
Definition: token.c:455
tds_submit_unprepare
TDSRET tds_submit_unprepare(TDSSOCKET *tds, TDSDYNAMIC *dyn)
Send a unprepare request for a prepared query.
Definition: query.c:1887
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:409
poll.h
Provide poll call where missing.
tds_peek
unsigned char tds_peek(TDSSOCKET *tds)
Reads a byte from the TDS stream without removing it.
Definition: read.c:100
tds_get_usmallint
TDS_USMALLINT tds_get_usmallint(TDSSOCKET *tds)
Get an int16 from the server.
Definition: read.c:113
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:2833
tds_process_compute_result
static TDSRET tds_process_compute_result(TDSSOCKET *tds)
tds_process_compute_result() processes compute result sets.
Definition: token.c:1409
des_key
Definition: des.h:15
tds_socket::current_results
TDSRESULTINFO * current_results
Current query information.
Definition: tds.h:1194
tds_socket::in_buf
unsigned char * in_buf
Input buffer.
Definition: tds.h:1154
tds_connection::product_version
TDS_UINT product_version
version of product (Sybase/MS and full version)
Definition: tds.h:1072
tds_dstr_zero
void tds_dstr_zero(DSTR *s)
clear all string filling with zeroes (mainly for security reason)
Definition: tdsstring.c:55
tds_get_byte
unsigned char tds_get_byte(TDSSOCKET *tds)
Return a single byte from the input buffer.
Definition: read.c:72
tds_socket::out_flag
unsigned char out_flag
output buffer type
Definition: tds.h:1172
tds_dataout_stream_init
void tds_dataout_stream_init(TDSDATAOUTSTREAM *stream, TDSSOCKET *tds)
Initialize a data output stream.
Definition: stream.c:244
ptw32_mcs_node_t_
Definition: ptw32_MCS_lock.c:97
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:307
tds_condition
Definition: thread.h:278
tds_capability_type
Definition: tds.h:498
TDS_SYB_VER
#define TDS_SYB_VER(maj, min, x)
Calc a version number for Sybase.
Definition: tds.h:1632
tds_socket
Information for a server connection.
Definition: tds.h:1141
determine_adjusted_size
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:3279
tds_env::charset
char * charset
character set encoding
Definition: tds.h:969
tds_process_tabname
static TDSRET tds_process_tabname(TDSSOCKET *tds)
Process list of table from network.
Definition: token.c:1183
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:2681
tds_dynamic::num_id
TDS_INT num_id
numeric id for mssql7+
Definition: tds.h:982
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:120
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:2603
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:93
tds_close_socket
void tds_close_socket(TDSSOCKET *tds)
Close current socket.
Definition: net.c:548
tds_socket::login
TDSLOGIN * login
config for login stuff.
Definition: tds.h:1214
tds_dynamic::id
char id[30]
id of dynamic.
Definition: tds.h:988
tds_prtype
const char * tds_prtype(int type)
Returns string representation of the given type.
Definition: token.c:3052
tds7_get_data_info
static TDSRET tds7_get_data_info(TDSSOCKET *tds, TDSCOLUMN *curcol)
Reads data information from wire.
Definition: token.c:1509
tds_dynamic::ref_count
TDS_INT ref_count
reference counter so client can retain safely a pointer
Definition: tds.h:980
tds_alloc_param_data
void * tds_alloc_param_data(TDSCOLUMN *curparam)
Allocate data for a parameter.
Definition: mem.c:364
tds_process_cancel
TDSRET tds_process_cancel(TDSSOCKET *tds)
Definition: token.c:2550
tds_connection::dyns
TDSDYNAMIC * dyns
list of dynamic allocated for this connection contains only dynamic allocated on the server
Definition: tds.h:1091
tds_encoding::name
const char * name
name of the encoding (ie UTF-8)
Definition: tds.h:615
tds_quote_id
size_t tds_quote_id(TDSSOCKET *tds, char *buffer, const char *id, int idlen)
Quote an id.
Definition: query.c:2266
tds_cursor::next
struct tds_cursor * next
next in linked list, keep first
Definition: tds.h:939
string_linked_list
Definition: vstrbuild.c:36
tds_process_param_result
static TDSRET tds_process_param_result(TDSSOCKET *tds, TDSPARAMINFO **info)
process output parameters of a stored procedure.
Definition: token.c:1297
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:256
tds_raw_mutex
Definition: thread.h:250
tds_dataout_stream
output stream to write data to tds protocol
Definition: stream.h:72
tds_process_cursor_tokens
static TDSRET tds_process_cursor_tokens(TDSSOCKET *tds)
Reads cursor command results.
Definition: token.c:2925
tds_cursor
Holds informations about a cursor.
Definition: tds.h:937
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_connection
Definition: tds.h:1069
tds_column::column_cur_size
TDS_INT column_cur_size
size written in variable (ie: char, text, binary).
Definition: tds.h:737
tds_process_tokens
TDSRET tds_process_tokens(TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag)
process all streams.
Definition: token.c:529
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:703
tds_env::database
char * database
database name
Definition: tds.h:971