~ubuntu-branches/ubuntu/dapper/psqlodbc/dapper

« back to all changes in this revision

Viewing changes to statement.h

  • Committer: Bazaar Package Importer
  • Author(s): Peter Eisentraut
  • Date: 2005-06-29 22:14:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050629221412-rtl1ztenrmllmz22
Tags: 1:08.00.0101-3
* Changed dependencies and rebuilt for new unixodbc version
* Updated standards version

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include <pthread.h>
20
20
#endif
21
21
 
22
 
#ifndef FALSE
23
 
#define FALSE   (BOOL)0
24
 
#endif
25
 
#ifndef TRUE
26
 
#define TRUE    (BOOL)1
27
 
#endif
28
22
 
29
23
typedef enum
30
24
{
125
119
        STMT_FETCH_EXTENDED
126
120
};
127
121
 
 
122
typedef RETCODE (*NeedDataCallfunc)(RETCODE, void *);
 
123
typedef struct
 
124
{
 
125
        NeedDataCallfunc        func;
 
126
        void                    *data;
 
127
}       NeedDataCallback;
128
128
 
129
129
/********       Statement Handle        ***********/
130
130
struct StatementClass_
136
136
        HSTMT FAR  *phstmt;
137
137
        StatementOptions options;
138
138
        StatementOptions options_orig;
139
 
        ARDFields ardopts;
140
 
        IRDFields irdopts;
141
 
        APDFields apdopts;
142
 
        IPDFields ipdopts;
 
139
        /* attached descriptor handles */
 
140
        ARDClass        *ard;
 
141
        APDClass        *apd;
 
142
        IRDClass        *ird;
 
143
        IPDClass        *ipd;
 
144
        /* implicit descriptor handles */
 
145
        ARDClass        ardi;
 
146
        IRDClass        irdi;
 
147
        APDClass        apdi;
 
148
        IPDClass        ipdi;
143
149
 
144
150
        STMT_Status status;
145
151
        char       *__error_message;
147
153
 
148
154
        Int4            currTuple;              /* current absolute row number (GetData,
149
155
                                                                 * SetPos, SQLFetch) */
 
156
        GetDataInfo     gdata_info;
150
157
        int                     save_rowset_size;               /* saved rowset size in case of
151
158
                                                                                 * change/FETCH_NEXT */
152
159
        Int4                    rowset_start;   /* start of rowset (an absolute row
171
178
        int                     data_at_exec;   /* Number of params needing SQLPutData */
172
179
        int                     current_exec_param;             /* The current parameter for
173
180
                                                                                 * SQLPutData */
 
181
        PutDataInfo     pdata_info;
174
182
 
175
183
        char            put_data;               /* Has SQLPutData been called yet? */
176
184
 
182
190
                                                 * prepared at the server ? */
183
191
        char            internal;               /* Is this statement being called
184
192
                                                                 * internally? */
 
193
 
185
194
        char            transition_status;      /* Transition status */
186
195
        char            cursor_name[MAX_CURSOR_LEN + 1];
187
196
 
 
197
        Int2            num_params;             /* number of parameters */
188
198
        char       *stmt_with_params;           /* statement after parameter
189
199
                                                                                 * substitution */
190
200
        int                     stmt_size_limit;
206
216
        Int4            where_pos;
207
217
        Int4            last_fetch_count_include_ommitted;
208
218
        time_t          stmt_time;
 
219
        /* SQL_NEED_DATA Callback list */
 
220
        StatementClass  *execute_delegate;
 
221
        UInt2           allocated_callbacks;
 
222
        UInt2           num_callbacks;
 
223
        NeedDataCallback        *callbacks;
209
224
#if defined(WIN_MULTITHREAD_SUPPORT)
210
225
        CRITICAL_SECTION        cs;
211
 
#elif defined(POSIX_MULTITHREAD_SUPPORT)
212
 
    pthread_mutex_t     cs;
 
226
#elif defined(POSIX_THREADMUTEX_SUPPORT)
 
227
        pthread_mutex_t         cs;
213
228
#endif /* WIN_MULTITHREAD_SUPPORT */
214
229
 
215
230
};
219
234
#define SC_get_Result(a)  (a->result)
220
235
#define SC_set_Curres(a, b)  (a->curres = b)
221
236
#define SC_get_Curres(a)  (a->curres)
222
 
#define SC_get_ARD(a)  (&(a->ardopts))
223
 
#define SC_get_APD(a)  (&(a->apdopts))
224
 
#define SC_get_IRD(a)  (&(a->irdopts))
225
 
#define SC_get_IPD(a)  (&(a->ipdopts))
 
237
#define SC_get_ARD(a)  (a->ard)
 
238
#define SC_get_APD(a)  (a->apd)
 
239
#define SC_get_IRD(a)  (a->ird)
 
240
#define SC_get_IPD(a)  (a->ipd)
 
241
#define SC_get_ARDF(a)  (&(SC_get_ARD(a)->ardopts))
 
