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