FreeTDS API
error_export.h
1 #undef tdsdump_log
2 
3 #ifdef ENABLE_ODBC_WIDE
4 static SQLRETURN _SQLGetDiagRec(SQLSMALLINT handleType,
5  SQLHANDLE handle,
6  SQLSMALLINT numRecord,
7  ODBC_CHAR * szSqlStat,
8  SQLINTEGER * pfNativeError,
9  ODBC_CHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT FAR* pcbErrorMsg, int wide);
10 
11 SQLRETURN ODBC_PUBLIC ODBC_API SQLGetDiagRecW(
12  SQLSMALLINT handleType,
13  SQLHANDLE handle,
14  SQLSMALLINT numRecord,
15  SQLWCHAR * szSqlStat,
16  SQLINTEGER * pfNativeError,
17  SQLWCHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT FAR* pcbErrorMsg)
18 {
19  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetDiagRecW(%d, %p, %d, %p, %p, %p, %d, %p)\n",
20  (int) handleType,
21  handle,
22  (int) numRecord,
23  szSqlStat,
24  pfNativeError,
25  szErrorMsg, (int) cbErrorMsgMax, pcbErrorMsg);
26  return _SQLGetDiagRec(handleType,
27  handle,
28  numRecord,
29  (ODBC_CHAR*) szSqlStat,
30  pfNativeError,
31  (ODBC_CHAR*) szErrorMsg, cbErrorMsgMax, pcbErrorMsg, 1);
32 }
33 #endif
34 
35 SQLRETURN ODBC_PUBLIC ODBC_API SQLGetDiagRec(
36  SQLSMALLINT handleType,
37  SQLHANDLE handle,
38  SQLSMALLINT numRecord,
39  SQLCHAR * szSqlStat,
40  SQLINTEGER * pfNativeError,
41  SQLCHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT FAR* pcbErrorMsg)
42 {
43  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetDiagRec(%d, %p, %d, %p, %p, %p, %d, %p)\n",
44  (int) handleType,
45  handle,
46  (int) numRecord,
47  szSqlStat,
48  pfNativeError,
49  szErrorMsg, (int) cbErrorMsgMax, pcbErrorMsg);
50 #ifdef ENABLE_ODBC_WIDE
51  return _SQLGetDiagRec(handleType,
52  handle,
53  numRecord,
54  (ODBC_CHAR*) szSqlStat,
55  pfNativeError,
56  (ODBC_CHAR*) szErrorMsg, cbErrorMsgMax, pcbErrorMsg, 0);
57 #else
58  return _SQLGetDiagRec(handleType,
59  handle,
60  numRecord,
61  szSqlStat,
62  pfNativeError,
63  szErrorMsg, cbErrorMsgMax, pcbErrorMsg);
64 #endif
65 }
66 
67 #ifdef ENABLE_ODBC_WIDE
68 static SQLRETURN _SQLError(SQLHENV henv,
69  SQLHDBC hdbc,
70  SQLHSTMT hstmt,
71  ODBC_CHAR * szSqlStat,
72  SQLINTEGER * pfNativeError,
73  ODBC_CHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT FAR* pcbErrorMsg, int wide);
74 
75 SQLRETURN ODBC_PUBLIC ODBC_API SQLErrorW(
76  SQLHENV henv,
77  SQLHDBC hdbc,
78  SQLHSTMT hstmt,
79  SQLWCHAR * szSqlStat,
80  SQLINTEGER * pfNativeError,
81  SQLWCHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT FAR* pcbErrorMsg)
82 {
83  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLErrorW(%p, %p, %p, %p, %p, %p, %d, %p)\n",
84  henv,
85  hdbc,
86  hstmt,
87  szSqlStat,
88  pfNativeError,
89  szErrorMsg, (int) cbErrorMsgMax, pcbErrorMsg);
90  return _SQLError(henv,
91  hdbc,
92  hstmt,
93  (ODBC_CHAR*) szSqlStat,
94  pfNativeError,
95  (ODBC_CHAR*) szErrorMsg, cbErrorMsgMax, pcbErrorMsg, 1);
96 }
97 #endif
98 
99 SQLRETURN ODBC_PUBLIC ODBC_API SQLError(
100  SQLHENV henv,
101  SQLHDBC hdbc,
102  SQLHSTMT hstmt,
103  SQLCHAR * szSqlStat,
104  SQLINTEGER * pfNativeError,
105  SQLCHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT FAR* pcbErrorMsg)
106 {
107  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLError(%p, %p, %p, %p, %p, %p, %d, %p)\n",
108  henv,
109  hdbc,
110  hstmt,
111  szSqlStat,
112  pfNativeError,
113  szErrorMsg, (int) cbErrorMsgMax, pcbErrorMsg);
114 #ifdef ENABLE_ODBC_WIDE
115  return _SQLError(henv,
116  hdbc,
117  hstmt,
118  (ODBC_CHAR*) szSqlStat,
119  pfNativeError,
120  (ODBC_CHAR*) szErrorMsg, cbErrorMsgMax, pcbErrorMsg, 0);
121 #else
122  return _SQLError(henv,
123  hdbc,
124  hstmt,
125  szSqlStat,
126  pfNativeError,
127  szErrorMsg, cbErrorMsgMax, pcbErrorMsg);
128 #endif
129 }
130 
131 #ifdef ENABLE_ODBC_WIDE
132 static SQLRETURN _SQLGetDiagField(SQLSMALLINT handleType,
133  SQLHANDLE handle,
134  SQLSMALLINT numRecord,
135  SQLSMALLINT diagIdentifier,
136  SQLPOINTER buffer,
137  SQLSMALLINT cbBuffer,
138  SQLSMALLINT * pcbBuffer, int wide);
139 
140 SQLRETURN ODBC_PUBLIC ODBC_API SQLGetDiagFieldW(
141  SQLSMALLINT handleType,
142  SQLHANDLE handle,
143  SQLSMALLINT numRecord,
144  SQLSMALLINT diagIdentifier,
145  SQLPOINTER buffer,
146  SQLSMALLINT cbBuffer,
147  SQLSMALLINT * pcbBuffer)
148 {
149  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetDiagFieldW(%d, %p, %d, %d, %p, %d, %p)\n",
150  (int) handleType,
151  handle,
152  (int) numRecord,
153  (int) diagIdentifier,
154  buffer,
155  (int) cbBuffer,
156  pcbBuffer);
157  return _SQLGetDiagField(handleType,
158  handle,
159  numRecord,
160  diagIdentifier,
161  buffer,
162  cbBuffer,
163  pcbBuffer, 1);
164 }
165 #endif
166 
167 SQLRETURN ODBC_PUBLIC ODBC_API SQLGetDiagField(
168  SQLSMALLINT handleType,
169  SQLHANDLE handle,
170  SQLSMALLINT numRecord,
171  SQLSMALLINT diagIdentifier,
172  SQLPOINTER buffer,
173  SQLSMALLINT cbBuffer,
174  SQLSMALLINT * pcbBuffer)
175 {
176  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetDiagField(%d, %p, %d, %d, %p, %d, %p)\n",
177  (int) handleType,
178  handle,
179  (int) numRecord,
180  (int) diagIdentifier,
181  buffer,
182  (int) cbBuffer,
183  pcbBuffer);
184 #ifdef ENABLE_ODBC_WIDE
185  return _SQLGetDiagField(handleType,
186  handle,
187  numRecord,
188  diagIdentifier,
189  buffer,
190  cbBuffer,
191  pcbBuffer, 0);
192 #else
193  return _SQLGetDiagField(handleType,
194  handle,
195  numRecord,
196  diagIdentifier,
197  buffer,
198  cbBuffer,
199  pcbBuffer);
200 #endif
201 }
202 
203 #define tdsdump_log TDSDUMP_LOG_FAST
tds_numeric_bytes_per_prec
const int tds_numeric_bytes_per_prec[]
The following little table is indexed by precision and will tell us the number of bytes required to s...
Definition: numeric.c:41
dbrpcsend
RETCODE dbrpcsend(DBPROCESS *dbproc)
Execute the procedure and free associated memory.
Definition: rpc.c:281
_hdbc
Definition: odbc.h:275
tdsdaterec
Used by tds_datecrack.
Definition: tds.h:159
tds_dstr_empty
#define tds_dstr_empty(s)
Make a string empty.
Definition: string.h:91
_drecord
Definition: odbc.h:163
tds_set_param_type
void tds_set_param_type(TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type)
Set type of column initializing all dependency.
Definition: data.c:246
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_login::password
DSTR password
password of account login
Definition: tds.h:535
tdsdaterec::decimicrosecond
TDS_INT decimicrosecond
0-9999999
Definition: tds.h:169
tds_strftime
size_t tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC *dr, int prec)
format a date string according to an "extended" strftime(3) formatting definition.
Definition: convert.c:2992
odbc_c_to_server_type
TDS_SERVER_TYPE odbc_c_to_server_type(int c_type)
Pass this an SQL_C_* type and get a SYB* type which most closely corresponds to the SQL_C_* type.
Definition: odbc_util.c:601
tds.h
Main include file for libtds.
tdsdaterec::day
TDS_INT day
day of month (1-31)
Definition: tds.h:163
tds_read_conf_section
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
_hdesc
Definition: odbc.h:204
tds_dstr_isempty
static int tds_dstr_isempty(const DSTR *s)
test if string is empty
Definition: string.h:60
DBNUMERIC
Definition: sybdb.h:275
tds_get_conversion_type
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
LOGINREC
Definition: bsqlodbc.c:100
tds_convert
TDS_INT tds_convert(const TDSCONTEXT *tds_ctx, int srctype, const void *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr)
tds_convert convert a type to another.
Definition: convert.c:1891
tds_column::column_prec
TDS_TINYINT column_prec
precision for decimal/numeric
Definition: tds.h:703
conv_result
Definition: convert.h:34
_sql_error
Definition: odbc.h:94
tds_iconv_get_info
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
dbrpcinit
RETCODE dbrpcinit(DBPROCESS *dbproc, const char rpcname[], DBSMALLINT options)
Initialize a remote procedure call.
Definition: rpc.c:72
DBREMOTE_PROC
Definition: dblib.h:101
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_variant
Store variant informations.
Definition: tds.h:604
tds_get_null_type
TDS_SERVER_TYPE tds_get_null_type(TDS_SERVER_TYPE srctype)
Get same type but nullable.
Definition: convert.c:2926
s_v3to2map
Definition: error.c:168
tagSS_TIME2_STRUCT
Definition: odbcss.h:132
tds_login::db_filename
DSTR db_filename
database filename to attach (MSSQL)
Definition: tds.h:529
tds_column
Metadata about columns in regular and compute rows.
Definition: tds.h:689
tdsiconvinfo
Definition: iconv.h:92
_hstmt
Definition: odbc.h:381
tdsunique
Definition: proto.h:62
tds_read_conf_file
bool tds_read_conf_file(TDSLOGIN *login, const char *server)
Read configuration info for given server return 0 on error.
Definition: config.c:346
tds_datecrack
TDSRET tds_datecrack(TDS_INT datetype, const void *di, TDSDATEREC *dr)
Convert from db date format to a structured date format.
Definition: convert.c:3172
tds_blob
Information about blobs (e.g.
Definition: tds.h:593
_hchk
Definition: odbc.h:230
tds_dstr
Structure to hold a string.
Definition: string.h:36
tds_result_info
Hold information for any results.
Definition: tds.h:769
tdsdaterec::hour
TDS_INT hour
0-23
Definition: tds.h:166
tds_alloc_param_result
TDSPARAMINFO * tds_alloc_param_result(TDSPARAMINFO *old_param)
Adds a output parameter to TDSPARAMINFO.
Definition: mem.c:284
tds_login::ip_addrs
struct addrinfo * ip_addrs
ip(s) of server
Definition: tds.h:546
tdsdaterec::month
TDS_INT month
month number (0-11)
Definition: tds.h:162
tdsdaterec::second
TDS_INT second
0-59
Definition: tds.h:168
tds_alloc_param_data
void * tds_alloc_param_data(TDSCOLUMN *curparam)
Allocate data for a parameter.
Definition: mem.c:364
tds_get_size_by_type
int tds_get_size_by_type(TDS_SERVER_TYPE servertype)
Return the number of bytes needed by specified type.
Definition: tds_types.h:9
tds_login::server_name
DSTR server_name
server name (in freetds.conf)
Definition: tds.h:518
tds_column::column_size
TDS_INT column_size
maximun size of data.
Definition: tds.h:694
tds_column::column_cur_size
TDS_INT column_cur_size
size written in variable (ie: char, text, binary).
Definition: tds.h:736
tds_column::char_conv
TDSICONV * char_conv
refers to previously allocated iconv information
Definition: tds.h:712
sybdb.h
Primary include file for db-lib applications.
TDS_PARSED_PARAM
Definition: odbc.h:532
tds_dstr_free
void tds_dstr_free(DSTR *s)
free string
Definition: tdsstring.c:62
tdsdaterec::year
TDS_INT year
year
Definition: tds.h:160
ProfileParam
Definition: connectparams.c:523
tds_dstr_copy
DSTR * tds_dstr_copy(DSTR *s, const char *src)
copy a string from another
Definition: tdsstring.c:122
tds_login::port
int port
port of database service
Definition: tds.h:519
tds_column::column_scale
TDS_TINYINT column_scale
scale for decimal/numeric
Definition: tds.h:704
tds_login::user_name
DSTR user_name
account for login
Definition: tds.h:534
tds_iconv
size_t tds_iconv(TDSSOCKET *tds, TDSICONV *conv, TDS_ICONV_DIRECTION io, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
Wrapper around iconv(3).
Definition: iconv.c:592
TDS_DATETIMEALL::offset
TDS_SMALLINT offset
time offset
Definition: tds.h:149
_sql_errors
Definition: odbc.h:106
TDS_DATETIMEALL
this structure is not directed connected to a TDS protocol but keeps any DATE/TIME information.
Definition: tds.h:146
DBREMOTE_PROC_PARAM
Definition: dblib.h:89
dbrpcparam
RETCODE dbrpcparam(DBPROCESS *dbproc, const char paramname[], BYTE status, int db_type, DBINT maxlen, DBINT datalen, BYTE *value)
Add a parameter to a remote procedure call.
Definition: rpc.c:155
tds_socket
Information for a server connection.
Definition: tds.h:1163
tds_dblib_dbprocess
Definition: dblib.h:123
DSTR_INITIALIZER
#define DSTR_INITIALIZER
Initializer, used to initialize string like in the following example.
Definition: string.h:49
tdsdaterec::minute
TDS_INT minute
0-59
Definition: tds.h:167
tds_submit_rpc
TDSRET tds_submit_rpc(TDSSOCKET *tds, const char *rpc_name, TDSPARAMINFO *params, TDSHEADERS *head)
Calls a RPC from server.
Definition: query.c:1929
tagSS_TIMESTAMPOFFSET_STRUCT
Definition: odbcss.h:139
_henv
Definition: odbc.h:237
tds_column::column_type
TDS_SERVER_TYPE column_type
This type can be different from wire type because conversion (e.g.
Definition: tds.h:696
tds_context
Definition: tds.h:1029
tdsnumeric
Definition: proto.h:26
tds_login
Definition: tds.h:517
s_SqlMsgMap
Definition: error.c:48
dbperror
int dbperror(DBPROCESS *dbproc, DBINT msgno, long errnum,...)
Call client-installed error handler.
Definition: dblib.c:8127
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:396