242
#define SC_get_APDF(a)  (&(SC_get_APD(a)->apdopts))
 
243
#define SC_get_IRDF(a)  (&(SC_get_IRD(a)->irdopts))
 
244
#define SC_get_IPDF(a)  (&(SC_get_IPD(a)->ipdopts))
 
245
#define SC_get_ARDi(a)  (&(a->ardi))
 
246
#define SC_get_APDi(a)  (&(a->apdi))
 
247
#define SC_get_IRDi(a)  (&(a->irdi))
 
248
#define SC_get_IPDi(a)  (&(a->ipdi))
 
249
#define SC_get_GDTI(a)  (&(a->gdata_info))
 
250
#define SC_get_PDTI(a)  (&(a->pdata_info))
226
251
 
227
252
#define SC_get_errornumber(a) (a->__error_number)
228
253
#define SC_set_errornumber(a, n) (a->__error_number = n)
229
254
#define SC_get_errormsg(a) (a->__error_message)
230
 
#if (ODBCVER >= 0x0300)
231
 
#define SC_is_lower_case(a, b) (a->options.metadata_id || b->connInfo.lower_case_identifier)
232
 
#else
233
 
#define SC_is_lower_case(a, b) (b->connInfo.lower_case_identifier)
234
 
#endif /* ODBCVER */
 
255
#define SC_is_lower_case(a, b) (a->options.metadata_id, b->connInfo.lower_case_identifier)
 
256
 
 
257
#define SC_MALLOC_return_with_error(t, tp, s, a, m, r) \
 
258
        { \
 
259
                if (t = (tp *) malloc(s), NULL == t) \
 
260
                { \
 
261
                        SC_set_error(a, STMT_NO_MEMORY_ERROR, m); \
 
262
                        return r; \
 
263
                } \
 
264
        }
 
265
#define SC_REALLOC_return_with_error(t, tp, s, a, m, r) \
 
266
        { \
 
267
                if (t = (tp *) realloc(t, s), NULL == t) \
 
268
                { \
 
269
                        SC_set_error(a, STMT_NO_MEMORY_ERROR, m); \
 
270
                        return r; \
 
271
                } \
 
272
        }
235
273
 
236
274
/*      options for SC_free_params() */
237
275
#define STMT_FREE_PARAMS_ALL                            0
254
292
#define ENTER_STMT_CS(x)        EnterCriticalSection(&((x)->cs))
255
293
#define LEAVE_STMT_CS(x)        LeaveCriticalSection(&((x)->cs))
256
294
#define DELETE_STMT_CS(x)       DeleteCriticalSection(&((x)->cs))
257
 
#elif defined(POSIX_MULTITHREAD_SUPPORT)
 
295
#elif defined(POSIX_THREADMUTEX_SUPPORT)
258
296
#define INIT_STMT_CS(x)         pthread_mutex_init(&((x)->cs),0)
259
297
#define ENTER_STMT_CS(x)        pthread_mutex_lock(&((x)->cs))
260
298
#define LEAVE_STMT_CS(x)        pthread_mutex_unlock(&((x)->cs))
269
307
StatementClass *SC_Constructor(void);
270
308
void            InitializeStatementOptions(StatementOptions *opt);
271
309
char            SC_Destructor(StatementClass *self);
 
310
BOOL            SC_opencheck(StatementClass *self, const char *func);
 
311
RETCODE         SC_initialize_and_recycle(StatementClass *self);
272
312
int             statement_type(const char *statement);
273
313
char            parse_statement(StatementClass *stmt);
274
314
void            SC_pre_execute(StatementClass *self);
289
329
void            SC_free_params(StatementClass *self, char option);
290
330
void            SC_log_error(const char *func, const char *desc, const StatementClass *self);
291
331
time_t          SC_get_time(StatementClass *self);
292
 
unsigned long SC_get_bookmark(StatementClass *self);
 
332
UInt4           SC_get_bookmark(StatementClass *self);
293
333
RETCODE         SC_pos_update(StatementClass *self, UWORD irow, UDWORD index);
294
334
RETCODE         SC_pos_delete(StatementClass *self, UWORD irow, UDWORD index);
295
335
RETCODE         SC_pos_refresh(StatementClass *self, UWORD irow, UDWORD index);
296
336
RETCODE         SC_pos_add(StatementClass *self, UWORD irow);
 
337
int             SC_set_current_col(StatementClass *self, int col);
 
338
 
 
339
DescriptorClass *SC_set_ARD(StatementClass *stmt, DescriptorClass *desc);
 
340
DescriptorClass *SC_set_APD(StatementClass *stmt, DescriptorClass *desc);
 
341
int             enqueueNeedDataCallback(StatementClass *self, NeedDataCallfunc, void *);
 
342
RETCODE         dequeueNeedDataCallback(RETCODE, StatementClass *self);
 
343
void            cancelNeedDataState(StatementClass *self);
297
344
 
298
345
/*
299
346
 *      Macros to convert global index <-> relative index in resultset/rowset