Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
eb6492f
Fix compilation errors in single-threaded builds.
ucko May 8, 2024
12dd457
Address Windows build errors, most config-dependent.
ucko May 8, 2024
a014512
Predefine _FREETDS_LIBRARY_SOURCE for all library code.
ucko May 9, 2024
8fce347
Accommodate potential mass renaming of non-ODBC symbols.
ucko May 9, 2024
4ef90f3
{dblib,odbc}/unittests/common.h: Allow FREETDS_SRCDIR overrides.
ucko May 9, 2024
893c490
unit tests: Accommodate using a substitute for <assert.h>.
ucko May 9, 2024
ac03955
tds_setup_connection: Skip nvc/uvc check under OpenServer.
ucko May 9, 2024
5ed7413
tds7_send_record: Reject invalid NULL data.
ucko May 9, 2024
f04bf65
Improve type handling, at least for Sybase.
ucko May 9, 2024
55c6522
Improve support for TDS 5 (Sybase) bulk transfers.
ucko May 9, 2024
535e289
tds_generic_put: Correct BCP 7.x new blob type handling
ucko May 9, 2024
bc00195
Improve TDS 5 (Sybase) LONGBINARY and LONGCHAR handling.
ucko May 10, 2024
8025999
tds_select: Treat EAGAIN and EINPROGRESS like EINTR.
ucko May 10, 2024
f3e1d4b
tds_fix_column_size: Allow full size for output columns.
ucko May 10, 2024
c31700a
tds5_process_dyn_result2: Don't trust Sybase w/blob params.
ucko May 10, 2024
2350bd3
read.c (tds_get_n): Avoid potential hangs on short replies.
ucko May 10, 2024
1971b33
Fix DATE and DATETIME2 bulk insertion via TDS 7.0 and 7.1.
ucko May 10, 2024
b151054
tds_iconv: Accommodate FreeBSD/Citrus iconv.
ucko May 10, 2024
4d4bf62
tds_check_column_extra: Skip size check for BLOBs.
ucko May 10, 2024
0ceb04d
Report system errors' descriptions to ctlib clients.
ucko May 10, 2024
572a3c9
ct_connect: Set client_charset in addition to server_charset.
ucko May 13, 2024
e444c55
ct_data_info: Encode/decode CS_IODESC datatype field.
ucko May 13, 2024
9f8e222
ctlib: Implement full Unicode support for TDS 7+ (MSSQL).
ucko May 13, 2024
4551722
ctlib: Optimize blob conversion for bulk transfers in.
ucko May 13, 2024
5178e94
_blk_get_col_data: Consistently return TDS_FAIL on failure.
ucko May 13, 2024
35d3c89
blk.c: Handle CS_BLK_CANCEL in blk_done.
ucko May 13, 2024
949038e
Implement blk_textxfer, adjusting libtds as needed.
ucko May 13, 2024
4e8f841
cs_convert, dbconvert: Truncate data as needed.
ucko May 13, 2024
cae3130
ct_get_data: Distinguish NULL and empty strings via *outlen.
ucko May 13, 2024
c58d671
ctlib: Better support new date/time types (DATETIME2, etc.)
ucko May 13, 2024
4c28686
_blk_get_col_data: Bail (successfully) on null columns.
ucko May 13, 2024
d5ba54a
Declare and implement blk_sethints.
ucko May 13, 2024
fbe1706
_ct_get_client_type: Handle SYBUINTN.
ucko May 13, 2024
b32da94
ct_cursor: Predict cursor type for CS_CURSOR_DECLARE.
ucko May 13, 2024
f9066c0
ct_get_data: Populate cmd->iodesc->name more efficiently.
ucko May 13, 2024
b4a5566
ct.c (paraminfoalloc): Report long variable-width values.
ucko May 13, 2024
a2ad0c5
ct_describe: Issue an error for unsupported server types.
ucko May 13, 2024
d183a18
cspublic.h: Formally define BLK_VERSION_{155,157,160}
ucko May 13, 2024
a72be42
dbwritetext: Fail if dbconvert does.
ucko May 13, 2024
498af55
SQLCancel: Lock DBC mutex around extracting tds.
ucko May 13, 2024
9c6517e
tds/unittests/freeze.c: Suppress SIGPIPE (helpful on macOS).
ucko May 13, 2024
6e4efae
odbc stats.c: Stick fully with the designated database.
ucko May 13, 2024
3d000c5
Address "declared with greater visibility" warnings.
ucko May 13, 2024
13da54e
Regroup pointer comparisons to avoid subtraction.
ucko May 13, 2024
1512645
Address most implicit conversion warnings.
ucko May 16, 2024
0ec213b
Comment out or fully retire unread variables.
ucko May 21, 2024
6c6981d
Acknowledge non-exhaustive TDS_SERVER_TYPE switch statements.
ucko May 21, 2024
526fe1c
Formally address static analyzer concerns.
ucko May 21, 2024
f703add
Fix miscellaneous one-off warnings.
ucko May 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/bkpublic.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ CS_RETCODE blk_rowxfer(CS_BLKDESC * blkdesc);
CS_RETCODE blk_rowxfer_mult(CS_BLKDESC * blkdesc, CS_INT * row_count);
CS_RETCODE blk_sendrow(CS_BLKDESC * blkdesc, CS_BLK_ROW * row);
CS_RETCODE blk_sendtext(CS_BLKDESC * blkdesc, CS_BLK_ROW * row, CS_BYTE * buffer, CS_INT buflen);
CS_RETCODE blk_sethints(CS_BLKDESC* blkdesc, CS_CHAR* hints, CS_INT hintslen);
CS_RETCODE blk_srvinit(SRV_PROC * srvproc, CS_BLKDESC * blkdescp);
CS_RETCODE blk_textxfer(CS_BLKDESC * blkdesc, CS_BYTE * buffer, CS_INT buflen, CS_INT * outlen);

