collct.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. /*
  2. * Licensed Materials - Property of IBM and/or HCL
  3. *
  4. * IBM Informix Dynamic Server
  5. * (c) Copyright IBM Corporation 1996, 2004 All rights reserved.
  6. * (c) Copyright HCL Technologies Ltd. 2017. All Rights Reserved.
  7. *
  8. ***************************************************************************
  9. *
  10. * Title: collct.h
  11. * Description:
  12. * collection header include file;
  13. *
  14. ***************************************************************************
  15. */
  16. #ifndef _COLLECTION_H
  17. #define _COLLECTION_H
  18. #include "ifxtypes.h"
  19. /* special position value IFX_COLL_USE_CURSOR_POSITION */
  20. #define IFX_COLL_USE_CURSOR_POSITION -5999
  21. /* size of the identifier. SHOULD BE SAME AS IN THE SERVER. */
  22. #ifndef IDENTSIZE
  23. #define IDENTSIZE 128
  24. #endif /* IDENTSIZE */
  25. typedef enum chlog_type
  26. {
  27. CH_INSERT,
  28. CH_UPDATE,
  29. CH_DELETE,
  30. CH_CLDATA
  31. } chlog_type_t;
  32. /* this structure is used when a DML is performed on a collection to store
  33. * the change.
  34. */
  35. typedef struct ifx_changelog_struct
  36. {
  37. mint ch_rownum; /* row number */
  38. chlog_type_t ch_modtype; /* modification type */
  39. char *ch_newrow; /* pointer to new row */
  40. mint ch_newrowlen; /* new row length */
  41. mint ch_flag; /* is changelog associated with data?*/
  42. struct ifx_changelog_struct *ch_next; /* next pointer */
  43. mint ch_maxrowlen; /* actual allocated size */
  44. }ifx_changelog_t;
  45. typedef struct _ifx_collection_struct ifx_collection_t;
  46. /* this is the structure every one registers with a collection manager */
  47. typedef struct ifx_coll_cur_struct ifx_coll_cur_t;
  48. struct ifx_coll_cur_struct
  49. {
  50. mint cur_position; /* position number */
  51. char *cur_elem; /* pointer to the current row in
  52. ** the data part
  53. */
  54. char *cur_row; /* current row to be updated */
  55. /* client collections need this */
  56. ifx_collection_t *cur_coll; /* current collection */
  57. ifx_changelog_t *cur_changelog; /* current change log entry */
  58. int2 cur_flags; /* for internal use only */
  59. ifx_coll_cur_t *cur_next; /* for use of collection manager */
  60. mint cur_run; /* for internal use only */
  61. };
  62. /* this is the structure that maps to one row of SYSATTR system table */
  63. typedef struct ifx_typerow_struct
  64. {
  65. int2 seqno;
  66. int2 level_no;
  67. int2 parent_no;
  68. int2 fieldnmlen;
  69. char fieldname[IDENTSIZE];
  70. int2 field_no;
  71. int2 type;
  72. int2 length;
  73. int4 xid;
  74. int2 flags;
  75. int2 xtype_nm_len;
  76. char xtype_name[IDENTSIZE];
  77. int2 xtype_owner_len;
  78. char xtype_owner_name[IDENTSIZE];
  79. int2 alignment;
  80. int4 sourcetype;
  81. #ifdef TURBO
  82. /* only used in the server. not sent over the wire from/to server */
  83. int2 elem_eq_udrid; /* varid for equal udr for this elem */
  84. #endif
  85. }ifx_typerow_t;
  86. /* this is the structure that holds the type information for a collection */
  87. typedef struct ifx_cltypeinfo_struct
  88. {
  89. /*
  90. * clt_datumbuf, used to return datums, keep 1st to align.
  91. */
  92. double clt_datumbuf[20];
  93. /* full type info for udt/collections this is a ddxtype_t */
  94. void *clt_ddxtype;
  95. int4 clt_typeid; /* type id */
  96. #ifdef TURBO
  97. /* to cache inner type info */
  98. void *clt_colldesc;
  99. #endif
  100. int2 clt_namelen; /* length of the type name */
  101. char clt_typename[IDENTSIZE]; /* name of the type */
  102. int2 clt_numrows; /* number of rows */
  103. /* THIS LINE HAS TO BE LAST DO NOT ADD ANYTHING AFTER IT */
  104. ifx_typerow_t clt_rows[1]; /* to make this struct contiguous */
  105. } ifx_cltypeinfo_t;
  106. /*
  107. * Since collections are of variable size, each tuple can be of variable
  108. * size. This structure holds the size of each tuple in the tuple buffer.
  109. */
  110. typedef struct ifx_cl_tupinfo
  111. {
  112. mint cti_current; /* current tuple */
  113. mint cti_totalsize; /* total tuple size */
  114. mint cti_maxsize; /* maximum array size */
  115. mint cti_tuplesize[1]; /* array containing each tuple size
  116. */
  117. } ifx_cl_tupinfo_t;
  118. /*
  119. * This can be extended later to support other kinds iterator collections
  120. */
  121. typedef struct ifx_coll_iter
  122. {
  123. void *subq_expr;
  124. } ifx_coll_iter_t;
  125. /*
  126. * note: whenever members are added/changed in ifx_collection_struct
  127. * remember to update ifx_coll_copy().
  128. */
  129. struct _ifx_collection_struct
  130. {
  131. mint cl_magic; /* see CL_MAGIC */
  132. mint cl_handle; /* 0 if collection is
  133. * procesed on client
  134. * !0 if processed on server
  135. */
  136. ifx_coll_cur_t *cl_curs; /* cursors specific data for all cursors
  137. ** declared on this collection.
  138. */
  139. mint cl_len; /* length of the collection. This at
  140. ** any time will maintain the total
  141. ** length required to hold
  142. ** the collection
  143. */
  144. mint cl_cardinality; /* #of elements in the collection */
  145. int2 cl_isfixed; /* 1 if elements are fixed size
  146. ** 0 otherwise.
  147. */
  148. #ifdef TURBO
  149. int2 cl_seq_udrid; /* for UDR's seq id of EQUAL func */
  150. #endif
  151. mint cl_elsize; /* size of each element,if fixed size.
  152. ** otherwise, size of the fixed part
  153. */
  154. mint cl_flags; /* flags */
  155. ifx_changelog_t *cl_lastlog; /* Last log entry;to make append easy */
  156. ifx_changelog_t *cl_log; /* list of change log structures */
  157. union
  158. {
  159. char *cldata; /* actual collection column as
  160. * retrieved from RSAM */
  161. ifx_coll_iter_t *cliter; /* opaque structure for iterator
  162. * collections */
  163. } cl_val;
  164. /* NOTE: cl_hashvalue must be an unsigned 32-bit integer. */
  165. /* on 16-bit platform, use unsigned long for cl_hashvalue */
  166. muint cl_hashvalue; /* hash value */
  167. mint cl_datalen; /* length of the data. This is the
  168. ** the length of the data field when
  169. ** the collection_t was first built
  170. */
  171. int2 cl_typed; /* 1 if type defined explicitly */
  172. mint cl_typelen; /* length of below pointer */
  173. ifx_cltypeinfo_t *cl_svr_typeinfo;/* Type information provided
  174. ** by the server.
  175. */
  176. ifx_cltypeinfo_t *cl_typeinfo; /* Type information returned by
  177. ** the server. or defined by user
  178. */
  179. struct heap *cl_heap; /* indicates the heap from which cldata
  180. and chlogs are allocated when the
  181. collection is initially created.
  182. note: in some cases, cldata may be
  183. allocated from outside the collctn */
  184. ifx_changelog_t *cl_freelst; /* sorted free list of change logs */
  185. /* it may be more efficient to use a
  186. binary search tree for the freelst */
  187. ifx_changelog_t *cl_data_hdr; /* info about the cl_data in use */
  188. };
  189. /*
  190. * defines for union between existing collections and subquery
  191. * collections.
  192. */
  193. #define cl_data cl_val.cldata
  194. #define cl_iter cl_val.cliter
  195. /*
  196. * This structure is used to record the names of the columns
  197. * in the projection list of an SQL statement.
  198. */
  199. typedef struct ifx_namelist{
  200. char col_name[150];
  201. }ifx_namelist_t;
  202. /*
  203. * This structure is used to insert data into the collection variable
  204. */
  205. typedef struct ifx_literal {
  206. char *litaddr; /* address of host variable */
  207. int2 littype; /* host type */
  208. int2 litlen; /* length of field type */
  209. int2 litqual; /* qualifier for DATETIME/INTERVAL */
  210. int2 literal; /* 1 if literal string 0 otherwise */
  211. }ifx_literal_t;
  212. /*
  213. used within value_t to store a tree of value_t.
  214. For example,
  215. the value_t tree for SET{1,2,3} looks like the following:
  216. value_t(SET)
  217. --(ct_child)--> value_t(1)
  218. --(v_next)--> value_t(2)
  219. --(v_next)--> value_t(3)
  220. */
  221. typedef struct
  222. {
  223. ifx_collection_t ct_coll; /* collection_t for collection/ROW */
  224. struct value *ct_child; /* 1st element in the collection/ROW */
  225. } ifx_collval_t;
  226. #endif /* _COLLECTION_H */