1
1
/* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns
2
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns
4
4
* This library is free software; you can redistribute it and/or
5
5
* modify it under the terms of the GNU Library General Public
45
48
TDSLOGIN *tds_login;
51
struct dblib_buffer_row;
48
53
typedef struct tag_DBPROC_ROWBUF
50
int buffering_on; /* (boolean) is row buffering turned on? */
51
int first_in_buf; /* result set row number of first row in buf */
52
int next_row; /* result set row number of next row */
53
int newest; /* index of most recent item in queue */
54
int oldest; /* index of least recent item in queue */
55
int elcount; /* max element count that buffer can hold */
56
int element_size; /* size in bytes of each element in queue */
57
int rows_in_buf; /* # of rows currently in buffer */
58
void *rows; /* pointer to the row storage */
55
int received; /* how many rows have been received for this result set */
56
int head; /* queue insertion point */
57
int tail; /* oldest item in queue */
58
int current; /* dbnextrow() reads this row */
59
int capacity; /* how many elements the queue can hold */
60
struct dblib_buffer_row *rows; /* pointer to the row storage */
148
166
char dbcurdb[DBMAXNAME + 1];
149
167
char servcharset[DBMAXNAME + 1];
151
DB_DBCHKINTR_FUNC dbchkintr;
152
DB_DBHNDLINTR_FUNC dbhndlintr;
169
DB_DBCHKINTR_FUNC chkintr;
170
DB_DBHNDLINTR_FUNC hndlintr;
154
172
/** boolean use ms behaviour */
177
/** default null values **/
178
NULLREP nullreps[MAXBINDTYPES];
158
#define DBLIB_INFO_MSG_TYPE 0
159
#define DBLIB_ERROR_MSG_TYPE 1
162
** internal prototypes
164
int _dblib_handle_info_message(TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE* msgptr);
165
int _dblib_handle_err_message(TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE* msgptr);
166
int _dblib_client_msg(DBPROCESS * dbproc, int dberr, int severity, const char *dberrstr);
182
* internal prototypes
184
int dbperror (DBPROCESS *dbproc, DBINT msgno, long errnum, ...);
185
int _dblib_handle_info_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE* msgptr);
186
int _dblib_handle_err_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE* msgptr);
187
int _dblib_check_and_handle_interrupt(void * vdbproc);
167
189
void _dblib_setTDS_version(TDSLOGIN * tds_login, DBINT version);
169
191
DBINT _convert_char(int srctype, BYTE * src, int destype, BYTE * dest, DBINT destlen);
170
192
DBINT _convert_intn(int srctype, BYTE * src, int destype, BYTE * dest, DBINT destlen);
172
194
RETCODE _bcp_clear_storage(DBPROCESS * dbproc);
173
RETCODE _bcp_get_term_var(BYTE * dataptr, BYTE * term, int term_len);
174
195
RETCODE _bcp_get_prog_data(DBPROCESS * dbproc);
175
int _bcp_readfmt_colinfo(DBPROCESS * dbproc, char *buf, BCP_HOSTCOLINFO * ci);
176
RETCODE _bcp_read_hostfile(DBPROCESS * dbproc, FILE * hostfile, FILE * errfile, int *row_error);
178
197
extern MHANDLEFUNC _dblib_msg_handler;
179
198
extern EHANDLEFUNC _dblib_err_handler;
200
#define CHECK_PARAMETER(x, msg, ret) if (!(x)) { dbperror(dbproc, (msg), 0); return ret; }
201
#define CHECK_DBPROC() CHECK_PARAMETER(dbproc, SYBENULL, FAIL)
202
#define CHECK_NULP(x, func, param_num, ret) if (!(x)) { dbperror(dbproc, SYBENULP, 0, func, (int) param_num); return ret; }
203
#define CHECK_PARAMETER_NOPROC(x, msg) if (!(x)) { dbperror(NULL, (msg), 0); return FAIL; }
204
#define DBPERROR_RETURN(x, msg) if (x) { dbperror(dbproc, (msg), 0); return FAIL; }
205
#define DBPERROR_RETURN3(x, msg, a, b, c) if (x) { dbperror(dbproc, (msg), 0, a, b, c); return FAIL; }
181
208
#ifdef __cplusplus