Expand Down
18 changes: 15 additions & 3 deletions include/cspublic.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,11 @@ enum
#define BLK_VERSION_120 CS_VERSION_120
#define BLK_VERSION_125 CS_VERSION_125
#define BLK_VERSION_150 CS_VERSION_150
#ifndef CS_NO_LARGE_IDENTIFIERS
#define BLK_VERSION_155 CS_VERSION_155
#define BLK_VERSION_157 CS_VERSION_157
#define BLK_VERSION_160 CS_VERSION_160
#endif

#define CS_FORCE_EXIT 300
#define CS_FORCE_CLOSE 301
Expand Down Expand Up @@ -613,9 +618,11 @@ enum
#define CS_IMAGELOCATOR_TYPE TDS_STATIC_CAST(CS_INT, 38)
#define CS_UNITEXTLOCATOR_TYPE TDS_STATIC_CAST(CS_INT, 39)
#define CS_UNIQUE_TYPE TDS_STATIC_CAST(CS_INT, 40)
#define CS_NVARCHAR_TYPE TDS_STATIC_CAST(CS_INT, 41)
#define CS_NLONGCHAR_TYPE TDS_STATIC_CAST(CS_INT, 42)

#define CS_MIN_SYBTYPE CS_CHAR_TYPE
#define CS_MAX_SYBTYPE CS_UNIQUE_TYPE
#define CS_MAX_SYBTYPE CS_NLONGCHAR_TYPE

