CUBRID Engine  latest
dbtype_def.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 /*
20  * dbtype_def.h - Definitions related to the memory representations of database
21  * attribute values. This is an application interface file. It should contain
22  * only definitions available to CUBRID customer applications. It will be exposed
23  * as part of the dbi_compat.h file.
24  */
25 
26 #ifndef _DBTYPE_DEF_H_
27 #define _DBTYPE_DEF_H_
28 
29 #include "error_code.h"
30 #include <stdint.h>
31 
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #endif
36 
37 /* todo: Decide what we do about this!! */
38 #ifdef __cplusplus
39  typedef bool need_clear_type;
40 #else
41  typedef char need_clear_type;
42 #endif
43 
44 #if defined (__GNUC__) && defined (NDEBUG)
45 #define ALWAYS_INLINE always_inline
46 #else
47 #define ALWAYS_INLINE
48 #endif
49 
50 #if !defined (__GNUC__)
51 #define __attribute__(X)
52 #endif
53 
54 #if defined (__cplusplus)
55  class JSON_DOC;
56  class JSON_VALIDATOR;
57 #else
58  typedef void JSON_DOC;
59  typedef void JSON_VALIDATOR;
60 #endif
61 
62  typedef enum
63  {
67  } STRING_STYLE;
68 
69  /******************************************/
70  /* From cubrid_api.h */
71 
72  typedef enum
73  {
122 
140 
143 
144  /********************************************************/
145  /* From object_accessor.h */
146  extern char *obj_Method_error_msg;
147 
148  /******************************************/
149  /* From dbdef.h */
150 
151  /* TODO: there is almost nothing left of current dbdef.h, and the remaining parts don't really belong to dbdef.h, but
152  * rather to other server/client common headers, like storage_common.h;
153  * then we can move all this back to dbdef, include dbdef in dbtype_common and add dbdef to the list of exposed
154  * headers.
155  */
156 
157 #define DB_AUTH_ALL \
158  ((DB_AUTH) (DB_AUTH_SELECT | DB_AUTH_INSERT | DB_AUTH_UPDATE | DB_AUTH_DELETE | \
159  DB_AUTH_ALTER | DB_AUTH_INDEX | DB_AUTH_EXECUTE))
160 
161 /* It is strongly advised that applications use these macros for access to the fields of the DB_QUERY_ERROR structure */
162 #define DB_QUERY_ERROR_LINE(error) ((error)->err_lineno)
163 #define DB_QUERY_ERROR_CHAR(error) ((error)->err_posno)
164 
165 /* These are the status codes that can be returned by the functions that iterate over statement results. */
166 #define DB_CURSOR_SUCCESS 0
167 #define DB_CURSOR_END 1
168 #define DB_CURSOR_ERROR -1
169 
170 #define DB_IS_CONSTRAINT_UNIQUE_FAMILY(c) \
171  ( ((c) == DB_CONSTRAINT_UNIQUE || (c) == DB_CONSTRAINT_REVERSE_UNIQUE || (c) == DB_CONSTRAINT_PRIMARY_KEY) ? true : false )
172 
173 #define DB_IS_CONSTRAINT_INDEX_FAMILY(c) \
174  ( (DB_IS_CONSTRAINT_UNIQUE_FAMILY(c) || (c) == DB_CONSTRAINT_INDEX || (c) == DB_CONSTRAINT_REVERSE_INDEX \
175  || (c) == DB_CONSTRAINT_FOREIGN_KEY) ? true : false )
176 
177 #define DB_IS_CONSTRAINT_REVERSE_INDEX_FAMILY(c) \
178  ( ((DB_CONSTRAINT_TYPE) (c) == DB_CONSTRAINT_REVERSE_UNIQUE || (DB_CONSTRAINT_TYPE) (c) == DB_CONSTRAINT_REVERSE_INDEX) \
179  ? true : false )
180 
181 #define DB_IS_CONSTRAINT_FAMILY(c) \
182  ( (DB_IS_CONSTRAINT_UNIQUE_FAMILY(c) || (c) == DB_CONSTRAINT_NOT_NULL || (c) == DB_CONSTRAINT_FOREIGN_KEY) ? true : false )
183 
184  /* Volume purposes constants. These are intended for use by the db_add_volext API function. */
185  typedef enum
186  {
188  DB_TEMPORARY_DATA_PURPOSE = 1, /* internal use only */
189  DISK_UNKNOWN_PURPOSE = 2, /* internal use only: Does not mean anything */
190  } DB_VOLPURPOSE;
191 
192  typedef enum
193  {
196  } DB_VOLTYPE;
197 
198  /* These are the status codes that can be returned by db_value_compare. */
199  typedef enum
200  {
201 
202  DB_SUBSET = -3, /* strict subset for set types. */
203  DB_UNK = -2, /* unknown */
204  DB_LT = -1, /* canonical less than */
205  DB_EQ = 0, /* equal */
206  DB_GT = 1, /* canonical greater than, */
207  DB_NE = 2, /* not equal because types incomparable */
208  DB_SUPERSET = 3 /* strict superset for set types. */
210 #define DB_INT_TO_COMPARE_RESULT(c) ((c) == 0 ? DB_EQ : ((c) > 0 ? DB_GT : DB_LT))
211 
212  /* Object fetch and locking constants.
213  * These are used to specify a lock mode when fetching objects using of the explicit fetch and lock functions.
214  */
215  typedef enum
216  {
217  DB_FETCH_READ = 0, /* Read an object (class or instance) */
218  DB_FETCH_WRITE = 1, /* Update an object (class or instance) */
219  DB_FETCH_DIRTY = 2, /* Does not care about the state of the object (class or instance). Get it even if it
220  * is obsolete or if it becomes obsolete. INTERNAL USE ONLY */
221  DB_FETCH_CLREAD_INSTREAD = 3, /* Read the class and read an instance of class. This is to access an instance in
222  * shared mode Note class must be given INTERNAL USE ONLY */
223  DB_FETCH_CLREAD_INSTWRITE = 4, /* Read the class and update an instance of the class. Note class must be given
224  * This is for creation of instances INTERNAL USE ONLY */
225  DB_FETCH_QUERY_READ = 5, /* Read the class and query (read) all instances of the class. Note class must be given
226  * This is for SQL select INTERNAL USE ONLY */
227  DB_FETCH_QUERY_WRITE = 6, /* Read the class and query (read) all instances of the class and update some of those
228  * instances. Note class must be given This is for Query update (SQL update) or Query
229  * delete (SQL delete) INTERNAL USE ONLY */
230  DB_FETCH_SCAN = 7, /* Read the class for scan purpose The lock of the lock should be kept since the actual
231  * access happens later. This is for loading an index. INTERNAL USE ONLY */
232  DB_FETCH_EXCLUSIVE_SCAN = 8 /* Read the class for exclusive scan purpose The lock of the lock should be kept since
233  * the actual access happens later. This is for loading an index. INTERNAL USE ONLY */
234  } DB_FETCH_MODE;
235 
236  /* Authorization type identifier constants. The numeric values of these are defined such that they can be used
237  * with the bitwise or operator "|" in order to specify more than one authorization type.
238  */
239  typedef enum
240  {
253  } DB_AUTH;
254 
255  /* object_id type constants used in a db_register_ldb api call to specify whether a local database supports intrinsic object
256  * identity or user-defined object identity.
257  */
258  typedef enum
259  {
263 
264  /* These are abstract data type pointers used by the functions that issue SQL statements and return their results. */
266  typedef struct db_query_type DB_QUERY_TYPE;
267 
268  /* Type of the column in SELECT list within DB_QUERY_TYPE structure */
269  typedef enum
270  {
278  } DB_COL_TYPE;
279 
281  {
286 
287  /* Structure used to contain information about the position of an error detected while compiling a statement. */
290  {
291  int err_lineno; /* Line number where error occurred */
292  int err_posno; /* Position number where error occurred */
293  };
294 
295  /* ESQL/CSQL/API INTERFACE */
296  typedef struct db_session DB_SESSION;
297  typedef struct parser_node DB_NODE;
302  typedef int STATEMENT_ID;
303 
304  /* These are abstract data type pointers used by the "browsing" functions.
305  * Currently they map directly onto internal unpublished data structures but that are subject to change. API programs are
306  * allowed to use them only for those API functions that return them or accept them as arguments. API functions cannot
307  * make direct structure references or make any assumptions about the actual definition of these structures.
308  */
309  typedef struct sm_attribute DB_ATTRIBUTE;
310  typedef struct sm_method DB_METHOD;
312  typedef struct sm_method_file DB_METHFILE;
313  typedef struct sm_resolution DB_RESOLUTION;
314  typedef struct sm_query_spec DB_QUERY_SPEC;
315  typedef struct tp_domain DB_DOMAIN;
316 
317  /* These are handles to attribute and method descriptors that can be used for optimized lookup during repeated operations.
318  * They are NOT the same as the DB_ATTRIBUTE and DB_METHOD handles.
319  */
320  typedef struct sm_descriptor DB_ATTDESC;
321  typedef struct sm_descriptor DB_METHDESC;
322 
323  /* These structures are used for building editing templates on classes and objects. Templates allow the specification of
324  * multiple operations to the object that are treated as an atomic unit. If any of the operations in the template fail,
325  * none of the operations will be applied to the object. They are defined as abstract data types on top of internal data
326  * structures, API programs are not allowed to make assumptions about the contents of these structures.
327  */
328  typedef struct sm_template DB_CTMPL;
329  typedef struct obj_template DB_OTMPL;
330 
331  /* Structure used to define statically linked methods. */
332  typedef void (*METHOD_LINK_FUNCTION) ();
335  {
336  const char *method;
338  };
339 
340  /* Used to indicate the status of a trigger.
341  * If a trigger is ACTIVE, it will be raised when its event is detected. If it is INACTIVE, it will not be raised. If it is
342  * INVALID, it indicates that the class associated with the trigger has been deleted.
343  */
344  typedef enum
345  {
350 
351 
352  /* These define the possible trigger event types.
353  * The system depends on the numeric order of these constants, do not modify this definition without understanding the trigger
354  * manager source.
355  */
356  typedef enum
357  {
358  /* common to both class cache & attribute cache */
362 
363  /* class cache events */
368  TR_EVENT_ALTER = 6, /* currently unsupported */
369  TR_EVENT_DROP = 7, /* currently unsupported */
371 
372  /* user cache events */
375  TR_EVENT_ABORT = 10, /* currently unsupported */
376  TR_EVENT_TIMEOUT = 11, /* currently unsupported */
377 
378  /* default */
380 
381  /* not really event, but used for processing */
384 
385  /* These define the possible trigger activity times. Numeric order is important here, don't change without understanding
386  * the trigger manager source.
387  */
388  typedef enum
389  {
394  } DB_TRIGGER_TIME;
395 
396  /* These define the possible trigger action types. */
397  typedef enum
398  {
399  TR_ACT_NULL = 0, /* no action */
400  TR_ACT_EXPRESSION = 1, /* complex expression */
401  TR_ACT_REJECT = 2, /* REJECT action */
402  TR_ACT_INVALIDATE = 3, /* INVALIDATE TRANSACTION action */
403  TR_ACT_PRINT = 4 /* PRINT action */
405 
406  /* This is the generic pointer to database objects. An object may be either an instance or a class. The actual structure is
407  * defined elsewhere and it is not necessary for database applications to understand its contents.
408  */
409  typedef struct db_object DB_OBJECT, *MOP;
410 
411  /* Structure defining the common list link header used by the general list routines. Any structure in the db_ layer that
412  * are linked in lists will follow this convention.
413  */
414  typedef struct db_list DB_LIST;
415  struct db_list
416  {
417  struct db_list *next;
418  };
419 
420  /* List structure with an additional name field.
421  * Used by: obsolete browsing functions
422  * pt_find_labels
423  * db_get_savepoints
424  * "object id" functions
425  */
426  typedef struct db_namelist DB_NAMELIST;
427 
428  struct db_namelist
429  {
430  struct db_namelist *next;
431  const char *name;
432  };
433 
434  /* List structure with additional object pointer field.
435  * Might belong in dbtype.h but we rarely use object lists on the server.
436  */
437  typedef struct db_objlist DB_OBJLIST;
438  typedef struct db_objlist *MOPLIST;
439 
440  struct db_objlist
441  {
442  struct db_objlist *next;
443  struct db_object *op;
444  };
445 
447  typedef struct sm_function_index_info DB_FUNCTION_INDEX_INFO;
448 
449  /* Types of constraints that may be applied to attributes. This type is used by the db_add_constraint()/db_drop_constraint()
450  * API functions.
451  */
452  typedef enum
453  {
462  } DB_CONSTRAINT_TYPE; /* TODO: only one enum for DB_CONSTRAINT_TYPE and SM_CONSTRAINT_TYPE */
463 
464  typedef enum
465  {
469 
470  typedef enum
471  {
477  } DB_OBJECT_TYPE;
478 
479  /* session state id */
480  typedef unsigned int SESSION_ID;
481 
482 /* uninitialized value for session id */
483 #define DB_EMPTY_SESSION 0
484 
485 /* uninitialized value for row count */
486 #define DB_ROW_COUNT_NOT_SET -2
487 
488  /******************************************/
489  /*
490  * DB_MAX_IDENTIFIER_LENGTH -
491  * This constant defines the maximum length of an identifier in the database. An identifier is anything that is passed as
492  * a string to the db_ functions (other than user attribute values). This includes such things as class names, attribute names
493  * etc. This isn't strictly enforced right now but applications must be aware that this will be a requirement.
494  */
495 #define DB_MAX_IDENTIFIER_LENGTH 255
496 
497 /* Maximum allowable user name.*/
498 #define DB_MAX_USER_LENGTH 32
499 
500 #define DB_MAX_PASSWORD_LENGTH 8
501 
502 /* Maximum allowable schema name. */
503 #define DB_MAX_SCHEMA_LENGTH DB_MAX_USER_LENGTH
504 
505 /* Maximum allowable class name. */
506 #define DB_MAX_CLASS_LENGTH (DB_MAX_IDENTIFIER_LENGTH-DB_MAX_SCHEMA_LENGTH-4)
507 
508 #define DB_MAX_SPEC_LENGTH (0x3FFFFFFF)
509 
510 /* Maximum allowable class comment length */
511 #define DB_MAX_CLASS_COMMENT_LENGTH 2048
512 /* Maximum allowable comment length */
513 #define DB_MAX_COMMENT_LENGTH 1024
514 
515 /* This constant defines the maximum length of a character string that can be used as the value of an attribute. */
516 #define DB_MAX_STRING_LENGTH 0x3fffffff
517 
518 /* This constant defines the maximum length of a bit string that can be used as the value of an attribute. */
519 #define DB_MAX_BIT_LENGTH 0x3fffffff
520 
521 /* The maximum precision that can be specified for a numeric domain. */
522 #define DB_MAX_NUMERIC_PRECISION 38
523 
524 /* The upper limit for a number that can be represented by a numeric type */
525 #define DB_NUMERIC_OVERFLOW_LIMIT 1e38
526 
527 /* The lower limit for a number that can be represented by a numeric type */
528 #define DB_NUMERIC_UNDERFLOW_LIMIT 1e-38
529 
530 /* The maximum precision of CHAR(n) domain that can be specified for an INTL_UTF8_MAX_CHAR_SIZE.
531  * We may need to define this functionally as the maximum precision will depend on the size multiplier of the codeset.
532  */
533 #define DB_MAX_CHAR_PRECISION (DB_MAX_STRING_LENGTH/4)
534 
535 /* The maximum precision that can be specified for a CHARACTER VARYING domain.*/
536 #define DB_MAX_VARCHAR_PRECISION DB_MAX_STRING_LENGTH
537 
538 /* The maximum precision that can be specified for a NATIONAL CHAR(n) domain. This probably isn't restrictive enough.
539  * We may need to define this functionally as the maximum precision will depend on the size multiplier of the codeset.
540  */
541 #define DB_MAX_NCHAR_PRECISION (DB_MAX_STRING_LENGTH/2)
542 
543 /* The maximum precision that can be specified for a NATIONAL CHARACTER VARYING domain. This probably isn't restrictive enough.
544  * We may need to define this functionally as the maximum precision will depend on the size multiplier of the codeset.
545  */
546 #define DB_MAX_VARNCHAR_PRECISION DB_MAX_NCHAR_PRECISION
547 
548 /* The maximum precision that can be specified for a BIT domain. */
549 #define DB_MAX_BIT_PRECISION DB_MAX_BIT_LENGTH
550 
551 /* The maximum precision that can be specified for a BIT VARYING domain. */
552 #define DB_MAX_VARBIT_PRECISION DB_MAX_BIT_PRECISION
553 
554 /* This constant indicates that the system defined default for determining the length of a string is to be used for a DB_VALUE. */
555 #define DB_DEFAULT_STRING_LENGTH -1
556 
557 /* This constant indicates that the system defined default for precision is to be used for a DB_VALUE. */
558 #define DB_DEFAULT_PRECISION -1
559 
560 /* This constant indicates that the system defined default for scale is to be used for a DB_VALUE. */
561 #define DB_DEFAULT_SCALE -1
562 
563 /* This constant defines the default precision of DB_TYPE_NUMERIC. */
564 #define DB_DEFAULT_NUMERIC_PRECISION 15
565 
566 /* This constant defines the default scale of DB_TYPE_NUMERIC. */
567 #define DB_DEFAULT_NUMERIC_SCALE 0
568 
569 /* This constant defines the default scale of result of numeric division operation */
570 #define DB_DEFAULT_NUMERIC_DIVISION_SCALE 9
571 
572 /* These constants define the size of buffers within a DB_VALUE. */
573 #define DB_NUMERIC_BUF_SIZE (2*sizeof(double))
574 #define DB_SMALL_CHAR_BUF_SIZE (2*sizeof(double) - 3*sizeof(unsigned char))
575 
576 /* This constant defines the default precision of DB_TYPE_BIGINT. */
577 #define DB_BIGINT_PRECISION 19
578 
579 /* This constant defines the default precision of DB_TYPE_INTEGER. */
580 #define DB_INTEGER_PRECISION 10
581 
582 /* This constant defines the default precision of DB_TYPE_SMALLINT. */
583 #define DB_SMALLINT_PRECISION 5
584 
585 /* This constant defines the default precision of DB_TYPE_SHORT.*/
586 #define DB_SHORT_PRECISION DB_SMALLINT_PRECISION
587 
588 /* This constant defines the default decimal precision of DB_TYPE_FLOAT. */
589 #define DB_FLOAT_DECIMAL_PRECISION 7
590 
591 /* This constant defines the default decimal precision of DB_TYPE_DOUBLE. */
592 #define DB_DOUBLE_DECIMAL_PRECISION 15
593 
594 /* This constant defines the default decimal precision of DB_TYPE_MONETARY. */
595 #define DB_MONETARY_DECIMAL_PRECISION DB_DOUBLE_DECIMAL_PRECISION
596 
597 /* This constant defines the default precision of DB_TYPE_TIME. */
598 #define DB_TIME_PRECISION 8
599 
600 /* This constant defines the default precision of DB_TYPE_DATE. */
601 #define DB_DATE_PRECISION 10
602 
603 /* This constant defines the default precision of DB_TYPE_TIMESTAMP. */
604 #define DB_TIMESTAMP_PRECISION 19
605 
606 /* This constant defines the default precision of DB_TYPE_TIMESTAMPTZ. */
607 #define DB_TIMESTAMPTZ_PRECISION DB_TIMESTAMP_PRECISION
608 
609 /* This constant defines the default precision of DB_TYPE_DATETIME. */
610 #define DB_DATETIME_PRECISION 23
611 
612 /* This constant defines the default precision of DB_TYPE_DATETIMETZ. */
613 #define DB_DATETIMETZ_PRECISION DB_DATETIME_PRECISION
614 
615 /* This constant defines the default scale of DB_TYPE_DATETIME. */
616 #define DB_DATETIME_DECIMAL_SCALE 3
617 
618 /* The maximum length of the partition expression after it is processed */
619 #define DB_MAX_PARTITION_EXPR_LENGTH 2048
620 
621 /* Defines the state of a value as not being compressable due to its bad compression size or
622  * its uncompressed size being lower than PRIM_MINIMUM_STRING_LENGTH_FOR_COMPRESSION
623  */
624 #define DB_UNCOMPRESSABLE -1
625 
626 /* Defines the state of a value not being yet prompted for a compression process. */
627 #define DB_NOT_YET_COMPRESSED 0
628 
629 #define DB_INT16_MIN (-(DB_INT16_MAX)-1)
630 #define DB_INT16_MAX 0x7FFF
631 #define DB_UINT16_MAX 0xFFFFU
632 #define DB_INT32_MIN (-(DB_INT32_MAX)-1)
633 #define DB_INT32_MAX 0x7FFFFFFF
634 #define DB_UINT32_MIN 0
635 #define DB_UINT32_MAX 0xFFFFFFFFU
636 #if (__WORDSIZE == 64) || defined(_WIN64)
637 #define DB_BIGINT_MAX 9223372036854775807L
638 #define DB_BIGINT_MIN (-DB_BIGINT_MAX - 1L)
639 #else /* (__WORDSIZE == 64) || defined(_WIN64) */
640 #define DB_BIGINT_MAX 9223372036854775807LL
641 #define DB_BIGINT_MIN (-DB_BIGINT_MAX - 1LL)
642 #endif /* (__WORDSIZE == 64) || defined(_WIN64) */
643 #define DB_ENUM_ELEMENTS_MAX 512
644 /* special ENUM index for PT_TO_ENUMERATION_VALUE function */
645 #define DB_ENUM_OVERFLOW_VAL 0xFFFF
646 
647 /* DB_DATE_MIN and DB_DATE_MAX are calculated by julian_encode function with arguments (1,1,1) and (12,31,9999) respectively. */
648 #define DB_DATE_ZERO DB_UINT32_MIN /* 0 means zero date */
649 #define DB_DATE_MIN 1721424
650 #define DB_DATE_MAX 5373484
651 
652 #define DB_TIME_MIN DB_UINT32_MIN
653 #define DB_TIME_MAX DB_UINT32_MAX
654 
655 #define DB_UTIME_ZERO DB_DATE_ZERO /* 0 means zero date */
656 #define DB_UTIME_MIN (DB_UTIME_ZERO + 1)
657 #define DB_UTIME_MAX DB_UINT32_MAX
658 
659 #define NULL_DEFAULT_EXPRESSION_OPERATOR (-1)
660 
661 #define DB_IS_DATETIME_DEFAULT_EXPR(v) ((v) == DB_DEFAULT_SYSDATE || \
662  (v) == DB_DEFAULT_CURRENTTIME || (v) == DB_DEFAULT_CURRENTDATE || \
663  (v) == DB_DEFAULT_SYSDATETIME || (v) == DB_DEFAULT_SYSTIMESTAMP || \
664  (v) == DB_DEFAULT_UNIX_TIMESTAMP || (v) == DB_DEFAULT_CURRENTDATETIME || \
665  (v) == DB_DEFAULT_CURRENTTIMESTAMP || (v) == DB_DEFAULT_SYSTIME)
666 
667  /* This defines the basic type identifier constants. These are used in the domain specifications of attributes and method
668  * arguments and as value type tags in the DB_VALUE structures.
669  */
670  typedef enum
671  {
672  DB_TYPE_FIRST = 0, /* first for iteration */
683  DB_TYPE_ELO = 9, /* obsolete... keep for backward compatibility. maybe we can replace with something else */
688  DB_TYPE_VARIABLE = 14, /* internal use only */
689  DB_TYPE_SUB = 15, /* internal use only */
690  DB_TYPE_POINTER = 16, /* method arguments only */
691  DB_TYPE_ERROR = 17, /* method arguments only */
693  DB_TYPE_VOBJ = 19, /* internal use only */
694  DB_TYPE_OID = 20, /* internal use only */
695  DB_TYPE_DB_VALUE = 21, /* special for esql */
696  DB_TYPE_NUMERIC = 22, /* SQL NUMERIC(p,s) values */
697  DB_TYPE_BIT = 23, /* SQL BIT(n) values */
698  DB_TYPE_VARBIT = 24, /* SQL BIT(n) VARYING values */
699  DB_TYPE_CHAR = 25, /* SQL CHAR(n) values */
700  DB_TYPE_NCHAR = 26, /* SQL NATIONAL CHAR(n) values */
701  DB_TYPE_VARNCHAR = 27, /* SQL NATIONAL CHAR(n) VARYING values */
702  DB_TYPE_RESULTSET = 28, /* internal use only */
703  DB_TYPE_MIDXKEY = 29, /* internal use only */
704  DB_TYPE_TABLE = 30, /* internal use only */
715 
716  /* aliases */
718  DB_TYPE_SMALLINT = DB_TYPE_SHORT, /* SQL SMALLINT */
719  DB_TYPE_VARCHAR = DB_TYPE_STRING, /* SQL CHAR(n) VARYING values */
720  DB_TYPE_UTIME = DB_TYPE_TIMESTAMP, /* SQL TIMESTAMP */
721 
723  } DB_TYPE;
724 
725  /* Domain information stored in DB_VALUE structures. */
728  {
730  {
731  unsigned char is_null;
732  unsigned char type;
733  } general_info;
735  {
736  unsigned char is_null;
737  unsigned char type;
738  unsigned char precision;
739  unsigned char scale;
740  } numeric_info;
741  struct char_info
742  {
743  unsigned char is_null;
744  unsigned char type;
745  int length;
747  } char_info;
748  };
749 
750  /* types used for the representation of bigint values. */
751  typedef int64_t DB_BIGINT;
752 
753  /* Structure used for the representation of time values. */
754  typedef unsigned int DB_TIME;
755 
756  typedef unsigned int TZ_ID;
757 
758  /* Structure used for the representation of universal times. These are compatible with the Unix time_t definition. */
759  typedef unsigned int DB_TIMESTAMP;
760 
761  typedef DB_TIMESTAMP DB_UTIME;
762 
765  {
766  DB_TIMESTAMP timestamp; /* Unix timestamp */
767  TZ_ID tz_id; /* zone id */
768  };
769 
770  /* Structure used for the representation of date values. */
771  typedef unsigned int DB_DATE;
772 
773  typedef struct db_datetime DB_DATETIME;
774  struct db_datetime
775  {
776  unsigned int date; /* date */
777  unsigned int time; /* time */
778  };
779 
780  typedef struct db_datetimetz DB_DATETIMETZ;
782  {
784  TZ_ID tz_id; /* zone id */
785  };
786 
787  /* Structure used for the representation of numeric values. */
788  typedef struct db_numeric DB_NUMERIC;
789  struct db_numeric
790  {
791  union
792  {
793  unsigned char *digits;
794  unsigned char buf[DB_NUMERIC_BUF_SIZE];
795  } d;
796  };
797 
798  /* Structure used for the representation of monetary amounts. */
799  typedef enum
800  {
826  } DB_CURRENCY;
827 
828  typedef struct db_monetary DB_MONETARY;
829  struct db_monetary
830  {
831  double amount;
832  DB_CURRENCY type;
833  };
834 
835  /* Definition for the collection descriptor structure. The structures for the collection descriptors and the sequence
836  * descriptors are identical internally but not all db_collection functions can be used with sequences and no db_seq functions
837  * can be used with sets. It is advisable to recognize the type of set being used, type it appropriately and only call those
838  * db_ functions defined for that type.
839  */
840  typedef struct db_set DB_COLLECTION;
844 
846  {
849  };
851 
852  /* Used in btree_coerce_key and btree_ils_adjust_range to represent min or max values, necessary in index search comparisons */
855  {
856  int position; /* position in the list of columns */
857  MIN_MAX_COLUMN_TYPE type; /* MIN or MAX column */
858  };
859 
860  typedef struct db_midxkey DB_MIDXKEY;
861  struct db_midxkey
862  {
863  int size; /* size of buf */
864  int ncolumns; /* # of elements */
865  DB_DOMAIN *domain; /* MIDXKEY domain */
866  char *buf; /* key structure */
867  MIN_MAX_COLUMN_INFO min_max_val; /* info about coerced column */
868  };
869 
870  /*
871  * DB_ELO
872  * This is the run-time state structure for an ELO. The ELO is part of the implementation of large object type and not intended
873  * to be used directly by the API.
874  */
875 
876  typedef struct vpid VPID; /* REAL PAGE IDENTIFIER */
877  struct vpid
878  {
879  int32_t pageid; /* Page identifier */
880  short volid; /* Volume identifier where the page resides */
881  };
882 
883  typedef struct vfid VFID; /* REAL FILE IDENTIFIER */
884  struct vfid
885  {
886  int32_t fileid; /* File identifier */
887  short volid; /* Volume identifier where the file resides */
888  };
889 
890 #define VFID_INITIALIZER { NULL_FILEID, NULL_VOLID }
891 
892 #define VFID_AS_ARGS(vfidp) (vfidp)->volid, (vfidp)->fileid
893 
894 #define VPID_INITIALIZER { NULL_PAGEID, NULL_VOLID }
895 
896 #define VPID_AS_ARGS(vpidp) (vpidp)->volid, (vpidp)->pageid
897 
898  /* Set a vpid with values of volid and pageid */
899 #define VPID_SET(vpid_ptr, volid_value, pageid_value) \
900  do { \
901  (vpid_ptr)->volid = (volid_value); \
902  (vpid_ptr)->pageid = (pageid_value); \
903  } while (0)
904 
905  /* Set the vpid to an invalid one */
906 #define VPID_SET_NULL(vpid_ptr) VPID_SET(vpid_ptr, NULL_VOLID, NULL_PAGEID)
907 
908  /* copy a VPID */
909 #define VPID_COPY(dest_ptr, src_ptr) \
910  do { \
911  *(dest_ptr) = *(src_ptr); \
912  } while (0)
913 
914  /* vpid1 == vpid2 ? */
915 #define VPID_EQ(vpid_ptr1, vpid_ptr2) \
916  ((vpid_ptr1) == (vpid_ptr2) \
917  || ((vpid_ptr1)->pageid == (vpid_ptr2)->pageid && (vpid_ptr1)->volid == (vpid_ptr2)->volid))
918 
919 #define VPID_LT(vpid_ptr1, vpid_ptr2) \
920  ((vpid_ptr1) != (vpid_ptr2) \
921  && ((vpid_ptr1)->volid < (vpid_ptr2)->volid \
922  || ((vpid_ptr1)->volid == (vpid_ptr2)->volid && (vpid_ptr1)->pageid < (vpid_ptr2)->pageid)))
923 
924  /* Is vpid NULL ? */
925 #define VPID_ISNULL(vpid_ptr) ((vpid_ptr)->pageid == NULL_PAGEID)
926 
927  typedef struct vsid VSID; /* REAL SECTOR IDENTIFIER */
928  struct vsid
929  {
930  int32_t sectid; /* Sector identifier */
931  short volid; /* Volume identifier where the sector resides */
932  };
933 #define VSID_INITIALIZER { NULL_SECTID, NULL_VOLID }
934 #define VSID_AS_ARGS(vsidp) (vsidp)->volid, (vsidp)->sectid
935 
936  typedef struct db_elo DB_ELO;
937 
939  {
940  ELO_NULL, /* do we need this anymore? */
942  };
943  typedef enum db_elo_type DB_ELO_TYPE;
944 
945  struct db_elo
946  {
947  int64_t size;
948  char *locator;
949  char *meta_data;
950  DB_ELO_TYPE type;
951  int es_type;
952  };
953 
954  /* This is the memory representation of an internal object identifier. It is in the API only for a few functions that are not
955  * intended for general use. An object identifier is NOT a fixed identifier; it cannot be used reliably as an object
956  * identifier across database sessions or even across transaction boundaries. API programs are not allowed to make assumptions
957  * about the contents of this structure.
958  */
959  typedef struct db_identifier DB_IDENTIFIER;
961  {
962  int pageid;
963  short slotid;
964  short volid;
965  };
966 
968 
969  /* Structure used for the representation of char, nchar and bit values. */
970  typedef struct db_large_string DB_LARGE_STRING;
971 
972  /* db_char.sm was formerly db_char.small. small is an (undocumented) reserved word on NT. */
973 
974  typedef union db_char DB_CHAR;
975  union db_char
976  {
977  struct
978  {
979  unsigned char style;
980  unsigned char codeset;
981  unsigned char is_max_string;
982  unsigned char compressed_need_clear;
983  } info;
984  struct
985  {
986  unsigned char style;
987  unsigned char codeset;
988  unsigned char is_max_string;
989  unsigned char compressed_need_clear;
990  unsigned char size;
992  } sm;
993  struct
994  {
995  unsigned char style;
996  unsigned char codeset;
997  unsigned char is_max_string;
998  unsigned char compressed_need_clear;
999  int size;
1000  const char *buf;
1003  } medium;
1004  struct
1005  {
1006  unsigned char style;
1007  unsigned char codeset;
1008  unsigned char is_max_string;
1009  unsigned char compressed_need_clear;
1011  } large;
1012  };
1013 
1015  typedef DB_CHAR DB_BIT;
1016 
1017  typedef int DB_RESULTSET;
1018 
1019  /* Structure for an ENUMERATION element */
1022  {
1023  unsigned short short_val; /* element index */
1024  DB_CHAR str_val; /* element string */
1025  };
1026 
1027  /* Structure for an ENUMERATION */
1030  {
1031  DB_ENUM_ELEMENT *elements; /* array of enumeration elements */
1032  int collation_id; /* collation */
1033  unsigned short count; /* count of enumeration elements */
1034  };
1035 
1036  typedef struct db_json DB_JSON;
1037  struct db_json
1038  {
1039  const char *schema_raw;
1040  JSON_DOC *document;
1041  };
1042 
1043  /* A union of all of the possible basic type values. This is used in the definition of the DB_VALUE which is the fundamental
1044  * structure used in passing data in and out of the db_ function layer.
1045  */
1046  typedef union db_data DB_DATA;
1047  union db_data
1048  {
1049  int i;
1050  short sh;
1051  DB_BIGINT bigint;
1052  float f;
1053  double d;
1054  void *p;
1056  DB_TIME time;
1057  DB_DATE date;
1058  DB_TIMESTAMP utime;
1067  int error;
1071  DB_RESULTSET rset;
1074  };
1075 
1076  /* This is the primary structure used for passing values in and out of the db_ function layer. Values are always tagged with
1077  * a datatype so that they can be identified and type checking can be performed.
1078  */
1079  typedef struct db_value DB_VALUE;
1080  struct db_value
1081  {
1084  need_clear_type need_clear;
1085  };
1086 
1087  /* This is used to chain DB_VALUEs into a list. */
1090  {
1093  };
1094 
1095  /* This is used to chain DB_VALUEs into a list. It is used as an argument to db_send_arglist. */
1098  {
1099  int size;
1101  };
1102 
1103  /* This is used to gather stats about the workspace.
1104  * It contains the number of object descriptors used and total number of object descriptors allocated.
1105  */
1108  {
1109  int obj_desc_used; /* number of object descriptors used */
1110  int obj_desc_total; /* total # of object descriptors allocated */
1111  };
1112 
1113  /* This defines the C language type identifier constants.
1114  * These are used to describe the types of values used for setting DB_VALUE contents or used to get DB_VALUE contents into.
1115  */
1116  typedef enum
1117  {
1119  DB_TYPE_C_FIRST = 100, /* first for iteration */
1144  DB_TYPE_C_LAST, /* last for iteration */
1146  } DB_TYPE_C;
1147 
1148  typedef DB_BIGINT DB_C_BIGINT;
1149  typedef int DB_C_INT;
1150  typedef short DB_C_SHORT;
1151  typedef long DB_C_LONG;
1152  typedef float DB_C_FLOAT;
1153  typedef double DB_C_DOUBLE;
1154  typedef char *DB_C_CHAR;
1155  typedef const char *DB_CONST_C_CHAR;
1156  typedef char *DB_C_NCHAR;
1157  typedef const char *DB_CONST_C_NCHAR;
1158  typedef char *DB_C_BIT;
1159  typedef const char *DB_CONST_C_BIT;
1163  typedef DB_ELO DB_C_ELO;
1164  typedef struct db_c_time DB_C_TIME;
1165  struct db_c_time
1166  {
1167  int hour;
1168  int minute;
1169  int second;
1170  };
1171 
1172  typedef struct db_c_date DB_C_DATE;
1173  struct db_c_date
1174  {
1175  int year;
1176  int month;
1177  int day;
1178  };
1179 
1180  /* identifiers for the default expression */
1181  typedef enum
1182  {
1197 
1198  /* An attribute having valid default expression, must have NULL default value. Currently, we allow simple expressions
1199  * like SYS_DATE, CURRENT_TIME. Also we allow to_char expression.
1200  */
1203  {
1204  DB_DEFAULT_EXPR_TYPE default_expr_type; /* default expression identifier */
1205  int default_expr_op; /* default expression operator */
1206  const char *default_expr_format; /* default expression format */
1207  };
1208 
1211  typedef DB_TIMESTAMP DB_C_TIMESTAMP;
1214  typedef unsigned char *DB_C_NUMERIC;
1215  typedef void *DB_C_POINTER;
1217 
1218  typedef enum
1219  {
1220  V_FALSE = 0,
1221  V_TRUE = 1,
1223  V_ERROR = -1
1224  } DB_LOGICAL;
1225 
1226 /********************************************************/
1227  /* From tz_support.h */
1229  {
1232  };
1234 
1235  typedef struct tz_region TZ_REGION;
1236  struct tz_region
1237  {
1238  TZ_REGION_TYPE type; /* 0 : offset ; 1 : zone */
1239  union
1240  {
1241  int offset; /* in seconds */
1242  unsigned int zone_id; /* geographical zone id */
1243  };
1244  };
1245 /********************************************************/
1246 
1247 #ifdef __cplusplus
1248 }
1249 #endif /* __cplusplus */
1250 
1251 #endif /* _DBTYPE_DEF_H_ */
DB_TIMESTAMP DB_C_TIMESTAMP
Definition: dbtype_def.h:1211
unsigned int TZ_ID
Definition: dbtype_def.h:756
MIN_MAX_COLUMN_INFO min_max_val
Definition: dbtype_def.h:867
DB_TIME time
Definition: dbtype_def.h:1056
DB_VALUE val
Definition: dbtype_def.h:1092
DB_COLLECTION DB_MULTISET
Definition: dbtype_def.h:841
long DB_C_LONG
Definition: dbtype_def.h:1151
short sh
Definition: dbtype_def.h:1050
DB_NUMERIC num
Definition: dbtype_def.h:1069
struct db_value_list * next
Definition: dbtype_def.h:1091
DB_NODE DB_SESSION_ERROR
Definition: dbtype_def.h:298
unsigned char codeset
Definition: dbtype_def.h:980
DB_NODE DB_SESSION_WARNING
Definition: dbtype_def.h:299
DB_VALUE * vals
Definition: dbtype_def.h:1100
const char * schema_raw
Definition: dbtype_def.h:1039
DB_TIMESTAMP timestamp
Definition: dbtype_def.h:766
enum tz_region_type TZ_REGION_TYPE
Definition: dbtype_def.h:1233
DB_TYPE
Definition: dbtype_def.h:670
unsigned short count
Definition: dbtype_def.h:1033
DB_IDENTIFIER oid
Definition: dbtype_def.h:1068
DB_COLLECTION DB_SET
Definition: dbtype_def.h:843
DB_ENUM_ELEMENT enumeration
Definition: dbtype_def.h:1072
CUBRID_STMT_TYPE
Definition: dbtype_def.h:72
DB_ELO_TYPE type
Definition: dbtype_def.h:950
DB_DATETIME datetime
Definition: dbtype_def.h:1060
void JSON_VALIDATOR
Definition: dbtype_def.h:59
DB_DATETIMETZ DB_C_DATETIMETZ
Definition: dbtype_def.h:1210
tz_region_type
Definition: dbtype_def.h:1228
DB_COLLECTION DB_C_SET
Definition: dbtype_def.h:1161
char * DB_C_NCHAR
Definition: dbtype_def.h:1156
DB_LARGE_STRING * str
Definition: dbtype_def.h:1010
DB_TIMESTAMPTZ DB_C_TIMESTAMPTZ
Definition: dbtype_def.h:1212
double DB_C_DOUBLE
Definition: dbtype_def.h:1153
const char * buf
Definition: dbtype_def.h:1000
int32_t pageid
Definition: dbtype_def.h:879
#define DB_SMALL_CHAR_BUF_SIZE
Definition: dbtype_def.h:574
int error
Definition: dbtype_def.h:1067
unsigned char style
Definition: dbtype_def.h:979
char * DB_C_BIT
Definition: dbtype_def.h:1158
DB_DOMAIN_INFO domain
Definition: dbtype_def.h:1082
DB_DATETIME DB_C_DATETIME
Definition: dbtype_def.h:1209
short DB_C_SHORT
Definition: dbtype_def.h:1150
DB_COLLECTION DB_C_COLLECTION
Definition: dbtype_def.h:1162
DB_DEFAULT_EXPR_TYPE default_expr_type
Definition: dbtype_def.h:1204
DB_ELO elo
Definition: dbtype_def.h:1066
MIN_MAX_COLUMN_TYPE type
Definition: dbtype_def.h:857
DB_NODE DB_PARAMETER
Definition: dbtype_def.h:300
void * p
Definition: dbtype_def.h:1054
DB_CHAR DB_BIT
Definition: dbtype_def.h:1015
DB_COLLECTION DB_SEQ
Definition: dbtype_def.h:842
DB_BIGINT bigint
Definition: dbtype_def.h:1051
DB_DATA data
Definition: dbtype_def.h:1083
DB_CURRENCY
Definition: dbtype_def.h:799
int STATEMENT_ID
Definition: dbtype_def.h:302
DB_JSON json
Definition: dbtype_def.h:1073
const char * name
Definition: dbtype_def.h:431
unsigned int DB_TIMESTAMP
Definition: dbtype_def.h:759
DB_OBJECT_ID_TYPE
Definition: dbtype_def.h:258
const char * DB_CONST_C_NCHAR
Definition: dbtype_def.h:1157
Definition: db_set.h:35
DB_TIMESTAMP utime
Definition: dbtype_def.h:1058
enum db_elo_type DB_ELO_TYPE
Definition: dbtype_def.h:943
DB_CONSTRAINT_TYPE
Definition: dbtype_def.h:452
DB_COL_TYPE
Definition: dbtype_def.h:269
int32_t fileid
Definition: dbtype_def.h:886
DB_NODE DB_MARKER
Definition: dbtype_def.h:301
const char * DB_CONST_C_BIT
Definition: dbtype_def.h:1159
struct db_large_string DB_LARGE_STRING
Definition: dbtype_def.h:970
DB_TYPE_C
Definition: dbtype_def.h:1116
DB_IDENTIFIER OID
Definition: dbtype_def.h:967
unsigned char * digits
Definition: dbtype_def.h:793
enum special_column_type MIN_MAX_COLUMN_TYPE
Definition: dbtype_def.h:850
db_elo_type
Definition: dbtype_def.h:938
int compressed_size
Definition: dbtype_def.h:1001
JSON_DOC * document
Definition: dbtype_def.h:1040
DB_DATETIME datetime
Definition: dbtype_def.h:783
void JSON_DOC
Definition: dbtype_def.h:58
char * compressed_buf
Definition: dbtype_def.h:1002
DB_OBJECT_TYPE
Definition: dbtype_def.h:470
void(* METHOD_LINK_FUNCTION)()
Definition: dbtype_def.h:332
db_class_modification_status
Definition: dbtype_def.h:280
DB_BIGINT DB_C_BIGINT
Definition: dbtype_def.h:1148
short volid
Definition: dbtype_def.h:880
int DB_RESULTSET
Definition: dbtype_def.h:1017
struct db_namelist * next
Definition: dbtype_def.h:430
unsigned char * DB_C_NUMERIC
Definition: dbtype_def.h:1214
DB_CHAR ch
Definition: dbtype_def.h:1070
unsigned char size
Definition: dbtype_def.h:990
DB_CURRENCY type
Definition: dbtype_def.h:832
DB_DATE date
Definition: dbtype_def.h:1057
DB_TIMESTAMPTZ timestamptz
Definition: dbtype_def.h:1059
TZ_REGION_TYPE type
Definition: dbtype_def.h:1238
enum db_class_modification_status DB_CLASS_MODIFICATION_STATUS
unsigned char is_max_string
Definition: dbtype_def.h:981
DB_OBJECT * op
Definition: dbtype_def.h:1055
need_clear_type need_clear
Definition: dbtype_def.h:1084
char need_clear_type
Definition: dbtype_def.h:41
struct db_objlist * next
Definition: dbtype_def.h:442
int size
Definition: dbtype_def.h:999
int64_t DB_BIGINT
Definition: dbtype_def.h:751
struct db_object * op
Definition: dbtype_def.h:443
DB_TRIGGER_TIME
Definition: dbtype_def.h:388
int ncolumns
Definition: dbtype_def.h:864
DB_VOLPURPOSE
Definition: dbtype_def.h:185
DB_RESULTSET rset
Definition: dbtype_def.h:1071
DB_IDENTIFIER DB_C_IDENTIFIER
Definition: dbtype_def.h:1216
unsigned char compressed_need_clear
Definition: dbtype_def.h:982
DB_AUTH
Definition: dbtype_def.h:239
DB_CHAR DB_NCHAR
Definition: dbtype_def.h:1014
const char * default_expr_format
Definition: dbtype_def.h:1206
STRING_STYLE
Definition: dbtype_def.h:62
DB_VOLTYPE
Definition: dbtype_def.h:192
unsigned int DB_TIME
Definition: dbtype_def.h:754
DB_ELO DB_C_ELO
Definition: dbtype_def.h:1163
unsigned int DB_DATE
Definition: dbtype_def.h:771
char * locator
Definition: dbtype_def.h:948
char * obj_Method_error_msg
void * DB_C_POINTER
Definition: dbtype_def.h:1215
int32_t sectid
Definition: dbtype_def.h:930
int es_type
Definition: dbtype_def.h:951
DB_ENUM_ELEMENT * elements
Definition: dbtype_def.h:1031
float DB_C_FLOAT
Definition: dbtype_def.h:1152
DB_DOMAIN * domain
Definition: dbtype_def.h:865
DB_TRIGGER_EVENT
Definition: dbtype_def.h:356
DB_MONETARY DB_C_MONETARY
Definition: dbtype_def.h:1213
unsigned int date
Definition: dbtype_def.h:776
unsigned int SESSION_ID
Definition: dbtype_def.h:480
char * DB_C_CHAR
Definition: dbtype_def.h:1154
DB_LOGICAL
Definition: dbtype_def.h:1218
int64_t size
Definition: dbtype_def.h:947
DB_OBJECT DB_C_OBJECT
Definition: dbtype_def.h:1160
struct db_object * MOP
Definition: dbtype_def.h:409
DB_COLLECTION * collect
Definition: dbtype_def.h:1064
DB_FK_ACTION_TYPE
Definition: dbtype_def.h:464
DB_TRIGGER_STATUS
Definition: dbtype_def.h:344
#define DB_NUMERIC_BUF_SIZE
Definition: dbtype_def.h:573
DB_FETCH_MODE
Definition: dbtype_def.h:215
DB_MIDXKEY midxkey
Definition: dbtype_def.h:1065
short volid
Definition: dbtype_def.h:931
int DB_C_INT
Definition: dbtype_def.h:1149
short volid
Definition: dbtype_def.h:887
unsigned short short_val
Definition: dbtype_def.h:1023
char * meta_data
Definition: dbtype_def.h:949
DB_TIMESTAMP DB_UTIME
Definition: dbtype_def.h:761
DB_TRIGGER_ACTION
Definition: dbtype_def.h:397
DB_VALUE_COMPARE_RESULT
Definition: dbtype_def.h:199
const char * DB_CONST_C_CHAR
Definition: dbtype_def.h:1155
struct db_list * next
Definition: dbtype_def.h:417
double amount
Definition: dbtype_def.h:831
char * buf
Definition: dbtype_def.h:866
float f
Definition: dbtype_def.h:1052
struct db_objlist * MOPLIST
Definition: dbtype_def.h:438
special_column_type
Definition: dbtype_def.h:845
struct sm_function_index_info DB_FUNCTION_INDEX_INFO
Definition: dbtype_def.h:447
double d
Definition: dbtype_def.h:1053
DB_MONETARY money
Definition: dbtype_def.h:1062
unsigned int zone_id
Definition: dbtype_def.h:1242
unsigned int time
Definition: dbtype_def.h:777
DB_DEFAULT_EXPR_TYPE
Definition: dbtype_def.h:1181
DB_DATETIMETZ datetimetz
Definition: dbtype_def.h:1061