FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
mysql/sql/handler.h at master · sateeshgithub/mysql · GitHub
sateeshgithub
/
mysql
Public
forked from
twitter-forks/mysql
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
mysql
/
sql
/
handler.h
Copy path
More file actions
More file actions
Latest commit
History
History
History
2421 lines (2153 loc) · 84.2 KB
Breadcrumbs
mysql
/
sql
/
handler.h
Copy path
File metadata and controls
2421 lines (2153 loc) · 84.2 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#
ifndef
HANDLER_INCLUDED
#
define
HANDLER_INCLUDED
/*
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2012, Twitter, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
Definitions for parameters to do with handler-routines
*/
#
ifdef
USE_PRAGMA_INTERFACE
#
pragma
interface
/*
gcc class implementation
*/
#
endif
#
include
"
sql_const.h
"
#
include
"
mysqld.h
"
/*
server_id
*/
#
include
"
sql_plugin.h
"
/*
plugin_ref, st_plugin_int, plugin
*/
#
include
"
thr_lock.h
"
/*
thr_lock_type, THR_LOCK_DATA
*/
#
include
"
sql_cache.h
"
#
include
"
structs.h
"
/*
SHOW_COMP_OPTION
*/
#
include
<
my_compare.h
>
#
include
<
ft_global.h
>
#
include
<
keycache.h
>
#
if
MAX_KEY > 128
#
error
MAX_KEY is too large. Values up to 128 are supported.
#
endif
//
the following is for checking tables
#
define
HA_ADMIN_ALREADY_DONE
1
#
define
HA_ADMIN_OK
0
#
define
HA_ADMIN_NOT_IMPLEMENTED
-
1
#
define
HA_ADMIN_FAILED
-
2
#
define
HA_ADMIN_CORRUPT
-
3
#
define
HA_ADMIN_INTERNAL_ERROR
-
4
#
define
HA_ADMIN_INVALID
-
5
#
define
HA_ADMIN_REJECT
-
6
#
define
HA_ADMIN_TRY_ALTER
-
7
#
define
HA_ADMIN_WRONG_CHECKSUM
-
8
#
define
HA_ADMIN_NOT_BASE_TABLE
-
9
#
define
HA_ADMIN_NEEDS_UPGRADE
-
10
#
define
HA_ADMIN_NEEDS_ALTER
-
11
#
define
HA_ADMIN_NEEDS_CHECK
-
12
/*
Bits in table_flags() to show what database can do
*/
#
define
HA_NO_TRANSACTIONS
(
1
<<
0
)
/*
Doesn't support transactions
*/
#
define
HA_PARTIAL_COLUMN_READ
(
1
<<
1
)
/*
read may not return all columns
*/
#
define
HA_TABLE_SCAN_ON_INDEX
(
1
<<
2
)
/*
No separate data/index file
*/
/*
The following should be set if the following is not true when scanning
a table with rnd_next()
- We will see all rows (including deleted ones)
- Row positions are 'table->s->db_record_offset' apart
If this flag is not set, filesort will do a position() call for each matched
row to be able to find the row later.
*/
#
define
HA_REC_NOT_IN_SEQ
(
1
<<
3
)
#
define
HA_CAN_GEOMETRY
(
1
<<
4
)
/*
Reading keys in random order is as fast as reading keys in sort order
(Used in records.cc to decide if we should use a record cache and by
filesort to decide if we should sort key + data or key + pointer-to-row
*/
#
define
HA_FAST_KEY_READ
(
1
<<
5
)
/*
Set the following flag if we on delete should force all key to be read
and on update read all keys that changes
*/
#
define
HA_REQUIRES_KEY_COLUMNS_FOR_DELETE
(
1
<<
6
)
#
define
HA_NULL_IN_KEY
(
1
<<
7
)
/*
One can have keys with NULL
*/
#
define
HA_DUPLICATE_POS
(
1
<<
8
)
/*
ha_position() gives dup row
*/
#
define
HA_NO_BLOBS
(
1
<<
9
)
/*
Doesn't support blobs
*/
#
define
HA_CAN_INDEX_BLOBS
(
1
<<
10
)
#
define
HA_AUTO_PART_KEY
(
1
<<
11
)
/*
auto-increment in multi-part key
*/
#
define
HA_REQUIRE_PRIMARY_KEY
(
1
<<
12
)
/*
.. and can't create a hidden one
*/
#
define
HA_STATS_RECORDS_IS_EXACT
(
1
<<
13
)
/*
stats.records is exact
*/
/*
INSERT_DELAYED only works with handlers that uses MySQL internal table
level locks
*/
#
define
HA_CAN_INSERT_DELAYED
(
1
<<
14
)
/*
If we get the primary key columns for free when we do an index read
It also implies that we have to retrive the primary key when using
position() and rnd_pos().
*/
#
define
HA_PRIMARY_KEY_IN_READ_INDEX
(
1
<<
15
)
/*
If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, it means that to position()
uses a primary key given by the record argument.
Without primary key, we can't call position().
If not set, the position is returned as the current rows position
regardless of what argument is given.
*/
#
define
HA_PRIMARY_KEY_REQUIRED_FOR_POSITION
(
1
<<
16
)
#
define
HA_CAN_RTREEKEYS
(
1
<<
17
)
#
define
HA_NOT_DELETE_WITH_CACHE
(
1
<<
18
)
/*
The following is we need to a primary key to delete (and update) a row.
If there is no primary key, all columns needs to be read on update and delete
*/
#
define
HA_PRIMARY_KEY_REQUIRED_FOR_DELETE
(
1
<<
19
)
#
define
HA_NO_PREFIX_CHAR_KEYS
(
1
<<
20
)
#
define
HA_CAN_FULLTEXT
(
1
<<
21
)
#
define
HA_CAN_SQL_HANDLER
(
1
<<
22
)
#
define
HA_NO_AUTO_INCREMENT
(
1
<<
23
)
#
define
HA_HAS_CHECKSUM
(
1
<<
24
)
/*
Table data are stored in separate files (for lower_case_table_names)
*/
#
define
HA_FILE_BASED
(
1
<<
26
)
#
define
HA_NO_VARCHAR
(
1
<<
27
)
#
define
HA_CAN_BIT_FIELD
(
1
<<
28
)
/*
supports bit fields
*/
#
define
HA_NEED_READ_RANGE_BUFFER
(
1
<<
29
)
/*
for read_multi_range
*/
#
define
HA_ANY_INDEX_MAY_BE_UNIQUE
(
1
<<
30
)
#
define
HA_NO_COPY_ON_ALTER
(
LL
(
1
) <<
31
)
#
define
HA_HAS_RECORDS
(
LL
(
1
) <<
32
)
/*
records() gives exact count
*/
/*
Has it's own method of binlog logging
*/
#
define
HA_HAS_OWN_BINLOGGING
(
LL
(
1
) <<
33
)
/*
Engine is capable of row-format and statement-format logging,
respectively
*/
#
define
HA_BINLOG_ROW_CAPABLE
(
LL
(
1
) <<
34
)
#
define
HA_BINLOG_STMT_CAPABLE
(
LL
(
1
) <<
35
)
/*
When a multiple key conflict happens in a REPLACE command mysql
expects the conflicts to be reported in the ascending order of
key names.
For e.g.
CREATE TABLE t1 (a INT, UNIQUE (a), b INT NOT NULL, UNIQUE (b), c INT NOT
NULL, INDEX(c));
REPLACE INTO t1 VALUES (1,1,1),(2,2,2),(2,1,3);
MySQL expects the conflict with 'a' to be reported before the conflict with
'b'.
If the underlying storage engine does not report the conflicting keys in
ascending order, it causes unexpected errors when the REPLACE command is
executed.
This flag helps the underlying SE to inform the server that the keys are not
ordered.
*/
#
define
HA_DUPLICATE_KEY_NOT_IN_ORDER
(
LL
(
1
) <<
36
)
/*
Engine supports REPAIR TABLE. Used by CHECK TABLE FOR UPGRADE if an
incompatible table is detected. If this flag is set, CHECK TABLE FOR UPGRADE
will report ER_TABLE_NEEDS_UPGRADE, otherwise ER_TABLE_NEED_REBUILD.
*/
#
define
HA_CAN_REPAIR
(
LL
(
1
) <<
37
)
/*
Set of all binlog flags. Currently only contain the capabilities
flags.
*/
#
define
HA_BINLOG_FLAGS
(
HA_BINLOG_ROW_CAPABLE
|
HA_BINLOG_STMT_CAPABLE
)
/*
bits in index_flags(index_number) for what you can do with index
*/
#
define
HA_READ_NEXT
1
/*
TODO really use this flag
*/
#
define
HA_READ_PREV
2
/*
supports ::index_prev
*/
#
define
HA_READ_ORDER
4
/*
index_next/prev follow sort order
*/
#
define
HA_READ_RANGE
8
/*
can find all records in a range
*/
#
define
HA_ONLY_WHOLE_INDEX
16
/*
Can't use part key searches
*/
#
define
HA_KEYREAD_ONLY
64
/*
Support HA_EXTRA_KEYREAD
*/
/*
bits in alter_table_flags:
*/
/*
These bits are set if different kinds of indexes can be created or dropped
in-place without re-creating the table using a temporary table.
NO_READ_WRITE indicates that the handler needs concurrent reads and writes
of table data to be blocked.
Partitioning needs both ADD and DROP to be supported by its underlying
handlers, due to error handling, see bug#57778.
*/
#
define
HA_INPLACE_ADD_INDEX_NO_READ_WRITE
(
1L
<<
0
)
#
define
HA_INPLACE_DROP_INDEX_NO_READ_WRITE
(
1L
<<
1
)
#
define
HA_INPLACE_ADD_UNIQUE_INDEX_NO_READ_WRITE
(
1L
<<
2
)
#
define
HA_INPLACE_DROP_UNIQUE_INDEX_NO_READ_WRITE
(
1L
<<
3
)
#
define
HA_INPLACE_ADD_PK_INDEX_NO_READ_WRITE
(
1L
<<
4
)
#
define
HA_INPLACE_DROP_PK_INDEX_NO_READ_WRITE
(
1L
<<
5
)
/*
These are set if different kinds of indexes can be created or dropped
in-place while still allowing concurrent reads (but not writes) of table
data. If a handler is capable of one or more of these, it should also set
the corresponding *_NO_READ_WRITE bit(s).
*/
#
define
HA_INPLACE_ADD_INDEX_NO_WRITE
(
1L
<<
6
)
#
define
HA_INPLACE_DROP_INDEX_NO_WRITE
(
1L
<<
7
)
#
define
HA_INPLACE_ADD_UNIQUE_INDEX_NO_WRITE
(
1L
<<
8
)
#
define
HA_INPLACE_DROP_UNIQUE_INDEX_NO_WRITE
(
1L
<<
9
)
#
define
HA_INPLACE_ADD_PK_INDEX_NO_WRITE
(
1L
<<
10
)
#
define
HA_INPLACE_DROP_PK_INDEX_NO_WRITE
(
1L
<<
11
)
/*
HA_PARTITION_FUNCTION_SUPPORTED indicates that the function is
supported at all.
HA_FAST_CHANGE_PARTITION means that optimised variants of the changes
exists but they are not necessarily done online.
HA_ONLINE_DOUBLE_WRITE means that the handler supports writing to both
the new partition and to the old partitions when updating through the
old partitioning schema while performing a change of the partitioning.
This means that we can support updating of the table while performing
the copy phase of the change. For no lock at all also a double write
from new to old must exist and this is not required when this flag is
set.
This is actually removed even before it was introduced the first time.
The new idea is that handlers will handle the lock level already in
store_lock for ALTER TABLE partitions.
HA_PARTITION_ONE_PHASE is a flag that can be set by handlers that take
care of changing the partitions online and in one phase. Thus all phases
needed to handle the change are implemented inside the storage engine.
The storage engine must also support auto-discovery since the frm file
is changed as part of the change and this change must be controlled by
the storage engine. A typical engine to support this is NDB (through
WL #2498).
*/
#
define
HA_PARTITION_FUNCTION_SUPPORTED
(
1L
<<
12
)
#
define
HA_FAST_CHANGE_PARTITION
(
1L
<<
13
)
#
define
HA_PARTITION_ONE_PHASE
(
1L
<<
14
)
/*
Index scan will not return records in rowid order. Not guaranteed to be
set for unordered (e.g. HASH) indexes.
*/
#
define
HA_KEY_SCAN_NOT_ROR
128
/*
operations for disable/enable indexes
*/
#
define
HA_KEY_SWITCH_NONUNIQ
0
#
define
HA_KEY_SWITCH_ALL
1
#
define
HA_KEY_SWITCH_NONUNIQ_SAVE
2
#
define
HA_KEY_SWITCH_ALL_SAVE
3
/*
Note: the following includes binlog and closing 0.
so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
example + csv + heap + blackhole + federated + 0
(yes, the sum is deliberately inaccurate)
TODO remove the limit, use dynarrays
*/
#
define
MAX_HA
15
/*
Use this instead of 0 as the initial value for the slot number of
handlerton, so that we can distinguish uninitialized slot number
from slot 0.
*/
#
define
HA_SLOT_UNDEF
((uint)-
1
)
/*
Parameters for open() (in register form->filestat)
HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
*/
#
define
HA_OPEN_KEYFILE
1
#
define
HA_OPEN_RNDFILE
2
#
define
HA_GET_INDEX
4
#
define
HA_GET_INFO
8
/*
do a ha_info() after open
*/
#
define
HA_READ_ONLY
16
/*
File opened as readonly
*/
/*
Try readonly if can't open with read and write
*/
#
define
HA_TRY_READ_ONLY
32
#
define
HA_WAIT_IF_LOCKED
64
/*
Wait if locked on open
*/
#
define
HA_ABORT_IF_LOCKED
128
/*
skip if locked on open.
*/
#
define
HA_BLOCK_LOCK
256
/*
unlock when reading some records
*/
#
define
HA_OPEN_TEMPORARY
512
/*
Some key definitions
*/
#
define
HA_KEY_NULL_LENGTH
1
#
define
HA_KEY_BLOB_LENGTH
2
#
define
HA_LEX_CREATE_TMP_TABLE
1
#
define
HA_LEX_CREATE_IF_NOT_EXISTS
2
#
define
HA_LEX_CREATE_TABLE_LIKE
4
#
define
HA_OPTION_NO_CHECKSUM
(
1L
<<
17
)
#
define
HA_OPTION_NO_DELAY_KEY_WRITE
(
1L
<<
18
)
#
define
HA_MAX_REC_LENGTH
65535
/*
Table caching type
*/
#
define
HA_CACHE_TBL_NONTRANSACT
0
#
define
HA_CACHE_TBL_NOCACHE
1
#
define
HA_CACHE_TBL_ASKTRANSACT
2
#
define
HA_CACHE_TBL_TRANSACT
4
/*
Options of START TRANSACTION statement (and later of SET TRANSACTION stmt)
*/
#
define
MYSQL_START_TRANS_OPT_WITH_CONS_SNAPSHOT
1
/*
Flags for method is_fatal_error
*/
#
define
HA_CHECK_DUP_KEY
1
#
define
HA_CHECK_DUP_UNIQUE
2
#
define
HA_CHECK_DUP
(
HA_CHECK_DUP_KEY
+
HA_CHECK_DUP_UNIQUE
)
enum
legacy_db_type
{
DB_TYPE_UNKNOWN
=
0
,
DB_TYPE_DIAB_ISAM
=
1
,
DB_TYPE_HASH
,
DB_TYPE_MISAM
,
DB_TYPE_PISAM
,
DB_TYPE_RMS_ISAM
,
DB_TYPE_HEAP
,
DB_TYPE_ISAM
,
DB_TYPE_MRG_ISAM
,
DB_TYPE_MYISAM
,
DB_TYPE_MRG_MYISAM
,
DB_TYPE_BERKELEY_DB
,
DB_TYPE_INNODB
,
DB_TYPE_GEMINI
,
DB_TYPE_NDBCLUSTER
,
DB_TYPE_EXAMPLE_DB
,
DB_TYPE_ARCHIVE_DB
,
DB_TYPE_CSV_DB
,
DB_TYPE_FEDERATED_DB
,
DB_TYPE_BLACKHOLE_DB
,
DB_TYPE_PARTITION_DB
,
DB_TYPE_BINLOG
,
DB_TYPE_SOLID
,
DB_TYPE_PBXT
,
DB_TYPE_TABLE_FUNCTION
,
DB_TYPE_MEMCACHE
,
DB_TYPE_FALCON
,
DB_TYPE_MARIA
,
/*
* Performance schema engine.
*/
DB_TYPE_PERFORMANCE_SCHEMA
,
DB_TYPE_FIRST_DYNAMIC
=
42
,
DB_TYPE_DEFAULT
=
127
//
Must be last
};
enum
row_type {
ROW_TYPE_NOT_USED
=-
1
,
ROW_TYPE_DEFAULT
,
ROW_TYPE_FIXED
,
ROW_TYPE_DYNAMIC
,
ROW_TYPE_COMPRESSED
,
ROW_TYPE_REDUNDANT
,
ROW_TYPE_COMPACT
,
/*
* Unused. Reserved for future versions.
*/
ROW_TYPE_PAGE
};
enum
enum_binlog_func {
BFN_RESET_LOGS
=
1
,
BFN_RESET_SLAVE
=
2
,
BFN_BINLOG_WAIT
=
3
,
BFN_BINLOG_END
=
4
,
BFN_BINLOG_PURGE_FILE
=
5
};
enum
enum_binlog_command {
LOGCOM_CREATE_TABLE
,
LOGCOM_ALTER_TABLE
,
LOGCOM_RENAME_TABLE
,
LOGCOM_DROP_TABLE
,
LOGCOM_CREATE_DB
,
LOGCOM_ALTER_DB
,
LOGCOM_DROP_DB
};
/*
struct to hold information about the table that should be created
*/
/*
Bits in used_fields
*/
#
define
HA_CREATE_USED_AUTO
(
1L
<<
0
)
#
define
HA_CREATE_USED_RAID
(
1L
<<
1
)
//
RAID is no longer availble
#
define
HA_CREATE_USED_UNION
(
1L
<<
2
)
#
define
HA_CREATE_USED_INSERT_METHOD
(
1L
<<
3
)
#
define
HA_CREATE_USED_MIN_ROWS
(
1L
<<
4
)
#
define
HA_CREATE_USED_MAX_ROWS
(
1L
<<
5
)
#
define
HA_CREATE_USED_AVG_ROW_LENGTH
(
1L
<<
6
)
#
define
HA_CREATE_USED_PACK_KEYS
(
1L
<<
7
)
#
define
HA_CREATE_USED_CHARSET
(
1L
<<
8
)
#
define
HA_CREATE_USED_DEFAULT_CHARSET
(
1L
<<
9
)
#
define
HA_CREATE_USED_DATADIR
(
1L
<<
10
)
#
define
HA_CREATE_USED_INDEXDIR
(
1L
<<
11
)
#
define
HA_CREATE_USED_ENGINE
(
1L
<<
12
)
#
define
HA_CREATE_USED_CHECKSUM
(
1L
<<
13
)
#
define
HA_CREATE_USED_DELAY_KEY_WRITE
(
1L
<<
14
)
#
define
HA_CREATE_USED_ROW_FORMAT
(
1L
<<
15
)
#
define
HA_CREATE_USED_COMMENT
(
1L
<<
16
)
#
define
HA_CREATE_USED_PASSWORD
(
1L
<<
17
)
#
define
HA_CREATE_USED_CONNECTION
(
1L
<<
18
)
#
define
HA_CREATE_USED_KEY_BLOCK_SIZE
(
1L
<<
19
)
/*
* Unused. Reserved for future versions.
*/
#
define
HA_CREATE_USED_TRANSACTIONAL
(
1L
<<
20
)
/*
* Unused. Reserved for future versions.
*/
#
define
HA_CREATE_USED_PAGE_CHECKSUM
(
1L
<<
21
)
/*
This is master database for most of system tables. However there
can be other databases which can hold system tables. Respective
storage engines define their own system database names.
*/
extern
const
char
*mysqld_system_database;
/*
Structure to hold list of system_database.system_table.
This is used at both mysqld and storage engine layer.
*/
struct
st_system_tablename
{
const
char
*db;
const
char
*tablename;
};
typedef
ulonglong my_xid;
//
this line is the same as in log_event.h
#
define
MYSQL_XID_PREFIX
"
MySQLXid
"
#
define
MYSQL_XID_PREFIX_LEN
8
//
must be a multiple of 8
#
define
MYSQL_XID_OFFSET
(
MYSQL_XID_PREFIX_LEN
+
sizeof
(server_id))
#
define
MYSQL_XID_GTRID_LEN
(
MYSQL_XID_OFFSET
+
sizeof
(my_xid))
#
define
XIDDATASIZE
MYSQL_XIDDATASIZE
#
define
MAXGTRIDSIZE
64
#
define
MAXBQUALSIZE
64
#
define
COMPATIBLE_DATA_YES
0
#
define
COMPATIBLE_DATA_NO
1
/*
*
struct xid_t is binary compatible with the XID structure as
in the X/Open CAE Specification, Distributed Transaction Processing:
The XA Specification, X/Open Company Ltd., 1991.
http://www.opengroup.org/bookstore/catalog/c193.htm
@see MYSQL_XID in mysql/plugin.h
*/
struct
xid_t
{
long
formatID;
long
gtrid_length;
long
bqual_length;
char
data[
XIDDATASIZE
];
//
not \0-terminated !
xid_t
() {}
/*
Remove gcc warning
*/
bool
eq
(
struct
xid_t
*xid)
{
return
eq
(xid->
gtrid_length
, xid->
bqual_length
, xid->
data
); }
bool
eq
(
long
g,
long
b,
const
char
*d)
{
return
g == gtrid_length && b == bqual_length && !
memcmp
(d, data, g+b); }
void
set
(
struct
xid_t
*xid)
{
memcpy
(
this
, xid, xid->
length
()); }
void
set
(
long
f,
const
char
*g,
long
gl,
const
char
*b,
long
bl)
{
formatID= f;
memcpy
(data, g, gtrid_length= gl);
memcpy
(data+gl, b, bqual_length= bl);
}
void
set
(ulonglong xid)
{
my_xid tmp;
formatID=
1
;
set
(
MYSQL_XID_PREFIX_LEN
,
0
,
MYSQL_XID_PREFIX
);
memcpy
(data+
MYSQL_XID_PREFIX_LEN
, &server_id,
sizeof
(server_id));
tmp= xid;
memcpy
(data+
MYSQL_XID_OFFSET
, &tmp,
sizeof
(tmp));
gtrid_length=
MYSQL_XID_GTRID_LEN
;
}
void
set
(
long
g,
long
b,
const
char
*d)
{
formatID=
1
;
gtrid_length= g;
bqual_length= b;
memcpy
(data, d, g+b);
}
bool
is_null
() {
return
formatID == -
1
; }
void
null
() { formatID= -
1
; }
my_xid
quick_get_my_xid
()
{
my_xid tmp;
memcpy
(&tmp, data+
MYSQL_XID_OFFSET
,
sizeof
(tmp));
return
tmp;
}
my_xid
get_my_xid
()
{
return
gtrid_length ==
MYSQL_XID_GTRID_LEN
&& bqual_length ==
0
&&
!
memcmp
(data,
MYSQL_XID_PREFIX
,
MYSQL_XID_PREFIX_LEN
) ?
quick_get_my_xid
() :
0
;
}
uint
length
()
{
return
sizeof
(formatID)+
sizeof
(gtrid_length)+
sizeof
(bqual_length)+
gtrid_length+bqual_length;
}
uchar *
key
()
{
return
(uchar *)>rid_length;
}
uint
key_length
()
{
return
sizeof
(gtrid_length)+
sizeof
(bqual_length)+gtrid_length+bqual_length;
}
};
typedef
struct
xid_t
XID
;
/*
for recover() handlerton call
*/
#
define
MIN_XID_LIST_SIZE
128
#
define
MAX_XID_LIST_SIZE
(
1024
*
128
)
/*
These structures are used to pass information from a set of SQL commands
on add/drop/change tablespace definitions to the proper hton.
*/
#
define
UNDEF_NODEGROUP
65535
enum
ts_command_type
{
TS_CMD_NOT_DEFINED
= -
1
,
CREATE_TABLESPACE
=
0
,
ALTER_TABLESPACE
=
1
,
CREATE_LOGFILE_GROUP
=
2
,
ALTER_LOGFILE_GROUP
=
3
,
DROP_TABLESPACE
=
4
,
DROP_LOGFILE_GROUP
=
5
,
CHANGE_FILE_TABLESPACE
=
6
,
ALTER_ACCESS_MODE_TABLESPACE
=
7
};
enum
ts_alter_tablespace_type
{
TS_ALTER_TABLESPACE_TYPE_NOT_DEFINED
= -
1
,
ALTER_TABLESPACE_ADD_FILE
=
1
,
ALTER_TABLESPACE_DROP_FILE
=
2
};
enum
tablespace_access_mode
{
TS_NOT_DEFINED
= -
1
,
TS_READ_ONLY
=
0
,
TS_READ_WRITE
=
1
,
TS_NOT_ACCESSIBLE
=
2
};
struct
handlerton
;
class
st_alter_tablespace
:
public
Sql_alloc
{
public:
const
char
*tablespace_name;
const
char
*logfile_group_name;
enum
ts_command_type ts_cmd_type;
enum
ts_alter_tablespace_type ts_alter_tablespace_type;
const
char
*data_file_name;
const
char
*undo_file_name;
const
char
*redo_file_name;
ulonglong extent_size;
ulonglong undo_buffer_size;
ulonglong redo_buffer_size;
ulonglong initial_size;
ulonglong autoextend_size;
ulonglong max_size;
uint nodegroup_id;
handlerton *storage_engine;
bool
wait_until_completed;
const
char
*ts_comment;
enum
tablespace_access_mode ts_access_mode;
st_alter_tablespace
()
{
tablespace_name=
NULL
;
logfile_group_name=
"
DEFAULT_LG
"
;
//
Default log file group
ts_cmd_type=
TS_CMD_NOT_DEFINED
;
data_file_name=
NULL
;
undo_file_name=
NULL
;
redo_file_name=
NULL
;
extent_size=
1024
*
1024
;
//
Default 1 MByte
undo_buffer_size=
8
*
1024
*
1024
;
//
Default 8 MByte
redo_buffer_size=
8
*
1024
*
1024
;
//
Default 8 MByte
initial_size=
128
*
1024
*
1024
;
//
Default 128 MByte
autoextend_size=
0
;
//
No autoextension as default
max_size=
0
;
//
Max size == initial size => no extension
storage_engine=
NULL
;
nodegroup_id=
UNDEF_NODEGROUP
;
wait_until_completed=
TRUE
;
ts_comment=
NULL
;
ts_access_mode=
TS_NOT_DEFINED
;
}
};
/*
The handler for a table type. Will be included in the TABLE structure
*/
struct
TABLE
;
/*
Make sure that the order of schema_tables and enum_schema_tables are the same.
*/
enum
enum_schema_tables
{
SCH_CHARSETS
=
0
,
SCH_CLIENT_STATS
,
SCH_COLLATIONS
,
SCH_COLLATION_CHARACTER_SET_APPLICABILITY
,
SCH_COLUMNS
,
SCH_COLUMN_PRIVILEGES
,
SCH_INDEX_STATS
,
SCH_ENGINES
,
SCH_EVENTS
,
SCH_FILES
,
SCH_GLOBAL_STATUS
,
SCH_GLOBAL_VARIABLES
,
SCH_KEY_COLUMN_USAGE
,
SCH_OPEN_TABLES
,
SCH_PARAMETERS
,
SCH_PARTITIONS
,
SCH_PLUGINS
,
SCH_PROCESSLIST
,
SCH_PROFILES
,
SCH_QUERY_STATISTICS
,
SCH_REFERENTIAL_CONSTRAINTS
,
SCH_PROCEDURES
,
SCH_SCHEMATA
,
SCH_SCHEMA_PRIVILEGES
,
SCH_SESSION_STATUS
,
SCH_SESSION_VARIABLES
,
SCH_STATISTICS
,
SCH_STATUS
,
SCH_TABLES
,
SCH_TABLESPACES
,
SCH_TABLE_CONSTRAINTS
,
SCH_TABLE_NAMES
,
SCH_TABLE_PRIVILEGES
,
SCH_TABLE_STATS
,
SCH_THREAD_STATS
,
SCH_TRIGGERS
,
SCH_USER_PRIVILEGES
,
SCH_USER_STATS
,
SCH_VARIABLES
,
SCH_VIEWS
};
struct
TABLE_SHARE
;
struct
st_foreign_key_info
;
typedef
struct
st_foreign_key_info
FOREIGN_KEY_INFO
;
typedef
bool
(stat_print_fn)(
THD
*thd,
const
char
*type, uint type_len,
const
char
*file, uint file_len,
const
char
*status, uint status_len);
enum
ha_stat_type {
HA_ENGINE_STATUS
,
HA_ENGINE_LOGS
,
HA_ENGINE_MUTEX
};
extern
st_plugin_int *hton2plugin[
MAX_HA
];
/*
Transaction log maintains type definitions
*/
enum
log_status
{
HA_LOG_STATUS_FREE
=
0
,
/*
log is free and can be deleted
*/
HA_LOG_STATUS_INUSE
=
1
,
/*
log can't be deleted because it is in use
*/
HA_LOG_STATUS_NOSUCHLOG
=
2
/*
no such log (can't be returned by
the log iterator status)
*/
};
/*
Function for signaling that the log file changed its state from
LOG_STATUS_INUSE to LOG_STATUS_FREE
Now it do nothing, will be implemented as part of new transaction
log management for engines.
TODO: implement the function.
*/
void
signal_log_not_needed
(
struct
handlerton
,
char
*log_file);
/*
Data of transaction log iterator.
*/
struct
handler_log_file_data
{
LEX_STRING
filename;
enum
log_status status;
};
enum
handler_iterator_type
{
/*
request of transaction log iterator
*/
HA_TRANSACTLOG_ITERATOR
=
1
};
enum
handler_create_iterator_result
{
HA_ITERATOR_OK
,
/*
iterator created
*/
HA_ITERATOR_UNSUPPORTED
,
/*
such type of iterator is not supported
*/
HA_ITERATOR_ERROR
/*
error during iterator creation
*/
};
/*
Iterator structure. Can be used by handler/handlerton for different purposes.
Iterator should be created in the way to point "before" the first object
it iterate, so next() call move it to the first object or return !=0 if
there is nothing to iterate through.
*/
struct
handler_iterator
{
/*
Moves iterator to next record and return 0 or return !=0
if there is no records.
iterator_object will be filled by this function if next() returns 0.
Content of the iterator_object depend on iterator type.
*/
int
(*next)(
struct
handler_iterator
*,
void
*iterator_object);
/*
Free resources allocated by iterator, after this call iterator
is not usable.
*/
void
(*destroy)(
struct
handler_iterator
*);
/*
Pointer to buffer for the iterator to use.
Should be allocated by function which created the iterator and
destroied by freed by above "destroy" call
*/
void
*buffer;
};
class
handler
;
/*
handlerton is a singleton structure - one instance per storage engine -
to provide access to storage engine functionality that works on the
"global" level (unlike handler class that works on a per-table basis)
usually handlerton instance is defined statically in ha_xxx.cc as
static handlerton { ... } xxx_hton;
savepoint_*, prepare, recover, and *_by_xid pointers can be 0.
*/
struct
handlerton
{
/*
Historical marker for if the engine is available of not
*/
SHOW_COMP_OPTION
state;
/*
Historical number used for frm file to determine the correct storage engine.
This is going away and new engines will just use "name" for this.
*/
enum
legacy_db_type db_type;
/*
each storage engine has it's own memory area (actually a pointer)
in the thd, for storing per-connection information.
It is accessed as
thd->ha_data[xxx_hton.slot]
slot number is initialized by MySQL after xxx_init() is called.
*/
uint slot;
/*
to store per-savepoint data storage engine is provided with an area
of a requested size (0 is ok here).
savepoint_offset must be initialized statically to the size of
the needed memory to store per-savepoint information.
After xxx_init it is changed to be an offset to savepoint storage
area and need not be used by storage engine.
see binlog_hton and binlog_savepoint_set/rollback for an example.
*/
uint savepoint_offset;
/*
handlerton methods:
close_connection is only called if
thd->ha_data[xxx_hton.slot] is non-zero, so even if you don't need
this storage area - set it to something, so that MySQL would know
this storage engine was accessed in this connection
*/
int
(*close_connection)(handlerton *hton,
THD
*thd);
/*
sv points to an uninitialized storage area of requested size
(see savepoint_offset description)
*/
int
(*savepoint_set)(handlerton *hton,
THD
*thd,
void
*sv);
/*
sv points to a storage area, that was earlier passed
to the savepoint_set call
*/
int
(*savepoint_rollback)(handlerton *hton,
THD
*thd,
void
*sv);
int
(*savepoint_release)(handlerton *hton,
THD
*thd,
void
*sv);
/*
'all' is true if it's a real commit, that makes persistent changes
'all' is false if it's not in fact a commit but an end of the
statement that is part of the transaction.
NOTE 'all' is also false in auto-commit mode where 'end of statement'
and 'real commit' mean the same event.
*/
int
(*commit)(handlerton *hton,
THD
*thd,
bool
all);
int
(*rollback)(handlerton *hton,
THD
*thd,
bool
all);
int
(*prepare)(handlerton *hton,
THD
*thd,
bool
all);
int
(*recover)(handlerton *hton,
XID
*xid_list, uint len);
int
(*commit_by_xid)(handlerton *hton,
XID
*xid);
int
(*rollback_by_xid)(handlerton *hton,
XID
*xid);
void
*(*create_cursor_read_view)(handlerton *hton,
THD
*thd);
void
(*set_cursor_read_view)(handlerton *hton,
THD
*thd,
void
*read_view);
void
(*close_cursor_read_view)(handlerton *hton,
THD
*thd,
void
*read_view);
handler *(*create)(handlerton *hton,
TABLE_SHARE
*table,
MEM_ROOT
*mem_root);
void
(*drop_database)(handlerton *hton,
char
* path);
int
(*panic)(handlerton *hton,
enum
ha_panic_function flag);
int
(*start_consistent_snapshot)(handlerton *hton,
THD
*thd);
bool
(*flush_logs)(handlerton *hton);
bool
(*show_status)(handlerton *hton,
THD
*thd, stat_print_fn *print,
enum
ha_stat_type stat);
uint
(*partition_flags)();
uint
(*alter_table_flags)(uint flags);
int
(*alter_tablespace)(handlerton *hton,
THD
*thd, st_alter_tablespace *ts_info);
int
(*fill_is_table)(handlerton *hton,
THD
*thd,
TABLE_LIST
*tables,
class
Item
*cond,
enum
enum_schema_tables);
uint32 flags;
/*
global handler flags
*/
/*
Those handlerton functions below are properly initialized at handler
init.
*/
int
(*binlog_func)(handlerton *hton,
THD
*thd, enum_binlog_func fn,
void
*arg);
void
(*binlog_log_query)(handlerton *hton,
THD
*thd,
enum_binlog_command binlog_command,
const
char
*query, uint query_length,
const
char
*db,
const
char
*table_name);
int
(*release_temporary_latches)(handlerton *hton,
THD
*thd);
/*
Get log status.
If log_status is null then the handler do not support transaction
log information (i.e. log iterator can't be created).
(see example of implementation in handler.cc, TRANS_LOG_MGM_EXAMPLE_CODE)
*/
enum
log_status
(*get_log_status)(handlerton *hton,
char
*log);
/*
Control the storage engine.
*/
longlong
(*control)(handlerton *hton,
const
char
*cmd,
Item **args, uint arg_count);
/*
Terminate connection/statement notification.
*/
void
(*kill_connection)(handlerton *hton,
THD
*thd);
/*
Iterators creator.
Presence of the pointer should be checked before using
*/
enum
handler_create_iterator_result
(*create_iterator)(handlerton *hton,
enum
handler_iterator_type type,
struct
handler_iterator
*fill_this_in);
int
(*discover)(handlerton *hton,
THD
* thd,
const
char
*db,
const
char
*name,
uchar **frmblob,
size_t
*frmlen);
int
(*find_files)(handlerton *hton,
THD
*thd,
const
char
*db,
const
char
*path,
const
char
*wild,
bool
dir, List<
LEX_STRING
> *files);
int
(*table_exists_in_engine)(handlerton *hton,
THD
* thd,
const
char
*db,
const
char
*name);
/*
*
List of all system tables specific to the SE.
Array element would look like below,
{ "<database_name>", "<system table name>" },
The last element MUST be,
{ (const char*)NULL, (const char*)NULL }
@see ha_example_system_tables in ha_example.cc
This interface is optional, so every SE need not implement it.
*/
const
char
* (*system_database)();
/*
*
Check if the given db.tablename is a system table for this SE.
@param db Database name to check.
@param table_name table name to check.
@param is_sql_layer_system_table if the supplied db.table_name is a SQL
layer system table.
@see example_is_supported_system_table in ha_example.cc
is_sql_layer_system_table is supplied to make more efficient
checks possible for SEs that support all SQL layer tables.
This interface is optional, so every SE need not implement it.
*/
bool
(*is_supported_system_table)(
const
char
*db,
const
char
*table_name,
bool
is_sql_layer_system_table);
uint32 license;
/*
Flag for Engine License
*/
void
*data;
/*
Location for engines to keep personal structures
*/
};
/*
Possible flags of a handlerton (there can be 32 of them)
*/
#
define
HTON_NO_FLAGS
0
#
define
HTON_CLOSE_CURSORS_AT_COMMIT
(
1
<<
0
)
#
define
HTON_ALTER_NOT_SUPPORTED
(
1
<<
1
)
//
Engine does not support alter
#
define
HTON_CAN_RECREATE
(
1
<<
2
)
//
Delete all is used fro truncate
#
define
HTON_HIDDEN
(
1
<<
3
)
//
Engine does not appear in lists
#
define
HTON_FLUSH_AFTER_RENAME
(
1
<<
4
)
#
define
HTON_NOT_USER_SELECTABLE
(
1
<<
5
)
#
define
HTON_TEMPORARY_NOT_SUPPORTED
(
1
<<
6
)
//
Having temporary tables not supported
#
define
HTON_SUPPORT_LOG_TABLES
(
1
<<
7
)
//
Engine supports log tables
#
define
HTON_NO_PARTITION
(
1
<<
8
)
//
You can not partition these tables
#
define
HTON_SUPPORTS_FOREIGN_KEYS
(
1
<<
9
)
//
Foreign key constraint supported.
class
Ha_trx_info
;
struct
THD_TRANS
{
/*
true is not all entries in the ht[] support 2pc
*/
bool
no_2pc;
/*
storage engines that registered in this transaction
*/
Ha_trx_info *ha_list;
/*
The purpose of this flag is to keep track of non-transactional
tables that were modified in scope of:
- transaction, when the variable is a member of
THD::transaction.all
- top-level statement or sub-statement, when the variable is a
member of THD::transaction.stmt
This member has the following life cycle:
* stmt.modified_non_trans_table is used to keep track of
modified non-transactional tables of top-level statements. At
the end of the previous statement and at the beginning of the session,
it is reset to FALSE. If such functions
as mysql_insert, mysql_update, mysql_delete etc modify a
non-transactional table, they set this flag to TRUE. At the
end of the statement, the value of stmt.modified_non_trans_table
is merged with all.modified_non_trans_table and gets reset.
* all.modified_non_trans_table is reset at the end of transaction
* Since we do not have a dedicated context for execution of a
sub-statement, to keep track of non-transactional changes in a
sub-statement, we re-use stmt.modified_non_trans_table.
At entrance into a sub-statement, a copy of the value of
stmt.modified_non_trans_table (containing the changes of the
outer statement) is saved on stack. Then
stmt.modified_non_trans_table is reset to FALSE and the
substatement is executed. Then the new value is merged with the
saved value.
*/
bool
modified_non_trans_table;
void
reset
() { no_2pc=
FALSE
; modified_non_trans_table=
FALSE
; }
bool
is_empty
()
const
{
return
ha_list ==
NULL
; }
};
/*
*
Either statement transaction or normal transaction - related
thread-specific storage engine data.
If a storage engine participates in a statement/transaction,
an instance of this class is present in
thd->transaction.{stmt|all}.ha_list. The addition to
{stmt|all}.ha_list is made by trans_register_ha().
When it's time to commit or rollback, each element of ha_list
is used to access storage engine's prepare()/commit()/rollback()
methods, and also to evaluate if a full two phase commit is
necessary.
@sa General description of transaction handling in handler.cc.
*/
class
Ha_trx_info
{
public:
/*
* Register this storage engine in the given transaction context.
*/
void
register_ha
(
THD_TRANS
*trans, handlerton *ht_arg)
{
DBUG_ASSERT
(m_flags ==
0
);
DBUG_ASSERT
(m_ht ==
NULL
);
DBUG_ASSERT
(m_next ==
NULL
);
m_ht= ht_arg;
m_flags= (
int
)
TRX_READ_ONLY
;
/*
Assume read-only at start.
*/
m_next= trans->
ha_list
;
trans->
ha_list
=
this
;
}
/*
* Clear, prepare for reuse.
*/
void
reset
()
{
m_next=
NULL
;
m_ht=
NULL
;
m_flags=
0
;
}
Ha_trx_info
() {
reset
(); }
void
set_trx_read_write
()
{
DBUG_ASSERT
(
is_started
());
m_flags|= (
int
)
TRX_READ_WRITE
;
}
bool
is_trx_read_write
()
const
{
DBUG_ASSERT
(
is_started
());
return
m_flags & (
int
)
TRX_READ_WRITE
;
}
bool
is_started
()
const
{
return
m_ht !=
NULL
; }
/*
* Mark this transaction read-write if the argument is read-write.
*/
void
coalesce_trx_with
(
const
Ha_trx_info *stmt_trx)
{
/*
Must be called only after the transaction has been started.
Can be called many times, e.g. when we have many
read-write statements in a transaction.
*/
DBUG_ASSERT
(
is_started
());
if
(stmt_trx->
is_trx_read_write
())
set_trx_read_write
();
}
View remainder of file in raw view
Back
|
FazBrowse Home
|
New Git URL