1 #define LIMIT_INDEXES_ADJUST 4
3 static const signed char limit_indexes[79]= {
85 static const TDS_WORD limits[]= {
int tds7_get_instance_port(struct addrinfo *addr, const char *instance)
Get port of given instance.
Definition: net.c:1229
unsigned int bulk_copy
if bulk copy should be enabled
Definition: tds.h:557
TDS_USMALLINT tds_version
TDS version.
Definition: tds.h:521
DSTR new_password
new password to set (TDS 7.2+)
Definition: tds.h:537
void tds_detach_results(TDSRESULTINFO *info)
Detach result info from it current socket.
Definition: mem.c:488
int tds_socket_set_nonblocking(TDS_SYS_SOCKET sock)
Set socket to non-blocking.
Definition: net.c:168
TDSCURSOR * cursors
linked list of cursors allocated for this connection contains only cursors allocated on the server
Definition: tds.h:1108
bool has_status
true is ret_status is valid
Definition: tds.h:1246
TDSRET tds_alloc_row(TDSRESULTINFO *res_info)
Allocate space for row store return NULL on out of memory.
Definition: mem.c:524
void tds_free_param_result(TDSPARAMINFO *param_info)
Delete latest parameter.
Definition: mem.c:320
struct addrinfo * ip_addrs
ip(s) of server
Definition: tds.h:547
DSTR cafile
certificate authorities file
Definition: tds.h:531
void tdsdump_on(void)
Turn logging back on.
Definition: log.c:88
TDSPACKET * frozen_packets
list of packets frozen, points to first one.
Definition: tds.h:1204
DSTR server_name
server name (in freetds.conf)
Definition: tds.h:519
void tds_dstr_free(DSTR *s)
free string
Definition: tdsstring.c:62
@ TDS_IDLE
no data expected
Definition: tds.h:791
unsigned char * in_buf
Input buffer.
Definition: tds.h:1178
TDSCURSOR * cur_cursor
cursor in use
Definition: tds.h:1244
TDSDYNAMIC * tds_alloc_dynamic(TDSCONNECTION *conn, const char *id)
Allocate a dynamic statement.
Definition: mem.c:160
TDSDYNAMIC * tds_lookup_dynamic(TDSCONNECTION *conn, const char *id)
Finds a dynamic given string id.
Definition: token.c:2583
Information about blobs (e.g.
Definition: tds.h:594
char * database
database name
Definition: tds.h:971
TDSPACKET * send_packet
packet we are preparing to send
Definition: tds.h:1232
TDSLOGIN * login
config for login stuff.
Definition: tds.h:1259
TDS 7.2 SMP packet header.
Definition: proto.h:361
int tdsdump_open(const char *filename)
Create and truncate a human readable dump file for the TDS traffic.
Definition: log.c:112
int tds_iconv_alloc(TDSCONNECTION *conn)
Allocate iconv stuff.
Definition: iconv.c:305
Hold information for any results.
Definition: tds.h:770
unsigned char * out_buf
Output buffer.
Definition: tds.h:1186
TDS_INT type
row fetched from this cursor
Definition: tds.h:957
TDS_INT cursor_id
cursor id returned by the server after cursor declare
Definition: tds.h:942
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
TDSENV env
environment is shared between all sessions
Definition: tds.h:1102
Information for a server connection.
Definition: tds.h:1164
TDSPARAMINFO * tds_alloc_param_result(TDSPARAMINFO *old_param)
Adds a output parameter to TDSPARAMINFO.
Definition: mem.c:284
DSTR crlfile
certificate revocation file
Definition: tds.h:532
DSTR db_filename
database filename to attach (MSSQL)
Definition: tds.h:530
TDSDYNAMIC * dyns
list of dynamic allocated for this connection contains only dynamic allocated on the server
Definition: tds.h:1113
void tds_dstr_zero(DSTR *s)
clear all string filling with zeroes (mainly for security reason)
Definition: tdsstring.c:55
TDSLOGIN * tds_init_login(TDSLOGIN *login, TDSLOCALE *locale)
Initialize login structure with locale information and other stuff for connection.
Definition: mem.c:800
bool in_row
true if we are getting rows
Definition: tds.h:1247
char * query
saved query, we need to know original query if prepare is impossible
Definition: tds.h:1010
static void tds_dstr_init(DSTR *s)
init a string with empty
Definition: string.h:53
DSTR server_spn
server SPN (in freetds.conf)
Definition: tds.h:529
const char * tds_prtype(int type)
Returns string representation of the given type.
Definition: token.c:3052
char * charset
character set encoding
Definition: tds.h:969
static int tds_socket_read(TDSCONNECTION *conn, TDSSOCKET *tds, unsigned char *buf, int buflen)
Read from an OS socket @TODO remove tds, save error somewhere, report error in another way.
Definition: net.c:727
TDS_INT ref_count
reference counter so client can retain safely a pointer
Definition: tds.h:940
int port
port of database service
Definition: tds.h:520
TDSDYNAMIC * cur_dyn
dynamic structure in use
Definition: tds.h:1257
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
TDSRESULTINFO * current_results
Current query information.
Definition: tds.h:1239
static int tds_socket_write(TDSCONNECTION *conn, TDSSOCKET *tds, const unsigned char *buf, int buflen)
Write to an OS socket.
Definition: net.c:762
DSTR server_charset
charset of server e.g.
Definition: tds.h:524
char * cursor_name
name of the cursor
Definition: tds.h:941
static int tds_dstr_isempty(const DSTR *s)
test if string is empty
Definition: string.h:60
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
#define tds_put_tinyint(tds, ti)
Output a tinyint value.
Definition: tds.h:1468
char * query
SQL query.
Definition: tds.h:948
struct tds_cursor * next
next in linked list, keep first
Definition: tds.h:939
void tdsdump_log(const char *file, unsigned int level_line, const char *fmt,...)
Write a message to the debug log.
Definition: log.c:354
TDS_INT column_size
maximun size of data.
Definition: tds.h:695
void tds_close_socket(TDSSOCKET *tds)
Close current socket.
Definition: net.c:548
static TDSERRNO tds_setup_socket(TDS_SYS_SOCKET *p_sock, struct addrinfo *addr, unsigned int port, int *p_oserr)
Setup the socket and attempt a connection.
Definition: net.c:249
void tdsdump_off(void)
Temporarily turn off logging.
Definition: log.c:76
int block_size
packet size (512-65535)
Definition: tds.h:966
Holds information for a dynamic (also called prepared) query.
Definition: tds.h:978
static const char * tds_dstr_cstr(const DSTR *s)
Returns a C version (NUL terminated string) of dstr.
Definition: string.h:78
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:1249
TDSPARAMINFO * params
query parameters.
Definition: tds.h:1008
TDSRET tds_process_tokens(TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag)
process all streams.
Definition: token.c:530
void tds_free_input_params(TDSDYNAMIC *dyn)
Frees all allocated input parameters of a dynamic statement.
Definition: mem.c:206
unsigned data_len
data length, this does not account SMP header, only TDS part
Definition: tds.h:1072
TDS_SYS_SOCKET s
tcp socket, INVALID_SOCKET if not connected
Definition: tds.h:1097
TDS_STATE tds_set_state(TDSSOCKET *tds, TDS_STATE state)
Set state of TDS connection, with logging and checking.
Definition: util.c:58
Holds informations about a cursor.
Definition: tds.h:938
unsigned char out_flag
output buffer type
Definition: tds.h:1197
int tds_select(TDSSOCKET *tds, unsigned tds_sel, int timeout_seconds)
Select on a socket until it's available or the timeout expires.
Definition: net.c:612
const char * tds_canonical_charset_name(const char *charset_name)
Determine canonical iconv character set name.
Definition: iconv.c:980
void * tds_realloc(void **pp, size_t new_size)
Reallocate a pointer and update it if success.
Definition: mem.c:1876
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 out_pos
current position in out_buf
Definition: tds.h:1194
TDS_INT num_id
numeric id for mssql7+
Definition: tds.h:982
TDSPARAMINFO * res_info
query results
Definition: tds.h:1000
bool tds_read_conf_section(FILE *in, const char *section, TDSCONFPARSE tds_conf_parse, void *param)
Read a section of configuration file (INI style file)
Definition: config.c:503
char id[30]
id of dynamic.
Definition: tds.h:988
TDS_INT column_cur_size
size written in variable (ie: char, text, binary).
Definition: tds.h:737
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
TDSLOCALE * tds_get_locale(void)
Get locale information.
Definition: locale.c:50
int tds_write_dump
Tell if TDS debug logging is turned on or off.
Definition: log.c:58
TDS_INT ref_count
reference counter so client can retain safely a pointer
Definition: tds.h:980
struct tds_dynamic * next
next in linked list, keep first
Definition: tds.h:979
static TDSCOMPUTEINFO * tds_alloc_compute_result(TDS_USMALLINT num_cols, TDS_USMALLINT by_cols)
Allocate memory for storing compute info return NULL on out of memory.
Definition: mem.c:395
TDS_INT ret_status
return status from store procedure
Definition: tds.h:1251
DSTR password
password of account login
Definition: tds.h:536
int tds7_get_instance_ports(FILE *output, struct addrinfo *addr)
Get port of all instances.
Definition: net.c:1093
void tds_release_dynamic(TDSDYNAMIC **pdyn)
Frees dynamic statement.
Definition: mem.c:253
void tdsdump_col(const TDSCOLUMN *col)
Write a column value to the debug log.
Definition: log.c:408
Provide poll call where missing.
unsigned int out_buf_max
Maximum size of packet pointed by out_buf.
Definition: tds.h:1192
int tds_goodwrite(TDSSOCKET *tds, const unsigned char *buffer, size_t buflen)
Definition: net.c:987
Metadata about columns in regular and compute rows.
Definition: tds.h:690
int tds_socket_set_nosigpipe(TDS_SYS_SOCKET sock, int on)
Set socket to not throw SIGPIPE.
Definition: net.c:72
@ TDS_DEAD
no connection
Definition: tds.h:796
TDSRET tds_flush_packet(TDSSOCKET *tds)
Flush packet to server.
Definition: write.c:224
#define TDS_IS_MSSQL(x)
Check if product is Microsft SQL Server.
Definition: tds.h:1715
DSTR user_name
account for login
Definition: tds.h:535
TDS_SERVER_TYPE column_type
This type can be different from wire type because conversion (e.g.
Definition: tds.h:697
static int tds_get_socket_error(TDS_SYS_SOCKET sock)
Returns error stored in the socket.
Definition: net.c:217
static char * tds_get_dynid(TDSCONNECTION *conn, char *id)
Get an id for dynamic query based on TDS information.
Definition: mem.c:94
void * tds_alloc_param_data(TDSCOLUMN *curparam)
Allocate data for a parameter.
Definition: mem.c:364
void tdsdump_close(void)
Close the TDS dump log file.
Definition: log.c:193
DSTR server_realm_name
server realm name (in freetds.conf)
Definition: tds.h:528
DSTR * tds_dstr_copy(DSTR *s, const char *src)
copy a string from another
Definition: tdsstring.c:122