#define CS_USER_TYPE TDS_STATIC_CAST(CS_INT, 100)
/* cs_dt_info type values */
Expand Down Expand Up @@ -770,10 +777,15 @@ CS_RETCODE cs_ctx_drop(CS_CONTEXT * ctx);
CS_RETCODE cs_config(CS_CONTEXT * ctx, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen);
CS_RETCODE cs_strbuild(CS_CONTEXT * ctx, CS_CHAR * buffer, CS_INT buflen, CS_INT * resultlen, CS_CHAR * text, CS_INT textlen,
CS_CHAR * formats, CS_INT formatlen, ...);
#undef cs_dt_crack
#ifndef cs_dt_crack_v2
# undef cs_dt_crack
#endif
CS_RETCODE cs_dt_crack(CS_CONTEXT * ctx, CS_INT datetype, CS_VOID * dateval, CS_DATEREC * daterec);
CS_RETCODE cs_dt_crack_v2(CS_CONTEXT * ctx, CS_INT datetype, CS_VOID * dateval, CS_DATEREC * daterec);
#define cs_dt_crack cs_dt_crack_v2
#ifndef _FREETDS_LIBRARY_SOURCE
# undef cs_dt_crack
# define cs_dt_crack cs_dt_crack_v2
#endif
CS_RETCODE cs_loc_alloc(CS_CONTEXT * ctx, CS_LOCALE ** locptr);
CS_RETCODE cs_loc_drop(CS_CONTEXT * ctx, CS_LOCALE * locale);
CS_RETCODE cs_locale(CS_CONTEXT * ctx, CS_INT action, CS_LOCALE * locale, CS_INT type, CS_VOID * buffer, CS_INT buflen,
Expand Down
32 changes: 23 additions & 9 deletions include/ctlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@
* Internal (not part of the exposed API) prototypes and such.
*/

/* Forward declarations to fix "declared with greater visibility" warnings */
struct _cs_dynamic;
struct _cs_param;
struct _csremote_proc;
struct cs_diag_msg;
struct cs_diag_msg_client;
struct cs_diag_msg_svr;
struct cs_servermsg_common1;
struct cs_servermsg_large;
struct cs_servermsg_small;
union cs_servermsg_internal;

#include <freetds/pushvis.h>

#ifdef __cplusplus
Expand Down Expand Up @@ -61,7 +73,7 @@ struct cs_diag_msg_client
CS_CLIENTMSG clientmsg;
};

