MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
api0api.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 2012, Oracle and/or its affiliates. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free Software
7 Foundation; version 2 of the License.
8 
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
16 
17 *****************************************************************************/
18 
19 /**************************************************/
27 #ifndef api0api_h
28 #define api0api_h
29 
30 #include "db0err.h"
31 #include <stdio.h>
32 
33 #ifdef _MSC_VER
34 #define strncasecmp _strnicmp
35 #define strcasecmp _stricmp
36 #endif
37 
38 #if defined(__GNUC__) && (__GNUC__ > 2) && ! defined(__INTEL_COMPILER)
39 #define UNIV_NO_IGNORE __attribute__ ((warn_unused_result))
40 #else
41 #define UNIV_NO_IGNORE
42 #endif /* __GNUC__ && __GNUC__ > 2 && !__INTEL_COMPILER */
43 
44 /* See comment about ib_bool_t as to why the two macros are unsigned long. */
46 #define IB_TRUE 0x1UL
47 
48 #define IB_FALSE 0x0UL
49 
50 /* Basic types used by the InnoDB API. */
52 typedef enum dberr_t ib_err_t;
54 typedef unsigned char ib_byte_t;
56 typedef unsigned long int ib_ulint_t;
57 
58 /* We assume C99 support except when using VisualStudio. */
59 #if !defined(_MSC_VER)
60 #include <stdint.h>
61 #endif /* _MSC_VER */
62 
63 /* Integer types used by the API. Microsft VS defines its own types
64 and we use the Microsoft types when building with Visual Studio. */
65 #if defined(_MSC_VER)
66 
67 typedef __int8 ib_i8_t;
68 #else
69 
70 typedef int8_t ib_i8_t;
71 #endif
72 
73 #if defined(_MSC_VER)
74 
75 typedef unsigned __int8 ib_u8_t;
76 #else
77 
78 typedef uint8_t ib_u8_t;
79 #endif
80 
81 #if defined(_MSC_VER)
82 
83 typedef __int16 ib_i16_t;
84 #else
85 
86 typedef int16_t ib_i16_t;
87 #endif
88 
89 #if defined(_MSC_VER)
90 
91 typedef unsigned __int16 ib_u16_t;
92 #else
93 
94 typedef uint16_t ib_u16_t;
95 #endif
96 
97 #if defined(_MSC_VER)
98 
99 typedef __int32 ib_i32_t;
100 #else
101 
102 typedef int32_t ib_i32_t;
103 #endif
104 
105 #if defined(_MSC_VER)
106 
107 typedef unsigned __int32 ib_u32_t;
108 #else
109 
110 typedef uint32_t ib_u32_t;
111 #endif
112 
113 #if defined(_MSC_VER)
114 
115 typedef __int64 ib_i64_t;
116 #else
117 
118 typedef int64_t ib_i64_t;
119 #endif
120 
121 #if defined(_MSC_VER)
122 
123 typedef unsigned __int64 ib_u64_t;
124 #else
125 
126 typedef uint64_t ib_u64_t;
127 #endif
128 
129 typedef void* ib_opaque_t;
130 typedef ib_opaque_t ib_charset_t;
131 typedef ib_ulint_t ib_bool_t;
132 typedef ib_u64_t ib_id_u64_t;
133 
135 typedef enum {
139  /* XXX Can we avoid having different types for ulint and ulong?
140  - On Win64 "unsigned long" is 32 bits
141  - ulong is always defined as "unsigned long"
142  - On Win64 ulint is defined as 64 bit integer
143  => On Win64 ulint != ulong.
144  If we typecast all ulong and ulint variables to the smaller type
145  ulong, then we will cut the range of the ulint variables.
146  This is not a problem for most ulint variables because their max
147  allowed values do not exceed 2^32-1 (e.g. log_groups is ulint
148  but its max allowed value is 10). BUT buffer_pool_size and
149  log_file_size allow up to 2^64-1. */
150 
162 } ib_cfg_type_t;
163 
165 typedef enum {
169  IB_CHAR = 2,
172  IB_BINARY = 3,
178  IB_BLOB = 5,
181  IB_INT = 6,
189  IB_SYS = 8,
193  IB_FLOAT = 9,
195  IB_DOUBLE = 10,
197  IB_DECIMAL = 11,
204 } ib_col_type_t;
205 
207 typedef enum {
224 } ib_tbl_fmt_t;
225 
227 typedef enum {
247 } ib_col_attr_t;
248 
249 /* Note: must match lock0types.h */
251 typedef enum {
270 } ib_lck_mode_t;
271 
272 typedef enum {
276 
279 typedef enum {
280  IB_CUR_G = 1,
284  IB_CUR_GE = 2,
289  IB_CUR_L = 3,
298 
300 typedef enum {
312 
314 typedef struct {
321  ib_u16_t client_type;
324  ib_charset_t* charset;
325 } ib_col_meta_t;
326 
327 /* Note: Must be in sync with trx0trx.h */
333 typedef enum {
345 
346 /* Note: Must be in sync with trx0trx.h */
348 typedef enum {
374 
376 typedef void (*ib_cb_t)(void);
377 
378 #define IB_CFG_BINLOG_ENABLED 0x1
379 #define IB_CFG_MDL_ENABLED 0x2
380 #define IB_CFG_DISABLE_ROWLOCK 0x4
381 
385 typedef FILE* ib_msg_stream_t;
386 
389 typedef int (*ib_msg_log_t)(ib_msg_stream_t, const char*, ...);
390 
391 /* Note: This is to make it easy for API users to have type
392 checking for arguments to our functions. Making it ib_opaque_t
393 by itself will result in pointer decay resulting in subverting
394 of the compiler's type checking. */
395 
401 typedef struct ib_tuple_t* ib_tpl_t;
402 
410 typedef struct trx_t* ib_trx_t;
411 
413 typedef struct ib_cursor_t* ib_crsr_t;
414 
415 /*************************************************************/
426 typedef int (*ib_client_cmp_t)(
427  const ib_col_meta_t* col_meta,
428  const ib_byte_t* p1,
429  ib_ulint_t p1_len,
430  const ib_byte_t* p2,
431  ib_ulint_t p2_len);
432 
433 /* This should be the same as univ.i */
435 #define IB_SQL_NULL 0xFFFFFFFF
436 
437 #define IB_N_SYS_COLS 3
438 
440 #define MAX_TEXT_LEN 4096
441 
442 /* MySQL uses 3 byte UTF-8 encoding. */
444 #define IB_MAX_COL_NAME_LEN (64 * 3)
445 
447 #define IB_MAX_TABLE_NAME_LEN (64 * 3) * 2
448 
449 /*****************************************************************/
458 ib_err_t
460 /*=========*/
461  ib_trx_t ib_trx,
462  ib_trx_level_t ib_trx_level,
463  void* thd);
465 /*****************************************************************/
470 ib_trx_t
472 /*=========*/
473  ib_trx_level_t ib_trx_level);
475 /*****************************************************************/
486 /*=========*/
487  ib_trx_t ib_trx);
489 /*****************************************************************/
495 ib_err_t
497 /*===========*/
498  ib_trx_t ib_trx);
500 /*****************************************************************/
505 ib_err_t
507 /*==========*/
508  ib_trx_t ib_trx);
510 /*****************************************************************/
515 ib_err_t
517 /*============*/
518  ib_trx_t ib_trx);
520 /*****************************************************************/
524 ib_err_t
526 /*==========================*/
527  ib_id_u64_t table_id,
528  ib_trx_t ib_trx,
530  ib_crsr_t* ib_crsr);
532 /*****************************************************************/
536 ib_err_t
538 /*==========================*/
539  ib_id_u64_t index_id,
540  ib_trx_t ib_trx,
542  ib_crsr_t* ib_crsr);
544 /*****************************************************************/
548 ib_err_t
550 /*============================*/
551  ib_crsr_t ib_open_crsr,
552  const char* index_name,
553  ib_crsr_t* ib_crsr,
554  int* idx_type,
555  ib_id_u64_t* idx_id);
557 /*****************************************************************/
561 ib_err_t
563 /*=================*/
564  const char* name,
565  ib_trx_t ib_trx,
567  ib_crsr_t* ib_crsr);
569 /*****************************************************************/
573 ib_err_t
575 /*============*/
576  ib_crsr_t ib_crsr);
579 /*****************************************************************/
582 void
584 /*================*/
585  ib_crsr_t ib_crsr);
587 /*****************************************************************/
591 ib_err_t
593 /*============*/
594  ib_crsr_t ib_crsr);
596 /*****************************************************************/
600 ib_err_t
602 /*==================*/
603  ib_crsr_t ib_crsr);
605 /*****************************************************************/
609 ib_err_t
611 /*==============*/
612  ib_crsr_t ib_crsr,
613  ib_trx_t ib_trx);
615 /*****************************************************************/
619 ib_err_t
621 /*=================*/
622  ib_crsr_t ib_crsr,
623  ib_trx_t ib_trx);
625 /********************************************************************/
629 void*
631 /*==================*/
632  const char* name);
634 /*****************************************************************/
638 ib_err_t
640 /*=================*/
641  ib_crsr_t ib_crsr,
642  const ib_tpl_t ib_tpl);
644 /*****************************************************************/
648 ib_err_t
650 /*=================*/
651  ib_crsr_t ib_crsr,
652  const ib_tpl_t ib_old_tpl,
653  const ib_tpl_t ib_new_tpl);
655 /*****************************************************************/
659 ib_err_t
661 /*=================*/
662  ib_crsr_t ib_crsr);
664 /*****************************************************************/
668 ib_err_t
670 /*===============*/
671  ib_crsr_t ib_crsr,
672  ib_tpl_t ib_tpl);
674 /*****************************************************************/
678 ib_err_t
680 /*============*/
681  ib_crsr_t ib_crsr);
683 /*****************************************************************/
687 ib_err_t
689 /*===========*/
690  ib_crsr_t ib_crsr);
692 /*****************************************************************/
696 ib_err_t
698 /*===========*/
699  ib_crsr_t ib_crsr);
701 /*****************************************************************/
705 ib_err_t
707 /*=============*/
708  ib_crsr_t ib_crsr,
709  ib_tpl_t ib_tpl,
710  ib_srch_mode_t ib_srch_mode);
712 /*****************************************************************/
715 void
717 /*=====================*/
718  ib_crsr_t ib_crsr,
721 /*****************************************************************/
725 ib_err_t
727 /*=============*/
728  ib_tpl_t ib_tpl,
729  ib_ulint_t col_no,
730  const void* src,
731  ib_ulint_t len,
732  ib_bool_t need_cpy);
735 /*****************************************************************/
741 /*===========*/
742  ib_tpl_t ib_tpl,
743  ib_ulint_t i);
745 /*****************************************************************/
751 /*==============*/
752  ib_tpl_t ib_tpl,
753  ib_ulint_t i,
754  void* dst,
755  ib_ulint_t len);
757 /*************************************************************/
761 ib_err_t
763 /*=============*/
764  ib_tpl_t ib_tpl,
765  ib_ulint_t i,
766  ib_i8_t* ival);
768 /*************************************************************/
772 ib_err_t
774 /*=============*/
775  ib_tpl_t ib_tpl,
776  ib_ulint_t i,
777  ib_u8_t* ival);
779 /*************************************************************/
783 ib_err_t
785 /*==============*/
786  ib_tpl_t ib_tpl,
787  ib_ulint_t i,
788  ib_i16_t* ival);
790 /*************************************************************/
794 ib_err_t
796 /*==============*/
797  ib_tpl_t ib_tpl,
798  ib_ulint_t i,
799  ib_u16_t* ival);
801 /*************************************************************/
805 ib_err_t
807 /*==============*/
808  ib_tpl_t ib_tpl,
809  ib_ulint_t i,
810  ib_i32_t* ival);
812 /*************************************************************/
816 ib_err_t
818 /*==============*/
819  ib_tpl_t ib_tpl,
820  ib_ulint_t i,
821  ib_u32_t* ival);
823 /*************************************************************/
827 ib_err_t
829 /*==============*/
830  ib_tpl_t ib_tpl,
831  ib_ulint_t i,
832  ib_i64_t* ival);
834 /*************************************************************/
838 ib_err_t
840 /*==============*/
841  ib_tpl_t ib_tpl,
842  ib_ulint_t i,
843  ib_u64_t* ival);
845 /*****************************************************************/
849 const void*
851 /*=============*/
852  ib_tpl_t ib_tpl,
853  ib_ulint_t i);
855 /*****************************************************************/
861 /*============*/
862  ib_tpl_t ib_tpl,
863  ib_ulint_t i,
864  ib_col_meta_t* ib_col_meta);
866 /*****************************************************************/
870 ib_tpl_t
872 /*============*/
873  ib_tpl_t ib_tpl);
875 /*****************************************************************/
881 ib_err_t
883 /*=====================*/
884  ib_crsr_t ib_crsr,
885  ib_tpl_t* ib_dst_tpl,
886  const ib_tpl_t ib_src_tpl);
888 /*****************************************************************/
893 ib_err_t
895 /*==========*/
896  ib_tpl_t ib_dst_tpl,
897  const ib_tpl_t ib_src_tpl);
899 /*****************************************************************/
903 ib_tpl_t
905 /*=======================*/
906  ib_crsr_t ib_crsr);
908 /*****************************************************************/
912 ib_tpl_t
914 /*=====================*/
915  ib_crsr_t ib_crsr);
917 /*****************************************************************/
921 ib_tpl_t
923 /*=========================*/
924  ib_crsr_t ib_crsr);
926 /*****************************************************************/
930 ib_tpl_t
932 /*=======================*/
933  ib_crsr_t ib_crsr);
935 /*****************************************************************/
941 /*=====================*/
942  const ib_tpl_t ib_tpl);
944 /*****************************************************************/
950 /*================*/
951  const ib_tpl_t ib_tpl);
953 /*****************************************************************/
956 void
958 /*============*/
959  ib_tpl_t ib_tpl);
961 /*****************************************************************/
966 ib_err_t
968 /*===============*/
969  ib_crsr_t* ib_crsr,
971  ib_id_u64_t* table_id);
973 /*****************************************************************/
977 ib_err_t
979 /*============*/
980  const char* table_name,
981  ib_id_u64_t* table_id);
983 /*****************************************************************/
987 ib_err_t
989 /*============*/
990  const char* table_name,
991  const char* index_name,
992  ib_id_u64_t* index_id);
994 /*****************************************************************/
998 ib_bool_t
1000 /*====================*/
1001  const ib_crsr_t ib_crsr);
1003 /*****************************************************************/
1008 ib_bool_t
1010 /*========================*/
1011  const ib_trx_t ib_trx);
1013 /*****************************************************************/
1017 ib_err_t
1019 /*===========*/
1020  ib_crsr_t ib_crsr,
1021  ib_lck_mode_t ib_lck_mode);
1023 /*****************************************************************/
1027 ib_err_t
1029 /*===========*/
1030  ib_trx_t ib_trx,
1031  ib_id_u64_t table_id,
1032  ib_lck_mode_t ib_lck_mode);
1034 /*****************************************************************/
1038 ib_err_t
1040 /*====================*/
1041  ib_crsr_t ib_crsr,
1042  ib_lck_mode_t ib_lck_mode);
1044 /*****************************************************************/
1047 void
1049 /*=========================*/
1050  ib_crsr_t ib_crsr);
1052 /*****************************************************************/
1057 ib_err_t
1059 /*==============*/
1060  ib_tpl_t ib_tpl,
1061  int col_no,
1062  ib_i8_t val);
1064 /*****************************************************************/
1069 ib_err_t
1071 /*=================*/
1072  ib_tpl_t ib_tpl,
1073  int col_no,
1074  ib_i16_t val);
1076 /*****************************************************************/
1081 ib_err_t
1083 /*===============*/
1084  ib_tpl_t ib_tpl,
1085  int col_no,
1086  ib_i32_t val);
1088 /*****************************************************************/
1093 ib_err_t
1095 /*===============*/
1096  ib_tpl_t ib_tpl,
1097  int col_no,
1098  ib_i64_t val);
1100 /*****************************************************************/
1105 ib_err_t
1107 /*==============*/
1108  ib_tpl_t ib_tpl,
1109  int col_no,
1110  ib_u8_t val);
1112 /*****************************************************************/
1117 ib_err_t
1119 /*===============*/
1120  ib_tpl_t ib_tpl,
1121  int col_no,
1122  ib_u16_t val);
1124 /*****************************************************************/
1129 ib_err_t
1131 /*=================*/
1132  ib_tpl_t ib_tpl,
1133  int col_no,
1134  ib_u32_t val);
1136 /*****************************************************************/
1141 ib_err_t
1143 /*===============*/
1144  ib_tpl_t ib_tpl,
1145  int col_no,
1146  ib_u64_t val);
1148 /*****************************************************************/
1151 void
1153 /*=================*/
1154  ib_crsr_t ib_crsr);
1156 /*****************************************************************/
1160 ib_err_t
1162 /*==================*/
1163  ib_tpl_t ib_tpl,
1164  int col_no,
1165  double val);
1167 /*************************************************************/
1171 ib_err_t
1173 /*=================*/
1174  ib_tpl_t ib_tpl,
1175  ib_ulint_t col_no,
1176  double* dval);
1178 /*****************************************************************/
1182 ib_err_t
1184 /*=================*/
1185  ib_tpl_t ib_tpl,
1186  int col_no,
1187  float val);
1189 /*************************************************************/
1193 ib_err_t
1195 /*================*/
1196  ib_tpl_t ib_tpl,
1197  ib_ulint_t col_no,
1198  float* fval);
1200 /*****************************************************************/
1204 const char*
1206 /*============*/
1207  ib_crsr_t ib_crsr,
1208  ib_ulint_t i);
1210 /*****************************************************************/
1214 const char*
1216 /*==================*/
1217  ib_crsr_t ib_crsr,
1218  ib_ulint_t i);
1220 /*****************************************************************/
1224 ib_err_t
1226 /*==============*/
1227  const char* table_name,
1228  ib_id_u64_t* table_id);
1230 /*****************************************************************/
1234 ib_err_t
1235 ib_close_thd(
1236 /*=========*/
1237  void* thd);
1241 /*****************************************************************/
1245 int
1246 ib_cfg_get_cfg();
1247 /*============*/
1248 
1249 /*****************************************************************/
1254 ib_err_t
1256 /*================*/
1257  const char* name);
1259 /*****************************************************************/
1265 /*==============*/
1266 
1267 /*****************************************************************/
1271 ib_ulint_t
1273 /*=======================*/
1274 
1275 /*****************************************************************/
1279 ib_u64_t
1281 /*==================*/
1282  ib_trx_t ib_trx);
1284 #endif /* api0api_h */