1 #define LIMIT_INDEXES_ADJUST 4
3 static const signed char limit_indexes[79]= {
85 static const TDS_WORD limits[]= {
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:504
struct tds_cursor * next
next in linked list, keep first
Definition: tds.h:940
TDSENV env
environment is shared between all sessions
Definition: tds.h:1081
int tds_write_dump
Tell if TDS debug logging is turned on or off.
Definition: log.c:58
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
DSTR server_name
server name (in freetds.conf)
Definition: tds.h:513
int block_size
packet size (512-65535)
Definition: tds.h:967
void tds_detach_results(TDSRESULTINFO *info)
Detach result info from it current socket.
Definition: mem.c:488
char * cursor_name
name of the cursor
Definition: tds.h:942
Metadata about columns in regular and compute rows.
Definition: tds.h:690
void tds_free_param_result(TDSPARAMINFO *param_info)
Delete latest parameter.
Definition: mem.c:320
TDS_USMALLINT tds_version
TDS version.
Definition: tds.h:515
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
Holds information for a dynamic (also called prepared) query.
Definition: tds.h:978
TDSPARAMINFO * res_info
query results
Definition: tds.h:1001
void tdsdump_col(const TDSCOLUMN *col)
Write a column value to the debug log.
Definition: log.c:408
void tdsdump_log(const char *file, unsigned int level_line, const char *fmt,...)
Write a message to the debug log.
Definition: log.c:354
int port
port of database service
Definition: tds.h:514
Information about blobs (e.g.
Definition: tds.h:587
TDSPARAMINFO * tds_alloc_param_result(TDSPARAMINFO *old_param)
Adds a output parameter to TDSPARAMINFO.
Definition: mem.c:284
TDSRET tds_alloc_row(TDSRESULTINFO *res_info)
Allocate space for row store return NULL on out of memory.
Definition: mem.c:524
DSTR password
password of account login
Definition: tds.h:530
static void tds_dstr_init(DSTR *s)
init a string with empty
Definition: string.h:53
void tdsdump_off(void)
Temporarily turn off logging.
Definition: log.c:76
char * charset
character set encoding
Definition: tds.h:970
int tds7_get_instance_port(struct addrinfo *addr, const char *instance)
Get port of given instance.
Definition: net.c:1229
static int tds_get_socket_error(TDS_SYS_SOCKET sock)
Returns error stored in the socket.
Definition: net.c:217
TDSRET tds_flush_packet(TDSSOCKET *tds)
Flush packet to server.
Definition: write.c:285
TDS_INT num_id
numeric id for mssql7+
Definition: tds.h:983
DSTR server_realm_name
server realm name (in freetds.conf)
Definition: tds.h:522
TDSDYNAMIC * tds_alloc_dynamic(TDSCONNECTION *conn, const char *id)
Allocate a dynamic statement.
Definition: mem.c:160
char id[30]
id of dynamic.
Definition: tds.h:989
char * query
SQL query.
Definition: tds.h:949
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
TDS_INT ret_status
return status from store procedure
Definition: tds.h:1204
static int tds_dstr_isempty(const DSTR *s)
test if string is empty
Definition: string.h:60
Hold information for any results.
Definition: tds.h:770
#define TDS_IS_MSSQL(x)
Check if product is Microsft SQL Server.
Definition: tds.h:1624
char * database
database name
Definition: tds.h:972
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:1207
static int tds_socket_write(TDSCONNECTION *conn, TDSSOCKET *tds, const unsigned char *buf, int buflen)
Write to an OS socket.
Definition: net.c:762
TDSLOGIN * tds_init_login(TDSLOGIN *login, TDSLOCALE *locale)
Initialize login structure with locale information and other stuff for connection.
Definition: mem.c:800
TDSRESULTINFO * current_results
Current query information.
Definition: tds.h:1195
Holds informations about a cursor.
Definition: tds.h:938
int tds_socket_set_nosigpipe(TDS_SYS_SOCKET sock, int on)
Set socket to not throw SIGPIPE.
Definition: net.c:72
int tds_goodwrite(TDSSOCKET *tds, const unsigned char *buffer, size_t buflen)
Definition: net.c:987
@ TDS_DEAD
no connection
Definition: tds.h:797
TDS_INT ref_count
reference counter so client can retain safely a pointer
Definition: tds.h:941
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
bool has_status
true is ret_status is valid
Definition: tds.h:1202
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:1087
void tdsdump_close(void)
Close the TDS dump log file.
Definition: log.c:193
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
TDSPACKET * send_packet
packet we are preparing to send
Definition: tds.h:1188
TDS_INT cursor_id
cursor id returned by the server after cursor declare
Definition: tds.h:943
DSTR * tds_dstr_copy(DSTR *s, const char *src)
copy a string from another
Definition: tdsstring.c:122
TDSPARAMINFO * params
query parameters.
Definition: tds.h:1009
int tds7_get_instance_ports(FILE *output, struct addrinfo *addr)
Get port of all instances.
Definition: net.c:1093
DSTR db_filename
database filename to attach (MSSQL)
Definition: tds.h:524
DSTR crlfile
certificate revocation file
Definition: tds.h:526
Information for a server connection.
Definition: tds.h:1142
TDS_INT column_size
maximun size of data.
Definition: tds.h:696
TDSDYNAMIC * tds_lookup_dynamic(TDSCONNECTION *conn, const char *id)
Finds a dynamic given string id.
Definition: token.c:2584
TDSDYNAMIC * cur_dyn
dynamic structure in use
Definition: tds.h:1213
void tdsdump_on(void)
Turn logging back on.
Definition: log.c:88
unsigned char * in_buf
Input buffer.
Definition: tds.h:1155
unsigned int bulk_copy
if bulk copy should be enabled
Definition: tds.h:551
TDS_INT column_cur_size
size written in variable (ie: char, text, binary).
Definition: tds.h:738
struct tds_dynamic * next
next in linked list, keep first
Definition: tds.h:980
DSTR new_password
new password to set (TDS 7.2+)
Definition: tds.h:531
TDS_SERVER_TYPE column_type
This type can be different from wire type because conversion (e.g.
Definition: tds.h:698
TDSCURSOR * cur_cursor
cursor in use
Definition: tds.h:1200
DSTR user_name
account for login
Definition: tds.h:529
@ TDS_IDLE
no data expected
Definition: tds.h:792
struct addrinfo * ip_addrs
ip(s) of server
Definition: tds.h:541
unsigned out_pos
current position in out_buf
Definition: tds.h:1170
void tds_release_dynamic(TDSDYNAMIC **pdyn)
Frees dynamic statement.
Definition: mem.c:253
const char * tds_canonical_charset_name(const char *charset_name)
Determine canonical iconv character set name.
Definition: iconv.c:959
int tds_iconv_alloc(TDSCONNECTION *conn)
Allocate iconv stuff.
Definition: iconv.c:266
bool in_row
true if we are getting rows
Definition: tds.h:1203
DSTR server_charset
charset of server e.g.
Definition: tds.h:518
Provide poll call where missing.
DSTR server_spn
server SPN (in freetds.conf)
Definition: tds.h:523
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
char * query
saved query, we need to know original query if prepare is impossible
Definition: tds.h:1011
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
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
TDS_SYS_SOCKET s
tcp socket, INVALID_SOCKET if not connected
Definition: tds.h:1076
void * tds_realloc(void **pp, size_t new_size)
Reallocate a pointer and update it if success.
Definition: mem.c:1819
void tds_dstr_zero(DSTR *s)
clear all string filling with zeroes (mainly for security reason)
Definition: tdsstring.c:55
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
int tds_socket_set_nonblocking(TDS_SYS_SOCKET sock)
Set socket to non-blocking.
Definition: net.c:168
TDSLOCALE * tds_get_locale(void)
Get locale information.
Definition: locale.c:50
unsigned char * out_buf
Output buffer.
Definition: tds.h:1162
TDS_INT ref_count
reference counter so client can retain safely a pointer
Definition: tds.h:981
void tds_close_socket(TDSSOCKET *tds)
Close current socket.
Definition: net.c:548
const char * tds_prtype(int type)
Returns string representation of the given type.
Definition: token.c:3053
int tdsdump_open(const char *filename)
Create and truncate a human readable dump file for the TDS traffic.
Definition: log.c:112
void * tds_alloc_param_data(TDSCOLUMN *curparam)
Allocate data for a parameter.
Definition: mem.c:364
static char * tds_get_dynid(TDSCONNECTION *conn, char *id)
Get an id for dynamic query based on TDS information.
Definition: mem.c:94
TDSDYNAMIC * dyns
list of dynamic allocated for this connection contains only dynamic allocated on the server
Definition: tds.h:1092
void tds_free_input_params(TDSDYNAMIC *dyn)
Frees all allocated input parameters of a dynamic statement.
Definition: mem.c:206
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
TDSLOGIN * login
config for login stuff.
Definition: tds.h:1215
DSTR cafile
certificate authorities file
Definition: tds.h:525
unsigned char out_flag
output buffer type
Definition: tds.h:1173
TDS_INT type
row fetched from this cursor
Definition: tds.h:958
unsigned int out_buf_max
Maximum size of packet pointed by out_buf.
Definition: tds.h:1168