3 * Description: This file contains defines and declarations that are related to
6 * Comments: See "notice.txt" for copyright and license information.
8 * $Id: descriptor.h,v 1.19 2006/10/13 13:13:31 hinoue Exp $
12 #ifndef __DESCRIPTOR_H__
13 #define __DESCRIPTOR_H__
21 #define GET_NAME(the_name) ((the_name).name)
22 #define SAFE_NAME(the_name) ((the_name).name ? (the_name).name : NULL_STRING)
23 #define PRINT_NAME(the_name) ((the_name).name ? (the_name).name : PRINT_NULL)
24 #define NAME_IS_NULL(the_name) (NULL == (the_name).name)
25 #define NAME_IS_VALID(the_name) (NULL != (the_name).name)
26 #define INIT_NAME(the_name) ((the_name).name = NULL)
27 #define NULL_THE_NAME(the_name) \
29 if ((the_name).name) free((the_name).name); \
30 (the_name).name = NULL; \
32 #define STR_TO_NAME(the_name, str) \
34 if ((the_name).name) \
35 free((the_name).name); \
36 (the_name).name = (str ? strdup((str)) : NULL); \
38 #define STRN_TO_NAME(the_name, str, n) \
40 if ((the_name).name) \
41 free((the_name).name); \
44 (the_name).name = (char *)malloc(n + 1); \
45 memcpy((the_name).name, str, n); \
46 (the_name).name[n] = '\0'; \
49 (the_name).name = NULL; \
51 #define NAME_TO_STR(str, the_name) \
53 if ((the_name).name) strcpy(str, (the_name).name); \
56 #define NAME_TO_NAME(to, from) \
61 (to).name = strdup(from.name); \
65 #define MOVE_NAME(to, from) \
69 (to).name = (from).name; \
72 #define SET_NAME(the_name, str) ((the_name).name = (str))
74 #define NAMECMP(name1, name2) (strcmp(SAFE_NAME(name1), SAFE_NAME(name2)))
75 #define NAMEICMP(name1, name2) (stricmp(SAFE_NAME(name1), SAFE_NAME(name2)))
79 ,TI_HASOIDS_CHECKED
= (1L << 1)
80 ,TI_HASOIDS
= (1L << 2)
81 ,TI_COLATTRIBUTE
= (1L << 3)
86 COL_INFO
*col_info
; /* cached SQLColumns info for this table */
94 #define TI_set_updatable(ti) (ti->flags |= TI_UPDATABLE)
95 #define TI_is_updatable(ti) (0 != (ti->flags &= TI_UPDATABLE))
96 #define TI_no_updatable(ti) (ti->flags &= (~TI_UPDATABLE))
97 #define TI_set_hasoids_checked(ti) (ti->flags |= TI_HASOIDS_CHECKED)
98 #define TI_checked_hasoids(ti) (0 != (ti->flags &= TI_HASOIDS))
99 #define TI_set_hasoids(ti) (ti->flags |= TI_HASOIDS)
100 #define TI_has_oids(ti) (0 != (ti->flags &= TI_HASOIDS))
101 #define TI_set_has_no_oids(ti) (ti->flags &= (~TI_HASOIDS))
102 void TI_Constructor(TABLE_INFO
*, const ConnectionClass
*);
103 void TI_Destructor(TABLE_INFO
**, int);
106 FIELD_INITIALIZED
= 0
108 ,FIELD_TEMP_SET
= (1L << 1)
109 ,FIELD_COL_ATTRIBUTE
= (1L << 2)
110 ,FIELD_PARSED_OK
= (1L << 3)
111 ,FIELD_PARSED_INCOMPLETE
= (1L << 4)
119 TABLE_INFO
*ti
; /* to resolve explicit table names */
125 int column_size
; /* precision in 2.x */
126 int decimal_digits
; /* scale in 2.x */
137 Int4
FI_precision(const FIELD_INFO
*);
138 Int4
FI_scale(const FIELD_INFO
*);
139 void FI_Constructor(FIELD_INFO
*, BOOL reuse
);
140 void FI_Destructor(FIELD_INFO
**, int, BOOL freeFI
);
141 #define FI_is_applicable(fi) (NULL != fi && (fi->flag & (FIELD_PARSED_OK | FIELD_COL_ATTRIBUTE)) != 0)
142 #define FI_type(fi) (0 == (fi)->basetype ? (fi)->columntype : (fi)->basetype)
144 typedef struct DescriptorHeader_
146 ConnectionClass
*conn_conn
;
150 UInt4 error_row
; /* 1-based row */
151 UInt4 error_index
; /* 1-based index */
153 char *__error_message
;
154 PG_ErrorInfo
*pgerror
;
157 // VX_CLEANUP: There's no longer any external access to the App/Implementation
158 // Row/Param Descriptors now that SQLGetDescField and SQLSetDescField are
159 // disabled. It might be possible to get rid of these altogether.
161 * ARD and APD are(must be) of the same format
163 // App Row Descriptor
166 SQLLEN size_of_rowset
; /* for ODBC3 fetch operation */
167 SQLUINTEGER bind_size
; /* size of each structure if using
168 * Row-wise Binding */
169 SQLUSMALLINT
*row_operation_ptr
;
170 SQLULEN
*row_offset_ptr
;
171 BindInfoClass
*bookmark
;
172 BindInfoClass
*bindings
;
173 SQLSMALLINT allocated
;
174 SQLLEN size_of_rowset_odbc2
; /* for SQLExtendedFetch */
178 * APD must be of the same format as ARD
180 // App Param Descriptor
183 SQLLEN paramset_size
; /* really an SQLINTEGER type */
184 SQLUINTEGER param_bind_type
; /* size of each structure if using
185 * Row-wise Parameter Binding */
186 SQLUSMALLINT
*param_operation_ptr
;
187 SQLULEN
*param_offset_ptr
;
188 ParameterInfoClass
*bookmark
; /* dummy item to fit APD to ARD */
189 ParameterInfoClass
*parameters
;
190 SQLSMALLINT allocated
;
191 SQLLEN paramset_size_dummy
; /* dummy item to fit APD to ARD */
194 // Implementation Row Descriptor
197 StatementClass
*stmt
;
198 SQLULEN
*rowsFetched
;
199 SQLUSMALLINT
*rowStatusArray
;
201 SQLSMALLINT allocated
;
205 // Implementation Param Descriptor
208 SQLUINTEGER
*param_processed_ptr
;
209 SQLUSMALLINT
*param_status_ptr
;
210 SQLSMALLINT allocated
;
211 ParameterImplClass
*parameters
;
216 DescriptorClass deschd
;
226 DescriptorClass deschd
;
231 DescriptorClass deschd
;
236 DescriptorClass deschd
;
241 DescriptorClass deschd
;
245 #define DC_get_conn(a) (a->conn_conn)
247 void InitializeEmbeddedDescriptor(DescriptorClass
*, StatementClass
*stmt
,
249 void DC_Destructor(DescriptorClass
*desc
);
250 void InitializeARDFields(ARDFields
*self
);
251 void InitializeAPDFields(APDFields
*self
);
252 /* void InitializeIRDFields(IRDFields *self);
253 void InitializeIPDFiedls(IPDFields *self); */
254 BindInfoClass
*ARD_AllocBookmark(ARDFields
*self
);
255 void ARD_unbind_cols(ARDFields
*self
, BOOL freeall
);
256 void APD_free_params(APDFields
*self
, char option
);
257 void IPD_free_params(IPDFields
*self
, char option
);
258 BOOL
getCOLIfromTI(const char *, ConnectionClass
*, StatementClass
*, const OID
, TABLE_INFO
**);
259 RETCODE
DC_set_stmt(DescriptorClass
*desc
, StatementClass
*stmt
);
260 void DC_clear_error(DescriptorClass
*desc
);
261 void DC_set_error(DescriptorClass
*desc
, int errornumber
, const char * errormsg
);
262 void DC_set_errormsg(DescriptorClass
*desc
, const char * errormsg
);
263 PG_ErrorInfo
*DC_get_error(DescriptorClass
*self
);
264 int DC_get_errornumber(const DescriptorClass
*self
);
265 const char *DC_get_errormsg(const DescriptorClass
*self
);
266 void DC_log_error(const char *func
, const char *desc
, const DescriptorClass
*self
);
268 /* Error numbers about descriptor handle */
270 LOWEST_DESC_ERROR
= -2
271 /* minus means warning/notice message */
272 ,DESC_ERROR_IN_ROW
= -2
273 ,DESC_OPTION_VALUE_CHANGED
= -1
278 ,DESC_NO_MEMORY_ERROR
281 ,DESC_ERROR_TAKEN_FROM_BACKEND
283 ,DESC_STILL_EXECUTING
284 ,DESC_NOT_IMPLEMENTED_ERROR
285 ,DESC_BAD_PARAMETER_NUMBER_ERROR
286 ,DESC_OPTION_OUT_OF_RANGE_ERROR
287 ,DESC_INVALID_COLUMN_NUMBER_ERROR
288 ,DESC_RESTRICTED_DATA_TYPE_ERROR
289 ,DESC_INVALID_CURSOR_STATE_ERROR
290 ,DESC_CREATE_TABLE_ERROR
292 ,DESC_INVALID_CURSOR_NAME
293 ,DESC_INVALID_ARGUMENT_NO
294 ,DESC_ROW_OUT_OF_RANGE
295 ,DESC_OPERATION_CANCELLED
296 ,DESC_INVALID_CURSOR_POSITION
297 ,DESC_VALUE_OUT_OF_RANGE
298 ,DESC_OPERATION_INVALID
299 ,DESC_PROGRAM_TYPE_OUT_OF_RANGE
301 ,DESC_INVALID_OPTION_IDENTIFIER
302 ,DESC_RETURN_NULL_WITHOUT_INDICATOR
303 ,DESC_INVALID_DESCRIPTOR_IDENTIFIER
304 ,DESC_OPTION_NOT_FOR_THE_DRIVER
305 ,DESC_FETCH_OUT_OF_RANGE
306 ,DESC_COUNT_FIELD_INCORRECT
308 #endif /* __DESCRIPTOR_H__ */