| 1 | /************** PlgDBSem H Declares Source Code File (.H) **************/ |
| 2 | /* Name: PLGDBSEM.H Version 3.7 */ |
| 3 | /* */ |
| 4 | /* (C) Copyright to the author Olivier BERTRAND 1998-2017 */ |
| 5 | /* */ |
| 6 | /* This file contains the CONNECT storage engine definitions. */ |
| 7 | /***********************************************************************/ |
| 8 | |
| 9 | /***********************************************************************/ |
| 10 | /* Include required application header files */ |
| 11 | /***********************************************************************/ |
| 12 | #include "checklvl.h" |
| 13 | |
| 14 | /***********************************************************************/ |
| 15 | /* DB Constant definitions. */ |
| 16 | /***********************************************************************/ |
| 17 | #if defined(FRENCH) |
| 18 | #define DEFAULT_LOCALE "French" |
| 19 | #else // !FRENCH |
| 20 | #define DEFAULT_LOCALE "English" |
| 21 | #endif // !FRENCH |
| 22 | |
| 23 | #define DOS_MAX_PATH 144 /* Must be the same across systems */ |
| 24 | #define DOS_BUFF_LEN 100 /* Number of lines in binary file buffer */ |
| 25 | #undef DOMAIN /* For Unix version */ |
| 26 | |
| 27 | enum BLKTYP {TYPE_TABLE = 50, /* Table Name/Srcdef/... Block */ |
| 28 | TYPE_COLUMN = 51, /* Column Name/Qualifier Block */ |
| 29 | TYPE_TDB = 53, /* Table Description Block */ |
| 30 | TYPE_COLBLK = 54, /* Column Description Block */ |
| 31 | TYPE_FILTER = 55, /* Filter Description Block */ |
| 32 | TYPE_ARRAY = 63, /* General array type */ |
| 33 | TYPE_PSZ = 64, /* Pointer to String ended by 0 */ |
| 34 | TYPE_SQL = 65, /* Pointer to SQL block */ |
| 35 | TYPE_XOBJECT = 69, /* Extended DB object */ |
| 36 | TYPE_COLCRT = 71, /* Column creation block */ |
| 37 | TYPE_CONST = 72, /* Constant */ |
| 38 | |
| 39 | /*-------------------- additional values used by LNA ------------------*/ |
| 40 | TYPE_COLIST = 14, /* Column list */ |
| 41 | TYPE_COL = 41, /* Column */ |
| 42 | /*-------------------- types used by scalar functions -----------------*/ |
| 43 | TYPE_NUM = 12, |
| 44 | TYPE_UNDEF = 13, |
| 45 | /*-------------------- file blocks used when closing ------------------*/ |
| 46 | TYPE_FB_FILE = 22, /* File block (stream) */ |
| 47 | TYPE_FB_MAP = 23, /* Mapped file block (storage) */ |
| 48 | TYPE_FB_HANDLE = 24, /* File block (handle) */ |
| 49 | TYPE_FB_XML = 21, /* DOM XML file block */ |
| 50 | TYPE_FB_XML2 = 27, /* libxml2 XML file block */ |
| 51 | TYPE_FB_ODBC = 25, /* ODBC file block */ |
| 52 | TYPE_FB_ZIP = 28, /* ZIP file block */ |
| 53 | TYPE_FB_JAVA = 29, /* JAVA file block */ |
| 54 | TYPE_FB_MONGO = 30}; /* MONGO file block */ |
| 55 | |
| 56 | enum TABTYPE {TAB_UNDEF = 0, /* Table of undefined type */ |
| 57 | TAB_DOS = 1, /* Fixed column offset, variable LRECL */ |
| 58 | TAB_FIX = 2, /* Fixed column offset, fixed LRECL */ |
| 59 | TAB_BIN = 3, /* Like FIX but can have binary fields */ |
| 60 | TAB_CSV = 4, /* DOS files with CSV records */ |
| 61 | TAB_FMT = 5, /* DOS files with formatted records */ |
| 62 | TAB_DBF = 6, /* DBF Dbase or Foxpro files */ |
| 63 | TAB_XML = 7, /* XML or HTML files */ |
| 64 | TAB_INI = 8, /* INI or CFG files */ |
| 65 | TAB_VEC = 9, /* Vector column arrangement */ |
| 66 | TAB_ODBC = 10, /* Table accessed via (unix)ODBC */ |
| 67 | TAB_MYSQL = 11, /* MySQL table accessed via MySQL API */ |
| 68 | TAB_DIR = 12, /* Returns a list of files */ |
| 69 | TAB_MAC = 13, /* MAC address (Windows only) */ |
| 70 | TAB_WMI = 14, /* WMI tables (Windows only) */ |
| 71 | TAB_TBL = 15, /* Collection of CONNECT tables */ |
| 72 | TAB_OEM = 16, /* OEM implemented table */ |
| 73 | TAB_XCL = 17, /* XCL table */ |
| 74 | TAB_OCCUR = 18, /* OCCUR table */ |
| 75 | TAB_PRX = 19, /* Proxy (catalog) table */ |
| 76 | TAB_PLG = 20, /* PLG NIY */ |
| 77 | TAB_PIVOT = 21, /* PIVOT table */ |
| 78 | TAB_VIR = 22, /* Virtual tables */ |
| 79 | TAB_JSON = 23, /* JSON tables */ |
| 80 | TAB_JCT = 24, /* Junction tables NIY */ |
| 81 | TAB_DMY = 25, /* DMY Dummy tables NIY */ |
| 82 | TAB_JDBC = 26, /* Table accessed via JDBC */ |
| 83 | TAB_ZIP = 27, /* ZIP file info table */ |
| 84 | TAB_MONGO = 28, /* Table retrieved from MongoDB */ |
| 85 | TAB_NIY = 30}; /* Table not implemented yet */ |
| 86 | |
| 87 | enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */ |
| 88 | TYPE_AM_ROWID = 1, /* ROWID type (special column) */ |
| 89 | TYPE_AM_FILID = 2, /* FILEID type (special column) */ |
| 90 | TYPE_AM_TAB = 3, /* Table (any type) */ |
| 91 | TYPE_AM_VIEW = 4, /* VIEW (any type) */ |
| 92 | TYPE_AM_SRVID = 5, /* SERVID type (special column) */ |
| 93 | TYPE_AM_TABID = 6, /* TABID type (special column) */ |
| 94 | TYPE_AM_CNSID = 7, /* CONSTID type (special column) */ |
| 95 | TYPE_AM_PRTID = 8, /* PARTID type (special column) */ |
| 96 | TYPE_AM_COUNT = 10, /* CPT AM type no (count table) */ |
| 97 | TYPE_AM_DCD = 20, /* Decode access method type no */ |
| 98 | TYPE_AM_CMS = 30, /* CMS access method type no */ |
| 99 | TYPE_AM_MAP = 32, /* MAP access method type no */ |
| 100 | TYPE_AM_FMT = 33, /* DOS files with formatted recs */ |
| 101 | TYPE_AM_CSV = 34, /* DOS files with CSV records */ |
| 102 | TYPE_AM_MCV = 35, /* MAP files with CSV records */ |
| 103 | TYPE_AM_DOS = 36, /* DOS am with Lrecl = V */ |
| 104 | TYPE_AM_FIX = 38, /* DOS am with Lrecl = F */ |
| 105 | TYPE_AM_BIN = 39, /* DOS am with Lrecl = B */ |
| 106 | TYPE_AM_VCT = 40, /* VCT access method type no */ |
| 107 | TYPE_AM_VMP = 43, /* VMP access method type no */ |
| 108 | TYPE_AM_QRY = 50, /* QRY access method type no */ |
| 109 | TYPE_AM_QRS = 51, /* QRYRES access method type no */ |
| 110 | TYPE_AM_SQL = 60, /* SQL VIEW access method type */ |
| 111 | TYPE_AM_PLG = 70, /* PLG access method type no */ |
| 112 | TYPE_AM_PLM = 71, /* PDM access method type no */ |
| 113 | TYPE_AM_DOM = 80, /* DOM access method type no */ |
| 114 | TYPE_AM_DIR = 90, /* DIR access method type no */ |
| 115 | TYPE_AM_ODBC = 100, /* ODBC access method type no */ |
| 116 | TYPE_AM_XDBC = 101, /* XDBC access method type no */ |
| 117 | TYPE_AM_JDBC = 102, /* JDBC access method type no */ |
| 118 | TYPE_AM_XJDC = 103, /* XJDC access method type no */ |
| 119 | TYPE_AM_OEM = 110, /* OEM access method type no */ |
| 120 | TYPE_AM_TBL = 115, /* TBL access method type no */ |
| 121 | TYPE_AM_PIVOT = 120, /* PIVOT access method type no */ |
| 122 | TYPE_AM_SRC = 121, /* PIVOT multiple column type no */ |
| 123 | TYPE_AM_FNC = 122, /* PIVOT source column type no */ |
| 124 | TYPE_AM_XCOL = 124, /* XCOL access method type no */ |
| 125 | TYPE_AM_XML = 127, /* XML access method type no */ |
| 126 | TYPE_AM_OCCUR = 128, /* OCCUR access method type no */ |
| 127 | TYPE_AM_PRX = 129, /* PROXY access method type no */ |
| 128 | TYPE_AM_XTB = 130, /* SYS table access method type */ |
| 129 | TYPE_AM_BLK = 131, /* BLK access method type no */ |
| 130 | TYPE_AM_GZ = 132, /* GZ access method type no */ |
| 131 | TYPE_AM_ZLIB = 133, /* ZLIB access method type no */ |
| 132 | TYPE_AM_JSON = 134, /* JSON access method type no */ |
| 133 | TYPE_AM_JSN = 135, /* JSN access method type no */ |
| 134 | TYPE_AM_MAC = 137, /* MAC table access method type */ |
| 135 | TYPE_AM_WMI = 139, /* WMI table access method type */ |
| 136 | TYPE_AM_XCL = 140, /* SYS column access method type */ |
| 137 | TYPE_AM_INI = 150, /* INI files access method */ |
| 138 | TYPE_AM_TFC = 155, /* TFC (Circa) (Fuzzy compare) */ |
| 139 | TYPE_AM_DBF = 160, /* DBF Dbase files am type no */ |
| 140 | TYPE_AM_JCT = 170, /* Junction tables am type no */ |
| 141 | TYPE_AM_VIR = 171, /* Virtual tables am type no */ |
| 142 | TYPE_AM_DMY = 172, /* DMY Dummy tables am type no */ |
| 143 | TYPE_AM_SET = 180, /* SET Set tables am type no */ |
| 144 | TYPE_AM_MYSQL = 190, /* MYSQL access method type no */ |
| 145 | TYPE_AM_MYX = 191, /* MYSQL EXEC access method type */ |
| 146 | TYPE_AM_CAT = 192, /* Catalog access method type no */ |
| 147 | TYPE_AM_ZIP = 193, /* ZIP access method type no */ |
| 148 | TYPE_AM_MGO = 194, /* MGO access method type no */ |
| 149 | TYPE_AM_OUT = 200}; /* Output relations (storage) */ |
| 150 | |
| 151 | enum RECFM {RECFM_NAF = -2, /* Not a file */ |
| 152 | RECFM_OEM = -1, /* OEM file access method */ |
| 153 | RECFM_VAR = 0, /* Varying length DOS files */ |
| 154 | RECFM_FIX = 1, /* Fixed length DOS files */ |
| 155 | RECFM_BIN = 2, /* Binary DOS files (also fixed) */ |
| 156 | RECFM_VCT = 3, /* VCT formatted files */ |
| 157 | RECFM_ODBC = 4, /* Table accessed via ODBC */ |
| 158 | RECFM_JDBC = 5, /* Table accessed via JDBC */ |
| 159 | RECFM_PLG = 6, /* Table accessed via PLGconn */ |
| 160 | RECFM_DBF = 7}; /* DBase formatted file */ |
| 161 | |
| 162 | enum MISC {DB_TABNO = 1, /* DB routines in Utility Table */ |
| 163 | MAX_MULT_KEY = 10, /* Max multiple key number */ |
| 164 | NAM_LEN = 128, /* Length of col and tab names */ |
| 165 | ARRAY_SIZE = 50, /* Default array block size */ |
| 166 | // MAXRES = 500, /* Default maximum result lines */ |
| 167 | // MAXLIN = 10000, /* Default maximum data lines */ |
| 168 | MAXBMP = 32}; /* Default XDB2 max bitmap size */ |
| 169 | |
| 170 | #if 0 |
| 171 | enum ALGMOD {AMOD_AUTO = 0, /* PLG chooses best algorithm */ |
| 172 | AMOD_SQL = 1, /* Use SQL algorithm */ |
| 173 | AMOD_QRY = 2}; /* Use QUERY algorithm */ |
| 174 | #endif // 0 |
| 175 | |
| 176 | enum MODE {MODE_ERROR = -1, /* Invalid mode */ |
| 177 | MODE_ANY = 0, /* Unspecified mode */ |
| 178 | MODE_READ = 10, /* Input/Output mode */ |
| 179 | MODE_READX = 11, /* Read indexed mode */ |
| 180 | MODE_WRITE = 20, /* Input/Output mode */ |
| 181 | MODE_UPDATE = 30, /* Input/Output mode */ |
| 182 | MODE_INSERT = 40, /* Input/Output mode */ |
| 183 | MODE_DELETE = 50, /* Input/Output mode */ |
| 184 | MODE_ALTER = 60}; /* alter mode */ |
| 185 | |
| 186 | #if !defined(RC_OK_DEFINED) |
| 187 | #define RC_OK_DEFINED |
| 188 | enum RCODE {RC_OK = 0, /* No error return code */ |
| 189 | RC_NF = 1, /* Not found return code */ |
| 190 | RC_EF = 2, /* End of file return code */ |
| 191 | RC_FX = 3, /* Error return code */ |
| 192 | RC_INFO = 4}; /* Success with info */ |
| 193 | #endif // !RC_OK_DEFINED |
| 194 | |
| 195 | enum OPVAL {OP_EQ = 1, /* Filtering operator = */ |
| 196 | OP_NE = 2, /* Filtering operator != */ |
| 197 | OP_GT = 3, /* Filtering operator > */ |
| 198 | OP_GE = 4, /* Filtering operator >= */ |
| 199 | OP_LT = 5, /* Filtering operator < */ |
| 200 | OP_LE = 6, /* Filtering operator <= */ |
| 201 | OP_IN = 7, /* Filtering operator IN */ |
| 202 | OP_NULL = 8, /* Filtering operator IS NULL */ |
| 203 | OP_EXIST = 9, /* Filtering operator EXISTS */ |
| 204 | OP_LIKE = 10, /* Filtering operator LIKE */ |
| 205 | OP_LOJ = -1, /* Filter op LEFT OUTER JOIN */ |
| 206 | OP_ROJ = -2, /* Filter op RIGHT OUTER JOIN */ |
| 207 | OP_DTJ = -3, /* Filter op DISTINCT JOIN */ |
| 208 | OP_XX = 11, /* Filtering operator unknown */ |
| 209 | OP_AND = 12, /* Filtering operator AND */ |
| 210 | OP_OR = 13, /* Filtering operator OR */ |
| 211 | OP_CNC = 14, /* Expression Concat operator */ |
| 212 | OP_NOT = 15, /* Filtering operator NOT */ |
| 213 | OP_SEP = 20, /* Filtering separator */ |
| 214 | OP_ADD = 16, /* Expression Add operator */ |
| 215 | OP_SUB = 17, /* Expression Substract operator */ |
| 216 | OP_MULT = 18, /* Expression Multiply operator */ |
| 217 | OP_DIV = 19, /* Expression Divide operator */ |
| 218 | OP_NUM = 22, /* Scalar function Op Num */ |
| 219 | OP_MAX = 24, /* Scalar function Op Max */ |
| 220 | OP_MIN = 25, /* Scalar function Op Min */ |
| 221 | OP_EXP = 36, /* Scalar function Op Exp */ |
| 222 | OP_FDISK = 94, /* Operator Disk of fileid */ |
| 223 | OP_FPATH = 95, /* Operator Path of fileid */ |
| 224 | OP_FNAME = 96, /* Operator Name of fileid */ |
| 225 | OP_FTYPE = 97, /* Operator Type of fileid */ |
| 226 | OP_LAST = 82, /* Index operator Find Last */ |
| 227 | OP_FIRST = 106, /* Index operator Find First */ |
| 228 | OP_NEXT = 107, /* Index operator Find Next */ |
| 229 | OP_SAME = 108, /* Index operator Find Next Same */ |
| 230 | OP_FSTDIF = 109, /* Index operator Find First dif */ |
| 231 | OP_NXTDIF = 110, /* Index operator Find Next dif */ |
| 232 | OP_PREV = 116}; /* Index operator Find Previous */ |
| 233 | #if 0 |
| 234 | OP_NOP = 21, /* Scalar function is nopped */ |
| 235 | OP_ABS = 23, /* Scalar function Op Abs */ |
| 236 | OP_CEIL = 26, /* Scalar function Op Ceil */ |
| 237 | OP_FLOOR = 27, /* Scalar function Op Floor */ |
| 238 | OP_MOD = 28, /* Scalar function Op Mod */ |
| 239 | OP_ROUND = 29, /* Scalar function Op Round */ |
| 240 | OP_SIGN = 30, /* Scalar function Op Sign */ |
| 241 | OP_LEN = 31, /* Scalar function Op Len */ |
| 242 | OP_INSTR = 32, /* Scalar function Op Instr */ |
| 243 | OP_LEFT = 33, /* Scalar function Op Left */ |
| 244 | OP_RIGHT = 34, /* Scalar function Op Right */ |
| 245 | OP_ASCII = 35, /* Scalar function Op Ascii */ |
| 246 | OP_EXP = 36, /* Scalar function Op Exp */ |
| 247 | OP_LN = 37, /* Scalar function Op Ln */ |
| 248 | OP_LOG = 38, /* Scalar function Op Log */ |
| 249 | OP_POWER = 39, /* Scalar function Op Power */ |
| 250 | OP_SQRT = 40, /* Scalar function Op Sqrt */ |
| 251 | OP_COS = 41, /* Scalar function Op Cos */ |
| 252 | OP_COSH = 42, /* Scalar function Op Cosh */ |
| 253 | OP_SIN = 43, /* Scalar function Op Sin */ |
| 254 | OP_SINH = 44, /* Scalar function Op Sinh */ |
| 255 | OP_TAN = 45, /* Scalar function Op Tan */ |
| 256 | OP_TANH = 46, /* Scalar function Op Tanh */ |
| 257 | OP_USER = 47, /* Scalar function Op User */ |
| 258 | OP_CHAR = 48, /* Scalar function Op Char */ |
| 259 | OP_UPPER = 49, /* Scalar function Op Upper */ |
| 260 | OP_LOWER = 50, /* Scalar function Op Lower */ |
| 261 | OP_RPAD = 51, /* Scalar function Op Rpad */ |
| 262 | OP_LPAD = 52, /* Scalar function Op Lpad */ |
| 263 | OP_LTRIM = 53, /* Scalar function Op Ltrim */ |
| 264 | OP_RTRIM = 54, /* Scalar function Op Rtrim */ |
| 265 | OP_REPL = 55, /* Scalar function Op Replace */ |
| 266 | OP_SUBST = 56, /* Scalar function Op Substr */ |
| 267 | OP_LJUST = 57, /* Scalar function Op Ljustify */ |
| 268 | OP_RJUST = 58, /* Scalar function Op Rjustify */ |
| 269 | OP_CJUST = 59, /* Scalar function Op Cjustify */ |
| 270 | OP_ENCODE = 60, /* Scalar function Op Encode */ |
| 271 | OP_DECODE = 61, /* Scalar function Op Decode */ |
| 272 | OP_SEQU = 62, /* Scalar function Op Sequence */ |
| 273 | OP_IF = 63, /* Scalar function Op If */ |
| 274 | OP_STRING = 64, /* Scalar function Op String */ |
| 275 | OP_TOKEN = 65, /* Scalar function Op Token */ |
| 276 | OP_SNDX = 66, /* Scalar function Op Soundex */ |
| 277 | OP_DATE = 67, /* Scalar function Op Date */ |
| 278 | OP_MDAY = 68, /* Scalar function Op Month Day */ |
| 279 | OP_MONTH = 69, /* Scalar function Op Month of */ |
| 280 | OP_YEAR = 70, /* Scalar function Op Year of */ |
| 281 | OP_WDAY = 71, /* Scalar function Op Week Day */ |
| 282 | OP_YDAY = 72, /* Scalar function Op Year Day */ |
| 283 | OP_DBTWN = 73, /* Scalar function Op Days betwn */ |
| 284 | OP_MBTWN = 74, /* Scalar function Op Months btw */ |
| 285 | OP_YBTWN = 75, /* Scalar function Op Years btwn */ |
| 286 | OP_ADDAY = 76, /* Scalar function Op Add Days */ |
| 287 | OP_ADDMTH = 77, /* Scalar function Op Add Months */ |
| 288 | OP_ADDYR = 78, /* Scalar function Op Add Years */ |
| 289 | OP_NXTDAY = 79, /* Scalar function Op Next Day */ |
| 290 | OP_SYSDT = 80, /* Scalar function Op SysDate */ |
| 291 | OP_DELTA = 81, /* Scalar function Op Delta */ |
| 292 | OP_LAST = 82, /* Scalar function Op Last */ |
| 293 | OP_IFF = 83, /* Scalar function Op Iff */ |
| 294 | OP_MAVG = 84, /* Scalar function Op Moving Avg */ |
| 295 | OP_VWAP = 85, /* Scalar function Op VWAP */ |
| 296 | OP_TIME = 86, /* Scalar function Op TIME */ |
| 297 | OP_SETLEN = 87, /* Scalar function Op Set Length */ |
| 298 | OP_TRANSL = 88, /* Scalar function Op Translate */ |
| 299 | OP_BITAND = 89, /* Expression BitAnd operator */ |
| 300 | OP_BITOR = 90, /* Expression BitOr operator */ |
| 301 | OP_BITXOR = 91, /* Expression XOR operator */ |
| 302 | OP_BITNOT = 92, /* Expression Complement operator*/ |
| 303 | OP_CNTIN = 93, /* Scalar function Count In */ |
| 304 | OP_FDISK = 94, /* Scalar function Disk of fileid*/ |
| 305 | OP_FPATH = 95, /* Scalar function Path of fileid*/ |
| 306 | OP_FNAME = 96, /* Scalar function Name of fileid*/ |
| 307 | OP_FTYPE = 97, /* Scalar function Type of fileid*/ |
| 308 | OP_XDATE = 98, /* Scalar function Op Fmt Date */ |
| 309 | OP_SWITCH = 99, /* Scalar function Op Switch */ |
| 310 | OP_EXIT = 100, /* Scalar function Op Exit */ |
| 311 | OP_LIT = 101, /* Scalar function Op Literal */ |
| 312 | OP_LOCALE = 102, /* Scalar function Op Locale */ |
| 313 | OP_FRNCH = 103, /* Scalar function Op French */ |
| 314 | OP_ENGLSH = 104, /* Scalar function Op English */ |
| 315 | OP_RAND = 105, /* Scalar function Op Rand(om) */ |
| 316 | OP_FIRST = 106, /* Index operator Find First */ |
| 317 | OP_NEXT = 107, /* Index operator Find Next */ |
| 318 | OP_SAME = 108, /* Index operator Find Next Same */ |
| 319 | OP_FSTDIF = 109, /* Index operator Find First dif */ |
| 320 | OP_NXTDIF = 110, /* Index operator Find Next dif */ |
| 321 | OP_VAL = 111, /* Scalar function Op Valist */ |
| 322 | OP_QUART = 112, /* Scalar function Op QUARTER */ |
| 323 | OP_CURDT = 113, /* Scalar function Op CurDate */ |
| 324 | OP_NWEEK = 114, /* Scalar function Op Week number*/ |
| 325 | OP_ROW = 115, /* Scalar function Op Row */ |
| 326 | OP_PREV = 116, /* Index operator Find Previous */ |
| 327 | OP_SYSTEM = 200, /* Scalar function Op System */ |
| 328 | OP_REMOVE = 201, /* Scalar function Op Remove */ |
| 329 | OP_RENAME = 202, /* Scalar function Op Rename */ |
| 330 | OP_FCOMP = 203}; /* Scalar function Op Compare */ |
| 331 | #endif // 0 |
| 332 | |
| 333 | enum TUSE {USE_NO = 0, /* Table is not yet linearized */ |
| 334 | USE_LIN = 1, /* Table is linearized */ |
| 335 | USE_READY = 2, /* Column buffers are allocated */ |
| 336 | USE_OPEN = 3, /* Table is open */ |
| 337 | USE_CNT = 4, /* Specific to LNA */ |
| 338 | USE_NOKEY = 5}; /* Specific to SqlToHql */ |
| 339 | |
| 340 | /***********************************************************************/ |
| 341 | /* Following definitions are used to indicate the status of a column. */ |
| 342 | /***********************************************************************/ |
| 343 | enum STATUS {BUF_NO = 0x00, /* Column buffer not allocated */ |
| 344 | BUF_EMPTY = 0x01, /* Column buffer is empty */ |
| 345 | BUF_READY = 0x02, /* Column buffer is ready */ |
| 346 | BUF_READ = 0x04, /* Column buffer has read value */ |
| 347 | BUF_MAPPED = 0x08}; /* Used by the VMPFAM class */ |
| 348 | |
| 349 | /***********************************************************************/ |
| 350 | /* Following definitions are used to indicate how a column is used. */ |
| 351 | /* Corresponding bits are ON if the column is used in: */ |
| 352 | /***********************************************************************/ |
| 353 | enum COLUSE {U_P = 0x01, /* the projection list. */ |
| 354 | U_J_EXT = 0x02, /* a join filter. */ |
| 355 | U_J_INT = 0x04, /* a join after linearisation. */ |
| 356 | /*-- Such a column have a constant value throughout a subquery eval. --*/ |
| 357 | U_CORREL = 0x08, /* a correlated sub-query */ |
| 358 | /*-------------------- additional values used by CONNECT --------------*/ |
| 359 | U_VAR = 0x10, /* a VARCHAR column */ |
| 360 | U_VIRTUAL = 0x20, /* a VIRTUAL column */ |
| 361 | U_NULLS = 0x40, /* The column may have nulls */ |
| 362 | U_IS_NULL = 0x80, /* The column has a null value */ |
| 363 | U_SPECIAL = 0x100, /* The column is special */ |
| 364 | U_UNSIGNED = 0x200, /* The column type is unsigned */ |
| 365 | U_ZEROFILL = 0x400, /* The column is zero filled */ |
| 366 | U_UUID = 0x800}; /* The column is a UUID */ |
| 367 | |
| 368 | /***********************************************************************/ |
| 369 | /* DB description class and block pointer definitions. */ |
| 370 | /***********************************************************************/ |
| 371 | typedef class XTAB *PTABLE; |
| 372 | typedef class COLUMN *PCOLUMN; |
| 373 | typedef class XOBJECT *PXOB; |
| 374 | typedef class COLBLK *PCOL; |
| 375 | typedef class TDB *PTDB; |
| 376 | typedef class TDBASE *PTDBASE; |
| 377 | typedef class TDBEXT *PTDBEXT; |
| 378 | typedef class TDBDOS *PTDBDOS; |
| 379 | typedef class TDBFIX *PTDBFIX; |
| 380 | typedef class TDBFMT *PTDBFMT; |
| 381 | typedef class TDBCSV *PTDBCSV; |
| 382 | typedef class TDBDOM *PTDBDOM; |
| 383 | typedef class TDBDIR *PTDBDIR; |
| 384 | typedef class DOSCOL *PDOSCOL; |
| 385 | typedef class CSVCOL *PCSVCOL; |
| 386 | typedef class MAPCOL *PMAPCOL; |
| 387 | typedef class TDBMFT *PTDBMFT; |
| 388 | typedef class TDBMCV *PTDBMCV; |
| 389 | typedef class MCVCOL *PMCVCOL; |
| 390 | typedef class RESCOL *PRESCOL; |
| 391 | typedef class XXBASE *PKXBASE; |
| 392 | typedef class KXYCOL *PXCOL; |
| 393 | typedef class CATALOG *PCATLG; |
| 394 | typedef class RELDEF *PRELDEF; |
| 395 | typedef class TABDEF *PTABDEF; |
| 396 | typedef class EXTDEF *PEXTBDEF; |
| 397 | typedef class DOSDEF *PDOSDEF; |
| 398 | typedef class CSVDEF *PCSVDEF; |
| 399 | typedef class VCTDEF *PVCTDEF; |
| 400 | typedef class PIVOTDEF *PPIVOTDEF; |
| 401 | typedef class DOMDEF *PDOMDEF; |
| 402 | typedef class DIRDEF *PDIRDEF; |
| 403 | typedef class OEMDEF *POEMDEF; |
| 404 | typedef class COLCRT *PCOLCRT; |
| 405 | typedef class COLDEF *PCOLDEF; |
| 406 | typedef class CONSTANT *PCONST; |
| 407 | typedef class VALUE *PVAL; |
| 408 | typedef class VALBLK *PVBLK; |
| 409 | typedef class FILTER *PFIL; |
| 410 | |
| 411 | typedef struct _fblock *PFBLOCK; |
| 412 | typedef struct _mblock *PMBLOCK; |
| 413 | typedef struct _cblock *PCBLOCK; |
| 414 | typedef struct _tabs *PTABS; |
| 415 | typedef struct _qryres *PQRYRES; |
| 416 | typedef struct _colres *PCOLRES; |
| 417 | typedef struct _datpar *PDTP; |
| 418 | typedef struct indx_used *PXUSED; |
| 419 | typedef struct ha_table_option_struct TOS, *PTOS; |
| 420 | |
| 421 | /***********************************************************************/ |
| 422 | /* Utility blocks for file and storage. */ |
| 423 | /***********************************************************************/ |
| 424 | typedef struct _fblock { /* Opened (mapped) file block */ |
| 425 | struct _fblock *Next; |
| 426 | LPCSTR Fname; /* Point on file name */ |
| 427 | size_t Length; /* File length (<4GB) */ |
| 428 | short Count; /* Nb of times map is used */ |
| 429 | short Type; /* TYPE_FB_FILE or TYPE_FB_MAP */ |
| 430 | MODE Mode; /* Open mode */ |
| 431 | char *Memory; /* Pointer to file mapping view */ |
| 432 | void *File; /* FILE pointer */ |
| 433 | HANDLE Handle; /* File handle */ |
| 434 | } FBLOCK; |
| 435 | |
| 436 | typedef struct _mblock { /* Memory block */ |
| 437 | PMBLOCK Next; |
| 438 | bool Inlist; /* True if in mblock list */ |
| 439 | size_t Size; /* Size of allocation */ |
| 440 | bool Sub; /* True if suballocated */ |
| 441 | void *Memp; /* Memory pointer */ |
| 442 | } MBLOCK; |
| 443 | |
| 444 | /***********************************************************************/ |
| 445 | /* The QUERY application User Block. */ |
| 446 | /***********************************************************************/ |
| 447 | typedef struct { /* User application block */ |
| 448 | NAME Name; /* User application name */ |
| 449 | char Server[17]; /* Server name */ |
| 450 | char DBName[17]; /* Current database name */ |
| 451 | PCATLG Catalog; /* To CATALOG class */ |
| 452 | PQRYRES Result; /* To query result blocks */ |
| 453 | PFBLOCK Openlist; /* To file/map open list */ |
| 454 | PMBLOCK Memlist; /* To memory block list */ |
| 455 | PXUSED Xlist; /* To used index list */ |
| 456 | int Maxbmp; /* Maximum XDB2 bitmap size */ |
| 457 | int Check; /* General level of checking */ |
| 458 | int Numlines; /* Number of lines involved */ |
| 459 | //USETEMP UseTemp; /* Use temporary file */ |
| 460 | int Vtdbno; /* Used for TDB number setting */ |
| 461 | bool Remote; /* true: if remotely called */ |
| 462 | bool Proginfo; /* true: return progress info */ |
| 463 | bool Subcor; /* Used for Progress info */ |
| 464 | size_t ProgMax; /* Used for Progress info */ |
| 465 | size_t ProgCur; /* Used for Progress info */ |
| 466 | size_t ProgSav; /* Used for Progress info */ |
| 467 | LPCSTR Step; /* Execution step name */ |
| 468 | } DBUSERBLK, *PDBUSER; |
| 469 | |
| 470 | /***********************************************************************/ |
| 471 | /* Column output format. */ |
| 472 | /***********************************************************************/ |
| 473 | typedef struct _format { /* Format descriptor block */ |
| 474 | char Type[2]; /* C:char, F:double, N:int, Dx: date */ |
| 475 | ushort Length; /* Output length */ |
| 476 | short Prec; /* Output precision */ |
| 477 | } FORMAT, *PFORMAT; |
| 478 | |
| 479 | /***********************************************************************/ |
| 480 | /* Definition of blocks used in type and copy routines. */ |
| 481 | /***********************************************************************/ |
| 482 | typedef struct _tabptr { /* start=P1 */ |
| 483 | struct _tabptr *Next; |
| 484 | int Num; /* alignement */ |
| 485 | void *Old[50]; |
| 486 | void *New[50]; /* old and new values of copied ptrs */ |
| 487 | } TABPTR, *PTABPTR; |
| 488 | |
| 489 | typedef struct _tabadr { /* start=P3 */ |
| 490 | struct _tabadr *Next; |
| 491 | int Num; |
| 492 | void *Adx[50]; /* addr of pointers to be reset */ |
| 493 | } TABADR, *PTABADR; |
| 494 | |
| 495 | typedef struct _tabs { |
| 496 | PGLOBAL G; |
| 497 | PTABPTR P1; |
| 498 | PTABADR P3; |
| 499 | } TABS; |
| 500 | |
| 501 | /***********************************************************************/ |
| 502 | /* Argument of expression, function, filter etc. (Xobject) */ |
| 503 | /***********************************************************************/ |
| 504 | typedef struct _arg { /* Argument */ |
| 505 | PXOB To_Obj; /* To the argument object */ |
| 506 | PVAL Value; /* Argument value */ |
| 507 | bool Conv; /* TRUE if conversion is required */ |
| 508 | } ARGBLK, *PARG; |
| 509 | |
| 510 | typedef struct _oper { /* Operator */ |
| 511 | PSZ Name; /* The input/output operator name */ |
| 512 | OPVAL Val; /* Operator numeric value */ |
| 513 | int Mod; /* The modificator */ |
| 514 | } OPER, *POPER; |
| 515 | |
| 516 | /***********************************************************************/ |
| 517 | /* Following definitions are used to define table fields (columns). */ |
| 518 | /***********************************************************************/ |
| 519 | enum XFLD {FLD_NO = 0, /* Not a field definition item */ |
| 520 | FLD_NAME = 1, /* Item name */ |
| 521 | FLD_TYPE = 2, /* Field type */ |
| 522 | FLD_TYPENAME = 3, /* Field type name */ |
| 523 | FLD_PREC = 4, /* Field precision (length?) */ |
| 524 | FLD_LENGTH = 5, /* Field length (?) */ |
| 525 | FLD_SCALE = 6, /* Field scale (precision) */ |
| 526 | FLD_RADIX = 7, /* Field radix */ |
| 527 | FLD_NULL = 8, /* Field nullable property */ |
| 528 | FLD_REM = 9, /* Field comment (remark) */ |
| 529 | FLD_CHARSET = 10, /* Field collation */ |
| 530 | FLD_KEY = 11, /* Field key property */ |
| 531 | FLD_DEFAULT = 12, /* Field default value */ |
| 532 | = 13, /* Field extra info */ |
| 533 | FLD_PRIV = 14, /* Field priviledges */ |
| 534 | FLD_DATEFMT = 15, /* Field date format */ |
| 535 | FLD_FORMAT = 16, /* Field format */ |
| 536 | FLD_CAT = 17, /* Table catalog */ |
| 537 | FLD_SCHEM = 18, /* Table schema */ |
| 538 | FLD_TABNAME = 19}; /* Column Table name */ |
| 539 | |
| 540 | /***********************************************************************/ |
| 541 | /* Result of last SQL noconv query. */ |
| 542 | /***********************************************************************/ |
| 543 | typedef struct _qryres { |
| 544 | PCOLRES Colresp; /* Points to columns of result */ |
| 545 | bool Continued; /* true when more rows to fetch */ |
| 546 | bool Truncated; /* true when truncated by maxres */ |
| 547 | bool Suball; /* true when entirely suballocated */ |
| 548 | bool Info; /* true when info msg generated */ |
| 549 | int Maxsize; /* Max query number of lines */ |
| 550 | int Maxres; /* Allocation size */ |
| 551 | int Nblin; /* Number of rows in result set */ |
| 552 | int Nbcol; /* Number of columns in result set */ |
| 553 | int Cursor; /* Starting position to get data */ |
| 554 | int BadLines; /* Skipped bad lines in table file */ |
| 555 | } QRYRES, *PQRYRES; |
| 556 | |
| 557 | typedef struct _colres { |
| 558 | PCOLRES Next; /* To next result column */ |
| 559 | PCOL Colp; /* To matching column block */ |
| 560 | PCSZ Name; /* Column header */ |
| 561 | PVBLK Kdata; /* Column block of values */ |
| 562 | char *Nulls; /* Column null value array */ |
| 563 | int Type; /* Internal type */ |
| 564 | int Datasize; /* Overall data size */ |
| 565 | int Ncol; /* Column number */ |
| 566 | int Clen; /* Data individual internal size */ |
| 567 | int Length; /* Data individual print length */ |
| 568 | int Prec; /* Precision */ |
| 569 | int Flag; /* Flag option value */ |
| 570 | XFLD Fld; /* Type of field info */ |
| 571 | char Var; /* Type added information */ |
| 572 | } COLRES; |
| 573 | |
| 574 | #if defined(__WIN__) && !defined(NOEX) |
| 575 | #define DllExport __declspec( dllexport ) |
| 576 | #else // !__WIN__ |
| 577 | #define DllExport |
| 578 | #endif // !__WIN__ |
| 579 | |
| 580 | /***********************************************************************/ |
| 581 | /* Utility routines. */ |
| 582 | /***********************************************************************/ |
| 583 | PPARM Vcolist(PGLOBAL, PTDB, PSZ, bool); |
| 584 | void PlugPutOut(PGLOBAL, FILE *, short, void *, uint); |
| 585 | void PlugLineDB(PGLOBAL, PSZ, short, void *, uint); |
| 586 | //ar *PlgGetDataPath(PGLOBAL g); |
| 587 | char *SetPath(PGLOBAL g, const char *path); |
| 588 | char *(PGLOBAL, char *, char *, OPVAL); |
| 589 | void AddPointer(PTABS, void *); |
| 590 | PDTP MakeDateFormat(PGLOBAL, PCSZ, bool, bool, int); |
| 591 | int (char *, PDTP, int, int val[6]); |
| 592 | |
| 593 | /**************************************************************************/ |
| 594 | /* Allocate the result structure that will contain result data. */ |
| 595 | /**************************************************************************/ |
| 596 | DllExport PQRYRES PlgAllocResult(PGLOBAL g, int ncol, int maxres, int ids, |
| 597 | int *buftyp, XFLD *fldtyp, |
| 598 | unsigned int *length, |
| 599 | bool blank, bool nonull); |
| 600 | |
| 601 | /***********************************************************************/ |
| 602 | /* Exported utility routines. */ |
| 603 | /***********************************************************************/ |
| 604 | DllExport FILE *PlugOpenFile(PGLOBAL, LPCSTR, LPCSTR); |
| 605 | DllExport FILE *PlugReopenFile(PGLOBAL, PFBLOCK, LPCSTR); |
| 606 | DllExport int PlugCloseFile(PGLOBAL, PFBLOCK, bool all = false); |
| 607 | DllExport void PlugCleanup(PGLOBAL, bool); |
| 608 | DllExport bool GetPromptAnswer(PGLOBAL, char *); |
| 609 | DllExport char *GetAmName(PGLOBAL g, AMT am, void *memp = NULL); |
| 610 | DllExport PDBUSER PlgMakeUser(PGLOBAL g); |
| 611 | DllExport PDBUSER PlgGetUser(PGLOBAL g); |
| 612 | DllExport PCATLG PlgGetCatalog(PGLOBAL g, bool jump = true); |
| 613 | DllExport bool PlgSetXdbPath(PGLOBAL g, PSZ, PSZ, char *, int, char *, int); |
| 614 | DllExport void PlgDBfree(MBLOCK&); |
| 615 | DllExport void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size); |
| 616 | DllExport char *PlgDBDup(PGLOBAL g, const char *str); |
| 617 | DllExport void *PlgDBalloc(PGLOBAL, void *, MBLOCK&); |
| 618 | DllExport void *PlgDBrealloc(PGLOBAL, void *, MBLOCK&, size_t); |
| 619 | DllExport void NewPointer(PTABS, void *, void *); |
| 620 | //lExport char *GetIni(int n= 0); // Not used anymore |
| 621 | DllExport void SetTrc(void); |
| 622 | DllExport PCSZ GetListOption(PGLOBAL, PCSZ, PCSZ, PCSZ def=NULL); |
| 623 | DllExport PCSZ GetStringTableOption(PGLOBAL, PTOS, PCSZ, PCSZ); |
| 624 | DllExport bool GetBooleanTableOption(PGLOBAL, PTOS, PCSZ, bool); |
| 625 | DllExport int GetIntegerTableOption(PGLOBAL, PTOS, PCSZ, int); |
| 626 | |
| 627 | #define MSGID_NONE 0 |
| 628 | #define MSGID_CANNOT_OPEN 1 |
| 629 | #define MSGID_OPEN_MODE_ERROR 2 |
| 630 | #define MSGID_OPEN_STRERROR 3 |
| 631 | #define MSGID_OPEN_ERROR_AND_STRERROR 4 |
| 632 | #define MSGID_OPEN_MODE_STRERROR 5 |
| 633 | #define MSGID_OPEN_EMPTY_FILE 6 |
| 634 | |
| 635 | FILE *global_fopen(GLOBAL *g, int msgid, const char *path, const char *mode); |
| 636 | int global_open(GLOBAL *g, int msgid, const char *filename, int flags); |
| 637 | int global_open(GLOBAL *g, int msgid, const char *filename, int flags, int mode); |
| 638 | DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR name, LPCSTR dir); |
| 639 | char *MakeEscape(PGLOBAL g, char* str, char q); |
| 640 | |
| 641 | DllExport bool PushWarning(PGLOBAL, PTDB, int level = 1); |
| 642 | |