cdrapi.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904
  1. /***************************************************************************
  2. *
  3. * Licensed Materials - Property of IBM and/or HCL
  4. *
  5. * __IFMX_DBSERVER_FULLNAME__
  6. * Copyright IBM Corporation 1996, 2013, 2015
  7. * (c) Copyright HCL Technologies Ltd. 2017. All Rights Reserved. 2015
  8. * All Rights Reserved
  9. *
  10. * Title: cdrapi.h
  11. * Description: definitions for CDR API
  12. *
  13. ***************************************************************************
  14. */
  15. #ifndef CDRAPI_H
  16. #define CDRAPI_H
  17. #ifdef NT
  18. #include <time.h>
  19. #else
  20. #include <sys/time.h> /* time_t */
  21. #endif /*NT*/
  22. #include "cdrerr.h"
  23. #ifndef CDR_NEWMSG
  24. #define CDR_NEWMSG(_x,_y) char *_x = _y
  25. #endif
  26. #ifdef NT
  27. #define CDRAPI_EXP_DECL __declspec(dllexport)
  28. #define CDRAPI_EXP_DEFN __declspec(dllexport)
  29. #else
  30. #define CDRAPI_EXP_DECL extern
  31. #define CDRAPI_EXP_DEFN
  32. #endif
  33. #define CDR_NAMESIZE 128 /* max len for CDR identifiers */
  34. #define CDR_PATHSIZE 256
  35. #define SVR_NAMESIZE CDR_NAMESIZE /* for server identifiers */
  36. #define CDR_USERSIZE 34 /* max name len for user name */
  37. /* 32 + 2bytes to allow quoted ownernames
  38. for ansi support */
  39. #define CDR_PROTOSIZE 16
  40. #ifndef CDR_DIRNAMESIZE
  41. #define CDR_DIRNAMESIZE CDR_PATHSIZE /* ATS and RIS dir names */
  42. #endif
  43. #define CDR_LOGFILESIZE CDR_PATHSIZE /* log filename */
  44. #define CDR_SELECTSIZE 30000 /* max len for select statement */
  45. #define CDR_STOREDPROCSIZE 128 /* max len for stored procedure */
  46. #define CDR_1K 1024 /* for 1K buffers */
  47. #define CDR_4K 4096 /* for 4K buffers */
  48. #define HOST_LEN 256 /* max length of host name */
  49. #define USERSIZE 32
  50. /* GLS support for client locale field widths */
  51. #ifndef TURBO /* frontend */
  52. /* max # of bytes occupied by a logical multi-byte character */
  53. #define MB_MAXSIZE 4
  54. #define CDR_GL_NAMESIZE (MB_MAXSIZE * CDR_NAMESIZE)
  55. #define SVR_GL_NAMESIZE (MB_MAXSIZE * SVR_NAMESIZE)
  56. #define CDR_GL_USERSIZE (MB_MAXSIZE * CDR_USERSIZE)
  57. #define CDR_GL_SPSIZE (MB_MAXSIZE * CDR_STOREDPROCSIZE)
  58. #else /* backend */
  59. #define CDR_GL_NAMESIZE CDR_NAMESIZE
  60. #define SVR_GL_NAMESIZE SVR_NAMESIZE
  61. #define CDR_GL_USERSIZE CDR_USERSIZE
  62. #define CDR_GL_SPSIZE CDR_STOREDPROCSIZE
  63. #endif /* ifndef TURBO */
  64. #define CDR_GL_SELECTSIZE CDR_SELECTSIZE
  65. #define CDR_INTERNAL_SET_NAME "ifx_internal_set"
  66. #define CDR_INTERNAL_SET_ID 0x8100
  67. /*
  68. * API datatypes
  69. */
  70. #ifdef TURBO
  71. #include <machine.h>
  72. #else
  73. #include <datetime.h>
  74. #include <decimal.h>
  75. #ifndef MACHINE_INCL
  76. #ifndef _IFXTYPES_H_
  77. typedef unsigned char uint1;
  78. typedef unsigned short uint2;
  79. #ifdef M64ADDR
  80. typedef unsigned int uint4;
  81. #else
  82. typedef unsigned long uint4;
  83. #endif /* M64ADDR */
  84. #endif /* _IFXTYPES_H_ */
  85. #ifndef IDENTSIZE
  86. #define IDENTSIZE SVR_NAMESIZE
  87. #endif /* IDENTSIZE */
  88. #endif /* !define(MACHINE_INCL) */
  89. #endif /* defined(TURBO) */
  90. /* replicate definition flags */
  91. #define D_MASTER 0x01U
  92. #define D_PARTICIPANTS 0x02U
  93. /*
  94. * Internal command. Used while cloning shadow replicate based on the
  95. * primary replicate information.
  96. */
  97. #define D_CDRFEINTERNALCMD 0x04U
  98. /* replicate participant modes */
  99. #define A_RDONLYMODE 0x001U
  100. #define A_PRIMARYMODE 0x002U
  101. /* replicate participant flags stored in the same field as modes */
  102. /* A_USEINFORMIX is not actually stored in the partdef table, but */
  103. /* is necessary to specifically tell the engine to use informix */
  104. #define A_USETABOWNER 0x004U
  105. #define A_USEINFORMIX 0x008U
  106. /* If the replicate is a external resync shadow replicate, then */
  107. /* we need to identify the source/targets so that we know remove the */
  108. /* replicate. */
  109. #define A_EXTSYNCSOURCE 0x010U
  110. #define A_EXTSYNCTARGET 0x020U
  111. #define A_PENDCHKREPAIR 0x040U /* Check repair pending for this participant */
  112. /*
  113. * The participant will send data only
  114. */
  115. #define A_SENDONLYMODE 0x080U
  116. #define A_FORCEACTIVE 0x100U
  117. #define A_SENDERMODE (A_PRIMARYMODE|A_SENDONLYMODE)
  118. #define GET_PART_MODE(_m) ((_m) & \
  119. (A_RDONLYMODE|A_PRIMARYMODE|A_SENDONLYMODE))
  120. #define GET_PART_FLAGS(_f) ((_f) & \
  121. (A_USETABOWNER|A_EXTSYNCSOURCE|A_EXTSYNCTARGET|A_PENDCHKREPAIR))
  122. #define STPARTMODE(flags) \
  123. ((flags & A_PRIMARYMODE) ? 'P' : \
  124. (flags & A_SENDONLYMODE) ? 'S' : 'R')
  125. #define LDPARTMODE(buf) ((buf) == 'P' ? A_PRIMARYMODE : \
  126. (buf) == 'S' ? A_SENDONLYMODE : A_RDONLYMODE)
  127. /* replicate attribute flags */
  128. /* #define A_NONSERIAL 0x00000001U */ /* DEAD? */
  129. /* #define A_PRIMARY 0x00010000U */ /* DEAD? active in 11.70 */
  130. /* #define A_SECONDARY 0x01000000U */ /* DEAD? active in 11.70 */
  131. #define A_CANONICAL 0x00000002U
  132. #define A_FREQ 0x00000008U
  133. /*
  134. * NOTE: These 2 options (sequential and parallel) are no longer supported
  135. */
  136. /* Apply sequential (serially) flag */
  137. #define A_SEQ 0x00000020U
  138. #define A_NONSEQ 0x00000040U /* Default */
  139. #define A_EXCLUSIVE 0x00000080U
  140. #define A_TSCOPE 0x00000100U /* txn conflict resolution */
  141. #define A_RSCOPE 0x00000200U /* row-by-row scope */
  142. #define A_RIS 0x00000400U /* activate RIS */
  143. #define A_ATS 0x00000800U /* activate ATS */
  144. #define A_TRIGGER 0x00001000U /* fire triggers */
  145. #define A_NRIS 0x00002000U /* deactivate RIS */
  146. #define A_NATS 0x00004000U /* deactivate ATS */
  147. #define A_NTRIGGER 0x00008000U /* don't fire triggers */
  148. #define A_REPL4RESYNC 0x00020000U /* Internal replicate for resync job */
  149. #define A_EXTENDEDATTR 0x00040000U /* Has Extended Attributes */
  150. #define A_SHARD 0x00080000U /* replset is a shard */
  151. #define A_GRID 0x00100000U /* Grid Object */
  152. #define A_TEMPLATE 0x00200000U /* Template replset */
  153. #define A_NONAMEVERF 0x00400000U /* Don't verify column names */
  154. #define A_MASTERED 0x00800000U /* Mastered Replicate */
  155. #define A_NSHADOWREPL 0x01000000U /* Unset Shadow Replicate flag*/
  156. #define A_SHADOWREPL 0x02000000U /* Shadow Replicate */
  157. #define A_IGNOREDELETES 0x04000000U /* Ignore any deletes */
  158. #define A_NOIGNOREDELETES 0x08000000U /* don't ignore deletes */
  159. #define A_NOCOLSKIP 0x10000000U /* Always send all data */
  160. #define A_COLSKIP 0x20000000U /* Send only changed data */
  161. #define A_FLOATIEEE 0x40000000U /* Send floating point as IEEE */
  162. #define ATTRSMASK (A_CANONICAL|A_FREQ|A_GRID|\
  163. A_SEQ|A_NONSEQ|A_EXCLUSIVE|\
  164. A_TEMPLATE|A_NONAMEVERF|A_MASTERED|\
  165. A_SHADOWREPL|A_IGNOREDELETES|\
  166. A_COLSKIP|A_FLOATIEEE)
  167. /*
  168. * conflict resolution scope and spooling flags
  169. * NOTE: these CANNOT conflict with replicate attribute flags above.
  170. */
  171. #define A_SCOPE (A_TSCOPE | A_RSCOPE) /* All possible scopes */
  172. #define A_DSFLAGS (A_SCOPE | A_TRIGGER | A_ATS | A_RIS | A_NOCOLSKIP | \
  173. A_COLSKIP | A_IGNOREDELETES |A_SEQ |A_SHADOWREPL | \
  174. A_REPL4RESYNC) /* All possible dsFlags */
  175. /* should go here */
  176. /*#define CRFLAGMASK 0x3602FF00U */ /* Mask out all but these flags */
  177. #define CRFLAGMASK (A_COLSKIP|A_NOCOLSKIP|\
  178. A_IGNOREDELETES|A_SHADOWREPL|A_REPL4RESYNC|\
  179. A_NTRIGGER|A_NATS|A_NRIS|A_TRIGGER|\
  180. A_ATS|A_RIS|A_RSCOPE|A_TSCOPE)
  181. /* conflict resolution rules */
  182. #define R_TIMESTAMP 0x01U
  183. #define R_STOREDPROC 0x02U
  184. #define R_IGNORE 0x04U
  185. #define R_DEFAULT 0x04U
  186. #define R_ALWAYSAPPLY 0x08U
  187. #define R_MANUAL 0x10U
  188. #define R_DELETEWINS 0x20U
  189. /* All possible conflict rules */
  190. #define R_CRRULES (R_TIMESTAMP | R_STOREDPROC | R_IGNORE |R_ALWAYSAPPLY | R_DELETEWINS)
  191. /* stored procedure options */
  192. #define R_STOREDPROC_OPTM 0x01 /* optimized option */
  193. #define R_STOREDPROC_EXEC 0x02 /* always execute option */
  194. /* server attribute flags */
  195. #define A_IDLE 0x01U
  196. #define A_SENDQ 0x02U /* obsolete */
  197. #define A_RECVQ 0x04U /* obsolete */
  198. #define A_ATSDIR 0x08U
  199. #define A_RISDIR 0x10U
  200. #define A_INIT 0x20U
  201. #define A_SYNCSERV 0x40U
  202. #define A_ATSRISXMLFMT 0x80U /* XML format for ATS/RIS files */
  203. /*
  204. * PLEASE NOTE: If we change value of A_LEAF we need to update dbv2k.h
  205. */
  206. #define A_ROOT 0x0100U
  207. #define A_NONROOT 0x0200U
  208. #define A_LEAF 0x0400U
  209. #define A_ROUTEMASK (A_ROOT|A_NONROOT|A_LEAF)
  210. #define A_ATSRISTXTFMT 0x0800U /* text(default) format for ATS/RIS files */
  211. #define A_SUSPENDAPPLY 0x1000U /* DS-apply suspend/resume flag */
  212. #define A_SUSPENDED 0x4000U /* A_SUSPENDED can never be set by api,
  213. used on server recovery */
  214. #define A_ATSRISFMTMASK (A_ATSRISXMLFMT|A_ATSRISTXTFMT)
  215. /*
  216. * Internal flag for server definition.
  217. */
  218. #define A_INITCONNECT 0x8000U
  219. #define CDR_ALTER_ON 0x01
  220. #define CDR_ALTER_OFF 0x02
  221. /* flags for forced spooling of queues */
  222. #define A_FORCE_SPOOL 0x01
  223. /* Define to truncate number of charaters in name of template objects */
  224. #define CDR_TEMPLATE_OBJECT_LEN 30
  225. #define CDR_MSGSIZEBIT 0x00004000
  226. #define CDR_MSGSIZEBIT_MASK 0xffffbfff
  227. typedef struct plist
  228. {
  229. char serv[SVR_GL_NAMESIZE + 1]; /* server name */
  230. char db[SVR_GL_NAMESIZE + 1]; /* database */
  231. char table[SVR_GL_NAMESIZE + 1]; /* table */
  232. char owner[CDR_GL_USERSIZE + 1]; /* owner */
  233. char selectstmt[CDR_GL_SELECTSIZE + 1]; /* select stmt */
  234. uint4 partmode; /* participant mode */
  235. struct plist *part_next; /* next participant */
  236. } CDR_plist;
  237. /*
  238. * Sharding Flags saved in syscdr:shard_tab
  239. */
  240. /* Shard Expression Flags */
  241. #define SHARD_EXPR 0x00000001
  242. #define SHARD_HASH 0x00000002
  243. #define SHARD_NOKEY 0x00000004
  244. #define SHARD_NOSQL 0x00000008
  245. #define SHARD_CHASH 0x00000010
  246. /* Type of shard replication */
  247. #define SHARD_INFO 0x00000100
  248. #define SHARD_KEEP 0x00000200
  249. #define SHARD_DELETE 0x00000400
  250. /* State of shard */
  251. #define SHARD_PENDING 0x00010000
  252. #define SHARD_DELETED 0x00020000
  253. typedef struct _shardList
  254. {
  255. int4 flags; /* see below */
  256. char serv[SVR_GL_NAMESIZE + 1]; /* server name */
  257. int4 servID; /* server ID */
  258. int4 replID; /* replicate ID */
  259. char value[CDR_GL_SELECTSIZE + 1]; /* value list */
  260. char where[CDR_GL_SELECTSIZE + 1];
  261. struct _shardList *next;
  262. } CDR_shardList;
  263. /*
  264. * Flags for the individual replicates within the shard collection
  265. */
  266. #define SHARDFLAGS_SENDONLY 0x00000001 /* node must send */
  267. #define SHARDFLAGS_EXISTING_NODE 0x00000002 /* old node of change shard */
  268. #define SHARDFLAGS_REMAINDER 0x00000004 /* node is a remainder node */
  269. #define SHARD_CHASH_RANGE 10000
  270. typedef struct _chash
  271. {
  272. char serv[SVR_GL_NAMESIZE + 1]; /* server name */
  273. char replica[SVR_GL_NAMESIZE + 10]; /* Replica name */
  274. int4 rval; /* Hash value for this replica partition */
  275. int4 lval; /* Next replica hash value */
  276. int4 hash_wrapped;
  277. struct _chash *chash_next;
  278. } CDR_chash;
  279. typedef struct _CDR_tablist
  280. {
  281. char db[SVR_GL_NAMESIZE + 1]; /* database */
  282. char table[SVR_GL_NAMESIZE + 1]; /* table */
  283. char owner[CDR_GL_USERSIZE + 1]; /* owner */
  284. int4 flags; /* flags */
  285. struct _CDR_tablist *tab_next;
  286. } CDR_tablist;
  287. /* Values for flags. */
  288. #define CDR_GRPBLOCK 0x01 /* Block grouper evaluation. */
  289. #define CDR_NODELTABALT 0x02 /* Do not alter delete table as part of alter
  290. * mode unset operation.
  291. */
  292. #define CDR_CACHEUPDATED 0x04 /* GC Cache updated for this table */
  293. #define CDR_ALTMODESET 0x08 /* GC has set alter mode for this table */
  294. typedef struct freq
  295. {
  296. uint2 hr; /* hour 0-32767 */
  297. uint1 min; /* minute 0-59 */
  298. uint1 type; /* see frequency types below values */
  299. uint1 day;
  300. uint1 month;
  301. } CDR_freq;
  302. /* frequency types */
  303. #define FREQ_IMMED 1 /* immediate */
  304. #define FREQ_INTERVAL 2 /* every hour,minute */
  305. #define FREQ_TIME 3 /* at specified time */
  306. #define FREQ_DAYOFWEEK 4 /* day=day of week (1-7) */
  307. #define FREQ_DAYOFMONTH 5 /* day=day of month (1-31,'L') */
  308. #define FREQ_UNDEFINED 6 /* Undefined for XReplsets */
  309. typedef struct conf
  310. {
  311. uint1 method; /* conflict method */
  312. char storedproc[CDR_GL_SPSIZE + 1]; /* stored procedure */
  313. uint1 storedprocopt; /* stored procedure option */
  314. } CDR_conf;
  315. /*
  316. * The structure used by control messages to pass the extended attributes.
  317. * the first half are the 'on' bits and the second half are the 'off bits'
  318. */
  319. #define XTD_ARRAY_SIZE 8
  320. typedef struct extended_attrs
  321. {
  322. uint4 flags[XTD_ARRAY_SIZE];
  323. } CDR_repl_extended_attrs;
  324. /*
  325. * Events for cdr (cdr_events)
  326. */
  327. #define EVENT_SHARD_DELETE_ROW 1
  328. #define EVENT_SHARD_RESYNC 2
  329. #define EVENT_SHARD_EXECUTE 3
  330. #define EVENT_SHARD_SYNCEND 4
  331. #define EVENT_SHARD_SYNCEND_ACK 5
  332. #define EVENT_SHARD_SYNC_COMPLETE 6
  333. #define EVENT_SHARD_REFRESH_CACHE 7
  334. #define EVENT_SHARD_APPLY_ERROR 8
  335. /*
  336. * The CDR_repl_internal_extended_attrs are contained in the
  337. * grouper and the datasync structures. It consists of the bits from the
  338. * syscdr sysxtdattr table and is set by the flags in the first half of the
  339. * extended_attrs array.
  340. */
  341. #define XTD_INTERNAL_ARRAY_SIZE (XTD_ARRAY_SIZE/2)
  342. typedef struct _internal_extended_attrs
  343. {
  344. uint4 flags[XTD_INTERNAL_ARRAY_SIZE];
  345. } CDR_repl_internal_extended_attrs;
  346. #define XTD_EXT2INT(to,from) \
  347. do { \
  348. if ((to) == NULL) break; \
  349. if ((from) == NULL) break; \
  350. (to)->flags[0] = (from)->flags[0]; \
  351. (to)->flags[1] = (from)->flags[1]; \
  352. (to)->flags[2] = (from)->flags[2]; \
  353. (to)->flags[3] = (from)->flags[3]; \
  354. } Once
  355. #define XTD_FLAGS IDS_INT8(0x7FFFFFFF)
  356. #define XTD_FLAG(Flag) (((bigint)(Flag)) & XTD_FLAGS)
  357. #define XTD_SUB(Flag) (((bigint)(Flag)) >> 32)
  358. #define SET_XTD_ATTRS(attr,Flag) \
  359. (attr).flags[XTD_SUB(Flag)] |= ((int4)XTD_FLAG((Flag)))
  360. #define CLEAR_XTD_ATTRS(attr,Flag) \
  361. (attr).flags[XTD_SUB(Flag)] &= (~((int4)(XTD_FLAG((Flag)))))
  362. #define CHECK_XTD_ATTRS(attr,Flag) \
  363. (attr).flags[XTD_SUB(Flag)] & ((int4)XTD_FLAG((Flag)))
  364. #define XTD_VALUE(x,y) ((x)|(((bigint)y) << 32))
  365. #define XTD_MERGE_FLAGS(o,n) \
  366. do { \
  367. mint _sub; \
  368. if ((o) == NULL) break; \
  369. if ((n) == NULL) break; \
  370. for (_sub = 0; _sub < (XTD_ARRAY_SIZE / 2); _sub++) \
  371. { \
  372. (o)->flags[_sub] |= (n)->flags[_sub]; \
  373. (o)->flags[_sub] &= (~(n)->flags[_sub + (XTD_ARRAY_SIZE / 2)]); \
  374. } \
  375. } Once
  376. #define XTD_ATTR1 0
  377. #define XTD_ATTR2 1
  378. #define XTD_ATTR3 2
  379. #define XTD_ATTR4 3
  380. #define XTD_OFF_ATTR1 4
  381. #define XTD_OFF_ATTR2 5
  382. #define XTD_OFF_ATTR3 6
  383. #define XTD_OFF_ATTR4 7
  384. /*
  385. * Max for any group of extended attributes is 0x4FFFFFFF (31 bits)
  386. * Since all attributes can be either on or off, the off
  387. * attributes are stored in specific locations. This way
  388. * in the code, we can explicitly check for the attribute.
  389. * N.B. we have to be careful not to generate a value of 0x80000000
  390. * as that is a NULL integer.
  391. */
  392. #define A_XTD_UNICODE XTD_VALUE(0x0000001,XTD_ATTR1)
  393. #define A_XTD_NOUNICODE XTD_VALUE(0x0000001,XTD_OFF_ATTR1)
  394. #define A_XTD_TIMESERIES XTD_VALUE(0x0000002,XTD_ATTR1)
  395. #define A_XTD_NOTIMESERIES XTD_VALUE(0x0000002,XTD_OFF_ATTR1)
  396. #define A_XTD_SERIAL_APPLY XTD_VALUE(0x0000004,XTD_ATTR1)
  397. #define A_XTD_NOSERIAL_APPLY XTD_VALUE(0x000004,XTD_OFF_ATTR1)
  398. #define A_XTD_USEUNIQUE_KEY XTD_VALUE(0x0000010,XTD_ATTR1)
  399. #define A_XTD_ALWAYS_REPLOBS XTD_VALUE(0x0000020,XTD_ATTR1)
  400. #define A_XTD_NOALWAYS_REPLOBS XTD_VALUE(0x0000020,XTD_OFF_ATTR1)
  401. #define A_XTD_SHARD_REPL XTD_VALUE(0x0000040,XTD_ATTR1)
  402. #define A_XTD_NOSHARD_REPL XTD_VALUE(0x0000040,XTD_OFF_ATTR1)
  403. #define A_XTD_SHARD_DELETE XTD_VALUE(0x0000080,XTD_ATTR1)
  404. #define A_XTD_NOSHARD_DELETE XTD_VALUE(0x0000080,XTD_OFF_ATTR1)
  405. #define A_XTD_SHARD_INFO XTD_VALUE(0x0000100,XTD_ATTR1)
  406. #define A_XTD_NOSHARD_INFO XTD_VALUE(0x0000100,XTD_OFF_ATTR1)
  407. #define A_XTD_EVENT_REPL XTD_VALUE(0x0000200,XTD_ATTR1)
  408. #define A_XTD_NOEVENT_REPL XTD_VALUE(0x0000200,XTD_OFF_ATTR1)
  409. /* shard replicate for hash-based sharding */
  410. #define A_XTD_SHARD_HASH XTD_VALUE(0x0000400,XTD_ATTR1)
  411. #define A_XTD_NOSHARD_HASH XTD_VALUE(0x0000400,XTD_OFF_ATTR1)
  412. #define A_XTD_SHARD_CHASH XTD_VALUE(0x0000800,XTD_ATTR1)
  413. #define A_XTD_NOSHARD_CHASH XTD_VALUE(0x0000800,XTD_OFF_ATTR1)
  414. #define A_XTD_TRANSIENT_REPL XTD_VALUE(0x0001000,XTD_ATTR1)
  415. #define A_XTD_NOTRANSIENT_REPL XTD_VALUE(0x0001000,XTD_OFF_ATTR1)
  416. #define A_XTD_CASCADE_REPL XTD_VALUE(0x0002000,XTD_ATTR1)
  417. #define A_XTD_NOCASCADE_REPL XTD_VALUE(0x0002000,XTD_OFF_ATTR1)
  418. #define A_XTD_TESTFLAG XTD_VALUE(0x40000000,XTD_ATTR4)
  419. #define A_XTD_NOTESTFLAG XTD_VALUE(0x40000000,XTD_OFF_ATTR4)
  420. #ifdef XTD_PRINT_TESTMODE /* turn on only when special build testing */
  421. #define XTD_PRINT_TESTFLAG(x) \
  422. do { \
  423. mt_logprintf("%s:%d A_XTD_TESTFLAG %s set", \
  424. __FILE__, __LINE__, \
  425. (CHECK_XTD_ATTRS((x), A_XTD_TESTFLAG) ? "is" : "is not")); \
  426. } Once
  427. #else
  428. #define XTD_PRINT_TESTFLAG(x)
  429. #endif
  430. typedef struct idlist
  431. {
  432. char id[SVR_GL_NAMESIZE+1]; /* identifier */
  433. struct idlist* id_next; /* next identifier */
  434. } CDR_idlist;
  435. typedef struct repl_attrs
  436. {
  437. uint4 flags; /* replicate attributes */
  438. CDR_freq* freq; /* freq tx's sent */
  439. CDR_conf* primary; /* primary method*/
  440. CDR_conf* secondary; /* secondary method */
  441. CDR_idlist* keyList; /* key(s) for the replicate */
  442. #ifdef TURBO
  443. CDR_repl_extended_attrs *xtdAttrs;
  444. #endif
  445. } CDR_repl_attrs;
  446. typedef struct serv_attrs
  447. {
  448. uint2 sflags; /* definition flags */
  449. uint2 idle; /* connection time-out (minutes)*/
  450. char atsDir[CDR_DIRNAMESIZE+1]; /* ATS spool dir */
  451. char risDir[CDR_DIRNAMESIZE+1]; /* RIS spool dir */
  452. char syncServ[SVR_GL_NAMESIZE+1];/* catalog sync server name */
  453. CDR_freq *freq; /* batch frequency */
  454. } CDR_serv_attrs;
  455. #define RSNC_TGTROW_DELETE 0x0001 /* Delete the tgt. only rows */
  456. #define RSNC_TGTROW_KEEP 0x0002 /* Keep the tgt. only rows */
  457. #define RSNC_TGTROW_MERGE 0x0004 /* replicate the tgt. only rows */
  458. #define RSNC_CHECKONLY 0x0008 /* Just do the checking of the data */
  459. #define RSNC_REPLICATE 0x0010 /* The job is for a replicate */
  460. #define RSNC_REPLSET 0x0020 /* The job is for a replicate set */
  461. #define RSNC_FULLSYNC 0x0040 /* This job is for initial/full synch */
  462. #define RSNC_DELETEONEND 0x0080 /* Delete this job after completion */
  463. #define RSNC_CASCADEDEL 0x0100 /* Delete this job after completion */
  464. #define RSNC_USERFILTER 0x0200 /* Job has user defined select and
  465. where clauses */
  466. #define RSNC_EXTERNAL 0x0400 /* This is an external sync/resync */
  467. #define RSNC_FOREGROUND 0x0800 /* This is a foreground sync */
  468. /*
  469. * Structure needed for resynch jobs
  470. */
  471. typedef struct resynch_attrs
  472. {
  473. uint4 flags; /* Resync attributes */
  474. int2 blocksize; /* #of rows per resync block */
  475. int4 syncMemAdjust; /* for foreground sync operation */
  476. char objname[CDR_GL_NAMESIZE+1]; /* replicate/replicateset name */
  477. char srcnode[SVR_GL_NAMESIZE+1]; /* source serv for the resync job */
  478. char connsvr[SVR_GL_NAMESIZE+1]; /* Connect server */
  479. } CDR_resynch_attrs;
  480. /*
  481. * Structures needed for Define Templates
  482. */
  483. typedef struct _CDR_templateTable {
  484. struct _CDR_templateTable *next;
  485. char replname[CDR_GL_NAMESIZE+1];
  486. void *replMast;
  487. CDR_idlist *keyList;
  488. char owner[CDR_GL_USERSIZE + 3]; /* name + quotes */
  489. char table[SVR_GL_NAMESIZE + 1];
  490. mint usesAnyUniqueKey;
  491. mint hasTSColumn;
  492. } CDR_templateTable;
  493. typedef struct _CDR_template {
  494. int4 templateID;
  495. CDR_repl_attrs *repl_attrs;
  496. CDR_repl_extended_attrs *xtd_attrs;
  497. int4 replset_flags;
  498. char template_name[CDR_GL_NAMESIZE+1];
  499. char serv[SVR_GL_NAMESIZE + 1];
  500. char dbname[CDR_GL_NAMESIZE+1];
  501. int2 dbflags;
  502. CDR_templateTable *tables;
  503. } CDR_template;
  504. /*
  505. * Structures needed for Realize Templates
  506. */
  507. typedef struct _CDR_templatePart {
  508. uint4 partmode; /* participant mode */
  509. char database[SVR_GL_NAMESIZE+1]; /* database */
  510. char serv[SVR_GL_NAMESIZE + 1]; /* Server name */
  511. struct _CDR_templatePart *next;
  512. } CDR_templatePart;
  513. typedef struct _CDR_realizeTemplate {
  514. char template_name[CDR_GL_NAMESIZE+1];
  515. uint4 flags;
  516. int4 syncMemAdjust;
  517. char dbspace[CDR_GL_NAMESIZE+1];
  518. char syncdatasource[CDR_GL_NAMESIZE+1];
  519. CDR_templatePart *part;
  520. } CDR_realizeTemplate;
  521. typedef void (*CDR_msgfunc_t) (char *);
  522. typedef struct _CDR_check {
  523. char name[CDR_GL_NAMESIZE+1]; /* object name */
  524. uint4 flags;
  525. char master[CDR_GL_NAMESIZE+1]; /* master node */
  526. char *connServer; /* -c server */
  527. CDR_idlist *target; /* list of targets */
  528. mint maxLobCheckSize; /* amount of lob to check */
  529. mint maxRowsInTxn; /* max Txn Size */
  530. mint jobID; /* token job id */
  531. mint resyncJobId; /* internal job id */
  532. int4 syncMemAdjust; /* adjustment for SENDQ */
  533. int4 inflightRetryTime; /* retry time */
  534. int4 maxFork; /* max number of forked subtasks */
  535. int4 cmdtimeout; /* max number seconds to wait for
  536. * server state to be changed from
  537. * disabled to active state. */
  538. char jobName[CDR_GL_NAMESIZE+1]; /* name of this job */
  539. char *whereFilter; /* additional where clause*/
  540. time_t sinceTime; /* check since this time */
  541. char firetrig[20]; /* master node */
  542. char checksum[CDR_GL_NAMESIZE+1]; /* checksum UDR */
  543. } CDR_Check;
  544. #define CHECK_Replset 0x0001 /* object is a set */
  545. #define CHECK_AllNodes 0x0002 /* Check all nodes */
  546. #define CHECK_Repair 0x0004 /* Perform repair on tables */
  547. #define CHECK_Verbose 0x0008 /* print all inconsistancies */
  548. #define CHECK_KeepExtra 0x0010 /* Keep extra rows on target */
  549. #define CHECK_MergeExtra 0x0020 /* Replicate extra rows on target */
  550. #define CHECK_DisableRI 0x0040 /* Disable RI constraints */
  551. #define CHECK_FullSync 0x0080 /* Perform full sync */
  552. #define CHECK_SYNC_Progress 0x0100 /* Perform full sync */
  553. #define CHECK_SkipLOBs 0x0200 /* Skip LOBS in check */
  554. #define CHECK_Background 0x0400 /* Perform background task */
  555. #define CHECK_Restarted 0x0800 /* Restarted Task */
  556. #define CHECK_Timestamp 0x1000 /* Perform timestamp comparison */
  557. #define CHECK_Deletwins 0x2000 /* Enable deletwins in timestamp repair */
  558. #define CHECK_AllRepls 0x4000 /* Check all replicates for the given participants */
  559. #define CHECK_EnableServ 0x8000 /* Enable participants if they are
  560. * in disabled state */
  561. #define CHECK_DeleteUniq 0x010000 /* delete if unique col conflict */
  562. #define CHECK_NoMaster 0x020000
  563. #define CHECK_ExcludeTS 0x040000 /* don't check any TimeSeries columns */
  564. #define CHECK_IgnoreHiddenTSElements \
  565. 0x080000 /* ignore hidden TimeSeries elements */
  566. #define CHECK_IgnoreParentUpd 0x100000 /* skip cascadeUpdate() */
  567. #define CHECK_ReplStateOnly 0x200000 /* Check replication metadata state */
  568. /* For shadowReplFlags */
  569. /* Disable triggers for shadow replicate */
  570. #define FLAG_4_SHADOW_DISABLE_FIRETRIG 0x00000001
  571. /*
  572. * Always enable triggers for shadow replicate even if base replicate
  573. * do not have triggers enabled.
  574. */
  575. #define FLAG_4_SHADOW_ENABLE_FIRETRIG 0x00000002
  576. /*
  577. * Enable triggers for shadow replicate if base replicate has triggers enabled
  578. */
  579. #define FLAG_4_SHADOW_FIRETRIG_FALLOW_BASEREPL 0x00000004
  580. /*
  581. * participate group operators
  582. */
  583. #define A_ADD 1U
  584. #define A_REMOVE 2U
  585. #define A_CREATE 4U /* mastered replicates only - create tables */
  586. #define A_VERIFY 8U /* mastered replicates only - verify tables */
  587. /*
  588. * options during sync of template
  589. */
  590. #define CDR_RT_DeleteExtraRows 0x00000010 /* delete extra rows */
  591. #define CDR_RT_MergeExtraRows 0x00000020 /* merge extra rows */
  592. #define CDR_RT_IgnoreExtraRows 0x00000040 /* ignore extra rows */
  593. #define CDR_RT_ForegroundSync 0x00000080 /* perform foreground sync */
  594. /*
  595. * mode flags for template
  596. */
  597. #define CDR_RT_TargetOnly 0x00000100 /* replication is target only */
  598. #define CDR_RT_ApplyAsInformix 0x00000200 /* apply data as informix */
  599. #define CDR_RT_SendOnly 0x00000400 /* perform as send only */
  600. /*
  601. * template verify/create option flags
  602. */
  603. #define CDR_RT_Verify 0x00010000 /* verify only */
  604. #define CDR_RT_AutoCreate 0x00020000 /* create missing tables */
  605. #define CDR_RT_DatabaseCreate 0x00040000 /* create database if needed */
  606. #define ReplDictCRCOLS 0x0001
  607. #define ReplDictRowLocks 0x0002
  608. #define ReplDictNeedCRCOLS 0x0004
  609. #define ReplDictNeedOffsets 0x0008
  610. #define ReplDictHasDroppedCol 0x0010
  611. #define ReplDictHasReplCheckCol 0x0020 /* replcheck shadow columns */
  612. #define ReplDictHasERKeyCol 0x0040 /* ER key shadow columns */
  613. #define ReplDictUTF8 0x0080 /* names stored in UTF8 format */
  614. #define ReplDictUsingUniqueIdx 0x0100 /* UniqueIndex is the key */
  615. #define ReplDictHasRowVer 0x0200
  616. #define ReplDictHasNoSQLCollection 0x0400 /* NOSQL collection table */
  617. /*
  618. * cdr trigger types...
  619. */
  620. #define CDR_INSERT_TRIGGER 1
  621. #define CDR_UPDATE_TRIGGER 2
  622. #define CDR_DELETE_TRIGGER 3
  623. #define CDR_POST_COMMIT_TRIGGER 4
  624. #define CDR_POST_FAILED_TRIGGER 5
  625. #ifndef TURBO
  626. /*
  627. * Used to make the current CLI and API work with old versions of CDR/SERVER.
  628. * Value of CDRversion Server Version(s)
  629. * ------------------- -----------------
  630. * 1 7.2x
  631. * 2 7.3
  632. * 3 7.31 and 9.20
  633. * 4 9.30, 9.40, 10.00 and 11.10
  634. */
  635. extern int CDRversion;
  636. extern char *SaveVerb;
  637. extern char *SaveObj;
  638. extern mint SaveVerifyOnly;
  639. extern mint ErrorPostCnt;
  640. extern char *ErrorPostID;
  641. /*
  642. * If this variable value is set to TRUE then cache the GLS descriptor
  643. * information instead of loading evrytime in cdr_gl_init() for each API call.
  644. */
  645. int CdrCacheGLSDesc;
  646. CDRAPI_EXP_DECL int cdr_define_repl(const char *, const CDR_repl_attrs *,
  647. const CDR_repl_extended_attrs*, uint4,
  648. CDR_plist *, void **);
  649. CDRAPI_EXP_DECL int cdr_check(CDR_Check *);
  650. CDRAPI_EXP_DECL int cdr_define_shadow_repl( char *, char *, CDR_repl_attrs *,
  651. CDR_repl_extended_attrs*, uint4, CDR_plist *,
  652. void *, void **);
  653. CDRAPI_EXP_DECL int cdr_modify_repl(const char *,
  654. const CDR_repl_attrs *, const CDR_repl_extended_attrs *);
  655. CDRAPI_EXP_DECL int cdr_start_repl( char *,CDR_idlist *, time_t, void **);
  656. int cdr_start_repl_int( char *,CDR_idlist *, time_t, CDR_resynch_attrs *,void **);
  657. CDRAPI_EXP_DECL int cdr_stop_repl( char *,CDR_idlist *, time_t, void **);
  658. CDRAPI_EXP_DECL int cdr_delete_repl( char *, time_t);
  659. CDRAPI_EXP_DECL int cdr_suspend_repl ( char*, time_t);
  660. CDRAPI_EXP_DECL int cdr_resume_repl ( char*, time_t);
  661. CDRAPI_EXP_DECL int cdr_modify_replmode( char *,CDR_plist *, void **);
  662. CDRAPI_EXP_DECL int cdr_define_serv( char *, CDR_serv_attrs *);
  663. CDRAPI_EXP_DECL int cdr_define_serv_v1( char *, CDR_serv_attrs *,
  664. char *, char *);
  665. CDRAPI_EXP_DECL int cdr_modify_serv( char *, CDR_serv_attrs *);
  666. CDRAPI_EXP_DECL int cdr_delete_serv( char *, mint force, mint *okToForceDel);
  667. CDRAPI_EXP_DECL int cdr_suspend_serv( char *,CDR_idlist *, time_t, void **);
  668. CDRAPI_EXP_DECL int cdr_resume_serv( char *,CDR_idlist *, time_t, void **);
  669. CDRAPI_EXP_DECL int cdr_modify_servmode( char *, uint4);
  670. CDRAPI_EXP_DECL int cdr_participate_replset( char *, uint1, CDR_idlist*, void**);
  671. CDRAPI_EXP_DECL int cdr_participate_repl( char*, uint4, char*, CDR_plist*, void**);
  672. CDRAPI_EXP_DECL int cdr_define_replset( char *, uint4,CDR_idlist*,
  673. CDR_freq*, void**);
  674. CDRAPI_EXP_DECL int cdr_delete_replset( char *, time_t);
  675. CDRAPI_EXP_DEFN int
  676. cdr_participate_repl_int(
  677. char *repl,
  678. uint1 op,
  679. CDR_plist *participants,
  680. void **which
  681. );
  682. CDRAPI_EXP_DECL int cdr_delete_replset_int( char *, time_t);
  683. CDRAPI_EXP_DECL int cdr_start_replset( char *,CDR_idlist*, time_t, void**);
  684. CDRAPI_EXP_DECL int cdr_stop_replset( char *,CDR_idlist*, time_t, void**);
  685. CDRAPI_EXP_DECL int cdr_suspend_replset( char *, time_t);
  686. CDRAPI_EXP_DECL int cdr_resume_replset( char *, time_t);
  687. CDRAPI_EXP_DECL int cdr_modify_replset( char *, uint4,
  688. CDR_repl_extended_attrs*, CDR_freq*);
  689. CDRAPI_EXP_DECL int cdr_prune_errors(dtime_t *, dtime_t *, int);
  690. CDRAPI_EXP_DECL int cdr_prune_single_error( char *, long);
  691. CDRAPI_EXP_DECL int cdr_error_reviewed( char *, long);
  692. CDRAPI_EXP_DECL int cdr_move_errortab( char *, int);
  693. CDRAPI_EXP_DECL int cdr_connect(char *, char*);
  694. CDRAPI_EXP_DECL int cdr_connect_useoriglocale(char *, char*);
  695. CDRAPI_EXP_DECL void cdr_closeAllConnections();
  696. CDRAPI_EXP_DECL int cdr_open_database(char*);
  697. CDRAPI_EXP_DECL int cdr_open_database_lockwait(char*);
  698. CDRAPI_EXP_DECL int cdr_open_database_orgiloc_lkwait(char*);
  699. CDRAPI_EXP_DECL int cdr_connect_to_serv(char*);
  700. CDRAPI_EXP_DECL char* cdr_getCurrentServer();
  701. CDRAPI_EXP_DECL int cdr_start_cdr(void);
  702. CDRAPI_EXP_DECL int cdr_continue_cdr(void);
  703. CDRAPI_EXP_DECL int cdr_stop_cdr(void);
  704. CDRAPI_EXP_DECL int cdr_stop_cdr2(uint4);
  705. CDRAPI_EXP_DECL int cdr_connect_serv( char *);
  706. CDRAPI_EXP_DECL int cdr_disconnect_serv( char *);
  707. CDRAPI_EXP_DECL int cdr_sync_checksum( char *, char *, int);
  708. CDRAPI_EXP_DECL int cdr_suspend_apply( char *, uint4);
  709. CDRAPI_EXP_DECL int cdr_swap_shadow(char *, uint4, char *, uint4);
  710. CDRAPI_EXP_DECL int cdr_define_resynch( char *, CDR_resynch_attrs *,
  711. CDR_idlist *, CDR_plist *);
  712. CDRAPI_EXP_DECL int cdr_delete_resynch( char*, char*, char*);
  713. CDRAPI_EXP_DECL int cdr_start_resynch( char*);
  714. CDRAPI_EXP_DECL int cdr_stop_resynch( char*);
  715. CDRAPI_EXP_DECL int cdr_define_template(CDR_template*, char**);
  716. CDRAPI_EXP_DECL int cdr_realize_template(CDR_realizeTemplate*, char*);
  717. CDRAPI_EXP_DECL int cdr_delete_template( char*);
  718. CDRAPI_EXP_DECL int cdr_define_trigger(int4, char*, char*,
  719. CDR_idlist*);
  720. CDRAPI_EXP_DECL int cdr_delete_trigger( char*, char*);
  721. CDRAPI_EXP_DECL mint cdr_alter_mode(int, CDR_tablist*, void **);
  722. CDRAPI_EXP_DECL char* cdr_find_error(int);
  723. CDRAPI_EXP_DEFN int cdr_remove_cdr(void);
  724. CDRAPI_EXP_DEFN int cdr_cleanstart_cdr(void);
  725. CDRAPI_EXP_DEFN mint cdr_remaster_repl(char *, char *, char *);
  726. CDRAPI_EXP_DEFN int cdr_start_replset_int( char *, CDR_resynch_attrs *, CDR_idlist *, time_t, void **);
  727. CDRAPI_EXP_DECL void cdr_register_msgfunc(CDR_msgfunc_t);
  728. CDRAPI_EXP_DECL char *cdr_getJobState(long);
  729. CDRAPI_EXP_DECL void cdr_ConnectionFailed(char*, char*, mint);
  730. CDRAPI_EXP_DECL char* cdrfmtmsg(char *fmt, ...);
  731. CDRAPI_EXP_DECL int cdr_disable_serv(char*);
  732. CDRAPI_EXP_DECL int cdr_enable_serv(char*);
  733. CDRAPI_EXP_DEFN int cdr_autoconfig_server(char*, char*, char*, char*);
  734. #endif /* TURBO */
  735. #ifdef TURBO
  736. #define CDRDEBUG(x,y,z)
  737. #define CDRTRACE(x)
  738. #define CDR_POSTERROR(x,y)
  739. #else
  740. CDRAPI_EXP_DECL mint cdr_post_error( mint errorcode, char *text);
  741. #define CDRDEBUG(x,y,z) \
  742. cdrdebug(__FILE__, __LINE__, (x), (y), (z))
  743. #define CDRTRACE(x) \
  744. cdrtrace(__FILE__,__LINE__, cdrfmtmsg x);
  745. #define CDR_POSTERROR(x,y) \
  746. do { \
  747. char buff[500]; \
  748. strcpy(buff, cdrfmtmsg y); \
  749. cdr_post_error(x, buff); } while (0)
  750. #endif
  751. extern void * dictMalloc(int);
  752. extern void * dictRealloc(void *, int);
  753. extern void dictFree(void *);
  754. extern void cdrdebug (char *file, int lineno, const char *msg,
  755. const char *buff, int size);
  756. CDRAPI_EXP_DEFN mint
  757. cdr_post_error(
  758. mint errorcode,
  759. char *text);
  760. extern char* trim(char*);
  761. /* Really should have an sql/network include prototype */
  762. extern mint ifx_iputint(mint);
  763. extern mint ifx_iputlong(mint);
  764. extern mint ifx_iputunsigned(muint);
  765. extern mint ifx_iwrite(char*, muint);
  766. extern mint ifx_iflushbuff();
  767. extern mint ifx_igetint();
  768. /* The CDR_Config structure is used
  769. * - to normalize the configuration command request.
  770. */
  771. typedef struct CDR_Config {
  772. unsigned int optionFlags;
  773. int operation;
  774. char* onConfigLine;
  775. } CDR_Config_t;
  776. #ifndef CDRZAP
  777. #define CDRZAP(x) memset(&(x), 0, sizeof((x)))
  778. #endif
  779. /* onconfig operation identifiers */
  780. #define CDR_ADD_CONFIG 1 /* for ADD operation */
  781. #define CDR_REMOVE_CONFIG 2 /* for REMOVE operation */
  782. #define CDR_CHANGE_CONFIG 3 /* for CHANGE operation */
  783. #define CDR_MAX_CONFIG_OPERATION CDR_CHANGE_CONFIG
  784. CDRAPI_EXP_DECL int cdr_config_cmd (CDR_Config_t);
  785. typedef enum {
  786. gridtable_noError = 0,
  787. gridtable_hasTS = -1,
  788. gridtable_isExternal = -2,
  789. gridtable_isView = -3,
  790. gridtable_hasLBAC = -4,
  791. gridtable_isSynonym = -5
  792. } gridtableError_td;
  793. #endif /* CDRAPI_H */