typedef struct {
typedef struct cs_servermsg_small {
CS_MSGNUM msgnumber;
CS_INT state;
CS_INT severity;
Expand All @@ -77,7 +89,7 @@ typedef struct {
CS_INT sqlstatelen;
} CS_SERVERMSG_SMALL;

typedef struct {
typedef struct cs_servermsg_large {
CS_MSGNUM msgnumber;
CS_INT state;
CS_INT severity;
Expand All @@ -93,7 +105,7 @@ typedef struct {
CS_INT sqlstatelen;
} CS_SERVERMSG_LARGE;

typedef struct {
typedef struct cs_servermsg_common1 {
CS_MSGNUM msgnumber;
CS_INT state;
CS_INT severity;
Expand All @@ -108,7 +120,7 @@ typedef struct {
CS_INT sqlstatelen;
} CS_SERVERMSG_COMMON2;

typedef union
typedef union cs_servermsg_internal
{
CS_SERVERMSG_SMALL small;
CS_SERVERMSG_LARGE large;
Expand Down Expand Up @@ -323,9 +335,9 @@ struct _cs_locale

/* internal defines for cursor processing */

#define _CS_CURS_TYPE_UNACTIONED 0
#define _CS_CURS_TYPE_REQUESTED 1
#define _CS_CURS_TYPE_SENT 2
#define _CS_CURS_TYPE_UNACTIONED TDS_CURSOR_STATE_UNACTIONED
#define _CS_CURS_TYPE_REQUESTED TDS_CURSOR_STATE_REQUESTED
#define _CS_CURS_TYPE_SENT TDS_CURSOR_STATE_SENT

typedef struct {
CS_CHAR name[132];
Expand Down Expand Up @@ -393,8 +405,10 @@ CS_INT _ct_get_string_length(const char *buf, CS_INT buflen);

int _cs_convert_not_client(CS_CONTEXT *ctx, const TDSCOLUMN *curcol, CONV_RESULT *convert_buffer, unsigned char **p_src);

CS_RETCODE _cs_convert(CS_CONTEXT * ctx, const CS_DATAFMT_COMMON * srcfmt, CS_VOID * srcdata,
const CS_DATAFMT_COMMON * destfmt, CS_VOID * destdata, CS_INT * resultlen);
CS_RETCODE _cs_convert(CS_CONTEXT * ctx, const CS_DATAFMT_COMMON * srcfmt,
CS_VOID * srcdata, const CS_DATAFMT_COMMON * destfmt,
CS_VOID * destdata, CS_INT * resultlen,
TDS_SERVER_TYPE desttype, CS_VOID ** handle);
bool _ct_is_large_identifiers_version(CS_INT version);
const CS_DATAFMT_COMMON * _ct_datafmt_common(CS_CONTEXT * ctx, const CS_DATAFMT * datafmt);
const CS_DATAFMT_LARGE *_ct_datafmt_conv_in(CS_CONTEXT * ctx, const CS_DATAFMT * datafmt, CS_DATAFMT_LARGE * fmtbuf);
Expand Down
2 changes: 1 addition & 1 deletion include/dblib.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ typedef struct dboption
typedef struct
{
const BYTE *bindval;
size_t len;
unsigned int len;
} NULLREP;

struct tds_dblib_dbprocess
Expand Down
2 changes: 2 additions & 0 deletions include/freetds/bool.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#ifndef freetds_bool_h_
#define freetds_bool_h_

#include <config.h>

#ifndef __cplusplus

#ifdef HAVE_STDBOOL_H
Expand Down
3 changes: 2 additions & 1 deletion include/freetds/convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ CONV_RESULT;
unsigned char tds_willconvert(int srctype, int desttype);

TDS_SERVER_TYPE tds_get_null_type(TDS_SERVER_TYPE srctype);
TDS_INT tds_char2hex(TDS_CHAR *dest, TDS_UINT destlen, const TDS_CHAR * src, TDS_UINT srclen);
ssize_t tds_char2hex(TDS_CHAR *dest, size_t destlen,
const TDS_CHAR * src, size_t srclen);
TDS_INT tds_convert(const TDSCONTEXT *context, int srctype, const void *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr);

size_t tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC * timeptr, int prec);
Expand Down
30 changes: 21 additions & 9 deletions include/freetds/odbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ extern "C"
#endif

#include <freetds/pushvis.h>
#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
#ifdef __clang__
#define ODBC_API SQL_API __attribute__((visibility("default")))
#elif defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
#define ODBC_API SQL_API __attribute__((externally_visible))
#else
#define ODBC_API SQL_API
Expand Down Expand Up @@ -152,7 +154,7 @@ struct _dheader
{
SQLSMALLINT sql_desc_alloc_type;
/* TODO SQLLEN ?? see http://support.microsoft.com/default.aspx?scid=kb;en-us;298678 */
SQLSMALLINT sql_desc_count;
SQLUSMALLINT sql_desc_count;
SQLINTEGER sql_desc_bind_type;
SQLULEN sql_desc_array_size;
SQLUSMALLINT *sql_desc_array_status_ptr;
Expand Down Expand Up @@ -632,7 +634,8 @@ typedef union {
# define _WIDE
# define ODBC_CHAR SQLCHAR
#endif
int odbc_set_stmt_query(struct _hstmt *stmt, const ODBC_CHAR *sql, int sql_len _WIDE);
int odbc_set_stmt_query(struct _hstmt *stmt, const ODBC_CHAR *sql,
ssize_t sql_len _WIDE);
void odbc_set_return_status(struct _hstmt *stmt, unsigned int n_row);
void odbc_set_return_params(struct _hstmt *stmt, unsigned int n_row);

Expand All @@ -642,23 +645,29 @@ int odbc_sql_to_c_type_default(int sql_type);
TDS_SERVER_TYPE odbc_sql_to_server_type(TDSCONNECTION * conn, int sql_type, int sql_unsigned);
TDS_SERVER_TYPE odbc_c_to_server_type(int c_type);

unsigned int odbc_get_string_size(int size, const ODBC_CHAR * str _WIDE);
size_t odbc_get_string_size(ssize_t size, const ODBC_CHAR * str _WIDE);
void odbc_rdbms_version(TDSSOCKET * tds_socket, char *pversion_string);
SQLINTEGER odbc_get_param_len(const struct _drecord *drec_axd, const struct _drecord *drec_ixd, const TDS_DESC* axd, unsigned int n_row);
SQLLEN odbc_get_param_len(const struct _drecord *drec_axd,
const struct _drecord *drec_ixd,
const TDS_DESC* axd, SQLSETPOSIROW n_row);

#ifdef ENABLE_ODBC_WIDE
DSTR* odbc_dstr_copy_flag(TDS_DBC *dbc, DSTR *s, int size, const ODBC_CHAR * str, int flag);
DSTR* odbc_dstr_copy_flag(TDS_DBC *dbc, DSTR *s, ssize_t size,
const ODBC_CHAR * str, int flag);
#define odbc_dstr_copy(dbc, s, len, out) \
odbc_dstr_copy_flag(dbc, s, len, sizeof((out)->mb) ? (out) : (out), wide)
#define odbc_dstr_copy_oct(dbc, s, len, out) \
odbc_dstr_copy_flag(dbc, s, len, out, wide|0x20)
#else
DSTR* odbc_dstr_copy(TDS_DBC *dbc, DSTR *s, int size, const ODBC_CHAR * str);
DSTR* odbc_dstr_copy(TDS_DBC *dbc, DSTR *s, ssize_t size,
const ODBC_CHAR * str);
#define odbc_dstr_copy_oct odbc_dstr_copy
#endif


SQLRETURN odbc_set_string_flag(TDS_DBC *dbc, SQLPOINTER buffer, SQLINTEGER cbBuffer, void FAR * pcbBuffer, const char *s, int len, int flag);
SQLRETURN odbc_set_string_flag(TDS_DBC *dbc, SQLPOINTER buffer,
SQLINTEGER cbBuffer, void FAR * pcbBuffer,
const char *s, ssize_t len, int flag);
#ifdef ENABLE_ODBC_WIDE
#define odbc_set_string(dbc, buf, buf_len, out_len, s, s_len) \
odbc_set_string_flag(dbc, sizeof((buf)->mb) ? (buf) : (buf), buf_len, out_len, s, s_len, (wide) | (sizeof(*(out_len)) == sizeof(SQLSMALLINT)?0:0x10))
Expand Down Expand Up @@ -696,7 +705,10 @@ const char *odbc_skip_rpc_name(const char *s);
/*
* sql2tds.c
*/
SQLRETURN odbc_sql2tds(TDS_STMT * stmt, const struct _drecord *drec_ixd, const struct _drecord *drec_axd, TDSCOLUMN *curcol, bool compute_row, const TDS_DESC* axd, unsigned int n_row);
SQLRETURN odbc_sql2tds(TDS_STMT * stmt, const struct _drecord *drec_ixd,
const struct _drecord *drec_axd, TDSCOLUMN *curcol,
bool compute_row, const TDS_DESC* axd,
SQLSETPOSIROW n_row);
TDS_INT convert_datetime2server(int bindtype, const void *src, TDS_DATETIMEALL * dta);

/*
Expand Down
2 changes: 2 additions & 0 deletions include/freetds/sysdep_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#ifndef _tds_sysdep_private_h_
#define _tds_sysdep_private_h_

#include <config.h>

#define TDS_ADDITIONAL_SPACE 16

#ifdef MSG_NOSIGNAL
Expand Down
Loading