From 59b560e09c77ede8800efab5f0260b6e4af0d7da Mon Sep 17 00:00:00 2001 From: Sunny Bains Date: Tue, 6 Feb 2018 22:00:10 +1100 Subject: [PATCH] Bug#27496251 REMOVE /*====*/ AND CHANGE /****/ /***/ TO /** .... */ --- storage/innobase/api/api0api.cc | 581 +++----- storage/innobase/api/api0misc.cc | 9 +- storage/innobase/arch/arch0arch.cc | 3 +- storage/innobase/arch/arch0log.cc | 3 +- storage/innobase/arch/arch0page.cc | 3 +- storage/innobase/btr/btr0btr.cc | 296 ++-- storage/innobase/btr/btr0bulk.cc | 5 +- storage/innobase/btr/btr0cur.cc | 132 +- storage/innobase/btr/btr0pcur.cc | 68 +- storage/innobase/btr/btr0sea.cc | 5 +- storage/innobase/buf/buf.cc | 5 +- storage/innobase/buf/buf.h | 3 +- storage/innobase/buf/buf0buddy.cc | 49 +- storage/innobase/buf/buf0buf.cc | 197 +-- storage/innobase/buf/buf0dblwr.cc | 77 +- storage/innobase/buf/buf0dump.cc | 41 +- storage/innobase/buf/buf0flu.cc | 136 +- storage/innobase/buf/buf0lru.cc | 88 +- storage/innobase/buf/buf0rea.cc | 9 +- storage/innobase/buf/checksum.cc | 23 +- storage/innobase/clone/clone0api.cc | 5 +- storage/innobase/clone/clone0apply.cc | 3 +- storage/innobase/clone/clone0clone.cc | 3 +- storage/innobase/clone/clone0copy.cc | 3 +- storage/innobase/clone/clone0desc.cc | 5 +- storage/innobase/clone/clone0snapshot.cc | 3 +- storage/innobase/data/data0data.cc | 85 +- storage/innobase/data/data0type.cc | 44 +- storage/innobase/dict/dict.cc | 5 +- storage/innobase/dict/dict.h | 5 +- storage/innobase/dict/dict0boot.cc | 63 +- storage/innobase/dict/dict0crea.cc | 14 +- storage/innobase/dict/dict0dict.cc | 483 ++----- storage/innobase/dict/dict0load.cc | 112 +- storage/innobase/dict/dict0mem.cc | 44 +- storage/innobase/dict/dict0stats.cc | 135 +- storage/innobase/dict/dict0stats_bg.cc | 49 +- storage/innobase/dict/mem.cc | 30 +- storage/innobase/dict/mem.h | 32 +- storage/innobase/eval/eval0eval.cc | 90 +- storage/innobase/eval/eval0proc.cc | 47 +- storage/innobase/fsp/fsp0file.cc | 3 +- storage/innobase/fsp/fsp0fsp.cc | 252 ++-- storage/innobase/fsp/fsp0space.cc | 5 +- storage/innobase/fsp/fsp0sysspace.cc | 5 +- storage/innobase/fts/fts0ast.cc | 117 +- storage/innobase/fts/fts0config.cc | 107 +- storage/innobase/fts/fts0fts.cc | 580 +++----- storage/innobase/fts/fts0opt.cc | 276 +--- storage/innobase/fts/fts0plugin.cc | 44 +- storage/innobase/fts/fts0que.cc | 302 ++-- storage/innobase/fts/fts0sql.cc | 55 +- storage/innobase/fut/fut0lst.cc | 41 +- storage/innobase/gis/gis0geo.cc | 39 +- storage/innobase/gis/gis0rtree.cc | 89 +- storage/innobase/gis/gis0sea.cc | 93 +- storage/innobase/ha/ha0ha.cc | 79 +- storage/innobase/ha/ha0storage.cc | 13 +- storage/innobase/ha/hash0hash.cc | 42 +- storage/innobase/handler/ha_innodb.cc | 1334 ++++++------------ storage/innobase/handler/ha_innodb.h | 4 +- storage/innobase/handler/handler0alter.cc | 199 +-- storage/innobase/handler/i_s.cc | 320 ++--- storage/innobase/handler/i_s.h | 5 +- storage/innobase/handler/p_s.cc | 5 +- storage/innobase/handler/p_s.h | 5 +- storage/innobase/ibuf/ibuf0ibuf.cc | 393 ++---- storage/innobase/include/api0api.h | 448 ++---- storage/innobase/include/api0misc.h | 6 +- storage/innobase/include/arch0arch.h | 3 +- storage/innobase/include/arch0log.h | 3 +- storage/innobase/include/arch0page.h | 5 +- storage/innobase/include/btr0btr.h | 210 +-- storage/innobase/include/btr0btr.ic | 65 +- storage/innobase/include/btr0bulk.h | 5 +- storage/innobase/include/btr0cur.h | 130 +- storage/innobase/include/btr0cur.ic | 63 +- storage/innobase/include/btr0pcur.h | 177 +-- storage/innobase/include/btr0pcur.ic | 125 +- storage/innobase/include/btr0sea.h | 12 +- storage/innobase/include/btr0sea.ic | 24 +- storage/innobase/include/btr0types.h | 5 +- storage/innobase/include/buf0buddy.h | 5 +- storage/innobase/include/buf0buddy.ic | 12 +- storage/innobase/include/buf0buf.h | 272 +--- storage/innobase/include/buf0buf.ic | 231 +-- storage/innobase/include/buf0checksum.h | 23 +- storage/innobase/include/buf0dblwr.h | 40 +- storage/innobase/include/buf0dump.h | 17 +- storage/innobase/include/buf0flu.h | 40 +- storage/innobase/include/buf0flu.ic | 21 +- storage/innobase/include/buf0lru.h | 48 +- storage/innobase/include/buf0lru.ic | 5 +- storage/innobase/include/buf0rea.h | 9 +- storage/innobase/include/buf0stats.h | 5 +- storage/innobase/include/buf0types.h | 5 +- storage/innobase/include/clone0api.h | 5 +- storage/innobase/include/clone0clone.h | 5 +- storage/innobase/include/clone0desc.h | 5 +- storage/innobase/include/clone0monitor.h | 5 +- storage/innobase/include/clone0snapshot.h | 3 +- storage/innobase/include/data0data.h | 194 +-- storage/innobase/include/data0data.ic | 221 +-- storage/innobase/include/data0type.h | 100 +- storage/innobase/include/data0type.ic | 174 +-- storage/innobase/include/data0types.h | 5 +- storage/innobase/include/db0err.h | 3 +- storage/innobase/include/dict0boot.h | 66 +- storage/innobase/include/dict0boot.ic | 28 +- storage/innobase/include/dict0crea.h | 21 +- storage/innobase/include/dict0crea.ic | 15 +- storage/innobase/include/dict0dd.ic | 5 +- storage/innobase/include/dict0dict.h | 482 ++----- storage/innobase/include/dict0dict.ic | 225 +-- storage/innobase/include/dict0load.h | 36 +- storage/innobase/include/dict0load.ic | 5 +- storage/innobase/include/dict0mem.h | 48 +- storage/innobase/include/dict0mem.ic | 9 +- storage/innobase/include/dict0priv.h | 16 +- storage/innobase/include/dict0priv.ic | 16 +- storage/innobase/include/dict0stats.h | 59 +- storage/innobase/include/dict0stats.ic | 33 +- storage/innobase/include/dict0stats_bg.h | 32 +- storage/innobase/include/dict0stats_bg.ic | 12 +- storage/innobase/include/dict0types.h | 5 +- storage/innobase/include/dyn0buf.h | 5 +- storage/innobase/include/dyn0types.h | 5 +- storage/innobase/include/eval0eval.h | 47 +- storage/innobase/include/eval0eval.ic | 79 +- storage/innobase/include/eval0proc.h | 61 +- storage/innobase/include/eval0proc.ic | 19 +- storage/innobase/include/fil0fil.h | 5 +- storage/innobase/include/fil0types.h | 3 +- storage/innobase/include/fsp0file.h | 3 +- storage/innobase/include/fsp0fsp.h | 109 +- storage/innobase/include/fsp0fsp.ic | 18 +- storage/innobase/include/fsp0space.h | 5 +- storage/innobase/include/fsp0sysspace.h | 5 +- storage/innobase/include/fts0ast.h | 74 +- storage/innobase/include/fts0fts.h | 352 ++--- storage/innobase/include/fts0opt.h | 6 +- storage/innobase/include/fts0plugin.h | 20 +- storage/innobase/include/fts0priv.h | 212 +-- storage/innobase/include/fts0priv.ic | 35 +- storage/innobase/include/fts0tokenize.h | 5 +- storage/innobase/include/fts0types.h | 20 +- storage/innobase/include/fts0types.ic | 61 +- storage/innobase/include/fts0vlc.ic | 30 +- storage/innobase/include/fut0fut.h | 5 +- storage/innobase/include/fut0fut.ic | 5 +- storage/innobase/include/fut0lst.h | 21 +- storage/innobase/include/fut0lst.ic | 45 +- storage/innobase/include/gis0geo.h | 16 +- storage/innobase/include/gis0rtree.h | 154 +- storage/innobase/include/gis0rtree.ic | 81 +- storage/innobase/include/gis0type.h | 5 +- storage/innobase/include/ha0ha.h | 59 +- storage/innobase/include/ha0ha.ic | 66 +- storage/innobase/include/ha0storage.h | 39 +- storage/innobase/include/ha0storage.ic | 30 +- storage/innobase/include/ha_prototypes.h | 215 +-- storage/innobase/include/handler0alter.h | 44 +- storage/innobase/include/hash0hash.h | 83 +- storage/innobase/include/hash0hash.ic | 100 +- storage/innobase/include/ib0mutex.h | 3 +- storage/innobase/include/ibuf0ibuf.h | 141 +- storage/innobase/include/ibuf0ibuf.ic | 58 +- storage/innobase/include/ibuf0types.h | 5 +- storage/innobase/include/lock0iter.h | 13 +- storage/innobase/include/lock0lock.h | 350 ++--- storage/innobase/include/lock0lock.ic | 37 +- storage/innobase/include/lock0prdt.h | 84 +- storage/innobase/include/lock0priv.h | 50 +- storage/innobase/include/lock0priv.ic | 119 +- storage/innobase/include/lock0types.h | 3 +- storage/innobase/include/log0ddl.h | 3 +- storage/innobase/include/log0log.h | 146 +- storage/innobase/include/log0log.ic | 144 +- storage/innobase/include/log0recv.h | 5 +- storage/innobase/include/log0recv.ic | 5 +- storage/innobase/include/log0types.h | 5 +- storage/innobase/include/mach0data.h | 35 +- storage/innobase/include/mach0data.ic | 110 +- storage/innobase/include/mem0mem.h | 31 +- storage/innobase/include/mem0mem.ic | 89 +- storage/innobase/include/mtr0log.h | 88 +- storage/innobase/include/mtr0log.ic | 51 +- storage/innobase/include/mtr0mtr.h | 5 +- storage/innobase/include/mtr0mtr.ic | 5 +- storage/innobase/include/mtr0types.h | 5 +- storage/innobase/include/os0atomic.h | 53 +- storage/innobase/include/os0atomic.ic | 33 +- storage/innobase/include/os0event.h | 33 +- storage/innobase/include/os0file.h | 5 +- storage/innobase/include/os0file.ic | 5 +- storage/innobase/include/os0numa.h | 5 +- storage/innobase/include/os0once.h | 5 +- storage/innobase/include/os0proc.h | 5 +- storage/innobase/include/os0proc.ic | 5 +- storage/innobase/include/os0thread-create.h | 5 +- storage/innobase/include/os0thread.h | 5 +- storage/innobase/include/page0cur.h | 108 +- storage/innobase/include/page0cur.ic | 85 +- storage/innobase/include/page0page.h | 439 ++---- storage/innobase/include/page0page.ic | 386 ++--- storage/innobase/include/page0size.h | 5 +- storage/innobase/include/page0types.h | 17 +- storage/innobase/include/page0zip.h | 138 +- storage/innobase/include/page0zip.ic | 79 +- storage/innobase/include/pars0opt.h | 16 +- storage/innobase/include/pars0opt.ic | 5 +- storage/innobase/include/pars0pars.h | 283 ++-- storage/innobase/include/pars0pars.ic | 5 +- storage/innobase/include/pars0sym.h | 61 +- storage/innobase/include/pars0sym.ic | 5 +- storage/innobase/include/pars0types.h | 3 +- storage/innobase/include/que0que.h | 201 +-- storage/innobase/include/que0que.ic | 116 +- storage/innobase/include/que0types.h | 5 +- storage/innobase/include/read0read.h | 5 +- storage/innobase/include/read0types.h | 5 +- storage/innobase/include/rem0cmp.h | 24 +- storage/innobase/include/rem0cmp.ic | 5 +- storage/innobase/include/rem0rec.h | 251 +--- storage/innobase/include/rem0rec.ic | 385 ++--- storage/innobase/include/rem0types.h | 3 +- storage/innobase/include/row0ext.h | 5 +- storage/innobase/include/row0ext.ic | 28 +- storage/innobase/include/row0ftsort.h | 46 +- storage/innobase/include/row0import.h | 9 +- storage/innobase/include/row0import.ic | 5 +- storage/innobase/include/row0ins.h | 36 +- storage/innobase/include/row0ins.ic | 5 +- storage/innobase/include/row0log.h | 63 +- storage/innobase/include/row0log.ic | 16 +- storage/innobase/include/row0merge.h | 100 +- storage/innobase/include/row0mysql.h | 162 +-- storage/innobase/include/row0mysql.ic | 5 +- storage/innobase/include/row0purge.h | 33 +- storage/innobase/include/row0purge.ic | 5 +- storage/innobase/include/row0quiesce.h | 22 +- storage/innobase/include/row0quiesce.ic | 5 +- storage/innobase/include/row0row.h | 155 +- storage/innobase/include/row0row.ic | 25 +- storage/innobase/include/row0sel.h | 53 +- storage/innobase/include/row0sel.ic | 33 +- storage/innobase/include/row0types.h | 5 +- storage/innobase/include/row0uins.h | 14 +- storage/innobase/include/row0uins.ic | 5 +- storage/innobase/include/row0umod.h | 14 +- storage/innobase/include/row0umod.ic | 5 +- storage/innobase/include/row0undo.h | 20 +- storage/innobase/include/row0undo.ic | 5 +- storage/innobase/include/row0upd.h | 120 +- storage/innobase/include/row0upd.ic | 37 +- storage/innobase/include/row0vers.h | 29 +- storage/innobase/include/row0vers.ic | 5 +- storage/innobase/include/sess0sess.h | 5 +- storage/innobase/include/srv0conc.h | 24 +- storage/innobase/include/srv0mon.h | 47 +- storage/innobase/include/srv0mon.ic | 20 +- storage/innobase/include/srv0srv.h | 80 +- storage/innobase/include/srv0srv.ic | 5 +- storage/innobase/include/srv0start.h | 30 +- storage/innobase/include/sync0arr.h | 36 +- storage/innobase/include/sync0arr.ic | 16 +- storage/innobase/include/sync0debug.h | 5 +- storage/innobase/include/sync0policy.h | 5 +- storage/innobase/include/sync0policy.ic | 5 +- storage/innobase/include/sync0rw.h | 135 +- storage/innobase/include/sync0rw.ic | 178 +-- storage/innobase/include/sync0sync.h | 3 +- storage/innobase/include/sync0types.h | 3 +- storage/innobase/include/trx0i_s.h | 94 +- storage/innobase/include/trx0purge.h | 45 +- storage/innobase/include/trx0purge.ic | 16 +- storage/innobase/include/trx0rec.h | 74 +- storage/innobase/include/trx0rec.ic | 25 +- storage/innobase/include/trx0roll.h | 69 +- storage/innobase/include/trx0roll.ic | 9 +- storage/innobase/include/trx0rseg.h | 5 +- storage/innobase/include/trx0rseg.ic | 17 +- storage/innobase/include/trx0sys.h | 73 +- storage/innobase/include/trx0sys.ic | 104 +- storage/innobase/include/trx0trx.h | 260 ++-- storage/innobase/include/trx0trx.ic | 71 +- storage/innobase/include/trx0types.h | 5 +- storage/innobase/include/trx0undo.h | 80 +- storage/innobase/include/trx0undo.ic | 59 +- storage/innobase/include/usr0sess.h | 16 +- storage/innobase/include/usr0sess.ic | 5 +- storage/innobase/include/usr0types.h | 5 +- storage/innobase/include/ut0byte.h | 32 +- storage/innobase/include/ut0byte.ic | 83 +- storage/innobase/include/ut0counter.h | 3 +- storage/innobase/include/ut0crc32.h | 12 +- storage/innobase/include/ut0dbg.h | 9 +- storage/innobase/include/ut0list.h | 47 +- storage/innobase/include/ut0list.ic | 20 +- storage/innobase/include/ut0lock_free_hash.h | 5 +- storage/innobase/include/ut0lst.h | 68 +- storage/innobase/include/ut0mem.h | 17 +- storage/innobase/include/ut0mem.ic | 33 +- storage/innobase/include/ut0mutex.h | 5 +- storage/innobase/include/ut0mutex.ic | 5 +- storage/innobase/include/ut0new.h | 3 +- storage/innobase/include/ut0pool.h | 5 +- storage/innobase/include/ut0rbt.h | 139 +- storage/innobase/include/ut0rnd.h | 52 +- storage/innobase/include/ut0rnd.ic | 54 +- storage/innobase/include/ut0sort.h | 8 +- storage/innobase/include/ut0stage.h | 5 +- storage/innobase/include/ut0ut.h | 118 +- storage/innobase/include/ut0ut.ic | 21 +- storage/innobase/include/ut0vec.h | 48 +- storage/innobase/include/ut0vec.ic | 92 +- storage/innobase/include/ut0wqueue.h | 38 +- storage/innobase/lock/lock0iter.cc | 13 +- storage/innobase/lock/lock0lock.cc | 660 +++------ storage/innobase/lock/lock0prdt.cc | 143 +- storage/innobase/lock/lock0wait.cc | 32 +- storage/innobase/log/log0ddl.cc | 3 +- storage/innobase/log/log0log.cc | 186 +-- storage/innobase/log/log0recv.cc | 5 +- storage/innobase/mach/mach0data.cc | 5 +- storage/innobase/mem/memory.cc | 57 +- storage/innobase/mtr/mtr0log.cc | 88 +- storage/innobase/mtr/mtr0mtr.cc | 5 +- storage/innobase/os/file.cc | 5 +- storage/innobase/os/file.h | 5 +- storage/innobase/os/os0event.cc | 40 +- storage/innobase/os/os0file.cc | 3 +- storage/innobase/os/os0proc.cc | 9 +- storage/innobase/os/os0thread.cc | 5 +- storage/innobase/page/page.ic | 21 +- storage/innobase/page/page0cur.cc | 78 +- storage/innobase/page/page0page.cc | 186 +-- storage/innobase/page/page0zip.cc | 174 +-- storage/innobase/page/zipdecompress.cc | 82 +- storage/innobase/page/zipdecompress.h | 9 +- storage/innobase/page/zipdecompress.ic | 31 +- storage/innobase/pars/pars0opt.cc | 117 +- storage/innobase/pars/pars0pars.cc | 354 ++--- storage/innobase/pars/pars0sym.cc | 61 +- storage/innobase/que/que0que.cc | 151 +- storage/innobase/read/read0read.cc | 5 +- storage/innobase/rem/rec.cc | 26 +- storage/innobase/rem/rec.h | 131 +- storage/innobase/rem/rem0cmp.cc | 47 +- storage/innobase/rem/rem0rec.cc | 165 +-- storage/innobase/row/row0ext.cc | 5 +- storage/innobase/row/row0ftsort.cc | 61 +- storage/innobase/row/row0import.cc | 76 +- storage/innobase/row/row0ins.cc | 175 +-- storage/innobase/row/row0log.cc | 108 +- storage/innobase/row/row0merge.cc | 135 +- storage/innobase/row/row0mysql.cc | 218 +-- storage/innobase/row/row0purge.cc | 68 +- storage/innobase/row/row0quiesce.cc | 54 +- storage/innobase/row/row0row.cc | 143 +- storage/innobase/row/row0sel.cc | 209 +-- storage/innobase/row/row0uins.cc | 46 +- storage/innobase/row/row0umod.cc | 80 +- storage/innobase/row/row0undo.cc | 30 +- storage/innobase/row/row0upd.cc | 204 +-- storage/innobase/row/row0vers.cc | 33 +- storage/innobase/srv/srv0conc.cc | 46 +- storage/innobase/srv/srv0mon.cc | 35 +- storage/innobase/srv/srv0srv.cc | 227 +-- storage/innobase/srv/srv0start.cc | 56 +- storage/innobase/sync/sync0arr.cc | 133 +- storage/innobase/sync/sync0debug.cc | 3 +- storage/innobase/sync/sync0rw.cc | 133 +- storage/innobase/sync/sync0sync.cc | 3 +- storage/innobase/trx/trx0i_s.cc | 151 +- storage/innobase/trx/trx0purge.cc | 111 +- storage/innobase/trx/trx0rec.cc | 95 +- storage/innobase/trx/trx0roll.cc | 137 +- storage/innobase/trx/trx0rseg.cc | 5 +- storage/innobase/trx/trx0sys.cc | 74 +- storage/innobase/trx/trx0trx.cc | 275 ++-- storage/innobase/trx/trx0undo.cc | 159 +-- storage/innobase/usr/usr0sess.cc | 19 +- storage/innobase/ut/crc32.cc | 19 +- storage/innobase/ut/ut.cc | 63 +- storage/innobase/ut/ut.h | 65 +- storage/innobase/ut/ut0dbg.cc | 9 +- storage/innobase/ut/ut0list.cc | 36 +- storage/innobase/ut/ut0mem.cc | 17 +- storage/innobase/ut/ut0new.cc | 3 +- storage/innobase/ut/ut0rbt.cc | 202 +-- storage/innobase/ut/ut0rnd.cc | 12 +- storage/innobase/ut/ut0ut.cc | 98 +- storage/innobase/ut/ut0vec.cc | 10 +- storage/innobase/ut/ut0wqueue.cc | 25 +- 395 files changed, 8700 insertions(+), 19467 deletions(-) diff --git a/storage/innobase/api/api0api.cc b/storage/innobase/api/api0api.cc index 59a590d055c6..5f973c790065 100644 --- a/storage/innobase/api/api0api.cc +++ b/storage/innobase/api/api0api.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2008, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2008, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file api/api0api.cc +/** @file api/api0api.cc InnoDB Native API 2008-08-01 Created Sunny Bains @@ -218,23 +217,19 @@ operation, we only do it every INNOBASE_WAKE_INTERVAL'th step. */ #define INNOBASE_WAKE_INTERVAL 32 -/*****************************************************************/ /** - Check whether the InnoDB persistent cursor is positioned. +/** Check whether the InnoDB persistent cursor is positioned. @return IB_true if positioned */ UNIV_INLINE ib_bool_t ib_btr_cursor_is_positioned( - /*========================*/ btr_pcur_t *pcur) /*!< in: InnoDB persistent cursor */ { return (pcur->old_stored && (pcur->pos_state == BTR_PCUR_IS_POSITIONED || pcur->pos_state == BTR_PCUR_WAS_POSITIONED)); } -/********************************************************************/ /** - Find table using table name. +/** Find table using table name. @return table instance if found */ static dict_table_t *ib_lookup_table_by_name( - /*====================*/ const char *name) /*!< in: table name to lookup */ { dict_table_t *table; @@ -248,15 +243,12 @@ static dict_table_t *ib_lookup_table_by_name( return (table); } -/********************************************************************/ /** - Increments innobase_active_counter and every INNOBASE_WAKE_INTERVALth +/** Increments innobase_active_counter and every INNOBASE_WAKE_INTERVALth time calls srv_active_wake_master_thread. This function should be used when a single database operation may introduce a small need for server utility activity, like checkpointing. */ UNIV_INLINE -void ib_wake_master_thread(void) -/*=======================*/ -{ +void ib_wake_master_thread(void) { static ulint ib_signal_counter = 0; ++ib_signal_counter; @@ -266,10 +258,8 @@ void ib_wake_master_thread(void) } } -/*****************************************************************/ /** - Read the columns from a rec into a tuple. */ +/** Read the columns from a rec into a tuple. */ static ib_err_t ib_read_tuple( - /*==========*/ const rec_t *rec, /*!< in: Record to read */ ib_bool_t page_format, /*!< in: IB_TRUE if compressed format */ ib_tuple_t *tuple, /*!< in: tuple to read into */ @@ -395,11 +385,9 @@ static ib_err_t ib_read_tuple( return (DB_SUCCESS); } -/*****************************************************************/ /** - Create an InnoDB key tuple. +/** Create an InnoDB key tuple. @return tuple instance created, or NULL */ static ib_tpl_t ib_key_tuple_new_low( - /*=================*/ const dict_index_t *index, /*!< in: index for which tuple required */ ulint n_cols, /*!< in: no. of user defined cols */ @@ -444,11 +432,9 @@ static ib_tpl_t ib_key_tuple_new_low( return ((ib_tpl_t)tuple); } -/*****************************************************************/ /** - Create an InnoDB key tuple. +/** Create an InnoDB key tuple. @return tuple instance created, or NULL */ static ib_tpl_t ib_key_tuple_new( - /*=============*/ const dict_index_t *index, /*!< in: index of tuple */ ulint n_cols) /*!< in: no. of user defined cols */ { @@ -463,11 +449,9 @@ static ib_tpl_t ib_key_tuple_new( return (ib_key_tuple_new_low(index, n_cols, heap)); } -/*****************************************************************/ /** - Create an InnoDB row tuple. +/** Create an InnoDB row tuple. @return tuple instance, or NULL */ static ib_tpl_t ib_row_tuple_new_low( - /*=================*/ const dict_index_t *index, /*!< in: index of tuple */ ulint n_cols, /*!< in: no. of cols in tuple */ mem_heap_t *heap) /*!< in: memory heap */ @@ -493,11 +477,9 @@ static ib_tpl_t ib_row_tuple_new_low( return ((ib_tpl_t)tuple); } -/*****************************************************************/ /** - Create an InnoDB row tuple. +/** Create an InnoDB row tuple. @return tuple instance, or NULL */ static ib_tpl_t ib_row_tuple_new( - /*=============*/ const dict_index_t *index, /*!< in: index of tuple */ ulint n_cols) /*!< in: no. of cols in tuple */ { @@ -512,11 +494,9 @@ static ib_tpl_t ib_row_tuple_new( return (ib_row_tuple_new_low(index, n_cols, heap)); } -/*****************************************************************/ /** - Begin a transaction. +/** Begin a transaction. @return innobase txn handle */ ib_err_t ib_trx_start( - /*=========*/ ib_trx_t ib_trx, /*!< in: transaction to restart */ ib_trx_level_t ib_trx_level, /*!< in: trx isolation level */ ib_bool_t read_write, /*!< in: true if read write @@ -545,12 +525,10 @@ ib_err_t ib_trx_start( return (err); } -/*****************************************************************/ /** - Begin a transaction. This will allocate a new transaction handle. +/** Begin a transaction. This will allocate a new transaction handle. put the transaction in the active state. @return innobase txn handle */ ib_trx_t ib_trx_begin( - /*=========*/ ib_trx_level_t ib_trx_level, /*!< in: trx isolation level */ ib_bool_t read_write, /*!< in: true if read write transaction */ @@ -570,33 +548,24 @@ ib_trx_t ib_trx_begin( return (static_cast(trx)); } -/*****************************************************************/ /** - Check if transaction is read_only +/** Check if transaction is read_only @return transaction read_only status */ -ib_u32_t ib_trx_read_only( - /*=============*/ - ib_trx_t ib_trx) /*!< in: trx handle */ +ib_u32_t ib_trx_read_only(ib_trx_t ib_trx) /*!< in: trx handle */ { trx_t *trx = (trx_t *)ib_trx; return (trx->read_only); } -/*****************************************************************/ /** - Get a trx start time. +/** Get a trx start time. @return trx start_time */ -ib_u64_t ib_trx_get_start_time( - /*==================*/ - ib_trx_t ib_trx) /*!< in: transaction */ +ib_u64_t ib_trx_get_start_time(ib_trx_t ib_trx) /*!< in: transaction */ { trx_t *trx = (trx_t *)ib_trx; return (static_cast(trx->start_time)); } -/*****************************************************************/ /** - Release the resources of the transaction. +/** Release the resources of the transaction. @return DB_SUCCESS or err code */ -ib_err_t ib_trx_release( - /*===========*/ - ib_trx_t ib_trx) /*!< in: trx handle */ +ib_err_t ib_trx_release(ib_trx_t ib_trx) /*!< in: trx handle */ { trx_t *trx = (trx_t *)ib_trx; @@ -606,13 +575,10 @@ ib_err_t ib_trx_release( return (DB_SUCCESS); } -/*****************************************************************/ /** - Commit a transaction. This function will also release the schema +/** Commit a transaction. This function will also release the schema latches too. @return DB_SUCCESS or err code */ -ib_err_t ib_trx_commit( - /*==========*/ - ib_trx_t ib_trx) /*!< in: trx handle */ +ib_err_t ib_trx_commit(ib_trx_t ib_trx) /*!< in: trx handle */ { ib_err_t err = DB_SUCCESS; trx_t *trx = reinterpret_cast(ib_trx); @@ -626,13 +592,10 @@ ib_err_t ib_trx_commit( return (DB_SUCCESS); } -/*****************************************************************/ /** - Rollback a transaction. This function will also release the schema +/** Rollback a transaction. This function will also release the schema latches too. @return DB_SUCCESS or err code */ -ib_err_t ib_trx_rollback( - /*============*/ - ib_trx_t ib_trx) /*!< in: trx handle */ +ib_err_t ib_trx_rollback(ib_trx_t ib_trx) /*!< in: trx handle */ { ib_err_t err; trx_t *trx = (trx_t *)ib_trx; @@ -646,11 +609,8 @@ ib_err_t ib_trx_rollback( } #ifdef _WIN32 -/*****************************************************************/ /** - Convert a string to lower case. */ -static void ib_to_lower_case( - /*=============*/ - char *ptr) /*!< string to convert to lower case */ +/** Convert a string to lower case. */ +static void ib_to_lower_case(char *ptr) /*!< string to convert to lower case */ { while (*ptr) { *ptr = tolower(*ptr); @@ -659,8 +619,7 @@ static void ib_to_lower_case( } #endif /* _WIN32 */ -/*****************************************************************/ /** - Normalizes a table name string. A normalized name consists of the +/** Normalizes a table name string. A normalized name consists of the database name catenated to '/' and table name. An example: test/mytable. On Windows normalization puts both the database name and the table name always to lower case. This function can be called for system @@ -669,7 +628,6 @@ static void ib_to_lower_case( The assumption is that they are system tables that reside in the system table space. */ static void ib_normalize_table_name( - /*====================*/ char *norm_name, /*!< out: normalized name as a null-terminated string */ const char *name) /*!< in: table name string */ @@ -713,11 +671,9 @@ static void ib_normalize_table_name( } } -/*****************************************************************/ /** - Get a table id. The caller must have acquired the dictionary mutex. +/** Get a table id. The caller must have acquired the dictionary mutex. @return DB_SUCCESS if found */ static ib_err_t ib_table_get_id_low( - /*================*/ const char *table_name, /*!< in: table to find */ ib_id_u64_t *table_id) /*!< out: table id if found */ { @@ -737,15 +693,12 @@ static ib_err_t ib_table_get_id_low( return (err); } -/*****************************************************************/ /** - Create an internal cursor instance. +/** Create an internal cursor instance. @return DB_SUCCESS or err code */ -static ib_err_t ib_create_cursor( - /*=============*/ - ib_crsr_t *ib_crsr, /*!< out: InnoDB cursor */ - dict_table_t *table, /*!< in: table instance */ - dict_index_t *index, /*!< in: index to use */ - trx_t *trx) /*!< in: transaction */ +static ib_err_t ib_create_cursor(ib_crsr_t *ib_crsr, /*!< out: InnoDB cursor */ + dict_table_t *table, /*!< in: table instance */ + dict_index_t *index, /*!< in: index to use */ + trx_t *trx) /*!< in: transaction */ { mem_heap_t *heap; ib_cursor_t *cursor; @@ -816,11 +769,9 @@ static ib_err_t ib_create_cursor_with_clust_index(ib_crsr_t *ib_crsr, return (ib_create_cursor(ib_crsr, table, index, trx)); } -/*****************************************************************/ /** - Open an InnoDB secondary index cursor and return a cursor handle to it. +/** Open an InnoDB secondary index cursor and return a cursor handle to it. @return DB_SUCCESS or err code */ ib_err_t ib_cursor_open_index_using_name( - /*============================*/ ib_crsr_t ib_open_crsr, /*!< in: open/active cursor */ const char *index_name, /*!< in: secondary index name */ ib_crsr_t *ib_crsr, /*!< out,own: InnoDB index cursor */ @@ -883,11 +834,9 @@ ib_err_t ib_cursor_open_index_using_name( return (err); } -/*****************************************************************/ /** - Open an InnoDB table and return a cursor handle to it. +/** Open an InnoDB table and return a cursor handle to it. @return DB_SUCCESS or err code */ ib_err_t ib_cursor_open_table( - /*=================*/ const char *name, /*!< in: table name */ ib_trx_t ib_trx, /*!< in: Current transaction handle can be NULL */ @@ -941,10 +890,8 @@ ib_bool_t ib_is_virtual_table(ib_crsr_t crsr) { return (crsr->prebuilt->table->n_v_cols > 0); } -/********************************************************************/ /** - Free a context struct for a table handle. */ +/** Free a context struct for a table handle. */ static void ib_qry_proc_free( - /*=============*/ ib_qry_proc_t *q_proc) /*!< in, own: qproc struct */ { que_graph_free_recursive(q_proc->grph.ins); @@ -954,12 +901,9 @@ static void ib_qry_proc_free( memset(q_proc, 0x0, sizeof(*q_proc)); } -/*****************************************************************/ /** - Reset the cursor. +/** Reset the cursor. @return DB_SUCCESS or err code */ -ib_err_t ib_cursor_reset( - /*============*/ - ib_crsr_t ib_crsr) /*!< in/out: InnoDB cursor */ +ib_err_t ib_cursor_reset(ib_crsr_t ib_crsr) /*!< in/out: InnoDB cursor */ { ib_cursor_t *cursor = (ib_cursor_t *)ib_crsr; row_prebuilt_t *prebuilt = cursor->prebuilt; @@ -978,13 +922,10 @@ ib_err_t ib_cursor_reset( return (DB_SUCCESS); } -/*****************************************************************/ /** - update the cursor with new transactions and also reset the cursor +/** update the cursor with new transactions and also reset the cursor @return DB_SUCCESS or err code */ -ib_err_t ib_cursor_new_trx( - /*==============*/ - ib_crsr_t ib_crsr, /*!< in/out: InnoDB cursor */ - ib_trx_t ib_trx) /*!< in: transaction */ +ib_err_t ib_cursor_new_trx(ib_crsr_t ib_crsr, /*!< in/out: InnoDB cursor */ + ib_trx_t ib_trx) /*!< in: transaction */ { ib_err_t err = DB_SUCCESS; ib_cursor_t *cursor = (ib_cursor_t *)ib_crsr; @@ -1005,13 +946,10 @@ ib_err_t ib_cursor_new_trx( return (err); } -/*****************************************************************/ /** - Commit the transaction in a cursor +/** Commit the transaction in a cursor @return DB_SUCCESS or err code */ -ib_err_t ib_cursor_commit_trx( - /*=================*/ - ib_crsr_t ib_crsr, /*!< in/out: InnoDB cursor */ - ib_trx_t ib_trx) /*!< in: transaction */ +ib_err_t ib_cursor_commit_trx(ib_crsr_t ib_crsr, /*!< in/out: InnoDB cursor */ + ib_trx_t ib_trx) /*!< in: transaction */ { ib_err_t err = DB_SUCCESS; ib_cursor_t *cursor = (ib_cursor_t *)ib_crsr; @@ -1025,12 +963,9 @@ ib_err_t ib_cursor_commit_trx( return (err); } -/*****************************************************************/ /** - Close an InnoDB table and free the cursor. +/** Close an InnoDB table and free the cursor. @return DB_SUCCESS or err code */ -ib_err_t ib_cursor_close( - /*============*/ - ib_crsr_t ib_crsr) /*!< in,own: InnoDB cursor */ +ib_err_t ib_cursor_close(ib_crsr_t ib_crsr) /*!< in,own: InnoDB cursor */ { ib_cursor_t *cursor = (ib_cursor_t *)ib_crsr; row_prebuilt_t *prebuilt; @@ -1063,12 +998,10 @@ ib_err_t ib_cursor_close( return (DB_SUCCESS); } -/**********************************************************************/ /** - Run the insert query and do error handling. +/** Run the insert query and do error handling. @return DB_SUCCESS or error code */ UNIV_INLINE ib_err_t ib_insert_row_with_lock_retry( - /*==========================*/ que_thr_t *thr, /*!< in: insert query graph */ ins_node_t *node, /*!< in: insert node for the query */ trx_savept_t *savept) /*!< in: savepoint to rollback to @@ -1105,11 +1038,9 @@ ib_err_t ib_insert_row_with_lock_retry( return (err); } -/*****************************************************************/ /** - Write a row. +/** Write a row. @return DB_SUCCESS or err code */ static ib_err_t ib_execute_insert_query_graph( - /*==========================*/ dict_table_t *table, /*!< in: table where to insert */ que_fork_t *ins_graph, /*!< in: query graph */ ins_node_t *node) /*!< in: insert node */ @@ -1142,10 +1073,8 @@ static ib_err_t ib_execute_insert_query_graph( return (err); } -/*****************************************************************/ /** - Create an insert query graph node. */ +/** Create an insert query graph node. */ static void ib_insert_query_graph_create( - /*==========================*/ ib_cursor_t *cursor) /*!< in: Cursor instance */ { ib_qry_proc_t *q_proc = &cursor->q_proc; @@ -1179,11 +1108,9 @@ static void ib_insert_query_graph_create( } } -/*****************************************************************/ /** - Insert a row to a table. +/** Insert a row to a table. @return DB_SUCCESS or err code */ ib_err_t ib_cursor_insert_row( - /*=================*/ ib_crsr_t ib_crsr, /*!< in/out: InnoDB cursor instance */ const ib_tpl_t ib_tpl) /*!< in: tuple to insert */ { @@ -1253,13 +1180,10 @@ ib_err_t ib_cursor_insert_row( return (err); } -/*********************************************************************/ /** - Gets pointer to a prebuilt update vector used in updates. +/** Gets pointer to a prebuilt update vector used in updates. @return update vector */ UNIV_INLINE -upd_t *ib_update_vector_create( - /*====================*/ - ib_cursor_t *cursor) /*!< in: current cursor */ +upd_t *ib_update_vector_create(ib_cursor_t *cursor) /*!< in: current cursor */ { trx_t *trx = cursor->prebuilt->trx; mem_heap_t *heap = cursor->query_heap; @@ -1285,10 +1209,8 @@ upd_t *ib_update_vector_create( return (node->upd->update); } -/**********************************************************************/ /** - Note that a column has changed. */ +/** Note that a column has changed. */ static void ib_update_col( - /*==========*/ ib_cursor_t *cursor, /*!< in: current cursor */ upd_field_t *upd_field, /*!< in/out: update field */ @@ -1314,12 +1236,10 @@ static void ib_update_col( upd_field->field_no = dict_col_get_clust_pos(&table->cols[col_no], index); } -/**********************************************************************/ /** - Checks which fields have changed in a row and stores the new data +/** Checks which fields have changed in a row and stores the new data to an update vector. @return DB_SUCCESS or err code */ static ib_err_t ib_calc_diff( - /*=========*/ ib_cursor_t *cursor, /*!< in: current cursor */ upd_t *upd, /*!< in/out: update vector */ const ib_tuple_t *old_tuple, /*!< in: Old tuple in table */ @@ -1376,12 +1296,10 @@ static ib_err_t ib_calc_diff( return (err); } -/**********************************************************************/ /** - Run the update query and do error handling. +/** Run the update query and do error handling. @return DB_SUCCESS or error code */ UNIV_INLINE ib_err_t ib_update_row_with_lock_retry( - /*==========================*/ que_thr_t *thr, /*!< in: Update query graph */ upd_node_t *node, /*!< in: Update node for the query */ trx_savept_t *savept) /*!< in: savepoint to rollback to @@ -1425,12 +1343,10 @@ ib_err_t ib_update_row_with_lock_retry( return (err); } -/*********************************************************************/ /** - Does an update or delete of a row. +/** Does an update or delete of a row. @return DB_SUCCESS or err code */ UNIV_INLINE ib_err_t ib_execute_update_query_graph( - /*==========================*/ ib_cursor_t *cursor, /*!< in: Cursor instance */ btr_pcur_t *pcur) /*!< in: Btree persistent cursor */ { @@ -1482,11 +1398,9 @@ ib_err_t ib_execute_update_query_graph( return (err); } -/*****************************************************************/ /** - Update a row in a table. +/** Update a row in a table. @return DB_SUCCESS or err code */ ib_err_t ib_cursor_update_row( - /*=================*/ ib_crsr_t ib_crsr, /*!< in: InnoDB cursor instance */ const ib_tpl_t ib_old_tpl, /*!< in: Old tuple in table */ const ib_tpl_t ib_new_tpl) /*!< in: New tuple to update */ @@ -1526,11 +1440,9 @@ ib_err_t ib_cursor_update_row( return (err); } -/**********************************************************************/ /** - Build the update query graph to delete a row from an index. +/** Build the update query graph to delete a row from an index. @return DB_SUCCESS or err code */ static ib_err_t ib_delete_row( - /*==========*/ ib_cursor_t *cursor, /*!< in: current cursor */ btr_pcur_t *pcur, /*!< in: Btree persistent cursor */ const rec_t *rec) /*!< in: record to delete */ @@ -1590,11 +1502,9 @@ static ib_err_t ib_delete_row( return (err); } -/*****************************************************************/ /** - Delete a row in a table. +/** Delete a row in a table. @return DB_SUCCESS or err code */ ib_err_t ib_cursor_delete_row( - /*=================*/ ib_crsr_t ib_crsr) /*!< in: InnoDB cursor instance */ { ib_err_t err; @@ -1660,11 +1570,9 @@ ib_err_t ib_cursor_delete_row( return (err); } -/*****************************************************************/ /** - Read current row. +/** Read current row. @return DB_SUCCESS or err code */ ib_err_t ib_cursor_read_row( - /*===============*/ ib_crsr_t ib_crsr, /*!< in: InnoDB cursor instance */ ib_tpl_t ib_tpl, /*!< out: read cols into this tuple */ ib_tpl_t cmp_tpl, /*!< in: tuple to compare and stop @@ -1735,12 +1643,10 @@ ib_err_t ib_cursor_read_row( return (err); } -/*****************************************************************/ /** - Move cursor to the first record in the table. +/** Move cursor to the first record in the table. @return DB_SUCCESS or err code */ UNIV_INLINE ib_err_t ib_cursor_position( - /*===============*/ ib_cursor_t *cursor, /*!< in: InnoDB cursor instance */ ib_srch_mode_t mode) /*!< in: Search mode */ { @@ -1765,24 +1671,18 @@ ib_err_t ib_cursor_position( return (err); } -/*****************************************************************/ /** - Move cursor to the first record in the table. +/** Move cursor to the first record in the table. @return DB_SUCCESS or err code */ -ib_err_t ib_cursor_first( - /*============*/ - ib_crsr_t ib_crsr) /*!< in: InnoDB cursor instance */ +ib_err_t ib_cursor_first(ib_crsr_t ib_crsr) /*!< in: InnoDB cursor instance */ { ib_cursor_t *cursor = (ib_cursor_t *)ib_crsr; return (ib_cursor_position(cursor, IB_CUR_G)); } -/*****************************************************************/ /** - Move cursor to the next user record in the table. +/** Move cursor to the next user record in the table. @return DB_SUCCESS or err code */ -ib_err_t ib_cursor_next( - /*===========*/ - ib_crsr_t ib_crsr) /*!< in: InnoDB cursor instance */ +ib_err_t ib_cursor_next(ib_crsr_t ib_crsr) /*!< in: InnoDB cursor instance */ { ib_err_t err; ib_cursor_t *cursor = (ib_cursor_t *)ib_crsr; @@ -1801,15 +1701,12 @@ ib_err_t ib_cursor_next( return (err); } -/*****************************************************************/ /** - Search for key. +/** Search for key. @return DB_SUCCESS or err code */ -ib_err_t ib_cursor_moveto( - /*=============*/ - ib_crsr_t ib_crsr, /*!< in: InnoDB cursor instance */ - ib_tpl_t ib_tpl, /*!< in: Key to search for */ - ib_srch_mode_t ib_srch_mode, /*!< in: search mode */ - ib_ulint_t direction) /*!< in: search direction */ +ib_err_t ib_cursor_moveto(ib_crsr_t ib_crsr, /*!< in: InnoDB cursor instance */ + ib_tpl_t ib_tpl, /*!< in: Key to search for */ + ib_srch_mode_t ib_srch_mode, /*!< in: search mode */ + ib_ulint_t direction) /*!< in: search direction */ { ulint i; ulint n_fields; @@ -1855,10 +1752,8 @@ ib_err_t ib_cursor_moveto( return (err); } -/*****************************************************************/ /** - Set the cursor search mode. */ +/** Set the cursor search mode. */ void ib_cursor_set_match_mode( - /*=====================*/ ib_crsr_t ib_crsr, /*!< in: Cursor instance */ ib_match_mode_t match_mode) /*!< in: ib_cursor_moveto match mode */ { @@ -1867,14 +1762,11 @@ void ib_cursor_set_match_mode( cursor->match_mode = match_mode; } -/*****************************************************************/ /** - Get the dfield instance for the column in the tuple. +/** Get the dfield instance for the column in the tuple. @return dfield instance in tuple */ UNIV_INLINE -dfield_t *ib_col_get_dfield( - /*==============*/ - ib_tuple_t *tuple, /*!< in: tuple instance */ - ulint col_no) /*!< in: col no. in tuple */ +dfield_t *ib_col_get_dfield(ib_tuple_t *tuple, /*!< in: tuple instance */ + ulint col_no) /*!< in: col no. in tuple */ { dfield_t *dfield; @@ -1883,13 +1775,10 @@ dfield_t *ib_col_get_dfield( return (dfield); } -/*****************************************************************/ /** - Predicate to check whether a column type contains variable length data. +/** Predicate to check whether a column type contains variable length data. @return DB_SUCCESS or error code */ UNIV_INLINE -ib_err_t ib_col_is_capped( - /*==============*/ - const dtype_t *dtype) /*!< in: column type */ +ib_err_t ib_col_is_capped(const dtype_t *dtype) /*!< in: column type */ { return (static_cast((dtype_get_mtype(dtype) == DATA_VARCHAR || dtype_get_mtype(dtype) == DATA_CHAR || @@ -1901,16 +1790,13 @@ ib_err_t ib_col_is_capped( dtype_get_len(dtype) > 0)); } -/*****************************************************************/ /** - Set a column of the tuple. Make a copy using the tuple's heap. +/** Set a column of the tuple. Make a copy using the tuple's heap. @return DB_SUCCESS or error code */ -ib_err_t ib_col_set_value( - /*=============*/ - ib_tpl_t ib_tpl, /*!< in: tuple instance */ - ib_ulint_t col_no, /*!< in: column index in tuple */ - const void *src, /*!< in: data value */ - ib_ulint_t len, /*!< in: data value len */ - ib_bool_t need_cpy) /*!< in: if need memcpy */ +ib_err_t ib_col_set_value(ib_tpl_t ib_tpl, /*!< in: tuple instance */ + ib_ulint_t col_no, /*!< in: column index in tuple */ + const void *src, /*!< in: data value */ + ib_ulint_t len, /*!< in: data value len */ + ib_bool_t need_cpy) /*!< in: if need memcpy */ { const dtype_t *dtype; dfield_t *dfield; @@ -2087,13 +1973,10 @@ ib_err_t ib_col_set_value( return (DB_SUCCESS); } -/*****************************************************************/ /** - Get the size of the data available in a column of the tuple. +/** Get the size of the data available in a column of the tuple. @return bytes avail or IB_SQL_NULL */ -ib_ulint_t ib_col_get_len( - /*===========*/ - ib_tpl_t ib_tpl, /*!< in: tuple instance */ - ib_ulint_t i) /*!< in: column index in tuple */ +ib_ulint_t ib_col_get_len(ib_tpl_t ib_tpl, /*!< in: tuple instance */ + ib_ulint_t i) /*!< in: column index in tuple */ { const dfield_t *dfield; ulint data_len; @@ -2107,12 +1990,10 @@ ib_ulint_t ib_col_get_len( : data_len)); } -/*****************************************************************/ /** - Copy a column value from the tuple. +/** Copy a column value from the tuple. @return bytes copied or IB_SQL_NULL */ UNIV_INLINE ib_ulint_t ib_col_copy_value_low( - /*==================*/ ib_tpl_t ib_tpl, /*!< in: tuple instance */ ib_ulint_t i, /*!< in: column index in tuple */ void *dst, /*!< out: copied data value */ @@ -2199,11 +2080,9 @@ ib_ulint_t ib_col_copy_value_low( return (static_cast(data_len)); } -/*****************************************************************/ /** - Copy a column value from the tuple. +/** Copy a column value from the tuple. @return bytes copied or IB_SQL_NULL */ ib_ulint_t ib_col_copy_value( - /*==============*/ ib_tpl_t ib_tpl, /*!< in: tuple instance */ ib_ulint_t i, /*!< in: column index in tuple */ void *dst, /*!< out: copied data value */ @@ -2212,13 +2091,10 @@ ib_ulint_t ib_col_copy_value( return (ib_col_copy_value_low(ib_tpl, i, dst, len)); } -/*****************************************************************/ /** - Get the InnoDB column attribute from the internal column precise type. +/** Get the InnoDB column attribute from the internal column precise type. @return precise type in api format */ UNIV_INLINE -ib_col_attr_t ib_col_get_attr( - /*============*/ - ulint prtype) /*!< in: column definition */ +ib_col_attr_t ib_col_get_attr(ulint prtype) /*!< in: column definition */ { ib_col_attr_t attr = IB_COL_NONE; @@ -2233,11 +2109,9 @@ ib_col_attr_t ib_col_get_attr( return (attr); } -/*****************************************************************/ /** - Get a column name from the tuple. +/** Get a column name from the tuple. @return name of the column */ const char *ib_col_get_name( - /*============*/ ib_crsr_t ib_crsr, /*!< in: InnoDB cursor instance */ ib_ulint_t i) /*!< in: column index in tuple */ { @@ -2252,11 +2126,9 @@ const char *ib_col_get_name( return (name); } -/*****************************************************************/ /** - Get an index field name from the cursor. +/** Get an index field name from the cursor. @return name of the field */ const char *ib_get_idx_field_name( - /*==================*/ ib_crsr_t ib_crsr, /*!< in: InnoDB cursor instance */ ib_ulint_t i) /*!< in: column index in tuple */ { @@ -2275,12 +2147,10 @@ const char *ib_get_idx_field_name( return (NULL); } -/*****************************************************************/ /** - Get a column type, length and attributes from the tuple. +/** Get a column type, length and attributes from the tuple. @return len of column data */ UNIV_INLINE ib_ulint_t ib_col_get_meta_low( - /*================*/ ib_tpl_t ib_tpl, /*!< in: tuple instance */ ib_ulint_t i, /*!< in: column index in tuple */ ib_col_meta_t *ib_col_meta) /*!< out: column meta data */ @@ -2309,15 +2179,12 @@ ib_ulint_t ib_col_get_meta_low( return (static_cast(data_len)); } -/*************************************************************/ /** - Read a signed int 8 bit column from an InnoDB tuple. */ +/** Read a signed int 8 bit column from an InnoDB tuple. */ UNIV_INLINE -ib_err_t ib_tuple_check_int( - /*===============*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t i, /*!< in: column number */ - ib_bool_t usign, /*!< in: true if unsigned */ - ulint size) /*!< in: size of integer */ +ib_err_t ib_tuple_check_int(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t i, /*!< in: column number */ + ib_bool_t usign, /*!< in: true if unsigned */ + ulint size) /*!< in: size of integer */ { ib_col_meta_t ib_col_meta; @@ -2336,14 +2203,11 @@ ib_err_t ib_tuple_check_int( return (DB_SUCCESS); } -/*************************************************************/ /** - Read a signed int 8 bit column from an InnoDB tuple. +/** Read a signed int 8 bit column from an InnoDB tuple. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_read_i8( - /*=============*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t i, /*!< in: column number */ - ib_i8_t *ival) /*!< out: integer value */ +ib_err_t ib_tuple_read_i8(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t i, /*!< in: column number */ + ib_i8_t *ival) /*!< out: integer value */ { ib_err_t err; @@ -2356,14 +2220,11 @@ ib_err_t ib_tuple_read_i8( return (err); } -/*************************************************************/ /** - Read an unsigned int 8 bit column from an InnoDB tuple. +/** Read an unsigned int 8 bit column from an InnoDB tuple. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_read_u8( - /*=============*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t i, /*!< in: column number */ - ib_u8_t *ival) /*!< out: integer value */ +ib_err_t ib_tuple_read_u8(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t i, /*!< in: column number */ + ib_u8_t *ival) /*!< out: integer value */ { ib_err_t err; @@ -2376,14 +2237,11 @@ ib_err_t ib_tuple_read_u8( return (err); } -/*************************************************************/ /** - Read a signed int 16 bit column from an InnoDB tuple. +/** Read a signed int 16 bit column from an InnoDB tuple. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_read_i16( - /*==============*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t i, /*!< in: column number */ - ib_i16_t *ival) /*!< out: integer value */ +ib_err_t ib_tuple_read_i16(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t i, /*!< in: column number */ + ib_i16_t *ival) /*!< out: integer value */ { ib_err_t err; @@ -2396,14 +2254,11 @@ ib_err_t ib_tuple_read_i16( return (err); } -/*************************************************************/ /** - Read an unsigned int 16 bit column from an InnoDB tuple. +/** Read an unsigned int 16 bit column from an InnoDB tuple. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_read_u16( - /*==============*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t i, /*!< in: column number */ - ib_u16_t *ival) /*!< out: integer value */ +ib_err_t ib_tuple_read_u16(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t i, /*!< in: column number */ + ib_u16_t *ival) /*!< out: integer value */ { ib_err_t err; @@ -2416,14 +2271,11 @@ ib_err_t ib_tuple_read_u16( return (err); } -/*************************************************************/ /** - Read a signed int 32 bit column from an InnoDB tuple. +/** Read a signed int 32 bit column from an InnoDB tuple. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_read_i32( - /*==============*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t i, /*!< in: column number */ - ib_i32_t *ival) /*!< out: integer value */ +ib_err_t ib_tuple_read_i32(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t i, /*!< in: column number */ + ib_i32_t *ival) /*!< out: integer value */ { ib_err_t err; @@ -2436,14 +2288,11 @@ ib_err_t ib_tuple_read_i32( return (err); } -/*************************************************************/ /** - Read an unsigned int 32 bit column from an InnoDB tuple. +/** Read an unsigned int 32 bit column from an InnoDB tuple. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_read_u32( - /*==============*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t i, /*!< in: column number */ - ib_u32_t *ival) /*!< out: integer value */ +ib_err_t ib_tuple_read_u32(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t i, /*!< in: column number */ + ib_u32_t *ival) /*!< out: integer value */ { ib_err_t err; @@ -2456,14 +2305,11 @@ ib_err_t ib_tuple_read_u32( return (err); } -/*************************************************************/ /** - Read a signed int 64 bit column from an InnoDB tuple. +/** Read a signed int 64 bit column from an InnoDB tuple. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_read_i64( - /*==============*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t i, /*!< in: column number */ - ib_i64_t *ival) /*!< out: integer value */ +ib_err_t ib_tuple_read_i64(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t i, /*!< in: column number */ + ib_i64_t *ival) /*!< out: integer value */ { ib_err_t err; @@ -2476,14 +2322,11 @@ ib_err_t ib_tuple_read_i64( return (err); } -/*************************************************************/ /** - Read an unsigned int 64 bit column from an InnoDB tuple. +/** Read an unsigned int 64 bit column from an InnoDB tuple. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_read_u64( - /*==============*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t i, /*!< in: column number */ - ib_u64_t *ival) /*!< out: integer value */ +ib_err_t ib_tuple_read_u64(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t i, /*!< in: column number */ + ib_u64_t *ival) /*!< out: integer value */ { ib_err_t err; @@ -2496,13 +2339,10 @@ ib_err_t ib_tuple_read_u64( return (err); } -/*****************************************************************/ /** - Get a column value pointer from the tuple. +/** Get a column value pointer from the tuple. @return NULL or pointer to buffer */ -const void *ib_col_get_value( - /*=============*/ - ib_tpl_t ib_tpl, /*!< in: tuple instance */ - ib_ulint_t i) /*!< in: column index in tuple */ +const void *ib_col_get_value(ib_tpl_t ib_tpl, /*!< in: tuple instance */ + ib_ulint_t i) /*!< in: column index in tuple */ { const void *data; const dfield_t *dfield; @@ -2517,11 +2357,9 @@ const void *ib_col_get_value( return (data_len != UNIV_SQL_NULL ? data : NULL); } -/*****************************************************************/ /** - Get a column type, length and attributes from the tuple. +/** Get a column type, length and attributes from the tuple. @return len of column data */ ib_ulint_t ib_col_get_meta( - /*============*/ ib_tpl_t ib_tpl, /*!< in: tuple instance */ ib_ulint_t i, /*!< in: column index in tuple */ ib_col_meta_t *ib_col_meta) /*!< out: column meta data */ @@ -2529,12 +2367,9 @@ ib_ulint_t ib_col_get_meta( return (ib_col_get_meta_low(ib_tpl, i, ib_col_meta)); } -/*****************************************************************/ /** - "Clear" or reset an InnoDB tuple. We free the heap and recreate the tuple. +/** "Clear" or reset an InnoDB tuple. We free the heap and recreate the tuple. @return new tuple, or NULL */ -ib_tpl_t ib_tuple_clear( - /*============*/ - ib_tpl_t ib_tpl) /*!< in,own: tuple (will be freed) */ +ib_tpl_t ib_tuple_clear(ib_tpl_t ib_tpl) /*!< in,own: tuple (will be freed) */ { const dict_index_t *index; ulint n_cols; @@ -2554,13 +2389,11 @@ ib_tpl_t ib_tuple_clear( } } -/*****************************************************************/ /** - Create a new cluster key search tuple and copy the contents of the +/** Create a new cluster key search tuple and copy the contents of the secondary index key tuple columns that refer to the cluster index record to the cluster key. It does a deep copy of the column data. @return DB_SUCCESS or error code */ ib_err_t ib_tuple_get_cluster_key( - /*=====================*/ ib_crsr_t ib_crsr, /*!< in: secondary index cursor */ ib_tpl_t *ib_dst_tpl, /*!< out,own: destination tuple */ const ib_tpl_t ib_src_tpl) /*!< in: source tuple */ @@ -2625,11 +2458,9 @@ ib_err_t ib_tuple_get_cluster_key( return (err); } -/*****************************************************************/ /** - Create an InnoDB tuple used for index/table search. +/** Create an InnoDB tuple used for index/table search. @return own: Tuple for current index */ ib_tpl_t ib_sec_search_tuple_create( - /*=======================*/ ib_crsr_t ib_crsr) /*!< in: Cursor instance */ { ulint n_cols; @@ -2640,12 +2471,9 @@ ib_tpl_t ib_sec_search_tuple_create( return (ib_key_tuple_new(index, n_cols)); } -/*****************************************************************/ /** - Create an InnoDB tuple used for index/table search. +/** Create an InnoDB tuple used for index/table search. @return own: Tuple for current index */ -ib_tpl_t ib_sec_read_tuple_create( - /*=====================*/ - ib_crsr_t ib_crsr) /*!< in: Cursor instance */ +ib_tpl_t ib_sec_read_tuple_create(ib_crsr_t ib_crsr) /*!< in: Cursor instance */ { ulint n_cols; ib_cursor_t *cursor = (ib_cursor_t *)ib_crsr; @@ -2655,11 +2483,9 @@ ib_tpl_t ib_sec_read_tuple_create( return (ib_row_tuple_new(index, n_cols)); } -/*****************************************************************/ /** - Create an InnoDB tuple used for table key operations. +/** Create an InnoDB tuple used for table key operations. @return own: Tuple for current table */ ib_tpl_t ib_clust_search_tuple_create( - /*=========================*/ ib_crsr_t ib_crsr) /*!< in: Cursor instance */ { ulint n_cols; @@ -2672,11 +2498,9 @@ ib_tpl_t ib_clust_search_tuple_create( return (ib_key_tuple_new(index, n_cols)); } -/*****************************************************************/ /** - Create an InnoDB tuple for table row operations. +/** Create an InnoDB tuple for table row operations. @return own: Tuple for current table */ ib_tpl_t ib_clust_read_tuple_create( - /*=======================*/ ib_crsr_t ib_crsr) /*!< in: Cursor instance */ { ulint n_cols; @@ -2689,11 +2513,9 @@ ib_tpl_t ib_clust_read_tuple_create( return (ib_row_tuple_new(index, n_cols)); } -/*****************************************************************/ /** - Return the number of user columns in the tuple definition. +/** Return the number of user columns in the tuple definition. @return number of user columns */ ib_ulint_t ib_tuple_get_n_user_cols( - /*=====================*/ const ib_tpl_t ib_tpl) /*!< in: Tuple for current table */ { const ib_tuple_t *tuple = (const ib_tuple_t *)ib_tpl; @@ -2706,11 +2528,9 @@ ib_ulint_t ib_tuple_get_n_user_cols( dict_index_get_n_ordering_defined_by_user(tuple->index))); } -/*****************************************************************/ /** - Return the number of columns in the tuple definition. +/** Return the number of columns in the tuple definition. @return number of columns */ ib_ulint_t ib_tuple_get_n_cols( - /*================*/ const ib_tpl_t ib_tpl) /*!< in: Tuple for table/index */ { const ib_tuple_t *tuple = (const ib_tuple_t *)ib_tpl; @@ -2718,11 +2538,8 @@ ib_ulint_t ib_tuple_get_n_cols( return (static_cast(dtuple_get_n_fields(tuple->ptr))); } -/*****************************************************************/ /** - Destroy an InnoDB tuple. */ -void ib_tuple_delete( - /*============*/ - ib_tpl_t ib_tpl) /*!< in,own: Tuple instance to delete */ +/** Destroy an InnoDB tuple. */ +void ib_tuple_delete(ib_tpl_t ib_tpl) /*!< in,own: Tuple instance to delete */ { ib_tuple_t *tuple = (ib_tuple_t *)ib_tpl; @@ -2733,13 +2550,10 @@ void ib_tuple_delete( mem_heap_free(tuple->heap); } -/*****************************************************************/ /** - Get a table id. This function will acquire the dictionary mutex. +/** Get a table id. This function will acquire the dictionary mutex. @return DB_SUCCESS if found */ -ib_err_t ib_table_get_id( - /*============*/ - const char *table_name, /*!< in: table to find */ - ib_id_u64_t *table_id) /*!< out: table id if found */ +ib_err_t ib_table_get_id(const char *table_name, /*!< in: table to find */ + ib_id_u64_t *table_id) /*!< out: table id if found */ { ib_err_t err; @@ -2752,11 +2566,9 @@ ib_err_t ib_table_get_id( return (err); } -/*****************************************************************/ /** - Check if cursor is positioned. +/** Check if cursor is positioned. @return IB_true if positioned */ ib_bool_t ib_cursor_is_positioned( - /*====================*/ const ib_crsr_t ib_crsr) /*!< in: InnoDB cursor instance */ { const ib_cursor_t *cursor = (const ib_cursor_t *)ib_crsr; @@ -2765,11 +2577,9 @@ ib_bool_t ib_cursor_is_positioned( return (ib_btr_cursor_is_positioned(prebuilt->pcur)); } -/*****************************************************************/ /** - Checks if the data dictionary is latched in exclusive mode. +/** Checks if the data dictionary is latched in exclusive mode. @return true if exclusive latch */ ib_bool_t ib_schema_lock_is_exclusive( - /*========================*/ const ib_trx_t ib_trx) /*!< in: transaction */ { const trx_t *trx = (const trx_t *)ib_trx; @@ -2777,13 +2587,10 @@ ib_bool_t ib_schema_lock_is_exclusive( return (trx->dict_operation_lock_mode == RW_X_LATCH); } -/*****************************************************************/ /** - Set the Lock an InnoDB cursor/table. +/** Set the Lock an InnoDB cursor/table. @return DB_SUCCESS or error code */ -ib_err_t ib_cursor_lock( - /*===========*/ - ib_crsr_t ib_crsr, /*!< in/out: InnoDB cursor */ - ib_lck_mode_t ib_lck_mode) /*!< in: InnoDB lock mode */ +ib_err_t ib_cursor_lock(ib_crsr_t ib_crsr, /*!< in/out: InnoDB cursor */ + ib_lck_mode_t ib_lck_mode) /*!< in: InnoDB lock mode */ { ib_cursor_t *cursor = (ib_cursor_t *)ib_crsr; row_prebuilt_t *prebuilt = cursor->prebuilt; @@ -2794,11 +2601,9 @@ ib_err_t ib_cursor_lock( ib_trx_lock_table_with_retry(trx, table, (enum lock_mode)ib_lck_mode)); } -/*****************************************************************/ /** - Set the Lock mode of the cursor. +/** Set the Lock mode of the cursor. @return DB_SUCCESS or error code */ ib_err_t ib_cursor_set_lock_mode( - /*====================*/ ib_crsr_t ib_crsr, /*!< in/out: InnoDB cursor */ ib_lck_mode_t ib_lck_mode) /*!< in: InnoDB lock mode */ { @@ -2822,10 +2627,8 @@ ib_err_t ib_cursor_set_lock_mode( return (err); } -/*****************************************************************/ /** - Set need to access clustered index record. */ +/** Set need to access clustered index record. */ void ib_cursor_set_cluster_access( - /*=========================*/ ib_crsr_t ib_crsr) /*!< in/out: InnoDB cursor */ { ib_cursor_t *cursor = (ib_cursor_t *)ib_crsr; @@ -2834,22 +2637,17 @@ void ib_cursor_set_cluster_access( prebuilt->need_to_access_clustered = TRUE; } -/*****************************************************************/ /** - Inform the cursor that it's the start of an SQL statement. */ -void ib_cursor_stmt_begin( - /*=================*/ - ib_crsr_t ib_crsr) /*!< in: cursor */ +/** Inform the cursor that it's the start of an SQL statement. */ +void ib_cursor_stmt_begin(ib_crsr_t ib_crsr) /*!< in: cursor */ { ib_cursor_t *cursor = (ib_cursor_t *)ib_crsr; cursor->prebuilt->sql_stat_start = TRUE; } -/*****************************************************************/ /** - Write a double value to a column. +/** Write a double value to a column. @return DB_SUCCESS or error */ ib_err_t ib_tuple_write_double( - /*==================*/ ib_tpl_t ib_tpl, /*!< in/out: tuple to write to */ int col_no, /*!< in: column number */ double val) /*!< in: value to write */ @@ -2866,14 +2664,11 @@ ib_err_t ib_tuple_write_double( } } -/*************************************************************/ /** - Read a double column value from an InnoDB tuple. +/** Read a double column value from an InnoDB tuple. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_read_double( - /*=================*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t col_no, /*!< in: column number */ - double *dval) /*!< out: double value */ +ib_err_t ib_tuple_read_double(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t col_no, /*!< in: column number */ + double *dval) /*!< out: double value */ { ib_err_t err; const dfield_t *dfield; @@ -2891,14 +2686,11 @@ ib_err_t ib_tuple_read_double( return (err); } -/*****************************************************************/ /** - Write a float value to a column. +/** Write a float value to a column. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_write_float( - /*=================*/ - ib_tpl_t ib_tpl, /*!< in/out: tuple to write to */ - int col_no, /*!< in: column number */ - float val) /*!< in: value to write */ +ib_err_t ib_tuple_write_float(ib_tpl_t ib_tpl, /*!< in/out: tuple to write to */ + int col_no, /*!< in: column number */ + float val) /*!< in: value to write */ { const dfield_t *dfield; ib_tuple_t *tuple = (ib_tuple_t *)ib_tpl; @@ -2912,14 +2704,11 @@ ib_err_t ib_tuple_write_float( } } -/*************************************************************/ /** - Read a float value from an InnoDB tuple. +/** Read a float value from an InnoDB tuple. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_read_float( - /*================*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t col_no, /*!< in: column number */ - float *fval) /*!< out: float value */ +ib_err_t ib_tuple_read_float(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t col_no, /*!< in: column number */ + float *fval) /*!< out: float value */ { ib_err_t err; const dfield_t *dfield; @@ -2937,30 +2726,21 @@ ib_err_t ib_tuple_read_float( return (err); } -/*****************************************************************/ /** - Return isolation configuration set by "innodb_api_trx_level" +/** Return isolation configuration set by "innodb_api_trx_level" @return trx isolation level*/ -ib_trx_level_t ib_cfg_trx_level() -/*==============*/ -{ +ib_trx_level_t ib_cfg_trx_level() { return (static_cast(ib_trx_level_setting)); } -/*****************************************************************/ /** - Return configure value for background commit interval (in seconds) +/** Return configure value for background commit interval (in seconds) @return background commit interval (in seconds) */ -ib_ulint_t ib_cfg_bk_commit_interval() -/*=======================*/ -{ +ib_ulint_t ib_cfg_bk_commit_interval() { return (static_cast(ib_bk_commit_interval)); } -/*****************************************************************/ /** - Get generic configure status +/** Get generic configure status @return configure status*/ -int ib_cfg_get_cfg() -/*============*/ -{ +int ib_cfg_get_cfg() { int cfg_status; cfg_status = (ib_binlog_enabled) ? IB_CFG_BINLOG_ENABLED : 0; @@ -2976,22 +2756,17 @@ int ib_cfg_get_cfg() return (cfg_status); } -/*****************************************************************/ /** - Wrapper of ut_strerr() which converts an InnoDB error number to a +/** Wrapper of ut_strerr() which converts an InnoDB error number to a human readable text message. @return string, describing the error */ -const char *ib_ut_strerr( - /*=========*/ - ib_err_t num) /*!< in: error number */ +const char *ib_ut_strerr(ib_err_t num) /*!< in: error number */ { return (ut_strerr(num)); } -/*****************************************************************/ /** - Open an InnoDB table and return a cursor handle to it. +/** Open an InnoDB table and return a cursor handle to it. @return DB_SUCCESS or err code */ static ib_err_t ib_cursor_open_table_using_id( - /*==========================*/ ib_id_u64_t table_id, /*!< in: table id of table to open */ ib_trx_t ib_trx, /*!< in: Current transaction handle can be NULL */ diff --git a/storage/innobase/api/api0misc.cc b/storage/innobase/api/api0misc.cc index 579d8726734c..a2acc198c30c 100644 --- a/storage/innobase/api/api0misc.cc +++ b/storage/innobase/api/api0misc.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2008, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2008, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file api/api0misc.cc +/** @file api/api0misc.cc InnoDB Native API 2008-08-01 Created by Sunny Bains @@ -43,11 +42,9 @@ this program; if not, write to the Free Software Foundation, Inc., #include "srv0srv.h" #include "trx0roll.h" -/*********************************************************************/ /** - Sets a lock on a table. +/** Sets a lock on a table. @return error code or DB_SUCCESS */ dberr_t ib_trx_lock_table_with_retry( - /*=========================*/ trx_t *trx, /*!< in/out: transaction */ dict_table_t *table, /*!< in: table to lock */ enum lock_mode mode) /*!< in: LOCK_X or LOCK_S */ diff --git a/storage/innobase/arch/arch0arch.cc b/storage/innobase/arch/arch0arch.cc index a092787be89e..6d4b868c9d45 100644 --- a/storage/innobase/arch/arch0arch.cc +++ b/storage/innobase/arch/arch0arch.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file arch/arch0arch.cc +/** @file arch/arch0arch.cc Common implementation for redo log and dirty page archiver system *******************************************************/ diff --git a/storage/innobase/arch/arch0log.cc b/storage/innobase/arch/arch0log.cc index 868301edddf3..91ffe73ca561 100644 --- a/storage/innobase/arch/arch0log.cc +++ b/storage/innobase/arch/arch0log.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file arch/arch0log.cc +/** @file arch/arch0log.cc Innodb implementation for log archive *******************************************************/ diff --git a/storage/innobase/arch/arch0page.cc b/storage/innobase/arch/arch0page.cc index 1c6126bfbb03..8eb9f8f52908 100644 --- a/storage/innobase/arch/arch0page.cc +++ b/storage/innobase/arch/arch0page.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file arch/arch0page.cc +/** @file arch/arch0page.cc Innodb implementation for page archive *******************************************************/ diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index bad604d8c470..14a9cd8490b9 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -25,8 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file btr/btr0btr.cc +/** @file btr/btr0btr.cc The B-tree Created 6/2/1994 Heikki Tuuri @@ -58,24 +57,19 @@ this program; if not, write to the Free Software Foundation, Inc., #endif /* !UNIV_HOTBACKUP */ #ifndef UNIV_HOTBACKUP -/**************************************************************/ /** - Checks if the page in the cursor can be merged with given page. +/** Checks if the page in the cursor can be merged with given page. If necessary, re-organize the merge_page. @return true if possible to merge. */ static bool btr_can_merge_with_page( - /*====================*/ btr_cur_t *cursor, /*!< in: cursor on the page to merge */ page_no_t page_no, /*!< in: a sibling page */ buf_block_t **merge_block, /*!< out: the merge block */ mtr_t *mtr); /*!< in: mini-transaction */ #endif /* !UNIV_HOTBACKUP */ -/**************************************************************/ /** - Report that an index page is corrupted. */ -void btr_corruption_report( - /*==================*/ - const buf_block_t *block, /*!< in: corrupted block */ - const dict_index_t *index) /*!< in: index tree */ +/** Report that an index page is corrupted. */ +void btr_corruption_report(const buf_block_t *block, /*!< in: corrupted block */ + const dict_index_t *index) /*!< in: index tree */ { ib::error() << "Flag mismatch in page " << block->page.id << " index " << index->name << " of table " << index->table->name; @@ -138,11 +132,9 @@ void btr_corruption_report( */ #ifdef UNIV_BTR_DEBUG -/**************************************************************/ /** - Checks a file segment header within a B-tree root page. +/** Checks a file segment header within a B-tree root page. @return true if valid */ static ibool btr_root_fseg_validate( - /*===================*/ const fseg_header_t *seg_header, /*!< in: segment header */ space_id_t space) /*!< in: tablespace identifier */ { @@ -155,11 +147,9 @@ static ibool btr_root_fseg_validate( } #endif /* UNIV_BTR_DEBUG */ -/**************************************************************/ /** - Gets the root node of a tree and x- or s-latches it. +/** Gets the root node of a tree and x- or s-latches it. @return root page, x- or s-latched */ buf_block_t *btr_root_block_get( - /*===============*/ const dict_index_t *index, /*!< in: index tree */ ulint mode, /*!< in: either RW_S_LATCH or RW_X_LATCH */ @@ -186,13 +176,10 @@ buf_block_t *btr_root_block_get( return (block); } -/**************************************************************/ /** - Gets the root node of a tree and sx-latches it for segment access. +/** Gets the root node of a tree and sx-latches it for segment access. @return root page, sx-latched */ -page_t *btr_root_get( - /*=========*/ - const dict_index_t *index, /*!< in: index tree */ - mtr_t *mtr) /*!< in: mtr */ +page_t *btr_root_get(const dict_index_t *index, /*!< in: index tree */ + mtr_t *mtr) /*!< in: mtr */ { /* Intended to be used for segment list access. SX lock doesn't block reading user data by other threads. @@ -200,15 +187,12 @@ page_t *btr_root_get( return (buf_block_get_frame(btr_root_block_get(index, RW_SX_LATCH, mtr))); } -/**************************************************************/ /** - Gets the height of the B-tree (the level of the root, when the leaf +/** Gets the height of the B-tree (the level of the root, when the leaf level is assumed to be 0). The caller must hold an S or X latch on the index. @return tree height (level of the root) */ -ulint btr_height_get( - /*===========*/ - dict_index_t *index, /*!< in: index tree */ - mtr_t *mtr) /*!< in/out: mini-transaction */ +ulint btr_height_get(dict_index_t *index, /*!< in: index tree */ + mtr_t *mtr) /*!< in/out: mini-transaction */ { ulint height; buf_block_t *root_block; @@ -232,12 +216,10 @@ ulint btr_height_get( return (height); } -/**************************************************************/ /** - Checks a file segment header within a B-tree root page and updates +/** Checks a file segment header within a B-tree root page and updates the segment header space id. @return true if valid */ static bool btr_root_fseg_adjust_on_import( - /*===========================*/ fseg_header_t *seg_header, /*!< in/out: segment header */ page_zip_des_t *page_zip, /*!< in/out: compressed page, or NULL */ @@ -259,11 +241,9 @@ static bool btr_root_fseg_adjust_on_import( return (TRUE); } -/**************************************************************/ /** - Checks and adjusts the root node of a tree during IMPORT TABLESPACE. +/** Checks and adjusts the root node of a tree during IMPORT TABLESPACE. @return error code, or DB_SUCCESS */ dberr_t btr_root_adjust_on_import( - /*======================*/ const dict_index_t *index) /*!< in: index tree */ { dberr_t err; @@ -334,11 +314,9 @@ dberr_t btr_root_adjust_on_import( return (err); } -/**************************************************************/ /** - Creates a new index page (not the root, and also not +/** Creates a new index page (not the root, and also not used in page reorganization). @see btr_page_empty(). */ void btr_page_create( - /*============*/ buf_block_t *block, /*!< in/out: page to be created */ page_zip_des_t *page_zip, /*!< in/out: compressed page, or NULL */ dict_index_t *index, /*!< in: index */ @@ -378,12 +356,10 @@ void btr_page_create( } } -/**************************************************************/ /** - Allocates a new file page to be used in an ibuf tree. Takes the page from +/** Allocates a new file page to be used in an ibuf tree. Takes the page from the free list of the tree, which must contain pages! @return new allocated block, x-latched */ static buf_block_t *btr_page_alloc_for_ibuf( - /*====================*/ dict_index_t *index, /*!< in: index tree */ mtr_t *mtr) /*!< in: mtr */ { @@ -411,15 +387,13 @@ static buf_block_t *btr_page_alloc_for_ibuf( return (new_block); } -/**************************************************************/ /** - Allocates a new file page to be used in an index tree. NOTE: we assume +/** Allocates a new file page to be used in an index tree. NOTE: we assume that the caller has made the reservation for free extents! @retval NULL if no page could be allocated @retval block, rw_lock_x_lock_count(&block->lock) == 1 if allocation succeeded (init_mtr == mtr, or the page was not previously freed in mtr) @retval block (not allocated or initialized) otherwise */ static MY_ATTRIBUTE((warn_unused_result)) buf_block_t *btr_page_alloc_low( - /*===============*/ dict_index_t *index, /*!< in: index */ page_no_t hint_page_no, /*!< in: hint of a good page */ byte file_direction, /*!< in: direction where a possible @@ -454,15 +428,13 @@ static MY_ATTRIBUTE((warn_unused_result)) buf_block_t *btr_page_alloc_low( TRUE, mtr, init_mtr)); } -/**************************************************************/ /** - Allocates a new file page to be used in an index tree. NOTE: we assume +/** Allocates a new file page to be used in an index tree. NOTE: we assume that the caller has made the reservation for free extents! @retval NULL if no page could be allocated @retval block, rw_lock_x_lock_count(&block->lock) == 1 if allocation succeeded (init_mtr == mtr, or the page was not previously freed in mtr) @retval block (not allocated or initialized) otherwise */ buf_block_t *btr_page_alloc( - /*===========*/ dict_index_t *index, /*!< in: index */ page_no_t hint_page_no, /*!< in: hint of a good page */ byte file_direction, /*!< in: direction where a possible @@ -491,15 +463,12 @@ buf_block_t *btr_page_alloc( return (new_block); } -/**************************************************************/ /** - Gets the number of pages in a B-tree. +/** Gets the number of pages in a B-tree. @return number of pages, or ULINT_UNDEFINED if the index is unavailable */ -ulint btr_get_size( - /*=========*/ - dict_index_t *index, /*!< in: index */ - ulint flag, /*!< in: BTR_N_LEAF_PAGES or BTR_TOTAL_SIZE */ - mtr_t *mtr) /*!< in/out: mini-transaction where index - is s-latched */ +ulint btr_get_size(dict_index_t *index, /*!< in: index */ + ulint flag, /*!< in: BTR_N_LEAF_PAGES or BTR_TOTAL_SIZE */ + mtr_t *mtr) /*!< in/out: mini-transaction where index + is s-latched */ { fseg_header_t *seg_header; page_t *root; @@ -538,11 +507,9 @@ ulint btr_get_size( return (n); } -/**************************************************************/ /** - Frees a page used in an ibuf tree. Puts the page to the free list of the +/** Frees a page used in an ibuf tree. Puts the page to the free list of the ibuf tree. */ static void btr_page_free_for_ibuf( - /*===================*/ dict_index_t *index, /*!< in: index tree */ buf_block_t *block, /*!< in: block to be freed, x-latched */ mtr_t *mtr) /*!< in: mtr */ @@ -560,11 +527,9 @@ static void btr_page_free_for_ibuf( ut_ad(flst_validate(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, mtr)); } -/**************************************************************/ /** - Frees a file page used in an index tree. Can be used also to (BLOB) +/** Frees a file page used in an index tree. Can be used also to (BLOB) external storage pages. */ void btr_page_free_low( - /*==============*/ dict_index_t *index, /*!< in: index tree */ buf_block_t *block, /*!< in: block to be freed, x-latched */ ulint level, /*!< in: page level (ULINT_UNDEFINED=BLOB) */ @@ -612,14 +577,11 @@ void btr_page_free_low( both the tablespace and the redo log. */ } -/**************************************************************/ /** - Frees a file page used in an index tree. NOTE: cannot free field external +/** Frees a file page used in an index tree. NOTE: cannot free field external storage pages because the page must contain info on its level. */ -void btr_page_free( - /*==========*/ - dict_index_t *index, /*!< in: index tree */ - buf_block_t *block, /*!< in: block to be freed, x-latched */ - mtr_t *mtr) /*!< in: mtr */ +void btr_page_free(dict_index_t *index, /*!< in: index tree */ + buf_block_t *block, /*!< in: block to be freed, x-latched */ + mtr_t *mtr) /*!< in: mtr */ { const page_t *page = buf_block_get_frame(block); ulint level = btr_page_get_level(page, mtr); @@ -629,11 +591,9 @@ void btr_page_free( btr_page_free_low(index, block, level, mtr); } -/**************************************************************/ /** - Sets the child node file address in a node pointer. */ +/** Sets the child node file address in a node pointer. */ UNIV_INLINE void btr_node_ptr_set_child_page_no( - /*===========================*/ rec_t *rec, /*!< in: node pointer record */ page_zip_des_t *page_zip, /*!< in/out: compressed page whose uncompressed part will be updated, or NULL */ @@ -661,11 +621,9 @@ void btr_node_ptr_set_child_page_no( } } -/************************************************************/ /** - Returns the child page of a node pointer and sx-latches it. +/** Returns the child page of a node pointer and sx-latches it. @return child page, sx-latched */ static buf_block_t *btr_node_ptr_get_child( - /*===================*/ const rec_t *node_ptr, /*!< in: node pointer */ dict_index_t *index, /*!< in: index */ const ulint *offsets, /*!< in: array returned by rec_get_offsets() */ @@ -680,12 +638,10 @@ static buf_block_t *btr_node_ptr_get_child( RW_SX_LATCH, index, mtr)); } -/************************************************************/ /** - Returns the upper level node pointer to a page. It is assumed that mtr holds +/** Returns the upper level node pointer to a page. It is assumed that mtr holds an sx-latch on the tree. @return rec_get_offsets() of the node pointer record */ static ulint *btr_page_get_father_node_ptr_func( - /*==============================*/ ulint *offsets, /*!< in: work area for the return value */ mem_heap_t *heap, /*!< in: memory heap to use */ btr_cur_t *cursor, /*!< in: cursor pointing to user record, @@ -769,12 +725,10 @@ static ulint *btr_page_get_father_node_ptr_func( btr_page_get_father_node_ptr_func(of, heap, cur, BTR_CONT_SEARCH_TREE, \ __FILE__, __LINE__, mtr) -/************************************************************/ /** - Returns the upper level node pointer to a page. It is assumed that mtr holds +/** Returns the upper level node pointer to a page. It is assumed that mtr holds an x-latch on the tree. @return rec_get_offsets() of the node pointer record */ static ulint *btr_page_get_father_block( - /*======================*/ ulint *offsets, /*!< in: work area for the return value */ mem_heap_t *heap, /*!< in: memory heap to use */ dict_index_t *index, /*!< in: b-tree index */ @@ -789,11 +743,9 @@ static ulint *btr_page_get_father_block( return (btr_page_get_father_node_ptr(offsets, heap, cursor, mtr)); } -/************************************************************/ /** - Seeks to the upper level node pointer to a page. +/** Seeks to the upper level node pointer to a page. It is assumed that mtr holds an x-latch on the tree. */ static void btr_page_get_father( - /*================*/ dict_index_t *index, /*!< in: b-tree index */ buf_block_t *block, /*!< in: child page in the index */ mtr_t *mtr, /*!< in: mtr */ @@ -1192,8 +1144,7 @@ void btr_truncate_recover(const dict_index_t *index) { } #endif /* !UNIV_HOTBACKUP */ -/*************************************************************/ /** - Reorganizes an index page. +/** Reorganizes an index page. IMPORTANT: On success, the caller will have to update IBUF_BITMAP_FREE if this is a compressed leaf page in a secondary index. This has to @@ -1204,7 +1155,6 @@ void btr_truncate_recover(const dict_index_t *index) { @retval true if the operation was successful @retval false if it is a compressed page, and recompression failed */ bool btr_page_reorganize_low( - /*====================*/ bool recovery, /*!< in: true if called in recovery: locks should not be updated, i.e., there cannot exist locks on the @@ -1400,8 +1350,7 @@ bool btr_page_reorganize_low( return (success); } -/*************************************************************/ /** - Reorganizes an index page. +/** Reorganizes an index page. IMPORTANT: On success, the caller will have to update IBUF_BITMAP_FREE if this is a compressed leaf page in a secondary index. This has to @@ -1412,7 +1361,6 @@ bool btr_page_reorganize_low( @retval true if the operation was successful @retval false if it is a compressed page, and recompression failed */ static bool btr_page_reorganize_block( - /*======================*/ bool recovery, /*!< in: true if called in recovery: locks should not be updated, i.e., there cannot exist locks on the @@ -1430,8 +1378,7 @@ static bool btr_page_reorganize_block( return (btr_page_reorganize_low(recovery, z_level, &cur, index, mtr)); } -/*************************************************************/ /** - Reorganizes an index page. +/** Reorganizes an index page. IMPORTANT: On success, the caller will have to update IBUF_BITMAP_FREE if this is a compressed leaf page in a secondary index. This has to @@ -1442,7 +1389,6 @@ static bool btr_page_reorganize_block( @retval true if the operation was successful @retval false if it is a compressed page, and recompression failed */ bool btr_page_reorganize( - /*================*/ page_cur_t *cursor, /*!< in/out: page cursor */ dict_index_t *index, /*!< in: the index tree of the page */ mtr_t *mtr) /*!< in/out: mini-transaction */ @@ -1450,11 +1396,9 @@ bool btr_page_reorganize( return (btr_page_reorganize_low(false, page_zip_level, cursor, index, mtr)); } -/***********************************************************/ /** - Parses a redo log record of reorganizing a page. +/** Parses a redo log record of reorganizing a page. @return end of log record or NULL */ byte *btr_parse_page_reorganize( - /*======================*/ byte *ptr, /*!< in: buffer */ byte *end_ptr, /*!< in: buffer end */ dict_index_t *index, /*!< in: record descriptor */ @@ -1492,10 +1436,8 @@ byte *btr_parse_page_reorganize( } #ifndef UNIV_HOTBACKUP -/*************************************************************/ /** - Empties an index page. @see btr_page_create(). */ +/** Empties an index page. @see btr_page_create(). */ static void btr_page_empty( - /*===========*/ buf_block_t *block, /*!< in: page to be emptied */ page_zip_des_t *page_zip, /*!< out: compressed page, or NULL */ dict_index_t *index, /*!< in: index of the page */ @@ -1532,15 +1474,13 @@ static void btr_page_empty( } } -/*************************************************************/ /** - Makes tree one level higher by splitting the root, and inserts +/** Makes tree one level higher by splitting the root, and inserts the tuple. It is assumed that mtr contains an x-latch on the tree. NOTE that the operation of this function must always succeed, we cannot reverse it: therefore enough free disk space must be guaranteed to be available before this function is called. @return inserted record */ rec_t *btr_root_raise_and_insert( - /*======================*/ ulint flags, /*!< in: undo logging and locking flags */ btr_cur_t *cursor, /*!< in: cursor at which to insert: must be on the root page; when the function returns, @@ -1716,12 +1656,10 @@ rec_t *btr_root_raise_and_insert( } } -/*************************************************************/ /** - Decides if the page should be split at the convergence point of inserts +/** Decides if the page should be split at the convergence point of inserts converging to the left. @return true if split recommended */ ibool btr_page_get_split_rec_to_left( - /*===========================*/ btr_cur_t *cursor, /*!< in: cursor at which to insert */ rec_t **split_rec) /*!< out: if split recommended, the first record on upper half page, @@ -1756,12 +1694,10 @@ ibool btr_page_get_split_rec_to_left( return (FALSE); } -/*************************************************************/ /** - Decides if the page should be split at the convergence point of inserts +/** Decides if the page should be split at the convergence point of inserts converging to the right. @return true if split recommended */ ibool btr_page_get_split_rec_to_right( - /*============================*/ btr_cur_t *cursor, /*!< in: cursor at which to insert */ rec_t **split_rec) /*!< out: if split recommended, the first record on upper half page, @@ -1809,14 +1745,12 @@ ibool btr_page_get_split_rec_to_right( return (FALSE); } -/*************************************************************/ /** - Calculates a split record such that the tuple will certainly fit on +/** Calculates a split record such that the tuple will certainly fit on its half-page when the split is performed. We assume in this function only that the cursor page has at least one user record. @return split record, or NULL if tuple will be the first record on the lower or upper half-page (determined by btr_page_tuple_smaller()) */ static rec_t *btr_page_get_split_rec( - /*===================*/ btr_cur_t *cursor, /*!< in: cursor at which insert should be made */ const dtuple_t *tuple, /*!< in: tuple to insert */ ulint n_ext) /*!< in: number of externally stored columns */ @@ -1924,12 +1858,10 @@ static rec_t *btr_page_get_split_rec( return (rec); } -/*************************************************************/ /** - Returns TRUE if the insert fits on the appropriate half-page with the +/** Returns TRUE if the insert fits on the appropriate half-page with the chosen split_rec. @return true if fits */ static MY_ATTRIBUTE((warn_unused_result)) bool btr_page_insert_fits( - /*=================*/ btr_cur_t *cursor, /*!< in: cursor at which insert should be made */ const rec_t *split_rec, /*!< in: suggestion for first record @@ -2008,11 +1940,9 @@ static MY_ATTRIBUTE((warn_unused_result)) bool btr_page_insert_fits( return (false); } -/*******************************************************/ /** - Inserts a data tuple to a tree on a non-leaf level. It is assumed +/** Inserts a data tuple to a tree on a non-leaf level. It is assumed that mtr holds an x-latch on the tree. */ void btr_insert_on_non_leaf_level_func( - /*==============================*/ ulint flags, /*!< in: undo logging and locking flags */ dict_index_t *index, /*!< in: index */ ulint level, /*!< in: level, must be > 0 */ @@ -2078,11 +2008,9 @@ void btr_insert_on_non_leaf_level_func( } } -/**************************************************************/ /** - Attaches the halves of an index page on the appropriate level in an +/** Attaches the halves of an index page on the appropriate level in an index tree. */ static void btr_attach_half_pages( - /*==================*/ ulint flags, /*!< in: undo logging and locking flags */ dict_index_t *index, /*!< in: the index tree */ @@ -2219,11 +2147,9 @@ static void btr_attach_half_pages( } } -/*************************************************************/ /** - Determine if a tuple is smaller than any record on the page. +/** Determine if a tuple is smaller than any record on the page. @return true if smaller */ static MY_ATTRIBUTE((warn_unused_result)) bool btr_page_tuple_smaller( - /*===================*/ btr_cur_t *cursor, /*!< in: b-tree cursor */ const dtuple_t *tuple, /*!< in: tuple to consider */ ulint **offsets, /*!< in/out: temporary storage */ @@ -2365,8 +2291,7 @@ static rec_t *btr_insert_into_right_sibling(ulint flags, btr_cur_t *cursor, return (rec); } -/*************************************************************/ /** - Splits an index page to halves and inserts the tuple. It is assumed +/** Splits an index page to halves and inserts the tuple. It is assumed that mtr holds an x-latch to the index tree. NOTE: the tree x-latch is released within this function! NOTE that the operation of this function must always succeed, we cannot reverse it: therefore enough @@ -2374,7 +2299,6 @@ static rec_t *btr_insert_into_right_sibling(ulint flags, btr_cur_t *cursor, this function is called. @return inserted record */ rec_t *btr_page_split_and_insert( - /*======================*/ ulint flags, /*!< in: undo logging and locking flags */ btr_cur_t *cursor, /*!< in: cursor at which to insert; when the function returns, the cursor is positioned @@ -2806,16 +2730,13 @@ static void btr_level_list_remove_func(space_id_t space, } } -/****************************************************************/ /** - Writes the redo log record for setting an index record as the predefined +/** Writes the redo log record for setting an index record as the predefined minimum record. */ UNIV_INLINE -void btr_set_min_rec_mark_log( - /*=====================*/ - rec_t *rec, /*!< in: record */ - mlog_id_t type, /*!< in: MLOG_COMP_REC_MIN_MARK or - MLOG_REC_MIN_MARK */ - mtr_t *mtr) /*!< in: mtr */ +void btr_set_min_rec_mark_log(rec_t *rec, /*!< in: record */ + mlog_id_t type, /*!< in: MLOG_COMP_REC_MIN_MARK or + MLOG_REC_MIN_MARK */ + mtr_t *mtr) /*!< in: mtr */ { mlog_write_initial_log_record(rec, type, mtr); @@ -2826,12 +2747,10 @@ void btr_set_min_rec_mark_log( #define btr_set_min_rec_mark_log(rec, comp, mtr) ((void)0) #endif /* !UNIV_HOTBACKUP */ -/****************************************************************/ /** - Parses the redo log record for setting an index record as the predefined +/** Parses the redo log record for setting an index record as the predefined minimum record. @return end of log record or NULL */ byte *btr_parse_set_min_rec_mark( - /*=======================*/ byte *ptr, /*!< in: buffer */ byte *end_ptr, /*!< in: buffer end */ ulint comp, /*!< in: nonzero=compact page format */ @@ -2855,12 +2774,9 @@ byte *btr_parse_set_min_rec_mark( return (ptr + 2); } -/****************************************************************/ /** - Sets a record as the predefined minimum record. */ -void btr_set_min_rec_mark( - /*=================*/ - rec_t *rec, /*!< in: record */ - mtr_t *mtr) /*!< in: mtr */ +/** Sets a record as the predefined minimum record. */ +void btr_set_min_rec_mark(rec_t *rec, /*!< in: record */ + mtr_t *mtr) /*!< in: mtr */ { ulint info_bits; @@ -2880,10 +2796,8 @@ void btr_set_min_rec_mark( } #ifndef UNIV_HOTBACKUP -/*************************************************************/ /** - Deletes on the upper level the node pointer to a page. */ +/** Deletes on the upper level the node pointer to a page. */ void btr_node_ptr_delete( - /*================*/ dict_index_t *index, /*!< in: index tree */ buf_block_t *block, /*!< in: page whose node pointer is deleted */ mtr_t *mtr) /*!< in: mtr */ @@ -2906,12 +2820,10 @@ void btr_node_ptr_delete( } } -/*************************************************************/ /** - If page is the only on its level, this function moves its records to the +/** If page is the only on its level, this function moves its records to the father page, thus reducing the tree height. @return father block */ static buf_block_t *btr_lift_page_up( - /*=============*/ dict_index_t *index, /*!< in: index tree */ buf_block_t *block, /*!< in: page which is the only on its level; must not be empty: use @@ -3078,8 +2990,7 @@ static buf_block_t *btr_lift_page_up( return (lift_father_up ? block_orig : father_block); } -/*************************************************************/ /** - Tries to merge the page first to the left immediate brother if such a +/** Tries to merge the page first to the left immediate brother if such a brother exists, and the node pointers to the current page and to the brother reside on the same page. If the left brother does not satisfy these conditions, looks at the right brother. If the page is the only one on that @@ -3089,7 +3000,6 @@ static buf_block_t *btr_lift_page_up( brothers, if they exist. @return true on success */ ibool btr_compress( - /*=========*/ btr_cur_t *cursor, /*!< in/out: cursor on the page to merge or lift; the page must not be empty: when deleting records, use btr_discard_page() @@ -3554,13 +3464,11 @@ ibool btr_compress( DBUG_RETURN(FALSE); } -/*************************************************************/ /** - Discards a page that is the only page on its level. This will empty +/** Discards a page that is the only page on its level. This will empty the whole B-tree, leaving just an empty root page. This function should never be reached, because btr_compress(), which is invoked in delete operations, calls btr_lift_page_up() to flatten the B-tree. */ static void btr_discard_only_page_on_level( - /*===========================*/ dict_index_t *index, /*!< in: index tree */ buf_block_t *block, /*!< in: page which is the only on its level */ mtr_t *mtr) /*!< in: mtr */ @@ -3630,12 +3538,10 @@ static void btr_discard_only_page_on_level( } } -/*************************************************************/ /** - Discards a page from a B-tree. This is used to remove the last record from +/** Discards a page from a B-tree. This is used to remove the last record from a B-tree page: the whole page must be removed at the same time. This cannot be used for the root page, which is allowed to be empty. */ void btr_discard_page( - /*=============*/ btr_cur_t *cursor, /*!< in: cursor on the page to discard: not on the root page */ mtr_t *mtr) /*!< in: mtr */ @@ -3774,11 +3680,8 @@ void btr_discard_page( } #ifdef UNIV_BTR_PRINT -/*************************************************************/ /** - Prints size info of a B-tree. */ -void btr_print_size( - /*===========*/ - dict_index_t *index) /*!< in: index tree */ +/** Prints size info of a B-tree. */ +void btr_print_size(dict_index_t *index) /*!< in: index tree */ { page_t *root; fseg_header_t *seg; @@ -3812,10 +3715,8 @@ void btr_print_size( mtr_commit(&mtr); } -/************************************************************/ /** - Prints recursively index tree pages. */ +/** Prints recursively index tree pages. */ static void btr_print_recursive( - /*================*/ dict_index_t *index, /*!< in: index tree */ buf_block_t *block, /*!< in: index page */ ulint width, /*!< in: print this many entries from start @@ -3866,13 +3767,10 @@ static void btr_print_recursive( } } -/**************************************************************/ /** - Prints directories and other info of all nodes in the tree. */ -void btr_print_index( - /*============*/ - dict_index_t *index, /*!< in: index */ - ulint width) /*!< in: print this many entries from start - and end */ +/** Prints directories and other info of all nodes in the tree. */ +void btr_print_index(dict_index_t *index, /*!< in: index */ + ulint width) /*!< in: print this many entries from start + and end */ { mtr_t mtr; buf_block_t *root; @@ -3902,14 +3800,11 @@ void btr_print_index( #endif /* UNIV_BTR_PRINT */ #ifdef UNIV_DEBUG -/************************************************************/ /** - Checks that the node pointer to a page is appropriate. +/** Checks that the node pointer to a page is appropriate. @return true */ -ibool btr_check_node_ptr( - /*===============*/ - dict_index_t *index, /*!< in: index tree */ - buf_block_t *block, /*!< in: index page */ - mtr_t *mtr) /*!< in: mtr */ +ibool btr_check_node_ptr(dict_index_t *index, /*!< in: index tree */ + buf_block_t *block, /*!< in: index page */ + mtr_t *mtr) /*!< in: mtr */ { mem_heap_t *heap; dtuple_t *tuple; @@ -3956,10 +3851,8 @@ ibool btr_check_node_ptr( } #endif /* UNIV_DEBUG */ -/************************************************************/ /** - Display identification information for a record. */ +/** Display identification information for a record. */ static void btr_index_rec_validate_report( - /*==========================*/ const page_t *page, /*!< in: index page */ const rec_t *rec, /*!< in: index record */ const dict_index_t *index) /*!< in: index */ @@ -3970,12 +3863,10 @@ static void btr_index_rec_validate_report( << ", at offset " << page_offset(rec); } -/************************************************************/ /** - Checks the size and number of fields in a record based on the definition of +/** Checks the size and number of fields in a record based on the definition of the index. @return true if ok */ ibool btr_index_rec_validate( - /*===================*/ const rec_t *rec, /*!< in: index record */ const dict_index_t *index, /*!< in: index */ ibool dump_on_error) /*!< in: TRUE if the function @@ -4101,14 +3992,11 @@ ibool btr_index_rec_validate( return (TRUE); } -/************************************************************/ /** - Checks the size and number of fields in records based on the definition of +/** Checks the size and number of fields in records based on the definition of the index. @return true if ok */ -static ibool btr_index_page_validate( - /*====================*/ - buf_block_t *block, /*!< in: index page */ - dict_index_t *index) /*!< in: index */ +static ibool btr_index_page_validate(buf_block_t *block, /*!< in: index page */ + dict_index_t *index) /*!< in: index */ { page_cur_t cur; ibool ret = TRUE; @@ -4150,10 +4038,8 @@ static ibool btr_index_page_validate( return (ret); } -/************************************************************/ /** - Report an error on one page of an index tree. */ +/** Report an error on one page of an index tree. */ static void btr_validate_report1( - /*=================*/ dict_index_t *index, /*!< in: index */ ulint level, /*!< in: B-tree level */ const buf_block_t *block) /*!< in: index page */ @@ -4167,10 +4053,8 @@ static void btr_validate_report1( } } -/************************************************************/ /** - Report an error on two pages of an index tree. */ +/** Report an error on two pages of an index tree. */ static void btr_validate_report2( - /*=================*/ const dict_index_t *index, /*!< in: index */ ulint level, /*!< in: B-tree level */ const buf_block_t *block1, /*!< in: first index page */ @@ -4185,11 +4069,9 @@ static void btr_validate_report2( } } -/************************************************************/ /** - Validates index tree level. +/** Validates index tree level. @return true if ok */ static bool btr_validate_level( - /*===============*/ dict_index_t *index, /*!< in: index tree */ const trx_t *trx, /*!< in: transaction or NULL */ ulint level, /*!< in: level number */ @@ -4617,11 +4499,9 @@ static bool btr_validate_level( return (ret); } -/**************************************************************/ /** - Do an index level validation of spaital index tree. +/** Do an index level validation of spaital index tree. @return true if no error found */ static bool btr_validate_spatial_index( - /*=======================*/ dict_index_t *index, /*!< in: index */ const trx_t *trx) /*!< in: transaction or NULL */ { @@ -4655,11 +4535,9 @@ static bool btr_validate_spatial_index( return (ok); } -/**************************************************************/ /** - Checks the consistency of an index tree. +/** Checks the consistency of an index tree. @return true if ok */ bool btr_validate_index( - /*===============*/ dict_index_t *index, /*!< in: index */ const trx_t *trx, /*!< in: transaction or NULL */ bool lockout) /*!< in: true if X-latch index is intended */ @@ -4702,12 +4580,10 @@ bool btr_validate_index( return (ok); } -/**************************************************************/ /** - Checks if the page in the cursor can be merged with given page. +/** Checks if the page in the cursor can be merged with given page. If necessary, re-organize the merge_page. @return true if possible to merge. */ static bool btr_can_merge_with_page( - /*====================*/ btr_cur_t *cursor, /*!< in: cursor on the page to merge */ page_no_t page_no, /*!< in: a sibling page */ buf_block_t **merge_block, /*!< out: the merge block */ diff --git a/storage/innobase/btr/btr0bulk.cc b/storage/innobase/btr/btr0bulk.cc index 955dd6be3ba5..f96cec0d7c93 100644 --- a/storage/innobase/btr/btr0bulk.cc +++ b/storage/innobase/btr/btr0bulk.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2014, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2014, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file btr/btr0bulk.cc +/** @file btr/btr0bulk.cc The B-tree bulk load Created 03/11/2014 Shaohua Wang diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 1dc0d75ad4b3..7345c8699d6e 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2012, Facebook Inc. @@ -32,8 +32,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file btr/btr0cur.cc +/** @file btr/btr0cur.cc The index tree cursor All changes that row operations make to a B-tree or the records @@ -153,11 +152,9 @@ can be released by page reorganize, then it is reorganized */ ((sample) + (ext_size))) #ifndef UNIV_HOTBACKUP -/*******************************************************************/ /** - Adds path information to the cursor for the current page, for which +/** Adds path information to the cursor for the current page, for which the binary search has been performed. */ static void btr_cur_add_path_info( - /*==================*/ btr_cur_t *cursor, /*!< in: cursor positioned on a page */ ulint height, /*!< in: height of the page in tree; 0 means leaf node */ @@ -590,8 +587,7 @@ static bool btr_cur_need_opposite_intention(const page_t *page, return (false); } -/********************************************************************/ /** - Searches an index tree and positions a tree cursor on a given level. +/** Searches an index tree and positions a tree cursor on a given level. NOTE: n_fields_cmp in tuple must be set so that it cannot be compared to node pointer page number fields on the upper levels of the tree! Note that if mode is PAGE_CUR_LE, which is used in inserts, then @@ -603,7 +599,6 @@ static bool btr_cur_need_opposite_intention(const page_t *page, immediately after the cursor. Thus, the cursor may end up on a user record, or on a page infimum record. */ void btr_cur_search_to_nth_level( - /*========================*/ dict_index_t *index, /*!< in: index */ ulint level, /*!< in: the tree level of search */ const dtuple_t *tuple, /*!< in: data tuple; NOTE: n_fields_cmp in @@ -1851,10 +1846,8 @@ void btr_cur_search_to_nth_level_with_no_latch(dict_index_t *index, ulint level, DBUG_VOID_RETURN; } -/*****************************************************************/ /** - Opens a cursor at either end of an index. */ +/** Opens a cursor at either end of an index. */ void btr_cur_open_at_index_side_func( - /*============================*/ bool from_left, /*!< in: true if open to the low end, false if to the high end */ dict_index_t *index, /*!< in: index */ @@ -2262,12 +2255,10 @@ void btr_cur_open_at_index_side_with_no_latch_func( } } -/**********************************************************************/ /** - Positions a cursor at a randomly chosen position within a B-tree. +/** Positions a cursor at a randomly chosen position within a B-tree. @return true if the index is available and we have put the cursor, false if the index is unavailable */ bool btr_cur_open_at_rnd_pos_func( - /*=========================*/ dict_index_t *index, /*!< in: index */ ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ... */ btr_cur_t *cursor, /*!< in/out: B-tree cursor */ @@ -2519,8 +2510,7 @@ bool btr_cur_open_at_rnd_pos_func( /*==================== B-TREE INSERT =========================*/ -/*************************************************************/ /** - Inserts a record if there is enough space, or if enough space can +/** Inserts a record if there is enough space, or if enough space can be freed by reorganizing. Differs from btr_cur_optimistic_insert because no heuristics is applied to whether it pays to use CPU time for reorganizing the page or not. @@ -2532,7 +2522,6 @@ bool btr_cur_open_at_rnd_pos_func( @return pointer to inserted record if succeed, else NULL */ static MY_ATTRIBUTE((warn_unused_result)) rec_t *btr_cur_insert_if_possible( - /*=======================*/ btr_cur_t *cursor, /*!< in: cursor on page after which to insert; cursor stays valid */ const dtuple_t *tuple, /*!< in: tuple to insert; the size info need not @@ -2568,12 +2557,10 @@ static MY_ATTRIBUTE((warn_unused_result)) rec_t *btr_cur_insert_if_possible( return (rec); } -/*************************************************************/ /** - For an insert, checks the locks and does the undo logging if desired. +/** For an insert, checks the locks and does the undo logging if desired. @return DB_SUCCESS, DB_WAIT_LOCK, DB_FAIL, or error number */ UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) dberr_t btr_cur_ins_lock_and_undo( - /*======================*/ ulint flags, /*!< in: undo logging and locking flags: if not zero, the parameters index and thr should be specified */ @@ -2674,15 +2661,13 @@ static void btr_cur_prefetch_siblings(buf_block_t *block) { } } -/*************************************************************/ /** - Tries to perform an insert to a page in an index tree, next to cursor. +/** Tries to perform an insert to a page in an index tree, next to cursor. It is assumed that mtr holds an x-latch on the page. The operation does not succeed if there is too little space on the page. If there is just one record on the page, the insert will always succeed; this is to prevent trying to split a page with just one record. @return DB_SUCCESS, DB_WAIT_LOCK, DB_FAIL, or error number */ dberr_t btr_cur_optimistic_insert( - /*======================*/ ulint flags, /*!< in: undo logging and locking flags: if not zero, the parameters index and thr should be specified */ @@ -2936,14 +2921,12 @@ dberr_t btr_cur_optimistic_insert( return (DB_SUCCESS); } -/*************************************************************/ /** - Performs an insert on a page of an index tree. It is assumed that mtr +/** Performs an insert on a page of an index tree. It is assumed that mtr holds an x-latch on the tree and on the cursor page. If the insert is made on the leaf level, to avoid deadlocks, mtr must also own x-latches to brothers of page, if those brothers exist. @return DB_SUCCESS or error number */ dberr_t btr_cur_pessimistic_insert( - /*=======================*/ ulint flags, /*!< in: undo logging and locking flags: if not zero, the parameter thr should be specified; if no undo logging is specified, @@ -3089,12 +3072,10 @@ dberr_t btr_cur_pessimistic_insert( /*==================== B-TREE UPDATE =========================*/ -/*************************************************************/ /** - For an update, checks the locks and does the undo logging. +/** For an update, checks the locks and does the undo logging. @return DB_SUCCESS, DB_WAIT_LOCK, or error number */ UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) dberr_t btr_cur_upd_lock_and_undo( - /*======================*/ ulint flags, /*!< in: undo logging and locking flags */ btr_cur_t *cursor, /*!< in: cursor on record to update */ const ulint *offsets, /*!< in: rec_get_offsets() on cursor */ @@ -3144,10 +3125,8 @@ UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) dberr_t roll_ptr)); } -/***********************************************************/ /** - Writes a redo log record of updating a record in-place. */ +/** Writes a redo log record of updating a record in-place. */ void btr_cur_update_in_place_log( - /*========================*/ ulint flags, /*!< in: flags */ const rec_t *rec, /*!< in: record */ dict_index_t *index, /*!< in: index of the record */ @@ -3202,11 +3181,9 @@ void btr_cur_update_in_place_log( } #endif /* UNIV_HOTBACKUP */ -/***********************************************************/ /** - Parses a redo log record of updating a record in-place. +/** Parses a redo log record of updating a record in-place. @return end of log record or NULL */ byte *btr_cur_parse_update_in_place( - /*==========================*/ byte *ptr, /*!< in: buffer */ byte *end_ptr, /*!< in: buffer end */ page_t *page, /*!< in/out: page or NULL */ @@ -3275,8 +3252,7 @@ byte *btr_cur_parse_update_in_place( } #ifndef UNIV_HOTBACKUP -/*************************************************************/ /** - See if there is enough place in the page modification log to log +/** See if there is enough place in the page modification log to log an update-in-place. @retval false if out of space; IBUF_BITMAP_FREE will be reset @@ -3288,7 +3264,6 @@ byte *btr_cur_parse_update_in_place( same mini-transaction, or by invoking ibuf_reset_free_bits() before mtr_commit(mtr). */ bool btr_cur_update_alloc_zip_func( - /*==========================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ page_cur_t *cursor, /*!< in/out: B-tree page cursor */ dict_index_t *index, /*!< in: the index corresponding to cursor */ @@ -3355,15 +3330,13 @@ bool btr_cur_update_alloc_zip_func( return (false); } -/*************************************************************/ /** - Updates a record when the update causes no size changes in its fields. +/** Updates a record when the update causes no size changes in its fields. We assume here that the ordering fields of the record do not change. @return locking or undo log related error code, or @retval DB_SUCCESS on success @retval DB_ZIP_OVERFLOW if there is not enough space left on the compressed page (IBUF_BITMAP_FREE was reset outside mtr) */ dberr_t btr_cur_update_in_place( - /*====================*/ ulint flags, /*!< in: undo logging and locking flags */ btr_cur_t *cursor, /*!< in: cursor on the record to update; cursor stays valid and positioned on the @@ -3498,8 +3471,7 @@ dberr_t btr_cur_update_in_place( return (err); } -/*************************************************************/ /** - Tries to update a record on a page in an index tree. It is assumed that mtr +/** Tries to update a record on a page in an index tree. It is assumed that mtr holds an x-latch on the page. The operation does not succeed if there is too little space on the page or if the update would result in too empty a page, so that tree compression is recommended. We assume here that the ordering @@ -3511,7 +3483,6 @@ dberr_t btr_cur_update_in_place( @retval DB_ZIP_OVERFLOW if there is not enough space left on the compressed page (IBUF_BITMAP_FREE was reset outside mtr) */ dberr_t btr_cur_optimistic_update( - /*======================*/ ulint flags, /*!< in: undo logging and locking flags */ btr_cur_t *cursor, /*!< in: cursor on the record to update; cursor stays valid and positioned on the @@ -3759,14 +3730,12 @@ dberr_t btr_cur_optimistic_update( return (err); } -/*************************************************************/ /** - If, in a split, a new supremum record was created as the predecessor of the +/** If, in a split, a new supremum record was created as the predecessor of the updated record, the supremum record must inherit exactly the locks on the updated record. In the split it may have inherited locks from the successor of the updated record, which is not correct. This function restores the right locks for the new supremum. */ static void btr_cur_pess_upd_restore_supremum( - /*==============================*/ buf_block_t *block, /*!< in: buffer block of rec */ const rec_t *rec, /*!< in: updated record */ mtr_t *mtr) /*!< in: mtr */ @@ -3798,15 +3767,13 @@ static void btr_cur_pess_upd_restore_supremum( lock_rec_reset_and_inherit_gap_locks(prev_block, block, PAGE_HEAP_NO_SUPREMUM, page_rec_get_heap_no(rec)); } -/*************************************************************/ /** - Performs an update of a record on a page of a tree. It is assumed +/** Performs an update of a record on a page of a tree. It is assumed that mtr holds an x-latch on the tree and on the cursor page. If the update is made on the leaf level, to avoid deadlocks, mtr must also own x-latches to brothers of page, if those brothers exist. We assume here that the ordering fields of the record do not change. @return DB_SUCCESS or error code */ dberr_t btr_cur_pessimistic_update( - /*=======================*/ ulint flags, /*!< in: undo logging, locking, and rollback flags */ btr_cur_t *cursor, /*!< in/out: cursor on the record to update; @@ -4198,12 +4165,10 @@ dberr_t btr_cur_pessimistic_update( /*==================== B-TREE DELETE MARK AND UNMARK ===============*/ -/****************************************************************/ /** - Writes the redo log record for delete marking or unmarking of an index +/** Writes the redo log record for delete marking or unmarking of an index record. */ UNIV_INLINE void btr_cur_del_mark_set_clust_rec_log( - /*===============================*/ rec_t *rec, /*!< in: record */ dict_index_t *index, /*!< in: index of the record */ trx_id_t trx_id, /*!< in: transaction id */ @@ -4237,12 +4202,10 @@ void btr_cur_del_mark_set_clust_rec_log( } #endif /* !UNIV_HOTBACKUP */ -/****************************************************************/ /** - Parses the redo log record for delete marking or unmarking of a clustered +/** Parses the redo log record for delete marking or unmarking of a clustered index record. @return end of log record or NULL */ byte *btr_cur_parse_del_mark_set_clust_rec( - /*=================================*/ byte *ptr, /*!< in: buffer */ byte *end_ptr, /*!< in: buffer end */ page_t *page, /*!< in/out: page or NULL */ @@ -4312,14 +4275,12 @@ byte *btr_cur_parse_del_mark_set_clust_rec( } #ifndef UNIV_HOTBACKUP -/***********************************************************/ /** - Marks a clustered index record deleted. Writes an undo log record to +/** Marks a clustered index record deleted. Writes an undo log record to undo log on this delete marking. Writes in the trx id field the id of the deleting transaction, and in the roll ptr field pointer to the undo log record created. @return DB_SUCCESS, DB_LOCK_WAIT, or error number */ dberr_t btr_cur_del_mark_set_clust_rec( - /*===========================*/ ulint flags, /*!< in: undo logging and locking flags */ buf_block_t *block, /*!< in/out: buffer block of the record */ rec_t *rec, /*!< in/out: record */ @@ -4396,15 +4357,12 @@ dberr_t btr_cur_del_mark_set_clust_rec( return (err); } -/****************************************************************/ /** - Writes the redo log record for a delete mark setting of a secondary +/** Writes the redo log record for a delete mark setting of a secondary index record. */ UNIV_INLINE -void btr_cur_del_mark_set_sec_rec_log( - /*=============================*/ - rec_t *rec, /*!< in: record */ - ibool val, /*!< in: value to set */ - mtr_t *mtr) /*!< in: mtr */ +void btr_cur_del_mark_set_sec_rec_log(rec_t *rec, /*!< in: record */ + ibool val, /*!< in: value to set */ + mtr_t *mtr) /*!< in: mtr */ { byte *log_ptr; ut_ad(val <= 1); @@ -4429,12 +4387,10 @@ void btr_cur_del_mark_set_sec_rec_log( } #endif /* !UNIV_HOTBACKUP */ -/****************************************************************/ /** - Parses the redo log record for delete marking or unmarking of a secondary +/** Parses the redo log record for delete marking or unmarking of a secondary index record. @return end of log record or NULL */ byte *btr_cur_parse_del_mark_set_sec_rec( - /*===============================*/ byte *ptr, /*!< in: buffer */ byte *end_ptr, /*!< in: buffer end */ page_t *page, /*!< in/out: page or NULL */ @@ -4471,11 +4427,9 @@ byte *btr_cur_parse_del_mark_set_sec_rec( } #ifndef UNIV_HOTBACKUP -/***********************************************************/ /** - Sets a secondary index record delete mark to TRUE or FALSE. +/** Sets a secondary index record delete mark to TRUE or FALSE. @return DB_SUCCESS, DB_LOCK_WAIT, or error number */ dberr_t btr_cur_del_mark_set_sec_rec( - /*=========================*/ ulint flags, /*!< in: locking flag */ btr_cur_t *cursor, /*!< in: cursor */ ibool val, /*!< in: value to set */ @@ -4513,11 +4467,9 @@ dberr_t btr_cur_del_mark_set_sec_rec( return (DB_SUCCESS); } -/***********************************************************/ /** - Sets a secondary index record's delete mark to the given value. This +/** Sets a secondary index record's delete mark to the given value. This function is only used by the insert buffer merge mechanism. */ void btr_cur_set_deleted_flag_for_ibuf( - /*==============================*/ rec_t *rec, /*!< in/out: record */ page_zip_des_t *page_zip, /*!< in/out: compressed page corresponding to rec, or NULL @@ -4539,15 +4491,13 @@ void btr_cur_set_deleted_flag_for_ibuf( /*==================== B-TREE RECORD REMOVE =========================*/ -/*************************************************************/ /** - Tries to compress a page of the tree if it seems useful. It is assumed +/** Tries to compress a page of the tree if it seems useful. It is assumed that mtr holds an x-latch on the tree and on the cursor page. To avoid deadlocks, mtr must also own x-latches to brothers of page, if those brothers exist. NOTE: it is assumed that the caller has reserved enough free extents so that the compression will always succeed if done! @return true if compression occurred */ ibool btr_cur_compress_if_useful( - /*=======================*/ btr_cur_t *cursor, /*!< in/out: cursor on the page to compress; cursor does not stay valid if !adjust and compression occurs */ @@ -4587,13 +4537,11 @@ ibool btr_cur_compress_if_useful( btr_compress(cursor, adjust, mtr)); } -/*******************************************************/ /** - Removes the record on which the tree cursor is positioned on a leaf page. +/** Removes the record on which the tree cursor is positioned on a leaf page. It is assumed that the mtr has an x-latch on the page where the cursor is positioned, but no latch on the whole tree. @return true if success, i.e., the page did not become too empty */ ibool btr_cur_optimistic_delete_func( - /*===========================*/ btr_cur_t *cursor, /*!< in: cursor on leaf page, on the record to delete; cursor stays valid: if deletion succeeds, on function exit it points to the @@ -4686,8 +4634,7 @@ ibool btr_cur_optimistic_delete_func( return (no_compress_needed); } -/*************************************************************/ /** - Removes the record on which the tree cursor is positioned. Tries +/** Removes the record on which the tree cursor is positioned. Tries to compress the page if its fillfactor drops below a threshold or if it is the only page on the level. It is assumed that mtr holds an x-latch on the tree and on the cursor page. To avoid deadlocks, @@ -4696,7 +4643,6 @@ ibool btr_cur_optimistic_delete_func( @return true if compression occurred and false if not or something wrong. */ ibool btr_cur_pessimistic_delete( - /*=======================*/ dberr_t *err, /*!< out: DB_SUCCESS or DB_OUT_OF_FILE_SPACE; the latter may occur because we may have to update node pointers on upper levels, @@ -4900,11 +4846,9 @@ ibool btr_cur_pessimistic_delete( DBUG_RETURN(ret); } -/*******************************************************************/ /** - Adds path information to the cursor for the current page, for which +/** Adds path information to the cursor for the current page, for which the binary search has been performed. */ static void btr_cur_add_path_info( - /*==================*/ btr_cur_t *cursor, /*!< in: cursor positioned on a page */ ulint height, /*!< in: height of the page in tree; 0 means leaf node */ @@ -4943,8 +4887,7 @@ static void btr_cur_add_path_info( slot->page_level = btr_page_get_level_low(page); } -/*******************************************************************/ /** - Estimate the number of rows between slot1 and slot2 for any level on a +/** Estimate the number of rows between slot1 and slot2 for any level on a B-tree. This function starts from slot1->page and reads a few pages to the right, counting their records. If we reach slot2->page quickly then we know exactly how many records there are between slot1 and slot2 and @@ -4956,7 +4899,6 @@ static void btr_cur_add_path_info( n_rows_on_prev_level). In this case we set is_n_rows_exact to FALSE. @return number of rows, not including the borders (exact or estimated) */ static int64_t btr_estimate_n_rows_in_range_on_level( - /*==================================*/ dict_index_t *index, /*!< in: index */ btr_path_t *slot1, /*!< in: left border */ btr_path_t *slot2, /*!< in: right border */ @@ -5437,13 +5379,11 @@ int64_t btr_estimate_n_rows_in_range(dict_index_t *index, return (ret); } -/*******************************************************************/ /** - Record the number of non_null key values in a given index for +/** Record the number of non_null key values in a given index for each n-column prefix of the index where 1 <= n <= dict_index_get_n_unique(index). The estimates are eventually stored in the array: index->stat_n_non_null_key_vals[], which is indexed from 0 to n-1. */ static void btr_record_not_null_field_in_rec( - /*=============================*/ ulint n_unique, /*!< in: dict_index_get_n_unique(index), number of columns uniquely determine an index entry */ @@ -5470,8 +5410,7 @@ static void btr_record_not_null_field_in_rec( } } -/*******************************************************************/ /** - Estimates the number of different key values in a given index, for +/** Estimates the number of different key values in a given index, for each n-column prefix of the index where 1 <= n <= dict_index_get_n_unique(index). The estimates are stored in the array index->stat_n_diff_key_vals[] (indexed 0..n_uniq-1) and the number of pages @@ -5482,7 +5421,6 @@ static void btr_record_not_null_field_in_rec( @return true if the index is available and we get the estimated numbers, false if the index is unavailable. */ bool btr_estimate_number_of_different_key_vals( - /*======================================*/ dict_index_t *index) /*!< in: index */ { btr_cur_t cursor; diff --git a/storage/innobase/btr/btr0pcur.cc b/storage/innobase/btr/btr0pcur.cc index 1193338c2228..b2d6957444e6 100644 --- a/storage/innobase/btr/btr0pcur.cc +++ b/storage/innobase/btr/btr0pcur.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file btr/btr0pcur.cc +/** @file btr/btr0pcur.cc The index tree persistent cursor Created 2/23/1996 Heikki Tuuri @@ -41,12 +40,9 @@ this program; if not, write to the Free Software Foundation, Inc., #include "trx0trx.h" #include "ut0byte.h" -/**************************************************************/ /** - Allocates memory for a persistent cursor object and initializes the cursor. +/** Allocates memory for a persistent cursor object and initializes the cursor. @return own: persistent cursor */ -btr_pcur_t *btr_pcur_create_for_mysql(void) -/*============================*/ -{ +btr_pcur_t *btr_pcur_create_for_mysql(void) { btr_pcur_t *pcur; DBUG_ENTER("btr_pcur_create_for_mysql"); @@ -59,12 +55,9 @@ btr_pcur_t *btr_pcur_create_for_mysql(void) DBUG_RETURN(pcur); } -/**************************************************************/ /** - Resets a persistent cursor object, freeing "::old_rec_buf" if it is +/** Resets a persistent cursor object, freeing "::old_rec_buf" if it is allocated and resetting the other members to their initial values. */ -void btr_pcur_reset( - /*===========*/ - btr_pcur_t *cursor) /*!< in, out: persistent cursor */ +void btr_pcur_reset(btr_pcur_t *cursor) /*!< in, out: persistent cursor */ { btr_pcur_free(cursor); cursor->old_rec_buf = NULL; @@ -78,10 +71,8 @@ void btr_pcur_reset( cursor->pos_state = BTR_PCUR_NOT_POSITIONED; } -/**************************************************************/ /** - Frees the memory for a persistent cursor object. */ +/** Frees the memory for a persistent cursor object. */ void btr_pcur_free_for_mysql( - /*====================*/ btr_pcur_t *cursor) /*!< in, own: persistent cursor */ { DBUG_ENTER("btr_pcur_free_for_mysql"); @@ -92,17 +83,14 @@ void btr_pcur_free_for_mysql( DBUG_VOID_RETURN; } -/**************************************************************/ /** - The position of the cursor is stored by taking an initial segment of the +/** The position of the cursor is stored by taking an initial segment of the record the cursor is positioned on, before, or after, and copying it to the cursor data structure, or just setting a flag if the cursor id before the first in an EMPTY tree, or after the last in an EMPTY tree. NOTE that the page where the cursor is positioned must not be empty if the index tree is not totally empty! */ -void btr_pcur_store_position( - /*====================*/ - btr_pcur_t *cursor, /*!< in: persistent cursor */ - mtr_t *mtr) /*!< in: mtr */ +void btr_pcur_store_position(btr_pcur_t *cursor, /*!< in: persistent cursor */ + mtr_t *mtr) /*!< in: mtr */ { page_cur_t *page_cursor; buf_block_t *block; @@ -186,10 +174,8 @@ void btr_pcur_store_position( cursor->withdraw_clock = buf_withdraw_clock; } -/**************************************************************/ /** - Copies the stored position of a pcur to another pcur. */ +/** Copies the stored position of a pcur to another pcur. */ void btr_pcur_copy_stored_position( - /*==========================*/ btr_pcur_t *pcur_receive, /*!< in: pcur which will receive the position info */ btr_pcur_t *pcur_donate) /*!< in: pcur from which the info is @@ -210,9 +196,8 @@ void btr_pcur_copy_stored_position( pcur_receive->old_n_fields = pcur_donate->old_n_fields; } -/**************************************************************/ /** - Restores the stored position of a persistent cursor bufferfixing the page and - obtaining the specified latches. If the cursor position was saved when the +/** Restores the stored position of a persistent cursor bufferfixing the page + and obtaining the specified latches. If the cursor position was saved when the (1) cursor was positioned on a user record: this function restores the position to the last record LESS OR EQUAL to the stored record; (2) cursor was positioned on a page infimum record: restores the position to @@ -226,7 +211,6 @@ void btr_pcur_copy_stored_position( record and it can be restored on a user record whose ordering fields are identical to the ones of the original user record */ ibool btr_pcur_restore_position_func( - /*===========================*/ ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ... */ btr_pcur_t *cursor, /*!< in: detached persistent cursor */ const char *file, /*!< in: file name */ @@ -374,13 +358,11 @@ ibool btr_pcur_restore_position_func( return (FALSE); } -/*********************************************************/ /** - Moves the persistent cursor to the first record on the next page. Releases the - latch on the current page, and bufferunfixes it. Note that there must not be - modifications on the current page, as then the x-latch can be released only in - mtr_commit. */ +/** Moves the persistent cursor to the first record on the next page. Releases + the latch on the current page, and bufferunfixes it. Note that there must not + be modifications on the current page, as then the x-latch can be released only + in mtr_commit. */ void btr_pcur_move_to_next_page( - /*=======================*/ btr_pcur_t *cursor, /*!< in: persistent cursor; must be on the last record of the current page */ mtr_t *mtr) /*!< in: mtr */ @@ -438,9 +420,8 @@ void btr_pcur_move_to_next_page( ut_d(page_check_dir(next_page)); } -/*********************************************************/ /** - Moves the persistent cursor backward if it is on the first record of the page. - Commits mtr. Note that to prevent a possible deadlock, the operation +/** Moves the persistent cursor backward if it is on the first record of the + page. Commits mtr. Note that to prevent a possible deadlock, the operation first stores the position of the cursor, commits mtr, acquires the necessary latches and restores the cursor position again before returning. The alphabetical position of the cursor is guaranteed to be sensible on @@ -448,7 +429,6 @@ void btr_pcur_move_to_next_page( record of any page, because the structure of the tree may have changed during the time when the cursor had no latches. */ static void btr_pcur_move_backward_from_page( - /*=============================*/ btr_pcur_t *cursor, /*!< in: persistent cursor, must be on the first record of the current page */ mtr_t *mtr) /*!< in: mtr */ @@ -513,12 +493,10 @@ static void btr_pcur_move_backward_from_page( cursor->old_stored = false; } -/*********************************************************/ /** - Moves the persistent cursor to the previous record in the tree. If no records - are left, the cursor stays 'before first in tree'. +/** Moves the persistent cursor to the previous record in the tree. If no + records are left, the cursor stays 'before first in tree'. @return true if the cursor was not before first in tree */ ibool btr_pcur_move_to_prev( - /*==================*/ btr_pcur_t *cursor, /*!< in: persistent cursor; NOTE that the function may release the page latch */ mtr_t *mtr) /*!< in: mtr */ @@ -543,15 +521,13 @@ ibool btr_pcur_move_to_prev( return (TRUE); } -/**************************************************************/ /** - If mode is PAGE_CUR_G or PAGE_CUR_GE, opens a persistent cursor on the first +/** If mode is PAGE_CUR_G or PAGE_CUR_GE, opens a persistent cursor on the first user record satisfying the search condition, in the case PAGE_CUR_L or PAGE_CUR_LE, on the last user record. If no such user record exists, then in the first case sets the cursor after last in tree, and in the latter case before first in tree. The latching mode must be BTR_SEARCH_LEAF or BTR_MODIFY_LEAF. */ void btr_pcur_open_on_user_rec_func( - /*===========================*/ dict_index_t *index, /*!< in: index */ const dtuple_t *tuple, /*!< in: tuple on which search done */ page_cur_mode_t mode, /*!< in: PAGE_CUR_L, ... */ diff --git a/storage/innobase/btr/btr0sea.cc b/storage/innobase/btr/btr0sea.cc index b0f39b3f0d40..8174d839b9c9 100644 --- a/storage/innobase/btr/btr0sea.cc +++ b/storage/innobase/btr/btr0sea.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -31,8 +31,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file btr/btr0sea.cc +/** @file btr/btr0sea.cc The index tree adaptive search Created 2/17/1996 Heikki Tuuri diff --git a/storage/innobase/buf/buf.cc b/storage/innobase/buf/buf.cc index cf7f7533d120..c5c50ca24327 100644 --- a/storage/innobase/buf/buf.cc +++ b/storage/innobase/buf/buf.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -31,8 +31,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file buf/buf.cc +/** @file buf/buf.cc The database buffer buf_pool Created 11/5/1995 Heikki Tuuri diff --git a/storage/innobase/buf/buf.h b/storage/innobase/buf/buf.h index 784138c0f915..8b0ee1b6f153 100644 --- a/storage/innobase/buf/buf.h +++ b/storage/innobase/buf/buf.h @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file buf/buf.h +/** @file buf/buf.h The database buffer pool high-level routines Created 11/5/1995 Heikki Tuuri diff --git a/storage/innobase/buf/buf0buddy.cc b/storage/innobase/buf/buf0buddy.cc index 36cb6a720ff4..bd431c069d28 100644 --- a/storage/innobase/buf/buf0buddy.cc +++ b/storage/innobase/buf/buf0buddy.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file buf/buf0buddy.cc +/** @file buf/buf0buddy.cc Binary buddy allocator for compressed pages Created December 2006 by Marko Makela @@ -91,13 +90,10 @@ enum buf_buddy_state_t { }; #ifdef UNIV_DEBUG_VALGRIND -/**********************************************************************/ /** - Invalidate memory area that we won't access while page is free */ +/** Invalidate memory area that we won't access while page is free */ UNIV_INLINE -void buf_buddy_mem_invalid( - /*==================*/ - buf_buddy_free_t *buf, /*!< in: block to check */ - ulint i) /*!< in: index of zip_free[] */ +void buf_buddy_mem_invalid(buf_buddy_free_t *buf, /*!< in: block to check */ + ulint i) /*!< in: index of zip_free[] */ { const size_t size = BUF_BUDDY_LOW << i; ut_ad(i <= BUF_BUDDY_SIZES); @@ -109,24 +105,19 @@ void buf_buddy_mem_invalid( #define buf_buddy_mem_invalid(buf, i) ut_ad((i) <= BUF_BUDDY_SIZES) #endif /* UNIV_DEBUG_VALGRIND */ -/**********************************************************************/ /** - Check if a buddy is stamped free. +/** Check if a buddy is stamped free. @return whether the buddy is free */ UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) bool buf_buddy_stamp_is_free( - /*====================*/ const buf_buddy_free_t *buf) /*!< in: block to check */ { return (mach_read_from_4(buf->stamp.bytes + BUF_BUDDY_STAMP_OFFSET) == BUF_BUDDY_STAMP_FREE); } -/**********************************************************************/ /** - Stamps a buddy free. */ +/** Stamps a buddy free. */ UNIV_INLINE -void buf_buddy_stamp_free( - /*=================*/ - buf_buddy_free_t *buf, /*!< in/out: block to stamp */ - ulint i) /*!< in: block size */ +void buf_buddy_stamp_free(buf_buddy_free_t *buf, /*!< in/out: block to stamp */ + ulint i) /*!< in: block size */ { ut_d(memset(&buf->stamp, static_cast(i), BUF_BUDDY_LOW << i)); buf_buddy_mem_invalid(buf, i); @@ -135,8 +126,7 @@ void buf_buddy_stamp_free( buf->stamp.size = i; } -/**********************************************************************/ /** - Stamps a buddy nonfree. +/** Stamps a buddy nonfree. @param[in,out] buf block to stamp @param[in] i block size */ #define buf_buddy_stamp_nonfree(buf, i) \ @@ -148,14 +138,11 @@ void buf_buddy_stamp_free( #error "BUF_BUDDY_STAMP_NONFREE != 0xffffffff" #endif -/**********************************************************************/ /** - Get the offset of the buddy of a compressed page frame. +/** Get the offset of the buddy of a compressed page frame. @return the buddy relative of page */ UNIV_INLINE -void *buf_buddy_get( - /*==========*/ - byte *page, /*!< in: compressed page */ - ulint size) /*!< in: page size in bytes */ +void *buf_buddy_get(byte *page, /*!< in: compressed page */ + ulint size) /*!< in: page size in bytes */ { ut_ad(ut_is_2pow(size)); ut_ad(size >= BUF_BUDDY_LOW); @@ -218,16 +205,14 @@ bool buf_buddy_check_free(buf_pool_t *buf_pool, const buf_buddy_free_t *buf, } #endif /* UNIV_DEBUG */ -/**********************************************************************/ /** - Checks if a buf is free i.e.: in the zip_free[]. +/** Checks if a buf is free i.e.: in the zip_free[]. @retval BUF_BUDDY_STATE_FREE if fully free @retval BUF_BUDDY_STATE_USED if currently in use @retval BUF_BUDDY_STATE_PARTIALLY_USED if partially in use. */ -static MY_ATTRIBUTE((warn_unused_result)) buf_buddy_state_t buf_buddy_is_free( - /*==============*/ - buf_buddy_free_t *buf, /*!< in: block to check */ - ulint i) /*!< in: index of - buf_pool->zip_free[] */ +static MY_ATTRIBUTE((warn_unused_result)) buf_buddy_state_t + buf_buddy_is_free(buf_buddy_free_t *buf, /*!< in: block to check */ + ulint i) /*!< in: index of + buf_pool->zip_free[] */ { #ifdef UNIV_DEBUG const ulint size = BUF_BUDDY_LOW << i; diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index dae45785a270..a0080aaae5dc 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -31,8 +31,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file buf/buf0buf.cc +/** @file buf/buf0buf.cc The database buffer buf_pool Created 11/5/1995 Heikki Tuuri @@ -354,13 +353,10 @@ static void buf_pool_register_chunk(buf_chunk_t *chunk) { buf_pool_chunk_map_t::value_type(chunk->blocks->frame, chunk)); } -/********************************************************************/ /** - Gets the smallest oldest_modification lsn for any page in the pool. Returns +/** Gets the smallest oldest_modification lsn for any page in the pool. Returns zero if all modified pages have been flushed to disk. @return oldest modification in pool, zero if none */ -lsn_t buf_pool_get_oldest_modification(void) -/*==================================*/ -{ +lsn_t buf_pool_get_oldest_modification(void) { lsn_t lsn = 0; lsn_t oldest_lsn = 0; @@ -406,10 +402,8 @@ lsn_t buf_pool_get_oldest_modification(void) return (oldest_lsn); } -/********************************************************************/ /** - Get total buffer pool statistics. */ +/** Get total buffer pool statistics. */ void buf_get_total_list_len( - /*===================*/ ulint *LRU_len, /*!< out: length of all LRU lists */ ulint *free_len, /*!< out: length of all free lists */ ulint *flush_list_len) /*!< out: length of all flush lists */ @@ -431,10 +425,8 @@ void buf_get_total_list_len( } } -/********************************************************************/ /** - Get total list size in bytes from all buffer pools. */ +/** Get total list size in bytes from all buffer pools. */ void buf_get_total_list_size_in_bytes( - /*=============================*/ buf_pools_list_size_t *buf_pools_list_size) /*!< out: list sizes in all buffer pools */ { @@ -454,10 +446,8 @@ void buf_get_total_list_size_in_bytes( } } -/********************************************************************/ /** - Get total buffer pool statistics. */ +/** Get total buffer pool statistics. */ void buf_get_total_stat( - /*===============*/ buf_pool_stat_t *tot_stat) /*!< out: buffer pool stats */ { ulint i; @@ -484,11 +474,9 @@ void buf_get_total_stat( } } -/********************************************************************/ /** - Allocates a buffer block. +/** Allocates a buffer block. @return own: the allocated block, in state BUF_BLOCK_MEMORY */ buf_block_t *buf_block_alloc( - /*============*/ buf_pool_t *buf_pool) /*!< in/out: buffer pool instance, or NULL for round-robin selection of the buffer pool */ @@ -657,14 +645,12 @@ void buf_page_print(const byte *read_buf, const page_size_t &page_size, extern mysql_pfs_key_t buffer_block_mutex_key; #endif /* !PFS_SKIP_BUFFER_MUTEX_RWLOCK */ -/********************************************************************/ /** - This function registers mutexes and rwlocks in buffer blocks with +/** This function registers mutexes and rwlocks in buffer blocks with performance schema. If PFS_MAX_BUFFER_MUTEX_LOCK_REGISTER is defined to be a value less than chunk->size, then only mutexes and rwlocks in the first PFS_MAX_BUFFER_MUTEX_LOCK_REGISTER blocks are registered. */ static void pfs_register_buffer_block( - /*======================*/ buf_chunk_t *chunk) /*!< in/out: chunk of buffers */ { buf_block_t *block; @@ -716,10 +702,8 @@ static void pfs_register_buffer_block( } #endif /* PFS_GROUP_BUFFER_SYNC */ -/********************************************************************/ /** - Initializes a buffer control block when the buf_pool is created. */ +/** Initializes a buffer control block when the buf_pool is created. */ static void buf_block_init( - /*===========*/ buf_pool_t *buf_pool, /*!< in: buffer pool instance */ buf_block_t *block, /*!< in: pointer to control block */ byte *frame) /*!< in: pointer to buffer frame */ @@ -785,12 +769,10 @@ static void buf_block_init( ut_ad(rw_lock_validate(&(block->lock))); } -/********************************************************************/ /** - Allocates a chunk of buffer frames. If called for an existing buf_pool, its +/** Allocates a chunk of buffer frames. If called for an existing buf_pool, its free_list_mutex must be locked. @return chunk, or NULL on failure */ static buf_chunk_t *buf_chunk_init( - /*===========*/ buf_pool_t *buf_pool, /*!< in: buffer pool instance */ buf_chunk_t *chunk, /*!< out: chunk of buffers */ ulint mem_size) /*!< in: requested size in bytes */ @@ -882,12 +864,10 @@ static buf_chunk_t *buf_chunk_init( } #ifdef UNIV_DEBUG -/*********************************************************************/ /** - Finds a block in the given buffer chunk that points to a +/** Finds a block in the given buffer chunk that points to a given compressed page. @return buffer block pointing to the compressed page, or NULL */ static buf_block_t *buf_chunk_contains_zip( - /*===================*/ buf_chunk_t *chunk, /*!< in: chunk being checked */ const void *data) /*!< in: pointer to compressed page */ { @@ -929,11 +909,9 @@ buf_block_t *buf_pool_contains_zip(buf_pool_t *buf_pool, const void *data) { } #endif /* UNIV_DEBUG */ -/*********************************************************************/ /** - Checks that all file pages in the buffer chunk are in a replaceable state. +/** Checks that all file pages in the buffer chunk are in a replaceable state. @return address of a non-free block, or NULL if all freed */ static const buf_block_t *buf_chunk_not_freed( - /*================*/ buf_chunk_t *chunk) /*!< in: chunk being checked */ { buf_block_t *block; @@ -975,12 +953,9 @@ static const buf_block_t *buf_chunk_not_freed( return (NULL); } -/********************************************************************/ /** - Set buffer pool size variables +/** Set buffer pool size variables Note: It's safe without mutex protection because of startup only. */ -static void buf_pool_set_sizes(void) -/*====================*/ -{ +static void buf_pool_set_sizes(void) { ulint i; ulint curr_size = 0; @@ -1200,11 +1175,9 @@ static void buf_pool_free_instance(buf_pool_t *buf_pool) { buf_pool->allocator.~ut_allocator(); } -/********************************************************************/ /** - Creates the buffer pool. +/** Creates the buffer pool. @return DB_SUCCESS if success, DB_ERROR if not enough memory or error */ dberr_t buf_pool_init( - /*==========*/ ulint total_size, /*!< in: size of the total pool in bytes */ ulint n_instances) /*!< in: number of instances */ { @@ -1248,12 +1221,9 @@ dberr_t buf_pool_init( return (DB_SUCCESS); } -/********************************************************************/ /** - Frees the buffer pool at shutdown. This must not be invoked before +/** Frees the buffer pool at shutdown. This must not be invoked before freeing all mutexes. */ -void buf_pool_free( - /*==========*/ - ulint n_instances) /*!< in: numbere of instances to free */ +void buf_pool_free(ulint n_instances) /*!< in: numbere of instances to free */ { UT_DELETE(buf_stat_per_index); @@ -2216,11 +2186,8 @@ void buf_resize_thread() { my_thread_end(); } -/********************************************************************/ /** - Clears the adaptive hash index on all pages in the buffer pool. */ -void buf_pool_clear_hash_index(void) -/*===========================*/ -{ +/** Clears the adaptive hash index on all pages in the buffer pool. */ +void buf_pool_clear_hash_index(void) { ulint p; ut_ad(btr_search_own_all(RW_LOCK_X)); @@ -2886,12 +2853,9 @@ buf_page_t *buf_page_get_zip(const page_id_t &page_id, return (bpage); } -/********************************************************************/ /** - Initialize some fields of a control block. */ +/** Initialize some fields of a control block. */ UNIV_INLINE -void buf_block_init_low( - /*===============*/ - buf_block_t *block) /*!< in: block to init */ +void buf_block_init_low(buf_block_t *block) /*!< in: block to init */ { /* No adaptive hash index entries may point to a previously unused (and now freshly allocated) block. */ @@ -2907,13 +2871,10 @@ void buf_block_init_low( } #endif /* !UNIV_HOTBACKUP */ -/********************************************************************/ /** - Decompress a block. +/** Decompress a block. @return true if successful */ -ibool buf_zip_decompress( - /*===============*/ - buf_block_t *block, /*!< in/out: block */ - ibool check) /*!< in: TRUE=verify the page checksum */ +ibool buf_zip_decompress(buf_block_t *block, /*!< in/out: block */ + ibool check) /*!< in: TRUE=verify the page checksum */ { const byte *frame = block->page.zip.data; @@ -3017,13 +2978,11 @@ buf_block_t *buf_block_from_ahi(const byte *ptr) { return (block); } -/********************************************************************/ /** - Find out if a pointer belongs to a buf_block_t. It can be a pointer to +/** Find out if a pointer belongs to a buf_block_t. It can be a pointer to the buf_block_t itself or a member of it. This functions checks one of the buffer pool instances. @return true if ptr belongs to a buf_block_t struct */ static ibool buf_pointer_is_block_field_instance( - /*================================*/ buf_pool_t *buf_pool, /*!< in: buffer pool instance */ const void *ptr) /*!< in: pointer not dereferenced */ { @@ -3045,11 +3004,9 @@ static ibool buf_pointer_is_block_field_instance( return (FALSE); } -/********************************************************************/ /** - Find out if a buffer block was created by buf_chunk_init(). +/** Find out if a buffer block was created by buf_chunk_init(). @return true if "block" has been added to buf_pool->free by buf_chunk_init() */ static ibool buf_block_is_uncompressed( - /*======================*/ buf_pool_t *buf_pool, /*!< in: buffer pool instance */ const buf_block_t *block) /*!< in: pointer to block, not dereferenced */ @@ -3063,12 +3020,9 @@ static ibool buf_block_is_uncompressed( } #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG -/********************************************************************/ /** - Return true if probe is enabled. +/** Return true if probe is enabled. @return true if probe enabled. */ -static bool buf_debug_execute_is_force_flush() -/*==============================*/ -{ +static bool buf_debug_execute_is_force_flush() { DBUG_EXECUTE_IF("ib_buf_force_flush", return (true);); /* This is used during queisce testing, we want to ensure maximum @@ -3690,12 +3644,10 @@ buf_block_t *buf_page_get_gen(const page_id_t &page_id, return (fix_block); } -/********************************************************************/ /** - This is the general function used to get optimistic access to a database +/** This is the general function used to get optimistic access to a database page. @return true if success */ ibool buf_page_optimistic_get( - /*====================*/ ulint rw_latch, /*!< in: RW_S_LATCH, RW_X_LATCH */ buf_block_t *block, /*!< in: guessed buffer block */ ib_uint64_t modify_clock, /*!< in: modify clock value */ @@ -3802,13 +3754,11 @@ ibool buf_page_optimistic_get( return (TRUE); } -/********************************************************************/ /** - This is used to get access to a known database page, when no waiting can be +/** This is used to get access to a known database page, when no waiting can be done. For example, if a search in an adaptive hash index leads us to this frame. @return true if success */ ibool buf_page_get_known_nowait( - /*======================*/ ulint rw_latch, /*!< in: RW_S_LATCH, RW_X_LATCH */ buf_block_t *block, /*!< in: the known page */ ulint mode, /*!< in: BUF_MAKE_YOUNG or BUF_KEEP_OLD */ @@ -3993,12 +3943,9 @@ const buf_block_t *buf_page_try_get_func(const page_id_t &page_id, return (block); } -/********************************************************************/ /** - Initialize some fields of a control block. */ +/** Initialize some fields of a control block. */ UNIV_INLINE -void buf_page_init_low( - /*==============*/ - buf_page_t *bpage) /*!< in: block to init */ +void buf_page_init_low(buf_page_t *bpage) /*!< in: block to init */ { bpage->flush_type = BUF_FLUSH_LRU; bpage->io_fix = BUF_IO_NONE; @@ -4437,12 +4384,10 @@ buf_block_t *buf_page_create(const page_id_t &page_id, return (block); } -/********************************************************************/ /** - Monitor the buffer page read/write activity, and increment corresponding +/** Monitor the buffer page read/write activity, and increment corresponding counter value if MONITOR_MODULE_BUF_PAGE (module_buf_page) module is enabled. */ static void buf_page_monitor( - /*=============*/ const buf_page_t *bpage, /*!< in: pointer to the block */ enum buf_io_fix io_type) /*!< in: io_fix types */ { @@ -4936,13 +4881,10 @@ static void buf_pool_invalidate_instance(buf_pool_t *buf_pool) { buf_refresh_io_stats(buf_pool); } -/*********************************************************************/ /** - Invalidates the file pages in the buffer pool when an archive recovery is +/** Invalidates the file pages in the buffer pool when an archive recovery is completed. All the file pages buffered must be in a replaceable state when this function is called: not latched and not modified. */ -void buf_pool_invalidate(void) -/*=====================*/ -{ +void buf_pool_invalidate(void) { ulint i; for (i = 0; i < srv_buf_pool_instances; i++) { @@ -5156,12 +5098,9 @@ static ibool buf_pool_validate_instance(buf_pool_t *buf_pool) { return (TRUE); } -/*********************************************************************/ /** - Validates the buffer buf_pool data structure. +/** Validates the buffer buf_pool data structure. @return true */ -ibool buf_validate(void) -/*==============*/ -{ +ibool buf_validate(void) { ulint i; for (i = 0; i < srv_buf_pool_instances; i++) { @@ -5260,11 +5199,8 @@ static void buf_print_instance(buf_pool_t *buf_pool) { ut_a(buf_pool_validate_instance(buf_pool)); } -/*********************************************************************/ /** - Prints info of the buffer buf_pool data structure. */ -void buf_print(void) -/*===========*/ -{ +/** Prints info of the buffer buf_pool data structure. */ +void buf_print(void) { ulint i; for (i = 0; i < srv_buf_pool_instances; i++) { @@ -5359,12 +5295,9 @@ static ulint buf_get_latched_pages_number_instance(buf_pool_t *buf_pool) { return (fixed_pages_number); } -/*********************************************************************/ /** - Returns the number of latched pages in all the buffer pools. +/** Returns the number of latched pages in all the buffer pools. @return number of latched pages */ -ulint buf_get_latched_pages_number(void) -/*==============================*/ -{ +ulint buf_get_latched_pages_number(void) { ulint i; ulint total_latched_pages = 0; @@ -5381,12 +5314,9 @@ ulint buf_get_latched_pages_number(void) #endif /* UNIV_DEBUG */ -/*********************************************************************/ /** - Returns the number of pending buf pool read ios. +/** Returns the number of pending buf pool read ios. @return number of pending read I/O operations */ -ulint buf_get_n_pending_read_ios(void) -/*============================*/ -{ +ulint buf_get_n_pending_read_ios(void) { ulint pend_ios = 0; os_rmb; @@ -5397,13 +5327,10 @@ ulint buf_get_n_pending_read_ios(void) return (pend_ios); } -/*********************************************************************/ /** - Returns the ratio in percents of modified pages in the buffer pool / +/** Returns the ratio in percents of modified pages in the buffer pool / database pages in the buffer pool. @return modified page percentage ratio */ -double buf_get_modified_ratio_pct(void) -/*============================*/ -{ +double buf_get_modified_ratio_pct(void) { double ratio; ulint lru_len = 0; ulint free_len = 0; @@ -5418,10 +5345,8 @@ double buf_get_modified_ratio_pct(void) return (ratio); } -/*******************************************************************/ /** - Aggregates a pool stats information with the total buffer pool stats */ +/** Aggregates a pool stats information with the total buffer pool stats */ static void buf_stats_aggregate_pool_info( - /*==========================*/ buf_pool_info_t *total_info, /*!< in/out: the buffer pool info to store aggregated result */ @@ -5471,12 +5396,10 @@ static void buf_stats_aggregate_pool_info( total_info->unzip_sum += pool_info->unzip_sum; total_info->unzip_cur += pool_info->unzip_cur; } -/*******************************************************************/ /** - Collect buffer pool stats information for a buffer pool. Also +/** Collect buffer pool stats information for a buffer pool. Also record aggregated stats if there are more than one buffer pool in the server */ void buf_stats_get_pool_info( - /*====================*/ buf_pool_t *buf_pool, /*!< in: buffer pool */ ulint pool_id, /*!< in: buffer pool ID */ buf_pool_info_t *all_pool_info) /*!< in/out: buffer pool info @@ -5596,10 +5519,8 @@ void buf_stats_get_pool_info( buf_refresh_io_stats(buf_pool); } -/*********************************************************************/ /** - Prints info of the buffer i/o. */ +/** Prints info of the buffer i/o. */ static void buf_print_io_instance( - /*==================*/ buf_pool_info_t *pool_info, /*!< in: buffer pool info */ FILE *file) /*!< in/out: buffer where to print */ { @@ -5674,11 +5595,8 @@ static void buf_print_io_instance( pool_info->io_cur, pool_info->unzip_sum, pool_info->unzip_cur); } -/*********************************************************************/ /** - Prints info of the buffer i/o. */ -void buf_print_io( - /*=========*/ - FILE *file) /*!< in/out: buffer where to print */ +/** Prints info of the buffer i/o. */ +void buf_print_io(FILE *file) /*!< in/out: buffer where to print */ { ulint i; buf_pool_info_t *pool_info; @@ -5738,11 +5656,8 @@ void buf_print_io( ut_free(pool_info); } -/**********************************************************************/ /** - Refreshes the statistics used to print per-second averages. */ -void buf_refresh_io_stats_all(void) -/*==========================*/ -{ +/** Refreshes the statistics used to print per-second averages. */ +void buf_refresh_io_stats_all(void) { for (ulint i = 0; i < srv_buf_pool_instances; i++) { buf_pool_t *buf_pool; @@ -5752,12 +5667,9 @@ void buf_refresh_io_stats_all(void) } } -/**********************************************************************/ /** - Check if all pages in all buffer pools are in a replacable state. +/** Check if all pages in all buffer pools are in a replacable state. @return false if not */ -ibool buf_all_freed(void) -/*===============*/ -{ +ibool buf_all_freed(void) { for (ulint i = 0; i < srv_buf_pool_instances; i++) { buf_pool_t *buf_pool; @@ -5802,7 +5714,6 @@ Gets the current length of the free list of buffer blocks. @return length of the free list */ ulint buf_get_free_list_len(void) -/*=======================*/ { ulint len; diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index 2b81a757e947..283b909995ac 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file buf/buf0dblwr.cc +/** @file buf/buf0dblwr.cc Doublwrite buffer module Created 2011/12/19 @@ -50,13 +49,10 @@ buf_dblwr_t *buf_dblwr = NULL; /** Set to TRUE when the doublewrite buffer is being created */ ibool buf_dblwr_being_created = FALSE; -/****************************************************************/ /** - Determines if a page number is located inside the doublewrite buffer. +/** Determines if a page number is located inside the doublewrite buffer. @return true if the location is inside the two blocks of the doublewrite buffer */ -ibool buf_dblwr_page_inside( - /*==================*/ - page_no_t page_no) /*!< in: page number */ +ibool buf_dblwr_page_inside(page_no_t page_no) /*!< in: page number */ { if (buf_dblwr == NULL) { return (FALSE); @@ -75,15 +71,12 @@ ibool buf_dblwr_page_inside( return (FALSE); } -/****************************************************************/ /** - Calls buf_page_get() on the TRX_SYS_PAGE and returns a pointer to the +/** Calls buf_page_get() on the TRX_SYS_PAGE and returns a pointer to the doublewrite buffer within it. @return pointer to the doublewrite buffer within the filespace header page. */ UNIV_INLINE -byte *buf_dblwr_get( - /*==========*/ - mtr_t *mtr) /*!< in/out: MTR to hold the page latch */ +byte *buf_dblwr_get(mtr_t *mtr) /*!< in/out: MTR to hold the page latch */ { buf_block_t *block; @@ -95,12 +88,9 @@ byte *buf_dblwr_get( return (buf_block_get_frame(block) + TRX_SYS_DOUBLEWRITE); } -/********************************************************************/ /** - Flush a batch of writes to the datafiles that have already been +/** Flush a batch of writes to the datafiles that have already been written to the dblwr buffer on disk. */ -void buf_dblwr_sync_datafiles() -/*======================*/ -{ +void buf_dblwr_sync_datafiles() { /* Wake possible simulated aio thread to actually post the writes to the operating system */ os_aio_simulated_wake_handler_threads(); @@ -113,10 +103,8 @@ void buf_dblwr_sync_datafiles() fil_flush_file_spaces(to_int(FIL_TYPE_TABLESPACE)); } -/****************************************************************/ /** - Creates or initialializes the doublewrite buffer at a database start. */ +/** Creates or initialializes the doublewrite buffer at a database start. */ static void buf_dblwr_init( - /*===========*/ byte *doublewrite) /*!< in: pointer to the doublewrite buf header on trx sys page */ { @@ -158,14 +146,11 @@ static void buf_dblwr_init( static_cast(ut_zalloc_nokey(buf_size * sizeof(void *))); } -/****************************************************************/ /** - Creates the doublewrite buffer to a new InnoDB installation. The header of the - doublewrite buffer is placed on the trx system header page. +/** Creates the doublewrite buffer to a new InnoDB installation. The header of + the doublewrite buffer is placed on the trx system header page. @return true if successful, false if not. */ MY_ATTRIBUTE((warn_unused_result)) -bool buf_dblwr_create(void) -/*==================*/ -{ +bool buf_dblwr_create(void) { buf_block_t *block2; buf_block_t *new_block; byte *doublewrite; @@ -662,11 +647,8 @@ void buf_dblwr_recover_pages(fil_space_t *space) { fil_flush_file_spaces(to_int(FIL_TYPE_TABLESPACE)); } -/****************************************************************/ /** - Frees doublewrite buffer. */ -void buf_dblwr_free(void) -/*================*/ -{ +/** Frees doublewrite buffer. */ +void buf_dblwr_free(void) { /* Free the double write data structures. */ ut_ad(buf_dblwr->s_reserved == 0); ut_ad(buf_dblwr->b_reserved == 0); @@ -687,10 +669,8 @@ void buf_dblwr_free(void) buf_dblwr = NULL; } -/********************************************************************/ /** - Updates the doublewrite buffer when an IO request is completed. */ +/** Updates the doublewrite buffer when an IO request is completed. */ void buf_dblwr_update( - /*=============*/ const buf_page_t *bpage, /*!< in: buffer block descriptor */ buf_flush_t flush_type) /*!< in: flush type */ { @@ -752,10 +732,8 @@ void buf_dblwr_update( } } -/********************************************************************/ /** - Check the LSN values on the page. */ +/** Check the LSN values on the page. */ static void buf_dblwr_check_page_lsn( - /*=====================*/ const page_t *page) /*!< in: page to check */ { if (memcmp(page + (FIL_PAGE_LSN + 4), @@ -773,11 +751,9 @@ static void buf_dblwr_check_page_lsn( } } -/********************************************************************/ /** - Asserts when a corrupt block is find during writing out data to the +/** Asserts when a corrupt block is find during writing out data to the disk. */ static void buf_dblwr_assert_on_corrupt_block( - /*==============================*/ const buf_block_t *block) /*!< in: block to check */ { buf_page_print(block->frame, univ_page_size, BUF_PAGE_PRINT_NO_CRASH); @@ -788,11 +764,9 @@ static void buf_dblwr_assert_on_corrupt_block( " data files."; } -/********************************************************************/ /** - Check the LSN values on the page with which this block is associated. +/** Check the LSN values on the page with which this block is associated. Also validate the page if the option is set. */ static void buf_dblwr_check_block( - /*==================*/ const buf_block_t *block) /*!< in: block to check */ { ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); @@ -852,11 +826,9 @@ static void buf_dblwr_check_block( buf_dblwr_assert_on_corrupt_block(block); } -/********************************************************************/ /** - Writes a page that has already been written to the doublewrite buffer +/** Writes a page that has already been written to the doublewrite buffer to the datafile. It is the job of the caller to sync the datafile. */ static void buf_dblwr_write_block_to_datafile( - /*==============================*/ const buf_page_t *bpage, /*!< in: page to write */ bool sync) /*!< in: true if sync IO is requested */ @@ -900,15 +872,12 @@ static void buf_dblwr_write_block_to_datafile( } } -/********************************************************************/ /** - Flushes possible buffered writes from the doublewrite memory buffer to disk, +/** Flushes possible buffered writes from the doublewrite memory buffer to disk, and also wakes up the aio thread if simulated aio is used. It is very important to call this function after a batch of writes has been posted, and also when we may have to wait for a page latch! Otherwise a deadlock of threads can occur. */ -void buf_dblwr_flush_buffered_writes(void) -/*=================================*/ -{ +void buf_dblwr_flush_buffered_writes(void) { ulint len; dberr_t err; byte *write_buf; @@ -1126,8 +1095,7 @@ void buf_dblwr_add_to_batch(buf_page_t *bpage) { mutex_exit(&(buf_dblwr->mutex)); } -/********************************************************************/ /** - Writes a page to the doublewrite buffer on disk, sync it, then write +/** Writes a page to the doublewrite buffer on disk, sync it, then write the page to the datafile and sync the datafile. This function is used for single page flushes. If all the buffers allocated for single page flushes in the doublewrite buffer are in use we wait here for one to @@ -1135,7 +1103,6 @@ void buf_dblwr_add_to_batch(buf_page_t *bpage) { thread that is using a slot must also release the slot before leaving this function. */ void buf_dblwr_write_single_page( - /*========================*/ buf_page_t *bpage, /*!< in: buffer block to write */ bool sync) /*!< in: true if sync IO requested */ { diff --git a/storage/innobase/buf/buf0dump.cc b/storage/innobase/buf/buf0dump.cc index 9f974666b895..4c16849b7aca 100644 --- a/storage/innobase/buf/buf0dump.cc +++ b/storage/innobase/buf/buf0dump.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file buf/buf0dump.cc +/** @file buf/buf0dump.cc Implements a buffer pool dump/load. Created April 08, 2011 Vasil Dimov @@ -77,32 +76,25 @@ typedef ib_uint64_t buf_dump_t; #define BUF_DUMP_SPACE(a) static_cast((a) >> 32) #define BUF_DUMP_PAGE(a) static_cast((a)&0xFFFFFFFFUL) -/*****************************************************************/ /** - Wakes up the buffer pool dump/load thread and instructs it to start +/** Wakes up the buffer pool dump/load thread and instructs it to start a dump. This function is called by MySQL code via buffer_pool_dump_now() and it should return immediately because the whole MySQL is frozen during its execution. */ -void buf_dump_start() -/*============*/ -{ +void buf_dump_start() { buf_dump_should_start = TRUE; os_event_set(srv_buf_dump_event); } -/*****************************************************************/ /** - Wakes up the buffer pool dump/load thread and instructs it to start +/** Wakes up the buffer pool dump/load thread and instructs it to start a load. This function is called by MySQL code via buffer_pool_load_now() and it should return immediately because the whole MySQL is frozen during its execution. */ -void buf_load_start() -/*============*/ -{ +void buf_load_start() { buf_load_should_start = TRUE; os_event_set(srv_buf_dump_event); } -/*****************************************************************/ /** - Sets the global variable that feeds MySQL's innodb_buffer_pool_dump_status +/** Sets the global variable that feeds MySQL's innodb_buffer_pool_dump_status to the specified string. The format and the following parameters are the same as the ones used for printf(3). The value of this variable can be retrieved by: @@ -111,7 +103,6 @@ void buf_load_start() or by: SHOW STATUS LIKE 'innodb_buffer_pool_dump_status'; */ static MY_ATTRIBUTE((format(printf, 2, 3))) void buf_dump_status( - /*============*/ enum status_severity severity, /*!< in: status severity */ const char *fmt, /*!< in: format */ ...) /*!< in: extra parameters according @@ -140,8 +131,7 @@ static MY_ATTRIBUTE((format(printf, 2, 3))) void buf_dump_status( va_end(ap); } -/*****************************************************************/ /** - Sets the global variable that feeds MySQL's innodb_buffer_pool_load_status +/** Sets the global variable that feeds MySQL's innodb_buffer_pool_load_status to the specified string. The format and the following parameters are the same as the ones used for printf(3). The value of this variable can be retrieved by: @@ -150,7 +140,6 @@ static MY_ATTRIBUTE((format(printf, 2, 3))) void buf_dump_status( or by: SHOW STATUS LIKE 'innodb_buffer_pool_load_status'; */ static MY_ATTRIBUTE((format(printf, 2, 3))) void buf_load_status( - /*============*/ enum status_severity severity, /*!< in: status severity */ const char *fmt, /*!< in: format */ ...) /*!< in: extra parameters according to fmt */ @@ -441,15 +430,12 @@ void buf_load_throttle_if_needed(ulint *last_check_time, *last_activity_count = srv_get_activity_count(); } -/*****************************************************************/ /** - Perform a buffer pool load from the file specified by +/** Perform a buffer pool load from the file specified by innodb_buffer_pool_filename. If any errors occur then the value of innodb_buffer_pool_load_status will be set accordingly, see buf_load_status(). The dump filename can be specified by (relative to srv_data_home): SET GLOBAL innodb_buffer_pool_filename='filename'; */ -static void buf_load() -/*======*/ -{ +static void buf_load() { char full_filename[OS_FILE_MAX_PATH]; char now[32]; FILE *f; @@ -681,15 +667,10 @@ static void buf_load() #endif /* HAVE_PSI_STAGE_INTERFACE */ } -/*****************************************************************/ /** - Aborts a currently running buffer pool load. This function is called by +/** Aborts a currently running buffer pool load. This function is called by MySQL code via buffer_pool_load_abort() and it should return immediately because the whole MySQL is frozen during its execution. */ -void buf_load_abort() -/*============*/ -{ - buf_load_abort_flag = TRUE; -} +void buf_load_abort() { buf_load_abort_flag = TRUE; } /** This is the main thread for buffer pool dump/load. It waits for an event and when waked up either performs a dump or load and sleeps diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index aea06525b9a7..12abbfcc9a68 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file buf/buf0flu.cc +/** @file buf/buf0flu.cc The database buffer buf_pool flush algorithm Created 11/11/1995 Heikki Tuuri @@ -224,10 +223,8 @@ static void buf_flush_page_coordinator_thread(size_t n_page_cleaners); /** Worker thread of page_cleaner. */ static void buf_flush_page_cleaner_thread(); -/******************************************************************/ /** - Increases flush_list size in bytes with the page size in inline function */ +/** Increases flush_list size in bytes with the page size in inline function */ static inline void incr_flush_list_size_in_bytes( - /*==========================*/ buf_block_t *block, /*!< in: control block */ buf_pool_t *buf_pool) /*!< in: buffer pool instance */ { @@ -239,18 +236,14 @@ static inline void incr_flush_list_size_in_bytes( } #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG -/******************************************************************/ /** - Validates the flush list. +/** Validates the flush list. @return true if ok */ static ibool buf_flush_validate_low( - /*===================*/ buf_pool_t *buf_pool); /*!< in: Buffer pool instance */ -/******************************************************************/ /** - Validates the flush list some of the time. +/** Validates the flush list some of the time. @return true if ok or the check was skipped */ static ibool buf_flush_validate_skip( - /*====================*/ buf_pool_t *buf_pool) /*!< in: Buffer pool instance */ { /** Try buf_flush_validate_low() every this many times */ @@ -273,13 +266,11 @@ static ibool buf_flush_validate_skip( } #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ -/******************************************************************/ /** - Insert a block in the flush_rbt and returns a pointer to its +/** Insert a block in the flush_rbt and returns a pointer to its predecessor or NULL if no predecessor. The ordering is maintained on the basis of the key. @return pointer to the predecessor or NULL if no predecessor. */ static buf_page_t *buf_flush_insert_in_flush_rbt( - /*==========================*/ buf_page_t *bpage) /*!< in: bpage to be inserted. */ { const ib_rbt_node_t *c_node; @@ -306,10 +297,8 @@ static buf_page_t *buf_flush_insert_in_flush_rbt( return (prev); } -/*********************************************************/ /** - Delete a bpage from the flush_rbt. */ +/** Delete a bpage from the flush_rbt. */ static void buf_flush_delete_from_flush_rbt( - /*============================*/ buf_page_t *bpage) /*!< in: bpage to be removed. */ { #ifdef UNIV_DEBUG @@ -327,8 +316,7 @@ static void buf_flush_delete_from_flush_rbt( ut_ad(ret); } -/*****************************************************************/ /** - Compare two modified blocks in the buffer pool. The key for comparison +/** Compare two modified blocks in the buffer pool. The key for comparison is: key = This comparison is used to maintian ordering of blocks in the @@ -337,10 +325,8 @@ static void buf_flush_delete_from_flush_rbt( on the oldest_modification. The other two fields are used to uniquely identify the blocks. @return < 0 if b2 < b1, 0 if b2 == b1, > 0 if b2 > b1 */ -static int buf_flush_block_cmp( - /*================*/ - const void *p1, /*!< in: block1 */ - const void *p2) /*!< in: block2 */ +static int buf_flush_block_cmp(const void *p1, /*!< in: block1 */ + const void *p2) /*!< in: block2 */ { int ret; const buf_page_t *b1 = *(const buf_page_t **)p1; @@ -371,13 +357,10 @@ static int buf_flush_block_cmp( return (ret ? ret : (int)(b2->id.page_no() - b1->id.page_no())); } -/********************************************************************/ /** - Initialize the red-black tree to speed up insertions into the flush_list +/** Initialize the red-black tree to speed up insertions into the flush_list during recovery process. Should be called at the start of recovery process before any page has been read/written. */ -void buf_flush_init_flush_rbt(void) -/*==========================*/ -{ +void buf_flush_init_flush_rbt(void) { ulint i; for (i = 0; i < srv_buf_pool_instances; i++) { @@ -396,11 +379,8 @@ void buf_flush_init_flush_rbt(void) } } -/********************************************************************/ /** - Frees up the red-black tree. */ -void buf_flush_free_flush_rbt(void) -/*==========================*/ -{ +/** Frees up the red-black tree. */ +void buf_flush_free_flush_rbt(void) { ulint i; for (i = 0; i < srv_buf_pool_instances; i++) { @@ -421,10 +401,8 @@ void buf_flush_free_flush_rbt(void) } } -/********************************************************************/ /** - Inserts a modified block into the flush list. */ +/** Inserts a modified block into the flush list. */ void buf_flush_insert_into_flush_list( - /*=============================*/ buf_pool_t *buf_pool, /*!< buffer pool instance */ buf_block_t *block, /*!< in/out: block which is modified */ lsn_t lsn) /*!< in: oldest modification */ @@ -474,12 +452,10 @@ void buf_flush_insert_into_flush_list( buf_flush_list_mutex_exit(buf_pool); } -/********************************************************************/ /** - Inserts a modified block into the flush list in the right sorted position. +/** Inserts a modified block into the flush list in the right sorted position. This function is used by recovery, because there the modifications do not necessarily come in the order of lsn's. */ void buf_flush_insert_sorted_into_flush_list( - /*====================================*/ buf_pool_t *buf_pool, /*!< in: buffer pool instance */ buf_block_t *block, /*!< in/out: block which is modified */ lsn_t lsn) /*!< in: oldest modification */ @@ -696,8 +672,7 @@ void buf_flush_remove(buf_page_t *bpage) { buf_flush_list_mutex_exit(buf_pool); } -/*******************************************************************/ /** - Relocates a buffer control block on the flush_list. +/** Relocates a buffer control block on the flush_list. Note that it is assumed that the contents of bpage have already been copied to dpage. IMPORTANT: When this function is called bpage and dpage are not @@ -708,7 +683,6 @@ void buf_flush_remove(buf_page_t *bpage) { the contents of bpage to the dpage and the flush list manipulation below. */ void buf_flush_relocate_on_flush_list( - /*=============================*/ buf_page_t *bpage, /*!< in/out: control block being moved */ buf_page_t *dpage) /*!< in/out: destination block */ { @@ -1812,15 +1786,12 @@ static ulint buf_flush_batch(buf_pool_t *buf_pool, buf_flush_t flush_type, return (count); } -/******************************************************************/ /** - Gather the aggregated stats for both flush list and LRU list flushing. +/** Gather the aggregated stats for both flush list and LRU list flushing. @param page_count_flush number of pages flushed from the end of the flush_list @param page_count_LRU number of pages flushed from the end of the LRU list */ -static void buf_flush_stats( - /*============*/ - ulint page_count_flush, ulint page_count_LRU) { +static void buf_flush_stats(ulint page_count_flush, ulint page_count_LRU) { DBUG_PRINT("ib_buf", ("flush completed, from flush_list %u pages, " "from LRU_list %u pages", unsigned(page_count_flush), unsigned(page_count_LRU))); @@ -1879,13 +1850,10 @@ static void buf_flush_end(buf_pool_t *buf_pool, buf_flush_t flush_type) { } } -/******************************************************************/ /** - Waits until a flush batch of the given type ends */ -void buf_flush_wait_batch_end( - /*=====================*/ - buf_pool_t *buf_pool, /*!< buffer pool instance */ - buf_flush_t type) /*!< in: BUF_FLUSH_LRU - or BUF_FLUSH_LIST */ +/** Waits until a flush batch of the given type ends */ +void buf_flush_wait_batch_end(buf_pool_t *buf_pool, /*!< buffer pool instance */ + buf_flush_t type) /*!< in: BUF_FLUSH_LRU + or BUF_FLUSH_LIST */ { ut_ad(type == BUF_FLUSH_LRU || type == BUF_FLUSH_LIST); @@ -2196,13 +2164,10 @@ void buf_flush_wait_LRU_batch_end(void) { } } -/*********************************************************************/ /** - Calculates if flushing is required based on number of dirty pages in +/** Calculates if flushing is required based on number of dirty pages in the buffer pool. @return percent of io_capacity to flush to manage dirty page ratio */ -static ulint af_get_pct_for_dirty() -/*==================*/ -{ +static ulint af_get_pct_for_dirty() { double dirty_pct = buf_get_modified_ratio_pct(); if (dirty_pct == 0.0) { @@ -2230,12 +2195,9 @@ static ulint af_get_pct_for_dirty() return (0); } -/*********************************************************************/ /** - Calculates if flushing is required based on redo generation rate. +/** Calculates if flushing is required based on redo generation rate. @return percent of io_capacity to flush to manage redo space */ -static ulint af_get_pct_for_lsn( - /*===============*/ - lsn_t age) /*!< in: current age of LSN. */ +static ulint af_get_pct_for_lsn(lsn_t age) /*!< in: current age of LSN. */ { lsn_t max_async_age; lsn_t lsn_age_factor; @@ -2266,17 +2228,15 @@ static ulint af_get_pct_for_lsn( 7.5)); } -/*********************************************************************/ /** - This function is called approximately once every second by the +/** This function is called approximately once every second by the page_cleaner thread. Based on various factors it decides if there is a need to do flushing. @return number of pages recommended to be flushed @param lsn_limit pointer to return LSN up to which flushing must happen @param last_pages_in the number of pages flushed by the last flush_list flushing. */ -static ulint page_cleaner_flush_pages_recommendation( - /*====================================*/ - lsn_t *lsn_limit, ulint last_pages_in) { +static ulint page_cleaner_flush_pages_recommendation(lsn_t *lsn_limit, + ulint last_pages_in) { static lsn_t prev_lsn = 0; static ulint sum_pages = 0; static ulint avg_page_rate = 0; @@ -2491,17 +2451,14 @@ static ulint page_cleaner_flush_pages_recommendation( return (n_pages); } -/*********************************************************************/ /** - Puts the page_cleaner thread to sleep if it has finished work in less +/** Puts the page_cleaner thread to sleep if it has finished work in less than a second @retval 0 wake up by event set, @retval OS_SYNC_TIME_EXCEEDED if timeout was exceeded @param next_loop_time time when next loop iteration should start @param sig_count zero or the value returned by previous call of os_event_reset() */ -static ulint pc_sleep_if_needed( - /*===============*/ - ulint next_loop_time, int64_t sig_count) { +static ulint pc_sleep_if_needed(ulint next_loop_time, int64_t sig_count) { ulint cur_time = ut_time_ms(); if (next_loop_time > cur_time) { @@ -3257,13 +3214,10 @@ static void buf_flush_page_cleaner_thread() { my_thread_end(); } -/*******************************************************************/ /** - Synchronously flush dirty blocks from the end of the flush list of all buffer - pool instances. - NOTE: The calling thread is not allowed to own any latches on pages! */ -void buf_flush_sync_all_buf_pools(void) -/*==============================*/ -{ +/** Synchronously flush dirty blocks from the end of the flush list of all + buffer pool instances. NOTE: The calling thread is not allowed to own any + latches on pages! */ +void buf_flush_sync_all_buf_pools(void) { bool success; do { success = buf_flush_lists(ULINT_MAX, LSN_MAX, NULL); @@ -3294,11 +3248,9 @@ struct Check { void operator()(const buf_page_t *elem) { ut_a(elem->in_flush_list); } }; -/******************************************************************/ /** - Validates the flush list. +/** Validates the flush list. @return true if ok */ static ibool buf_flush_validate_low( - /*===================*/ buf_pool_t *buf_pool) /*!< in: Buffer pool instance */ { buf_page_t *bpage; @@ -3358,12 +3310,9 @@ static ibool buf_flush_validate_low( return (TRUE); } -/******************************************************************/ /** - Validates the flush list. +/** Validates the flush list. @return true if ok */ -ibool buf_flush_validate( - /*===============*/ - buf_pool_t *buf_pool) /*!< buffer pool instance */ +ibool buf_flush_validate(buf_pool_t *buf_pool) /*!< buffer pool instance */ { ibool ret; @@ -3377,12 +3326,10 @@ ibool buf_flush_validate( } #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ -/******************************************************************/ /** - Check if there are any dirty pages that belong to a space id in the flush +/** Check if there are any dirty pages that belong to a space id in the flush list in a particular buffer pool. @return number of dirty pages present in a single buffer pool */ ulint buf_pool_get_dirty_pages_count( - /*===========================*/ buf_pool_t *buf_pool, /*!< in: buffer pool */ space_id_t id, /*!< in: space id to check */ FlushObserver *observer) /*!< in: flush observer to check */ @@ -3412,11 +3359,10 @@ ulint buf_pool_get_dirty_pages_count( return (count); } -/******************************************************************/ /** - Check if there are any dirty pages that belong to a space id in the flush list. +/** Check if there are any dirty pages that belong to a space id in the flush + list. @return number of dirty pages present in all the buffer pools */ static ulint buf_flush_get_dirty_pages_count( - /*============================*/ space_id_t id, /*!< in: space id to check */ FlushObserver *observer) /*!< in: flush observer to check */ { diff --git a/storage/innobase/buf/buf0lru.cc b/storage/innobase/buf/buf0lru.cc index 2022692b91ef..ad94af810f84 100644 --- a/storage/innobase/buf/buf0lru.cc +++ b/storage/innobase/buf/buf0lru.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file buf/buf0lru.cc +/** @file buf/buf0lru.cc The database buffer replacement algorithm Created 11/5/1995 Heikki Tuuri @@ -92,8 +91,7 @@ static const ulint BUF_LRU_SEARCH_SCAN_THRESHOLD = 100; frames in the buffer pool, we set this to TRUE */ static bool buf_lru_switched_on_innodb_mon = false; -/******************************************************************/ /** - These statistics are not 'of' LRU but 'for' LRU. We keep count of I/O +/** These statistics are not 'of' LRU but 'for' LRU. We keep count of I/O and page_zip_decompress() operations. Based on the statistics, buf_LRU_evict_from_unzip_LRU() decides if we want to evict from unzip_LRU or the regular LRU. From unzip_LRU, we will only evict the @@ -159,10 +157,8 @@ this case the block is already returned to the buddy allocator. */ static MY_ATTRIBUTE((warn_unused_result)) bool buf_LRU_block_remove_hashed( buf_page_t *bpage, bool zip, bool ignore_content); -/******************************************************************/ /** - Puts a file page whose has no hash index to the free list. */ +/** Puts a file page whose has no hash index to the free list. */ static void buf_LRU_block_free_hashed_page( - /*===========================*/ buf_block_t *block); /*!< in: block, must contain a file page and be in a state where it can be freed */ @@ -392,13 +388,11 @@ static void buf_flush_yield(buf_pool_t *buf_pool, buf_page_t *bpage) { mutex_exit(block_mutex); } -/******************************************************************/ /** - If we have hogged the resources for too long then release the LRU list and +/** If we have hogged the resources for too long then release the LRU list and flush list mutexes and do a thread yield. Set the current page to "sticky" so that it is not relocated during the yield. @return true if yielded */ static MY_ATTRIBUTE((warn_unused_result)) bool buf_flush_try_yield( - /*================*/ buf_pool_t *buf_pool, /*!< in/out: buffer pool instance */ buf_page_t *bpage, /*!< in/out: bpage to remove */ ulint processed, /*!< in: number of pages processed */ @@ -835,14 +829,12 @@ static void buf_LRU_remove_all_pages(buf_pool_t *buf_pool, ulint id) { } } -/******************************************************************/ /** - Remove pages belonging to a given tablespace inside a specific +/** Remove pages belonging to a given tablespace inside a specific buffer pool instance when we are deleting the data file(s) of that tablespace. The pages still remain a part of LRU and are evicted from the list as they age towards the tail of the LRU only if buf_remove is BUF_REMOVE_FLUSH_NO_WRITE. */ static void buf_LRU_remove_pages( - /*=================*/ buf_pool_t *buf_pool, /*!< buffer pool instance */ space_id_t id, /*!< in: space id */ buf_remove_t buf_remove, /*!< in: remove or flush strategy */ @@ -874,13 +866,11 @@ static void buf_LRU_remove_pages( } } -/******************************************************************/ /** - Flushes all dirty pages or removes all pages belonging +/** Flushes all dirty pages or removes all pages belonging to a given tablespace. A PROBLEM: if readahead is being started, what guarantees that it will not try to read in pages after this operation has completed? */ void buf_LRU_flush_or_remove_pages( - /*==========================*/ space_id_t id, /*!< in: space id */ buf_remove_t buf_remove, /*!< in: remove or flush strategy */ const trx_t *trx) /*!< to check if the operation must @@ -1078,14 +1068,11 @@ bool buf_LRU_scan_and_free_block(buf_pool_t *buf_pool, bool scan_all) { return (freed); } -/******************************************************************/ /** - Returns TRUE if less than 25 % of the buffer pool in any instance is +/** Returns TRUE if less than 25 % of the buffer pool in any instance is available. This can be used in heuristics to prevent huge transactions eating up the whole buffer pool for their locks. @return true if less than 25 % of buffer pool left */ -ibool buf_LRU_buf_pool_running_out(void) -/*==============================*/ -{ +ibool buf_LRU_buf_pool_running_out(void) { ibool ret = FALSE; for (ulint i = 0; i < srv_buf_pool_instances && !ret; i++) { @@ -1152,13 +1139,11 @@ buf_block_t *buf_LRU_get_free_only(buf_pool_t *buf_pool) { return (block); } -/******************************************************************/ /** - Checks how much of buf_pool is occupied by non-data objects like +/** Checks how much of buf_pool is occupied by non-data objects like AHI, lock heaps etc. Depending on the size of non-data objects this function will either assert or issue a warning and switch on the status monitor. */ static void buf_LRU_check_size_of_non_data_objects( - /*===================================*/ const buf_pool_t *buf_pool) /*!< in: buffer pool instance */ { if (!recv_recovery_is_on() && buf_pool->curr_size == buf_pool->old_size && @@ -1458,12 +1443,9 @@ static void buf_unzip_LRU_remove_block_if_needed(buf_page_t *bpage) { } } -/******************************************************************/ /** - Adjust LRU hazard pointers if needed. */ -void buf_LRU_adjust_hp( - /*==============*/ - buf_pool_t *buf_pool, /*!< in: buffer pool instance */ - const buf_page_t *bpage) /*!< in: control block */ +/** Adjust LRU hazard pointers if needed. */ +void buf_LRU_adjust_hp(buf_pool_t *buf_pool, /*!< in: buffer pool instance */ + const buf_page_t *bpage) /*!< in: control block */ { buf_pool->lru_hp.adjust(bpage); buf_pool->lru_scan_itr.adjust(bpage); @@ -1627,18 +1609,15 @@ void buf_LRU_add_block_low(buf_page_t *bpage, ibool old) { } } -/******************************************************************/ /** - Adds a block to the LRU list. Please make sure that the page_size is +/** Adds a block to the LRU list. Please make sure that the page_size is already set when invoking the function, so that we can get correct page_size from the buffer page when adding a block into LRU */ -void buf_LRU_add_block( - /*==============*/ - buf_page_t *bpage, /*!< in: control block */ - ibool old) /*!< in: TRUE if should be put to the old - blocks in the LRU list, else put to the start; - if the LRU list is very short, the block is - added to the start, regardless of this - parameter */ +void buf_LRU_add_block(buf_page_t *bpage, /*!< in: control block */ + ibool old) /*!< in: TRUE if should be put to the old + blocks in the LRU list, else put to the start; + if the LRU list is very short, the block is + added to the start, regardless of this + parameter */ { buf_LRU_add_block_low(bpage, old); } @@ -2221,10 +2200,8 @@ static bool buf_LRU_block_remove_hashed(buf_page_t *bpage, bool zip, return (false); } -/******************************************************************/ /** - Puts a file page whose has no hash index to the free list. */ +/** Puts a file page whose has no hash index to the free list. */ static void buf_LRU_block_free_hashed_page( - /*===========================*/ buf_block_t *block) /*!< in: block, must contain a file page and be in a state where it can be freed */ { @@ -2310,11 +2287,9 @@ static uint buf_LRU_old_ratio_update_instance(buf_pool_t *buf_pool, return ((uint)(ratio * 100 / (double)BUF_LRU_OLD_RATIO_DIV + 0.5)); } -/**********************************************************************/ /** - Updates buf_pool->LRU_old_ratio. +/** Updates buf_pool->LRU_old_ratio. @return updated old_pct */ uint buf_LRU_old_ratio_update( - /*=====================*/ uint old_pct, /*!< in: Reserve this percentage of the buffer pool for "old" blocks. */ ibool adjust) /*!< in: TRUE=adjust the LRU list; @@ -2334,12 +2309,9 @@ uint buf_LRU_old_ratio_update( return (new_ratio); } -/********************************************************************/ /** - Update the historical stats that we are collecting for LRU eviction +/** Update the historical stats that we are collecting for LRU eviction policy at the end of each interval. */ -void buf_LRU_stat_update(void) -/*=====================*/ -{ +void buf_LRU_stat_update(void) { buf_LRU_stat_t *item; buf_pool_t *buf_pool; bool evict_started = FALSE; @@ -2472,12 +2444,9 @@ static void buf_LRU_validate_instance(buf_pool_t *buf_pool) { mutex_exit(&buf_pool->LRU_list_mutex); } -/**********************************************************************/ /** - Validates the LRU list. +/** Validates the LRU list. @return true */ -ibool buf_LRU_validate(void) -/*==================*/ -{ +ibool buf_LRU_validate(void) { for (ulint i = 0; i < srv_buf_pool_instances; i++) { buf_pool_t *buf_pool; @@ -2547,11 +2516,8 @@ static void buf_LRU_print_instance(buf_pool_t *buf_pool) { mutex_exit(&buf_pool->LRU_list_mutex); } -/**********************************************************************/ /** - Prints the LRU list. */ -void buf_LRU_print(void) -/*===============*/ -{ +/** Prints the LRU list. */ +void buf_LRU_print(void) { for (ulint i = 0; i < srv_buf_pool_instances; i++) { buf_pool_t *buf_pool; diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc index b80b2c601868..ab9d91a0212e 100644 --- a/storage/innobase/buf/buf0rea.cc +++ b/storage/innobase/buf/buf0rea.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file buf/buf0rea.cc +/** @file buf/buf0rea.cc The database buffer read Created 11/5/1995 Heikki Tuuri @@ -645,12 +644,10 @@ ulint buf_read_ahead_linear(const page_id_t &page_id, return (count); } -/********************************************************************/ /** - Issues read requests for pages which the ibuf module wants to read in, in +/** Issues read requests for pages which the ibuf module wants to read in, in order to contract the insert buffer tree. Technically, this function is like a read-ahead function. */ void buf_read_ibuf_merge_pages( - /*======================*/ bool sync, /*!< in: true if the caller wants this function to wait for the highest address page diff --git a/storage/innobase/buf/checksum.cc b/storage/innobase/buf/checksum.cc index 518f38ea3d0a..2f6af0c24bb6 100644 --- a/storage/innobase/buf/checksum.cc +++ b/storage/innobase/buf/checksum.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file buf/checksum.cc +/** @file buf/checksum.cc Buffer pool checksum functions, also linked from /extra/innochecksum.cc Created Aug 11, 2011 Vasil Dimov @@ -89,14 +88,11 @@ uint32_t buf_calc_page_crc32(const byte *page, return (c1 ^ c2); } -/********************************************************************/ /** - Calculates a page checksum which is stored to the page when it is written +/** Calculates a page checksum which is stored to the page when it is written to a file. Note that we must be careful to calculate the same value on 32-bit and 64-bit architectures. @return checksum */ -ulint buf_calc_page_new_checksum( - /*=======================*/ - const byte *page) /*!< in: buffer page */ +ulint buf_calc_page_new_checksum(const byte *page) /*!< in: buffer page */ { ulint checksum; @@ -118,17 +114,14 @@ ulint buf_calc_page_new_checksum( return (checksum); } -/********************************************************************/ /** - In versions < 4.0.14 and < 4.1.1 there was a bug that the checksum only +/** In versions < 4.0.14 and < 4.1.1 there was a bug that the checksum only looked at the first few bytes of the page. This calculates that old checksum. NOTE: we must first store the new formula checksum to FIL_PAGE_SPACE_OR_CHKSUM before calculating and storing this old checksum because this takes that field as an input! @return checksum */ -ulint buf_calc_page_old_checksum( - /*=======================*/ - const byte *page) /*!< in: buffer page */ +ulint buf_calc_page_old_checksum(const byte *page) /*!< in: buffer page */ { ulint checksum; @@ -139,11 +132,9 @@ ulint buf_calc_page_old_checksum( return (checksum); } -/********************************************************************/ /** - Return a printable string describing the checksum algorithm. +/** Return a printable string describing the checksum algorithm. @return algorithm name */ const char *buf_checksum_algorithm_name( - /*========================*/ srv_checksum_algorithm_t algo) /*!< in: algorithm */ { switch (algo) { diff --git a/storage/innobase/clone/clone0api.cc b/storage/innobase/clone/clone0api.cc index 1fc875f05bd4..de11b53e7ce4 100644 --- a/storage/innobase/clone/clone0api.cc +++ b/storage/innobase/clone/clone0api.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file clone/clone0api.cc +/** @file clone/clone0api.cc Innodb Clone Interface *******************************************************/ diff --git a/storage/innobase/clone/clone0apply.cc b/storage/innobase/clone/clone0apply.cc index 34b44ced9476..7b55d9e0c155 100644 --- a/storage/innobase/clone/clone0apply.cc +++ b/storage/innobase/clone/clone0apply.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file clone/clone0apply.cc +/** @file clone/clone0apply.cc Innodb apply snapshot data *******************************************************/ diff --git a/storage/innobase/clone/clone0clone.cc b/storage/innobase/clone/clone0clone.cc index 2c25d2012840..f6701c735ee3 100644 --- a/storage/innobase/clone/clone0clone.cc +++ b/storage/innobase/clone/clone0clone.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file clone/clone0clone.cc +/** @file clone/clone0clone.cc Innodb Clone System *******************************************************/ diff --git a/storage/innobase/clone/clone0copy.cc b/storage/innobase/clone/clone0copy.cc index 0e39949d78fd..2ba0ec263fe0 100644 --- a/storage/innobase/clone/clone0copy.cc +++ b/storage/innobase/clone/clone0copy.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file clone/clone0copy.cc +/** @file clone/clone0copy.cc Innodb copy snapshot data *******************************************************/ diff --git a/storage/innobase/clone/clone0desc.cc b/storage/innobase/clone/clone0desc.cc index 4fa5d4c74301..af518783d1fe 100644 --- a/storage/innobase/clone/clone0desc.cc +++ b/storage/innobase/clone/clone0desc.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file clone/clone0desc.cc +/** @file clone/clone0desc.cc Innodb clone descriptors *******************************************************/ diff --git a/storage/innobase/clone/clone0snapshot.cc b/storage/innobase/clone/clone0snapshot.cc index 3b2410eb1eb2..8dcc9a5267fd 100644 --- a/storage/innobase/clone/clone0snapshot.cc +++ b/storage/innobase/clone/clone0snapshot.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file clone/clone0snapshot.cc +/** @file clone/clone0snapshot.cc Innodb physical Snaphot *******************************************************/ diff --git a/storage/innobase/data/data0data.cc b/storage/innobase/data/data0data.cc index d8809290f008..e5ec2eea973b 100644 --- a/storage/innobase/data/data0data.cc +++ b/storage/innobase/data/data0data.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file data/data0data.cc +/** @file data/data0data.cc SQL data field and tuple Created 5/30/1994 Heikki Tuuri @@ -89,13 +88,10 @@ bool dtuple_coll_eq(const dtuple_t *tuple1, const dtuple_t *tuple2) { return (cmp == 0); } -/*********************************************************************/ /** - Sets number of fields used in a tuple. Normally this is set in +/** Sets number of fields used in a tuple. Normally this is set in dtuple_create, but if you want later to set it smaller, you can use this. */ -void dtuple_set_n_fields( - /*================*/ - dtuple_t *tuple, /*!< in: tuple */ - ulint n_fields) /*!< in: number of fields */ +void dtuple_set_n_fields(dtuple_t *tuple, /*!< in: tuple */ + ulint n_fields) /*!< in: number of fields */ { ut_ad(tuple); @@ -103,11 +99,9 @@ void dtuple_set_n_fields( tuple->n_fields_cmp = n_fields; } -/**********************************************************/ /** - Checks that a data field is typed. +/** Checks that a data field is typed. @return true if ok */ static ibool dfield_check_typed_no_assert( - /*=========================*/ const dfield_t *field) /*!< in: data field */ { if (dfield_get_type(field)->mtype > DATA_MTYPE_CURRENT_MAX || @@ -121,11 +115,9 @@ static ibool dfield_check_typed_no_assert( return (TRUE); } -/**********************************************************/ /** - Checks that a data tuple is typed. +/** Checks that a data tuple is typed. @return true if ok */ static ibool dtuple_check_typed_no_assert( - /*=========================*/ const dtuple_t *tuple) /*!< in: tuple */ { const dfield_t *field; @@ -155,12 +147,9 @@ static ibool dtuple_check_typed_no_assert( #endif /* !UNIV_HOTBACKUP */ #ifdef UNIV_DEBUG -/**********************************************************/ /** - Checks that a data field is typed. Asserts an error if not. +/** Checks that a data field is typed. Asserts an error if not. @return true if ok */ -ibool dfield_check_typed( - /*===============*/ - const dfield_t *field) /*!< in: data field */ +ibool dfield_check_typed(const dfield_t *field) /*!< in: data field */ { if (dfield_get_type(field)->mtype > DATA_MTYPE_CURRENT_MAX || dfield_get_type(field)->mtype < DATA_MTYPE_CURRENT_MIN) { @@ -171,12 +160,9 @@ ibool dfield_check_typed( return (TRUE); } -/**********************************************************/ /** - Checks that a data tuple is typed. Asserts an error if not. +/** Checks that a data tuple is typed. Asserts an error if not. @return true if ok */ -ibool dtuple_check_typed( - /*===============*/ - const dtuple_t *tuple) /*!< in: tuple */ +ibool dtuple_check_typed(const dtuple_t *tuple) /*!< in: tuple */ { const dfield_t *field; ulint i; @@ -190,13 +176,10 @@ ibool dtuple_check_typed( return (TRUE); } -/**********************************************************/ /** - Validates the consistency of a tuple which must be complete, i.e, +/** Validates the consistency of a tuple which must be complete, i.e, all fields must have been set. @return true if ok */ -ibool dtuple_validate( - /*============*/ - const dtuple_t *tuple) /*!< in: tuple */ +ibool dtuple_validate(const dtuple_t *tuple) /*!< in: tuple */ { const dfield_t *field; ulint n_fields; @@ -237,12 +220,9 @@ ibool dtuple_validate( #endif /* UNIV_DEBUG */ #ifndef UNIV_HOTBACKUP -/*************************************************************/ /** - Pretty prints a dfield value according to its data type. Also the hex string +/** Pretty prints a dfield value according to its data type. Also the hex string is printed if a string contains non-printable characters. */ -void dfield_print_also_hex( - /*==================*/ - const dfield_t *dfield) /*!< in: dfield */ +void dfield_print_also_hex(const dfield_t *dfield) /*!< in: dfield */ { const byte *data; ulint len; @@ -395,12 +375,9 @@ void dfield_print_also_hex( } } -/*************************************************************/ /** - Print a dfield value using ut_print_buf. */ -static void dfield_print_raw( - /*=============*/ - FILE *f, /*!< in: output stream */ - const dfield_t *dfield) /*!< in: dfield */ +/** Print a dfield value using ut_print_buf. */ +static void dfield_print_raw(FILE *f, /*!< in: output stream */ + const dfield_t *dfield) /*!< in: dfield */ { ulint len = dfield_get_len(dfield); if (!dfield_is_null(dfield)) { @@ -415,12 +392,9 @@ static void dfield_print_raw( } } -/**********************************************************/ /** - The following function prints the contents of a tuple. */ -void dtuple_print( - /*=========*/ - FILE *f, /*!< in: output stream */ - const dtuple_t *tuple) /*!< in: tuple */ +/** The following function prints the contents of a tuple. */ +void dtuple_print(FILE *f, /*!< in: output stream */ + const dtuple_t *tuple) /*!< in: tuple */ { ulint n_fields; ulint i; @@ -485,21 +459,18 @@ void dtuple_print(std::ostream &o, const dtuple_t *tuple) { o << "}"; } -/**************************************************************/ /** - Moves parts of long fields in entry to the big record vector so that +/** Moves parts of long fields in entry to the big record vector so that the size of tuple drops below the maximum record size allowed in the database. Moves data only from those fields which are not necessary to determine uniquely the insertion place of the tuple in the index. @return own: created big record vector, NULL if we are not able to shorten the entry enough, i.e., if there are too many fixed-length or short fields in entry or the index is clustered */ -big_rec_t *dtuple_convert_big_rec( - /*===================*/ - dict_index_t *index, /*!< in: index */ - upd_t *upd, /*!< in/out: update vector */ - dtuple_t *entry, /*!< in/out: index entry */ - ulint *n_ext) /*!< in/out: number of - externally stored columns */ +big_rec_t *dtuple_convert_big_rec(dict_index_t *index, /*!< in: index */ + upd_t *upd, /*!< in/out: update vector */ + dtuple_t *entry, /*!< in/out: index entry */ + ulint *n_ext) /*!< in/out: number of + externally stored columns */ { DBUG_ENTER("dtuple_convert_big_rec"); @@ -696,12 +667,10 @@ big_rec_t *dtuple_convert_big_rec( DBUG_RETURN(vector); } -/**************************************************************/ /** - Puts back to entry the data stored in vector. Note that to ensure the +/** Puts back to entry the data stored in vector. Note that to ensure the fields in entry can accommodate the data, vector must have been created from entry with dtuple_convert_big_rec. */ void dtuple_convert_back_big_rec( - /*========================*/ dict_index_t *index MY_ATTRIBUTE((unused)), /*!< in: index */ dtuple_t *entry, /*!< in: entry whose data was put to vector */ big_rec_t *vector) /*!< in, own: big rec vector; it is diff --git a/storage/innobase/data/data0type.cc b/storage/innobase/data/data0type.cc index 0a8a4ed72640..db0528f5dd26 100644 --- a/storage/innobase/data/data0type.cc +++ b/storage/innobase/data/data0type.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file data/data0type.cc +/** @file data/data0type.cc Data types Created 1/16/1996 Heikki Tuuri @@ -44,13 +43,11 @@ charset-collation code for them. */ ulint data_mysql_default_charset_coll; -/*********************************************************************/ /** - Determine how many bytes the first n characters of the given string occupy. +/** Determine how many bytes the first n characters of the given string occupy. If the string is shorter than n characters, returns the number of bytes the characters in the string occupy. @return length of the prefix, in bytes */ ulint dtype_get_at_most_n_mbchars( - /*========================*/ ulint prtype, /*!< in: precise type */ ulint mbminmaxlen, /*!< in: minimum and maximum length of a multi-byte character */ @@ -80,12 +77,10 @@ ulint dtype_get_at_most_n_mbchars( return (data_len); } -/*********************************************************************/ /** - Checks if a data main type is a string type. Also a BLOB is considered a +/** Checks if a data main type is a string type. Also a BLOB is considered a string type. @return true if string type */ ibool dtype_is_string_type( - /*=================*/ ulint mtype) /*!< in: InnoDB main data type code: DATA_CHAR, ... */ { if (mtype <= DATA_BLOB || mtype == DATA_MYSQL || mtype == DATA_VARMYSQL) { @@ -95,15 +90,12 @@ ibool dtype_is_string_type( return (FALSE); } -/*********************************************************************/ /** - Checks if a type is a binary string type. Note that for tables created with +/** Checks if a type is a binary string type. Note that for tables created with < 4.0.14, we do not know if a DATA_BLOB column is a BLOB or a TEXT column. For those DATA_BLOB columns this function currently returns FALSE. @return true if binary string type */ -ibool dtype_is_binary_string_type( - /*========================*/ - ulint mtype, /*!< in: main data type */ - ulint prtype) /*!< in: precise type */ +ibool dtype_is_binary_string_type(ulint mtype, /*!< in: main data type */ + ulint prtype) /*!< in: precise type */ { if ((mtype == DATA_FIXBINARY) || (mtype == DATA_BINARY) || (mtype == DATA_BLOB && (prtype & DATA_BINARY_TYPE))) { @@ -113,16 +105,13 @@ ibool dtype_is_binary_string_type( return (FALSE); } -/*********************************************************************/ /** - Checks if a type is a non-binary string type. That is, dtype_is_string_type is - TRUE and dtype_is_binary_string_type is FALSE. Note that for tables created +/** Checks if a type is a non-binary string type. That is, dtype_is_string_type + is TRUE and dtype_is_binary_string_type is FALSE. Note that for tables created with < 4.0.14, we do not know if a DATA_BLOB column is a BLOB or a TEXT column. For those DATA_BLOB columns this function currently returns TRUE. @return true if non-binary string type */ -ibool dtype_is_non_binary_string_type( - /*============================*/ - ulint mtype, /*!< in: main data type */ - ulint prtype) /*!< in: precise type */ +ibool dtype_is_non_binary_string_type(ulint mtype, /*!< in: main data type */ + ulint prtype) /*!< in: precise type */ { if (dtype_is_string_type(mtype) == TRUE && dtype_is_binary_string_type(mtype, prtype) == FALSE) { @@ -132,12 +121,10 @@ ibool dtype_is_non_binary_string_type( return (FALSE); } -/*********************************************************************/ /** - Forms a precise type from the < 4.1.2 format precise type plus the +/** Forms a precise type from the < 4.1.2 format precise type plus the charset-collation code. @return precise type, including the charset-collation code */ ulint dtype_form_prtype( - /*==============*/ ulint old_prtype, /*!< in: the MySQL type code and the flags DATA_BINARY_TYPE etc. */ ulint charset_coll) /*!< in: MySQL charset-collation code */ @@ -148,12 +135,9 @@ ulint dtype_form_prtype( return (old_prtype + (charset_coll << 16)); } -/*********************************************************************/ /** - Validates a data type structure. +/** Validates a data type structure. @return true if ok */ -ibool dtype_validate( - /*===========*/ - const dtype_t *type) /*!< in: type struct to validate */ +ibool dtype_validate(const dtype_t *type) /*!< in: type struct to validate */ { ut_a(type); ut_a(type->mtype >= DATA_VARCHAR); diff --git a/storage/innobase/dict/dict.cc b/storage/innobase/dict/dict.cc index 4272be8ae668..eb3f3ff90505 100644 --- a/storage/innobase/dict/dict.cc +++ b/storage/innobase/dict/dict.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -25,8 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file dict/dict.cc +/** @file dict/dict.cc Data dictionary system Created 1/8/1996 Heikki Tuuri diff --git a/storage/innobase/dict/dict.h b/storage/innobase/dict/dict.h index 5d2310a2faa9..3904a83f0972 100644 --- a/storage/innobase/dict/dict.h +++ b/storage/innobase/dict/dict.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -25,8 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file dict/dict.h +/** @file dict/dict.h Data dictionary system Created 1/8/1996 Heikki Tuuri diff --git a/storage/innobase/dict/dict0boot.cc b/storage/innobase/dict/dict0boot.cc index 7b32551b36ec..c8f48d19f3d5 100644 --- a/storage/innobase/dict/dict0boot.cc +++ b/storage/innobase/dict/dict0boot.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file dict/dict0boot.cc +/** @file dict/dict0boot.cc Data dictionary creation and booting Created 4/18/1996 Heikki Tuuri @@ -45,12 +44,9 @@ this program; if not, write to the Free Software Foundation, Inc., #include "srv0srv.h" #include "trx0trx.h" -/**********************************************************************/ /** - Gets a pointer to the dictionary header and x-latches its page. +/** Gets a pointer to the dictionary header and x-latches its page. @return pointer to the dictionary header, page x-latched */ -dict_hdr_t *dict_hdr_get( - /*=========*/ - mtr_t *mtr) /*!< in: mtr */ +dict_hdr_t *dict_hdr_get(mtr_t *mtr) /*!< in: mtr */ { buf_block_t *block; dict_hdr_t *header; @@ -64,20 +60,17 @@ dict_hdr_t *dict_hdr_get( return (header); } -/**********************************************************************/ /** - Returns a new table, index, or space id. */ -void dict_hdr_get_new_id( - /*================*/ - table_id_t *table_id, /*!< out: table id - (not assigned if NULL) */ - space_index_t *index_id, /*!< out: index id - (not assigned if NULL) */ - space_id_t *space_id, /*!< out: space id - (not assigned if NULL) */ - const dict_table_t *table, /*!< in: table */ - bool disable_redo) /*!< in: if true and table - object is NULL - then disable-redo */ +/** Returns a new table, index, or space id. */ +void dict_hdr_get_new_id(table_id_t *table_id, /*!< out: table id + (not assigned if NULL) */ + space_index_t *index_id, /*!< out: index id + (not assigned if NULL) */ + space_id_t *space_id, /*!< out: space id + (not assigned if NULL) */ + const dict_table_t *table, /*!< in: table */ + bool disable_redo) /*!< in: if true and table + object is NULL + then disable-redo */ { dict_hdr_t *dict_hdr; ib_id_t id; @@ -154,12 +147,9 @@ void dict_hdr_get_new_id( mtr_commit(&mtr); } -/**********************************************************************/ /** - Writes the current value of the row id counter to the dictionary header file +/** Writes the current value of the row id counter to the dictionary header file page. */ -void dict_hdr_flush_row_id(void) -/*=======================*/ -{ +void dict_hdr_flush_row_id(void) { dict_hdr_t *dict_hdr; row_id_t id; mtr_t mtr; @@ -177,13 +167,10 @@ void dict_hdr_flush_row_id(void) mtr_commit(&mtr); } -/*****************************************************************/ /** - Creates the file page for the dictionary header. This function is +/** Creates the file page for the dictionary header. This function is called only at the database creation. @return true if succeed */ -static ibool dict_hdr_create( - /*============*/ - mtr_t *mtr) /*!< in: mtr */ +static ibool dict_hdr_create(mtr_t *mtr) /*!< in: mtr */ { buf_block_t *block; dict_hdr_t *dict_header; @@ -213,13 +200,10 @@ static ibool dict_hdr_create( return (TRUE); } -/*****************************************************************/ /** - Initializes the data dictionary memory structures when the database is +/** Initializes the data dictionary memory structures when the database is started. This function is also called when the data dictionary is created. @return DB_SUCCESS or error code. */ -dberr_t dict_boot(void) -/*===========*/ -{ +dberr_t dict_boot(void) { dict_hdr_t *dict_hdr; mtr_t mtr; dberr_t err = DB_SUCCESS; @@ -451,12 +435,9 @@ dberr_t dict_boot(void) return (err); } -/*****************************************************************/ /** - Creates and initializes the data dictionary at the server bootstrap. +/** Creates and initializes the data dictionary at the server bootstrap. @return DB_SUCCESS or error code. */ -dberr_t dict_create(void) -/*=============*/ -{ +dberr_t dict_create(void) { mtr_t mtr; mtr_start(&mtr); diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc index 5395a8ff007e..3b0593c20eb4 100644 --- a/storage/innobase/dict/dict0crea.cc +++ b/storage/innobase/dict/dict0crea.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file dict/dict0crea.cc +/** @file dict/dict0crea.cc Database object creation Created 1/8/1996 Heikki Tuuri @@ -301,14 +300,11 @@ dberr_t dict_build_tablespace_for_table(dict_table_t *table, trx_t *trx) { return (DB_SUCCESS); } -/***************************************************************/ /** - Builds an index definition +/** Builds an index definition @return DB_SUCCESS or error code */ -void dict_build_index_def( - /*=================*/ - const dict_table_t *table, /*!< in: table */ - dict_index_t *index, /*!< in/out: index */ - trx_t *trx) /*!< in/out: InnoDB transaction handle */ +void dict_build_index_def(const dict_table_t *table, /*!< in: table */ + dict_index_t *index, /*!< in/out: index */ + trx_t *trx) /*!< in/out: InnoDB transaction handle */ { ut_ad(!mutex_own(&dict_sys->mutex)); ut_ad((UT_LIST_GET_LEN(table->indexes) > 0) || index->is_clustered()); diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 9589bae330bf..d3b0c2084780 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -25,8 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file dict/dict0dict.cc +/** @file dict/dict0dict.cc Data dictionary system Created 1/8/1996 Heikki Tuuri @@ -190,63 +189,48 @@ index. static ibool dict_index_find_cols(const dict_table_t *table, dict_index_t *index, const dict_add_v_col_t *add_v); -/*******************************************************************/ /** - Builds the internal dictionary cache representation for a clustered +/** Builds the internal dictionary cache representation for a clustered index, containing also system fields not defined by the user. @return own: the internal representation of the clustered index */ static dict_index_t *dict_index_build_internal_clust( - /*============================*/ const dict_table_t *table, /*!< in: table */ dict_index_t *index); /*!< in: user representation of a clustered index */ -/*******************************************************************/ /** - Builds the internal dictionary cache representation for a non-clustered +/** Builds the internal dictionary cache representation for a non-clustered index, containing also system fields not defined by the user. @return own: the internal representation of the non-clustered index */ static dict_index_t *dict_index_build_internal_non_clust( - /*================================*/ const dict_table_t *table, /*!< in: table */ dict_index_t *index); /*!< in: user representation of a non-clustered index */ -/**********************************************************************/ /** - Builds the internal dictionary cache representation for an FTS index. +/** Builds the internal dictionary cache representation for an FTS index. @return own: the internal representation of the FTS index */ static dict_index_t *dict_index_build_internal_fts( - /*==========================*/ dict_table_t *table, /*!< in: table */ dict_index_t *index); /*!< in: user representation of an FTS index */ -/**********************************************************************/ /** - Removes an index from the dictionary cache. */ +/** Removes an index from the dictionary cache. */ static void dict_index_remove_from_cache_low( - /*=============================*/ dict_table_t *table, /*!< in/out: table */ dict_index_t *index, /*!< in, own: index */ ibool lru_evict); /*!< in: TRUE if page being evicted to make room in the table LRU list */ -/**********************************************************************/ /** - Removes a table object from the dictionary cache. */ +/** Removes a table object from the dictionary cache. */ static void dict_table_remove_from_cache_low( dict_table_t *table, /*!< in, own: table */ ibool lru_evict); /*!< in: TRUE if evicting from LRU */ #ifdef UNIV_DEBUG -/**********************************************************************/ /** - Validate the dictionary table LRU list. +/** Validate the dictionary table LRU list. @return true if validate OK */ static ibool dict_lru_validate(void); -/*===================*/ -/**********************************************************************/ /** - Check if table is in the dictionary table LRU list. +/** Check if table is in the dictionary table LRU list. @return true if table found */ static ibool dict_lru_find_table( - /*================*/ const dict_table_t *find_table); /*!< in: table to find */ -/**********************************************************************/ /** - Check if a table exists in the dict table non-LRU list. +/** Check if a table exists in the dict table non-LRU list. @return true if table found */ static ibool dict_non_lru_find_table( - /*====================*/ const dict_table_t *find_table); /*!< in: table to find */ #endif /* UNIV_DEBUG */ @@ -256,11 +240,9 @@ FILE *dict_foreign_err_file = NULL; /* mutex protecting the foreign and unique error buffers */ ib_mutex_t dict_foreign_err_mutex; -/********************************************************************/ /** - Checks if the database name in two table names is the same. +/** Checks if the database name in two table names is the same. @return true if same db name */ ibool dict_tables_have_same_db( - /*=====================*/ const char *name1, /*!< in: table name in the form dbname '/' tablename */ const char *name2) /*!< in: table name in the form @@ -275,11 +257,9 @@ ibool dict_tables_have_same_db( return (FALSE); } -/********************************************************************/ /** - Return the end of table name where we have removed dbname and '/'. +/** Return the end of table name where we have removed dbname and '/'. @return table name */ const char *dict_remove_db_name( - /*================*/ const char *name) /*!< in: table name in the form dbname '/' tablename */ { @@ -290,13 +270,10 @@ const char *dict_remove_db_name( } #endif /* !UNIV_HOTBACKUP */ -/********************************************************************/ /** - Get the database name length in a table name. +/** Get the database name length in a table name. @return database name length */ -ulint dict_get_db_name_len( - /*=================*/ - const char *name) /*!< in: table name in the form - dbname '/' tablename */ +ulint dict_get_db_name_len(const char *name) /*!< in: table name in the form + dbname '/' tablename */ { const char *s; s = strchr(name, '/'); @@ -307,21 +284,11 @@ ulint dict_get_db_name_len( } #ifndef UNIV_HOTBACKUP -/********************************************************************/ /** - Reserves the dictionary system mutex for MySQL. */ -void dict_mutex_enter_for_mysql(void) -/*============================*/ -{ - mutex_enter(&dict_sys->mutex); -} +/** Reserves the dictionary system mutex for MySQL. */ +void dict_mutex_enter_for_mysql(void) { mutex_enter(&dict_sys->mutex); } -/********************************************************************/ /** - Releases the dictionary system mutex for MySQL. */ -void dict_mutex_exit_for_mysql(void) -/*===========================*/ -{ - mutex_exit(&dict_sys->mutex); -} +/** Releases the dictionary system mutex for MySQL. */ +void dict_mutex_exit_for_mysql(void) { mutex_exit(&dict_sys->mutex); } /** Allocate and init a dict_table_t's stats latch. This function must not be called concurrently on the same table object. @@ -435,11 +402,9 @@ void dict_table_stats_unlock(dict_table_t *table, ulint latch_mode) { } } -/**********************************************************************/ /** - Try to drop any indexes after an aborted index creation. +/** Try to drop any indexes after an aborted index creation. This can also be after a server kill during DROP INDEX. */ static void dict_table_try_drop_aborted( - /*========================*/ dict_table_t *table, /*!< in: table, or NULL if it needs to be looked up again */ table_id_t table_id, /*!< in: table identifier */ @@ -477,12 +442,10 @@ static void dict_table_try_drop_aborted( trx_free_for_background(trx); } -/**********************************************************************/ /** - When opening a table, +/** When opening a table, try to drop any indexes after an aborted index creation. Release the dict_sys->mutex. */ static void dict_table_try_drop_aborted_and_mutex_exit( - /*=======================================*/ dict_table_t *table, /*!< in: table (may be NULL) */ ibool try_drop) /*!< in: FALSE if should try to drop indexes whose online creation @@ -503,15 +466,12 @@ static void dict_table_try_drop_aborted_and_mutex_exit( } #endif /* !UNIV_HOTBACKUP */ -/********************************************************************/ /** - Decrements the count of open handles to a table. */ -void dict_table_close( - /*=============*/ - dict_table_t *table, /*!< in/out: table */ - ibool dict_locked, /*!< in: TRUE=data dictionary locked */ - ibool try_drop) /*!< in: TRUE=try to drop any orphan - indexes after an aborted online - index creation */ +/** Decrements the count of open handles to a table. */ +void dict_table_close(dict_table_t *table, /*!< in/out: table */ + ibool dict_locked, /*!< in: TRUE=data dictionary locked */ + ibool try_drop) /*!< in: TRUE=try to drop any orphan + indexes after an aborted online + index creation */ { ibool drop_aborted; @@ -589,14 +549,12 @@ void dict_table_close( } #ifndef UNIV_HOTBACKUP -/********************************************************************/ /** - Closes the only open handle to a table and drops a table while assuring +/** Closes the only open handle to a table and drops a table while assuring that dict_sys->mutex is held the whole time. This assures that the table is not evicted after the close when the count of open handles goes to zero. Because dict_sys->mutex is held, we do not need to call dict_table_prevent_eviction(). */ void dict_table_close_and_drop( - /*======================*/ trx_t *trx, /*!< in: data dictionary transaction */ dict_table_t *table) /*!< in/out: table */ { @@ -754,11 +712,8 @@ static void dict_index_zip_pad_alloc(void *index_void) { mutex_create(LATCH_ID_ZIP_PAD_MUTEX, index->zip_pad.mutex); } -/********************************************************************/ /** - Acquire the autoinc lock. */ -void dict_table_autoinc_lock( - /*====================*/ - dict_table_t *table) /*!< in/out: table */ +/** Acquire the autoinc lock. */ +void dict_table_autoinc_lock(dict_table_t *table) /*!< in/out: table */ { os_once::do_or_wait_for_done(&table->autoinc_mutex_created, dict_table_autoinc_alloc, table); @@ -775,10 +730,8 @@ static void dict_index_zip_pad_lock(dict_index_t *index) { mutex_enter(index->zip_pad.mutex); } -/********************************************************************/ /** - Unconditionally set the autoinc counter. */ +/** Unconditionally set the autoinc counter. */ void dict_table_autoinc_initialize( - /*==========================*/ dict_table_t *table, /*!< in/out: table */ ib_uint64_t value) /*!< in: next value to assign to a row */ { @@ -806,24 +759,19 @@ ulint dict_table_get_all_fts_indexes(dict_table_t *table, return (ib_vector_size(indexes)); } -/********************************************************************/ /** - Reads the next autoinc value (== autoinc counter value), 0 if not yet +/** Reads the next autoinc value (== autoinc counter value), 0 if not yet initialized. @return value for a new row, or 0 */ -ib_uint64_t dict_table_autoinc_read( - /*====================*/ - const dict_table_t *table) /*!< in: table */ +ib_uint64_t dict_table_autoinc_read(const dict_table_t *table) /*!< in: table */ { ut_ad(dict_table_autoinc_own(table)); return (table->autoinc); } -/********************************************************************/ /** - Updates the autoinc counter if the value supplied is greater than the +/** Updates the autoinc counter if the value supplied is greater than the current value. */ void dict_table_autoinc_update_if_greater( - /*=================================*/ dict_table_t *table, /*!< in/out: table */ ib_uint64_t value) /*!< in: value which was assigned to a row */ @@ -835,11 +783,8 @@ void dict_table_autoinc_update_if_greater( } } -/********************************************************************/ /** - Release the autoinc lock. */ -void dict_table_autoinc_unlock( - /*======================*/ - dict_table_t *table) /*!< in/out: table */ +/** Release the autoinc lock. */ +void dict_table_autoinc_unlock(dict_table_t *table) /*!< in/out: table */ { mutex_exit(table->autoinc_mutex); } @@ -882,15 +827,13 @@ ibool dict_index_contains_col_or_prefix(const dict_index_t *index, ulint n, return (FALSE); } -/********************************************************************/ /** - Looks for a matching field in an index. The column has to be the same. The +/** Looks for a matching field in an index. The column has to be the same. The column in index must be complete, or must contain a prefix longer than the column in index2. That is, we must be able to construct the prefix in index2 from the prefix in index. @return position in internal representation of the index; ULINT_UNDEFINED if not contained */ ulint dict_index_get_nth_field_pos( - /*=========================*/ const dict_index_t *index, /*!< in: index from which to search */ const dict_index_t *index2, /*!< in: index */ ulint n) /*!< in: field number in index2 */ @@ -933,13 +876,10 @@ ulint dict_index_get_nth_field_pos( return (ULINT_UNDEFINED); } -/********************************************************************/ /** - Looks for non-virtual column n position in the clustered index. +/** Looks for non-virtual column n position in the clustered index. @return position in internal representation of the clustered index */ -ulint dict_table_get_nth_col_pos( - /*=======================*/ - const dict_table_t *table, /*!< in: table */ - ulint n) /*!< in: column number */ +ulint dict_table_get_nth_col_pos(const dict_table_t *table, /*!< in: table */ + ulint n) /*!< in: column number */ { return (table->first_index()->get_col_pos(n)); } @@ -973,12 +913,10 @@ ulint dict_table_mysql_pos_to_innodb(const dict_table_t *table, ulint n) { return (n - v_before); } -/********************************************************************/ /** - Checks if a column is in the ordering columns of the clustered index of a +/** Checks if a column is in the ordering columns of the clustered index of a table. Column prefixes are treated like whole columns. @return true if the column, or its prefix, is in the clustered key */ ibool dict_table_col_in_clustered_key( - /*============================*/ const dict_table_t *table, /*!< in: table */ ulint n) /*!< in: column number */ { @@ -1008,11 +946,8 @@ ibool dict_table_col_in_clustered_key( } #endif /* !UNIV_HOTBACKUP */ -/**********************************************************************/ /** - Inits the data dictionary module. */ -void dict_init(void) -/*===========*/ -{ +/** Inits the data dictionary module. */ +void dict_init(void) { dict_operation_lock = static_cast(ut_zalloc_nokey(sizeof(*dict_operation_lock))); @@ -1043,11 +978,8 @@ void dict_init(void) } #ifndef UNIV_HOTBACKUP -/**********************************************************************/ /** - Move to the most recently used segment of the LRU list. */ -void dict_move_to_mru( - /*=============*/ - dict_table_t *table) /*!< in: table to move to MRU */ +/** Move to the most recently used segment of the LRU list. */ +void dict_move_to_mru(dict_table_t *table) /*!< in: table to move to MRU */ { ut_ad(mutex_own(&dict_sys->mutex)); ut_ad(dict_lru_validate()); @@ -1062,14 +994,12 @@ void dict_move_to_mru( ut_ad(dict_lru_validate()); } -/**********************************************************************/ /** - Returns a table object and increment its open handle count. +/** Returns a table object and increment its open handle count. NOTE! This is a high-level function to be used mainly from outside the 'dict' module. Inside this directory dict_table_get_low is usually the appropriate function. @return table, NULL if does not exist */ dict_table_t *dict_table_open_on_name( - /*====================*/ const char *table_name, /*!< in: table name */ ibool dict_locked, /*!< in: TRUE=data dictionary locked */ ibool try_drop, /*!< in: TRUE=try to drop any orphan @@ -1131,12 +1061,9 @@ dict_table_t *dict_table_open_on_name( } #endif /* !UNIV_HOTBACKUP */ -/**********************************************************************/ /** - Adds system columns to a table object. */ -void dict_table_add_system_columns( - /*==========================*/ - dict_table_t *table, /*!< in/out: table */ - mem_heap_t *heap) /*!< in: temporary heap */ +/** Adds system columns to a table object. */ +void dict_table_add_system_columns(dict_table_t *table, /*!< in/out: table */ + mem_heap_t *heap) /*!< in: temporary heap */ { ut_ad(table); ut_ad(table->n_def == (table->n_cols - table->get_n_sys_cols())); @@ -1281,11 +1208,9 @@ void dict_table_add_to_cache(dict_table_t *table, ibool can_be_evicted, }); } -/**********************************************************************/ /** - Test whether a table can be evicted from the LRU cache. +/** Test whether a table can be evicted from the LRU cache. @return true if table can be evicted. */ static ibool dict_table_can_be_evicted( - /*======================*/ dict_table_t *table) /*!< in: table to test */ { ut_ad(mutex_own(&dict_sys->mutex)); @@ -1333,14 +1258,12 @@ static ibool dict_table_can_be_evicted( return (FALSE); } -/**********************************************************************/ /** - Make room in the table cache by evicting an unused table. The unused table +/** Make room in the table cache by evicting an unused table. The unused table should not be part of FK relationship and currently not used in any user transaction. There is no guarantee that it will remove a table. @return number of tables evicted. If the number of tables in the dict_LRU is less than max_tables it will not do anything. */ ulint dict_make_room_in_cache( - /*====================*/ ulint max_tables, /*!< in: max tables allowed in cache */ ulint pct_check) /*!< in: max percent to check */ { @@ -1399,10 +1322,8 @@ ulint dict_make_room_in_cache( return (n_evicted); } -/**********************************************************************/ /** - Move a table to the non-LRU list from the LRU list. */ +/** Move a table to the non-LRU list from the LRU list. */ void dict_table_move_from_lru_to_non_lru( - /*================================*/ dict_table_t *table) /*!< in: table to move from LRU to non-LRU */ { ut_ad(mutex_own(&dict_sys->mutex)); @@ -1493,11 +1414,9 @@ struct dict_foreign_remove_partial { } }; -/**********************************************************************/ /** - Renames a table object. +/** Renames a table object. @return true if success */ dberr_t dict_table_rename_in_cache( - /*=======================*/ dict_table_t *table, /*!< in/out: table */ const char *new_name, /*!< in: new name */ ibool rename_also_foreigns) /*!< in: in ALTER TABLE we want @@ -1861,11 +1780,9 @@ dberr_t dict_table_rename_in_cache( return (DB_SUCCESS); } -/**********************************************************************/ /** - Change the id of a table object in the dictionary cache. This is used in +/** Change the id of a table object in the dictionary cache. This is used in DISCARD TABLESPACE. */ void dict_table_change_id_in_cache( - /*==========================*/ dict_table_t *table, /*!< in/out: table object already in cache */ table_id_t new_id) /*!< in: new id to set */ { @@ -1884,8 +1801,7 @@ void dict_table_change_id_in_cache( ut_fold_ull(table->id), table); } -/**********************************************************************/ /** - Removes a table object from the dictionary cache. */ +/** Removes a table object from the dictionary cache. */ static void dict_table_remove_from_cache_low( dict_table_t *table, /*!< in, own: table */ ibool lru_evict) /*!< in: TRUE if table being evicted @@ -1977,11 +1893,8 @@ static void dict_table_remove_from_cache_low( dict_mem_table_free(table); } -/**********************************************************************/ /** - Removes a table object from the dictionary cache. */ -void dict_table_remove_from_cache( - /*=========================*/ - dict_table_t *table) /*!< in, own: table */ +/** Removes a table object from the dictionary cache. */ +void dict_table_remove_from_cache(dict_table_t *table) /*!< in, own: table */ { dict_table_remove_from_cache_low(table, FALSE); } @@ -2030,13 +1943,10 @@ void dict_table_remove_from_cache_debug(dict_table_t *table, bool lru_evict) { } #endif /* UNIV_DEBUG */ -/****************************************************************/ /** - If the given column name is reserved for InnoDB system columns, return +/** If the given column name is reserved for InnoDB system columns, return TRUE. @return true if name is reserved */ -ibool dict_col_name_is_reserved( - /*======================*/ - const char *name) /*!< in: column name */ +ibool dict_col_name_is_reserved(const char *name) /*!< in: column name */ { /* This check reminds that if a new system column is added to the program, it should be dealt with here. */ @@ -2058,12 +1968,9 @@ the program, it should be dealt with here. */ return (FALSE); } -/****************************************************************/ /** - Return maximum size of the node pointer record. +/** Return maximum size of the node pointer record. @return maximum size of the record in bytes */ -ulint dict_index_node_ptr_max_size( - /*=========================*/ - const dict_index_t *index) /*!< in: index */ +ulint dict_index_node_ptr_max_size(const dict_index_t *index) /*!< in: index */ { ulint comp; ulint i; @@ -2139,12 +2046,10 @@ ulint dict_index_node_ptr_max_size( return (rec_max_size); } -/****************************************************************/ /** - If a record of this index might not fit on a single B-tree page, +/** If a record of this index might not fit on a single B-tree page, return TRUE. @return true if the index record could become too big */ static bool dict_index_too_big_for_tree( - /*========================*/ const dict_table_t *table, /*!< in: table */ const dict_index_t *new_index, /*!< in: index */ bool strict) /*!< in: TRUE=report error if @@ -2544,10 +2449,8 @@ dberr_t dict_index_add_to_cache_w_vcol(dict_table_t *table, dict_index_t *index, return (DB_SUCCESS); } -/**********************************************************************/ /** - Removes an index from the dictionary cache. */ +/** Removes an index from the dictionary cache. */ static void dict_index_remove_from_cache_low( - /*=============================*/ dict_table_t *table, /*!< in/out: table */ dict_index_t *index, /*!< in, own: index */ ibool lru_evict) /*!< in: TRUE if index being evicted @@ -2668,12 +2571,9 @@ static void dict_index_remove_from_cache_low( dict_mem_index_free(index); } -/**********************************************************************/ /** - Removes an index from the dictionary cache. */ -void dict_index_remove_from_cache( - /*=========================*/ - dict_table_t *table, /*!< in/out: table */ - dict_index_t *index) /*!< in, own: index */ +/** Removes an index from the dictionary cache. */ +void dict_index_remove_from_cache(dict_table_t *table, /*!< in/out: table */ + dict_index_t *index) /*!< in, own: index */ { dict_index_remove_from_cache_low(table, index, FALSE); } @@ -2762,15 +2662,12 @@ static ibool dict_index_find_cols(const dict_table_t *table, return (TRUE); } -/*******************************************************************/ /** - Copies fields contained in index2 to index1. */ -static void dict_index_copy( - /*============*/ - dict_index_t *index1, /*!< in: index to copy to */ - dict_index_t *index2, /*!< in: index to copy from */ - const dict_table_t *table, /*!< in: table */ - ulint start, /*!< in: first position to copy */ - ulint end) /*!< in: last position to copy */ +/** Copies fields contained in index2 to index1. */ +static void dict_index_copy(dict_index_t *index1, /*!< in: index to copy to */ + dict_index_t *index2, /*!< in: index to copy from */ + const dict_table_t *table, /*!< in: table */ + ulint start, /*!< in: first position to copy */ + ulint end) /*!< in: last position to copy */ { dict_field_t *field; ulint i; @@ -2785,14 +2682,11 @@ static void dict_index_copy( } } -/*******************************************************************/ /** - Copies types of fields contained in index to tuple. */ -void dict_index_copy_types( - /*==================*/ - dtuple_t *tuple, /*!< in/out: data tuple */ - const dict_index_t *index, /*!< in: index */ - ulint n_fields) /*!< in: number of - field types to copy */ +/** Copies types of fields contained in index to tuple. */ +void dict_index_copy_types(dtuple_t *tuple, /*!< in/out: data tuple */ + const dict_index_t *index, /*!< in: index */ + ulint n_fields) /*!< in: number of + field types to copy */ { ulint i; @@ -2837,14 +2731,11 @@ void dict_table_copy_v_types(dtuple_t *tuple, const dict_table_t *table) { dict_table_get_nth_v_col(table, i)->m_col.copy_type(dtype); } } -/*******************************************************************/ /** - Copies types of columns contained in table to tuple and sets all +/** Copies types of columns contained in table to tuple and sets all fields of the tuple to the SQL NULL value. This function should be called right after dtuple_create(). */ -void dict_table_copy_types( - /*==================*/ - dtuple_t *tuple, /*!< in/out: data tuple */ - const dict_table_t *table) /*!< in: table */ +void dict_table_copy_types(dtuple_t *tuple, /*!< in/out: data tuple */ + const dict_table_t *table) /*!< in: table */ { ulint i; @@ -2864,7 +2755,6 @@ Wait until all the background threads of the given table have exited, i.e., bg_threads == 0. Note: bg_threads_mutex must be reserved when calling this. */ void dict_table_wait_for_bg_threads_to_exit( - /*===================================*/ dict_table_t *table, /*!< in: table */ ulint delay) /*!< in: time in microseconds to wait between checks of bg_threads. */ @@ -2882,12 +2772,10 @@ void dict_table_wait_for_bg_threads_to_exit( } } -/*******************************************************************/ /** - Builds the internal dictionary cache representation for a clustered +/** Builds the internal dictionary cache representation for a clustered index, containing also system fields not defined by the user. @return own: the internal representation of the clustered index */ static dict_index_t *dict_index_build_internal_clust( - /*============================*/ const dict_table_t *table, /*!< in: table */ dict_index_t *index) /*!< in: user representation of a clustered index */ @@ -3033,12 +2921,10 @@ static dict_index_t *dict_index_build_internal_clust( return (new_index); } -/*******************************************************************/ /** - Builds the internal dictionary cache representation for a non-clustered +/** Builds the internal dictionary cache representation for a non-clustered index, containing also system fields not defined by the user. @return own: the internal representation of the non-clustered index */ static dict_index_t *dict_index_build_internal_non_clust( - /*================================*/ const dict_table_t *table, /*!< in: table */ dict_index_t *index) /*!< in: user representation of a non-clustered index */ @@ -3136,7 +3022,6 @@ static dict_index_t *dict_index_build_internal_non_clust( Builds the internal dictionary cache representation for an FTS index. @return own: the internal representation of the FTS index */ static dict_index_t *dict_index_build_internal_fts( - /*==========================*/ dict_table_t *table, /*!< in: table */ dict_index_t *index) /*!< in: user representation of an FTS index */ { @@ -3177,20 +3062,16 @@ static dict_index_t *dict_index_build_internal_fts( } /*====================== FOREIGN KEY PROCESSING ========================*/ -/*********************************************************************/ /** - Checks if a table is referenced by foreign keys. +/** Checks if a table is referenced by foreign keys. @return true if table is referenced by a foreign key */ ibool dict_table_is_referenced_by_foreign_key( - /*====================================*/ const dict_table_t *table) /*!< in: InnoDB table */ { return (!table->referenced_set.empty()); } -/**********************************************************************/ /** - Removes a foreign constraint struct from the dictionary cache. */ +/** Removes a foreign constraint struct from the dictionary cache. */ void dict_foreign_remove_from_cache( - /*===========================*/ dict_foreign_t *foreign) /*!< in, own: foreign constraint */ { ut_ad(mutex_own(&dict_sys->mutex)); @@ -3207,12 +3088,10 @@ void dict_foreign_remove_from_cache( dict_foreign_free(foreign); } -/**********************************************************************/ /** - Looks for the foreign constraint from the foreign and referenced lists +/** Looks for the foreign constraint from the foreign and referenced lists of a table. @return foreign constraint */ static dict_foreign_t *dict_foreign_find( - /*==============*/ dict_table_t *table, /*!< in: table object */ dict_foreign_t *foreign) /*!< in: foreign constraint */ { @@ -3236,13 +3115,11 @@ static dict_foreign_t *dict_foreign_find( return (NULL); } -/*********************************************************************/ /** - Tries to find an index whose first fields are the columns in the array, +/** Tries to find an index whose first fields are the columns in the array, in the same order and is not marked for deletion and is not the same as types_idx. @return matching index, NULL if not found */ dict_index_t *dict_foreign_find_index( - /*====================*/ const dict_table_t *table, /*!< in: table */ const char **col_names, /*!< in: column names, or NULL @@ -3285,10 +3162,8 @@ NOT NULL */ return (NULL); } -/**********************************************************************/ /** - Report an error in a foreign key definition. */ +/** Report an error in a foreign key definition. */ static void dict_foreign_error_report_low( - /*==========================*/ FILE *file, /*!< in: output stream */ const char *name) /*!< in: table name */ { @@ -3297,10 +3172,8 @@ static void dict_foreign_error_report_low( fprintf(file, " Error in foreign key constraint of table %s:\n", name); } -/**********************************************************************/ /** - Report an error in a foreign key definition. */ +/** Report an error in a foreign key definition. */ static void dict_foreign_error_report( - /*======================*/ FILE *file, /*!< in: output stream */ dict_foreign_t *fk, /*!< in: foreign key constraint */ const char *msg) /*!< in: the error message */ @@ -3320,25 +3193,22 @@ static void dict_foreign_error_report( mutex_exit(&dict_foreign_err_mutex); } -/**********************************************************************/ /** - Adds a foreign key constraint object to the dictionary cache. May free +/** Adds a foreign key constraint object to the dictionary cache. May free the object if there already is an object with the same identifier in. At least one of the foreign table and the referenced table must already be in the dictionary cache! @return DB_SUCCESS or error code */ -dberr_t dict_foreign_add_to_cache( - /*======================*/ - dict_foreign_t *foreign, - /*!< in, own: foreign key constraint */ - const char **col_names, - /*!< in: column names, or NULL to use - foreign->foreign_table->col_names */ - bool check_charsets, - /*!< in: whether to check charset - compatibility */ - bool can_free_fk, - /*!< in: whether free existing FK */ - dict_err_ignore_t ignore_err) +dberr_t dict_foreign_add_to_cache(dict_foreign_t *foreign, + /*!< in, own: foreign key constraint */ + const char **col_names, + /*!< in: column names, or NULL to use + foreign->foreign_table->col_names */ + bool check_charsets, + /*!< in: whether to check charset + compatibility */ + bool can_free_fk, + /*!< in: whether free existing FK */ + dict_err_ignore_t ignore_err) /*!< in: error to be ignored */ { dict_table_t *for_table; @@ -3466,15 +3336,12 @@ dberr_t dict_foreign_add_to_cache( DBUG_RETURN(DB_SUCCESS); } -/*********************************************************************/ /** - Scans from pointer onwards. Stops if is at the start of a copy of +/** Scans from pointer onwards. Stops if is at the start of a copy of 'string' where characters are compared without case sensitivity, and only outside `` or "" quotes. Stops also at NUL. @return scanned up to this */ -static const char *dict_scan_to( - /*=========*/ - const char *ptr, /*!< in: scan from */ - const char *string) /*!< in: look for this */ +static const char *dict_scan_to(const char *ptr, /*!< in: scan from */ + const char *string) /*!< in: look for this */ { char quote = '\0'; bool escape = false; @@ -3518,12 +3385,10 @@ static const char *dict_scan_to( return (ptr); } -/*********************************************************************/ /** - Accepts a specified string. Comparisons are case-insensitive. +/** Accepts a specified string. Comparisons are case-insensitive. @return if string was accepted, the pointer is moved after that, else ptr is returned */ static const char *dict_accept( - /*========*/ const CHARSET_INFO *cs, /*!< in: the character set of ptr */ const char *ptr, /*!< in: scan from this */ const char *string, /*!< in: accept only this string as the next @@ -3552,12 +3417,10 @@ static const char *dict_accept( return (ptr + ut_strlen(string)); } -/*********************************************************************/ /** - Scans an id. For the lexical definition of an 'id', see the code below. +/** Scans an id. For the lexical definition of an 'id', see the code below. Strips backquotes or double quotes from around the id. @return scanned to */ static const char *dict_scan_id( - /*=========*/ const CHARSET_INFO *cs, /*!< in: the character set of ptr */ const char *ptr, /*!< in: scanned to */ mem_heap_t *heap, /*!< in: heap where to allocate the id @@ -3660,11 +3523,9 @@ always */ return (ptr); } -/*********************************************************************/ /** - Tries to scan a column name. +/** Tries to scan a column name. @return scanned to */ static const char *dict_scan_col( - /*==========*/ const CHARSET_INFO *cs, /*!< in: the character set of ptr */ const char *ptr, /*!< in: scanned to */ ibool *success, /*!< out: TRUE if success */ @@ -3706,13 +3567,11 @@ static const char *dict_scan_col( return (ptr); } -/*********************************************************************/ /** - Open a table from its database and table name, this is currently used by +/** Open a table from its database and table name, this is currently used by foreign constraint parser to get the referenced table. @return complete table name with database and table name, allocated from heap memory passed in */ char *dict_get_referenced_table( - /*======================*/ const char *name, /*!< in: foreign key table name */ const char *database_name, /*!< in: table db name */ ulint database_name_len, /*!< in: db name length */ @@ -3770,11 +3629,9 @@ char *dict_get_referenced_table( return (ref); } -/*********************************************************************/ /** - Scans a table name from an SQL string. +/** Scans a table name from an SQL string. @return scanned to */ static const char *dict_scan_table_name( - /*=================*/ const CHARSET_INFO *cs, /*!< in: the character set of ptr */ const char *ptr, /*!< in: scanned to */ dict_table_t **table, /*!< out: table object or NULL */ @@ -3842,11 +3699,9 @@ static const char *dict_scan_table_name( return (ptr); } -/*********************************************************************/ /** - Skips one id. The id is allowed to contain also '.'. +/** Skips one id. The id is allowed to contain also '.'. @return scanned to */ static const char *dict_skip_word( - /*===========*/ const CHARSET_INFO *cs, /*!< in: the character set of ptr */ const char *ptr, /*!< in: scanned to */ ibool *success) /*!< out: TRUE if success, FALSE if just spaces @@ -3865,8 +3720,7 @@ static const char *dict_skip_word( return (ptr); } -/*********************************************************************/ /** - Removes MySQL comments from an SQL string. A comment is either +/** Removes MySQL comments from an SQL string. A comment is either (a) '#' to the end of the line, (b) '--[space]' to the end of the line, or (c) '[slash][asterisk]' till the next '[asterisk][slash]' (like the familiar @@ -3874,7 +3728,6 @@ static const char *dict_skip_word( @return own: SQL string stripped from comments; the caller must free this with ut_free()! */ static char *dict_strip_comments( - /*================*/ const char *sql_string, /*!< in: SQL string */ size_t sql_length) /*!< in: length of sql_string */ { @@ -3974,13 +3827,11 @@ static char *dict_strip_comments( } } -/*********************************************************************/ /** - Finds the highest [number] for foreign key constraints of the table. Looks +/** Finds the highest [number] for foreign key constraints of the table. Looks only at the >= 4.0.18-format id's, which are of the form databasename/tablename_ibfk_[number]. @return highest number, 0 if table has no new format foreign key constraints */ ulint dict_table_get_highest_foreign_id( - /*==============================*/ dict_table_t *table) /*!< in: table in the dictionary memory cache */ { dict_foreign_t *foreign; @@ -4025,10 +3876,8 @@ ulint dict_table_get_highest_foreign_id( DBUG_RETURN(biggest_id); } -/*********************************************************************/ /** - Reports a simple foreign key create clause syntax error. */ +/** Reports a simple foreign key create clause syntax error. */ static void dict_foreign_report_syntax_err( - /*===========================*/ const char *name, /*!< in: table name */ const char *start_of_latest_foreign, /*!< in: start of the foreign key clause @@ -4046,10 +3895,9 @@ static void dict_foreign_report_syntax_err( mutex_exit(&dict_foreign_err_mutex); } -/*********************************************************************/ /** - Scans a table create SQL string and adds to the data dictionary the foreign key - constraints declared in the string. This function should be called after the - indexes for a table have been created. Each foreign key constraint must be +/** Scans a table create SQL string and adds to the data dictionary the foreign + key constraints declared in the string. This function should be called after + the indexes for a table have been created. Each foreign key constraint must be accompanied with indexes in bot participating tables. The indexes are allowed to contain more fields than mentioned in the constraint. @@ -4710,12 +4558,10 @@ dberr_t dict_create_foreign_constraints(trx_t *trx, const char *sql_string, return (err); } -/**********************************************************************/ /** - Parses the CONSTRAINT id's to be dropped in an ALTER TABLE statement. +/** Parses the CONSTRAINT id's to be dropped in an ALTER TABLE statement. @return DB_SUCCESS or DB_CANNOT_DROP_CONSTRAINT if syntax error or the constraint id does not match */ dberr_t dict_foreign_parse_drop_constraints( - /*================================*/ mem_heap_t *heap, /*!< in: heap from which we can allocate memory */ trx_t *trx, /*!< in: transaction */ @@ -4841,12 +4687,10 @@ dberr_t dict_foreign_parse_drop_constraints( /*==================== END OF FOREIGN KEY PROCESSING ====================*/ #ifdef UNIV_DEBUG -/**********************************************************************/ /** - Checks that a tuple has n_fields_cmp value in a sensible range, so that +/** Checks that a tuple has n_fields_cmp value in a sensible range, so that no comparison can occur with the page number field in a node pointer. @return true if ok */ ibool dict_index_check_search_tuple( - /*==========================*/ const dict_index_t *index, /*!< in: index tree */ const dtuple_t *tuple) /*!< in: tuple used in a search */ { @@ -4861,11 +4705,9 @@ ibool dict_index_check_search_tuple( } #endif /* UNIV_DEBUG */ -/**********************************************************************/ /** - Builds a node pointer out of a physical record and a page number. +/** Builds a node pointer out of a physical record and a page number. @return own: node pointer */ dtuple_t *dict_index_build_node_ptr( - /*======================*/ const dict_index_t *index, /*!< in: index */ const rec_t *rec, /*!< in: record for which to build node pointer */ @@ -4928,12 +4770,10 @@ dtuple_t *dict_index_build_node_ptr( return (tuple); } -/**********************************************************************/ /** - Copies an initial segment of a physical record, long enough to specify an +/** Copies an initial segment of a physical record, long enough to specify an index entry uniquely. @return pointer to the prefix record */ rec_t *dict_index_copy_rec_order_prefix( - /*=============================*/ const dict_index_t *index, /*!< in: index */ const rec_t *rec, /*!< in: record for which to copy prefix */ @@ -4967,11 +4807,9 @@ rec_t *dict_index_copy_rec_order_prefix( return (rec_copy_prefix_to_buf(rec, index, n, buf, buf_size)); } -/**********************************************************************/ /** - Builds a typed data tuple out of a physical record. +/** Builds a typed data tuple out of a physical record. @return own: data tuple */ dtuple_t *dict_index_build_data_tuple( - /*========================*/ dict_index_t *index, /*!< in: index tree */ rec_t *rec, /*!< in: record for which to build data tuple */ ulint n_fields, /*!< in: number of data fields */ @@ -4993,11 +4831,8 @@ dtuple_t *dict_index_build_data_tuple( return (tuple); } -/*********************************************************************/ /** - Calculates the minimum record length in an index. */ -ulint dict_index_calc_min_rec_len( - /*========================*/ - const dict_index_t *index) /*!< in: index */ +/** Calculates the minimum record length in an index. */ +ulint dict_index_calc_min_rec_len(const dict_index_t *index) /*!< in: index */ { ulint sum = 0; ulint i; @@ -5040,11 +4875,9 @@ ulint dict_index_calc_min_rec_len( return (sum); } -/**********************************************************************/ /** - Outputs info on a foreign key of a table in a format suitable for +/** Outputs info on a foreign key of a table in a format suitable for CREATE TABLE. */ void dict_print_info_on_foreign_key_in_create_format( - /*============================================*/ FILE *file, /*!< in: file where to print */ trx_t *trx, /*!< in: transaction */ dict_foreign_t *foreign, /*!< in: foreign key constraint */ @@ -5136,10 +4969,8 @@ void dict_print_info_on_foreign_key_in_create_format( #endif /* HAS_RUNTIME_WL6049 */ } -/**********************************************************************/ /** - Outputs info on foreign keys of a table. */ +/** Outputs info on foreign keys of a table. */ void dict_print_info_on_foreign_keys( - /*============================*/ ibool create_table_format, /*!< in: if TRUE then print in a format suitable to be inserted into a CREATE TABLE, otherwise in the format @@ -5687,11 +5518,8 @@ void dict_set_merge_threshold_all_debug(uint merge_threshold_all) { } #endif /* UNIV_DEBUG */ -/**********************************************************************/ /** - Inits dict_ind_redundant. */ -void dict_ind_init(void) -/*===============*/ -{ +/** Inits dict_ind_redundant. */ +void dict_ind_init(void) { dict_table_t *table; /* create dummy table and index for REDUNDANT infimum and supremum */ @@ -5707,11 +5535,8 @@ void dict_ind_init(void) dict_ind_redundant->cached = TRUE; } -/**********************************************************************/ /** - Frees dict_ind_redundant. */ -static void dict_ind_free(void) -/*===============*/ -{ +/** Frees dict_ind_redundant. */ +static void dict_ind_free(void) { dict_table_t *table; table = dict_ind_redundant->table; @@ -5744,12 +5569,10 @@ dict_index_t *dict_table_get_index_on_name(dict_table_t *table, return (NULL); } -/**********************************************************************/ /** - Replace the index passed in with another equivalent index in the +/** Replace the index passed in with another equivalent index in the foreign key lists of the table. @return whether all replacements were found */ bool dict_foreign_replace_index( - /*=======================*/ dict_table_t *table, /*!< in/out: table */ const char **col_names, /*!< in: column names, or NULL @@ -5810,10 +5633,8 @@ bool dict_foreign_replace_index( } #ifdef UNIV_DEBUG -/**********************************************************************/ /** - Check for duplicate index entries in a table [using the index name] */ +/** Check for duplicate index entries in a table [using the index name] */ void dict_table_check_for_dup_indexes( - /*=============================*/ const dict_table_t *table, /*!< in: Check for dup indexes in this table */ enum check_name check) /*!< in: whether and when to allow @@ -5961,11 +5782,8 @@ void dict_resize() { mutex_exit(&dict_sys->mutex); } -/**********************************************************************/ /** - Closes the data dictionary module. */ -void dict_close(void) -/*============*/ -{ +/** Closes the data dictionary module. */ +void dict_close(void) { if (dict_sys == NULL) { /* This should only happen if a failure occurred during redo log processing. */ @@ -6035,12 +5853,9 @@ void dict_close(void) } #ifdef UNIV_DEBUG -/**********************************************************************/ /** - Validate the dictionary table LRU list. +/** Validate the dictionary table LRU list. @return true if valid */ -static ibool dict_lru_validate(void) -/*===================*/ -{ +static ibool dict_lru_validate(void) { dict_table_t *table; ut_ad(mutex_own(&dict_sys->mutex)); @@ -6058,11 +5873,9 @@ static ibool dict_lru_validate(void) return (TRUE); } -/**********************************************************************/ /** - Check if a table exists in the dict table LRU list. +/** Check if a table exists in the dict table LRU list. @return true if table found in LRU list */ static ibool dict_lru_find_table( - /*================*/ const dict_table_t *find_table) /*!< in: table to find */ { dict_table_t *table; @@ -6082,11 +5895,9 @@ static ibool dict_lru_find_table( return (FALSE); } -/**********************************************************************/ /** - Check if a table exists in the dict table non-LRU list. +/** Check if a table exists in the dict table non-LRU list. @return true if table found in non-LRU list */ static ibool dict_non_lru_find_table( - /*====================*/ const dict_table_t *find_table) /*!< in: table to find */ { dict_table_t *table; @@ -6106,13 +5917,11 @@ static ibool dict_non_lru_find_table( return (FALSE); } #endif /* UNIV_DEBUG */ -/*********************************************************************/ /** - Check an index to see whether its first fields are the columns in the array, +/** Check an index to see whether its first fields are the columns in the array, in the same order and is not marked for deletion and is not the same as types_idx. @return true if the index qualifies, otherwise false */ bool dict_foreign_qualify_index( - /*=======================*/ const dict_table_t *table, /*!< in: table */ const char **col_names, /*!< in: column names, or NULL @@ -6174,12 +5983,10 @@ NOT NULL */ return (true); } -/*********************************************************************/ /** - Update the state of compression failure padding heuristics. This is +/** Update the state of compression failure padding heuristics. This is called whenever a compression operation succeeds or fails. The caller must be holding info->mutex */ static void dict_index_zip_pad_update( - /*======================*/ zip_pad_info_t *info, /*!< in/out: info to be updated */ ulint zip_threshold) /*!< in: zip threshold value */ { @@ -6249,11 +6056,9 @@ static void dict_index_zip_pad_update( } } -/*********************************************************************/ /** - This function should be called whenever a page is successfully +/** This function should be called whenever a page is successfully compressed. Updates the compression padding information. */ void dict_index_zip_success( - /*===================*/ dict_index_t *index) /*!< in/out: index to be updated. */ { ut_ad(index); @@ -6270,11 +6075,9 @@ void dict_index_zip_success( dict_index_zip_pad_unlock(index); } -/*********************************************************************/ /** - This function should be called whenever a page compression attempt +/** This function should be called whenever a page compression attempt fails. Updates the compression padding information. */ void dict_index_zip_failure( - /*===================*/ dict_index_t *index) /*!< in/out: index to be updated. */ { ut_ad(index); @@ -6291,11 +6094,9 @@ void dict_index_zip_failure( dict_index_zip_pad_unlock(index); } -/*********************************************************************/ /** - Return the optimal page size, for which page will likely compress. +/** Return the optimal page size, for which page will likely compress. @return page size beyond which page might not compress */ ulint dict_index_zip_pad_optimal_page_size( - /*=================================*/ dict_index_t *index) /*!< in: index for which page size is requested */ { @@ -6359,11 +6160,9 @@ ulint dict_tf_to_fsp_flags(ulint table_flags, bool is_encrypted) { return (fsp_flags); } -/*************************************************************/ /** - Convert table flag to row format string. +/** Convert table flag to row format string. @return row format name. */ const char *dict_tf_to_row_format_string( - /*=========================*/ ulint table_flag) /*!< in: row format setting */ { switch (dict_tf_get_rec_format(table_flag)) { diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index d6577f380337..7c7fc2d6a589 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file dict/dict0load.cc +/** @file dict/dict0load.cc Loads to the memory cache database object definitions from dictionary tables @@ -128,15 +127,12 @@ metadata even if it is marked as "corrupted". */ bool srv_load_corrupted = FALSE; #ifdef UNIV_DEBUG -/****************************************************************/ /** - Compare the name of an index column. +/** Compare the name of an index column. @return true if the i'th column of index is 'name'. */ -static ibool name_of_col_is( - /*===========*/ - const dict_table_t *table, /*!< in: table */ - const dict_index_t *index, /*!< in: index */ - ulint i, /*!< in: index field offset */ - const char *name) /*!< in: name to compare to */ +static ibool name_of_col_is(const dict_table_t *table, /*!< in: table */ + const dict_index_t *index, /*!< in: index */ + ulint i, /*!< in: index field offset */ + const char *name) /*!< in: name to compare to */ { ulint tmp = dict_col_get_no(index->get_field(i)->col); @@ -144,12 +140,10 @@ static ibool name_of_col_is( } #endif /* UNIV_DEBUG */ -/********************************************************************/ /** - Finds the first table name in the given database. +/** Finds the first table name in the given database. @return own: table name, NULL if does not exist; the caller must free the memory in the string! */ char *dict_get_first_table_name_in_db( - /*============================*/ const char *name) /*!< in: database name which ends in '/' */ { dict_table_t *sys_tables; @@ -223,11 +217,9 @@ char *dict_get_first_table_name_in_db( goto loop; } -/********************************************************************/ /** - This function gets the next system table record as it scans the table. +/** This function gets the next system table record as it scans the table. @return the next record if found, NULL if end of scan */ static const rec_t *dict_getnext_system_low( - /*====================*/ btr_pcur_t *pcur, /*!< in/out: persistent cursor to the record*/ mtr_t *mtr) /*!< in: the mini-transaction */ @@ -253,11 +245,9 @@ static const rec_t *dict_getnext_system_low( return (rec); } -/********************************************************************/ /** - This function opens a system table, and returns the first record. +/** This function opens a system table, and returns the first record. @return first record of the system table */ const rec_t *dict_startscan_system( - /*==================*/ btr_pcur_t *pcur, /*!< out: persistent cursor to the record */ mtr_t *mtr, /*!< in: the mini-transaction */ @@ -281,11 +271,9 @@ const rec_t *dict_startscan_system( return (rec); } -/********************************************************************/ /** - This function gets the next system table record as it scans the table. +/** This function gets the next system table record as it scans the table. @return the next record if found, NULL if end of scan */ const rec_t *dict_getnext_system( - /*================*/ btr_pcur_t *pcur, /*!< in/out: persistent cursor to the record */ mtr_t *mtr) /*!< in: the mini-transaction */ @@ -921,12 +909,10 @@ static const char *dict_load_field_low( return (NULL); } -/********************************************************************/ /** - This function parses a SYS_TABLESPACES record, extracts necessary +/** This function parses a SYS_TABLESPACES record, extracts necessary information from the record and returns to caller. @return error message, or NULL on success */ const char *dict_process_sys_tablespaces( - /*=========================*/ mem_heap_t *heap, /*!< in/out: heap memory */ const rec_t *rec, /*!< in: current SYS_TABLESPACES rec */ space_id_t *space, /*!< out: space id */ @@ -1553,13 +1539,10 @@ space_id_t dict_check_sys_tables(bool validate) { DBUG_RETURN(max_space_id); } -/********************************************************************/ /** - Loads definitions for table columns. */ -static void dict_load_columns( - /*==============*/ - dict_table_t *table, /*!< in/out: table */ - mem_heap_t *heap) /*!< in/out: memory heap - for temporary storage */ +/** Loads definitions for table columns. */ +static void dict_load_columns(dict_table_t *table, /*!< in/out: table */ + mem_heap_t *heap) /*!< in/out: memory heap + for temporary storage */ { dict_table_t *sys_columns; dict_index_t *sys_index; @@ -1664,11 +1647,9 @@ static void dict_load_columns( mtr_commit(&mtr); } -/********************************************************************/ /** - Loads definitions for index fields. +/** Loads definitions for index fields. @return DB_SUCCESS if ok, DB_CORRUPTION if corruption */ static ulint dict_load_fields( - /*=============*/ dict_index_t *index, /*!< in/out: index whose fields to load */ mem_heap_t *heap) /*!< in: memory heap for temporary storage */ { @@ -1735,13 +1716,11 @@ static ulint dict_load_fields( return (error); } -/********************************************************************/ /** - Loads definitions for table indexes. Adds them to the data dictionary +/** Loads definitions for table indexes. Adds them to the data dictionary cache. @return DB_SUCCESS if ok, DB_CORRUPTION if corruption of dictionary table or DB_UNSUPPORTED if table has unknown index type */ static dberr_t dict_load_indexes( - /*==============*/ dict_table_t *table, /*!< in/out: table */ mem_heap_t *heap, /*!< in: memory heap for temporary storage */ dict_err_ignore_t ignore_err) @@ -2539,11 +2518,9 @@ static dict_table_t *dict_load_table_one(table_name_t &name, bool cached, DBUG_RETURN(table); } -/***********************************************************************/ /** - Loads a table object based on the table id. +/** Loads a table object based on the table id. @return table; NULL if table does not exist */ dict_table_t *dict_load_table_on_id( - /*==================*/ table_id_t table_id, /*!< in: table id */ dict_err_ignore_t ignore_err) /*!< in: errors to ignore when loading the table */ @@ -2632,13 +2609,10 @@ dict_table_t *dict_load_table_on_id( return (table); } -/********************************************************************/ /** - This function is called when the database is booted. Loads system table +/** This function is called when the database is booted. Loads system table index definitions except for the clustered index which is added to the dictionary cache at booting before calling this function. */ -void dict_load_sys_table( - /*================*/ - dict_table_t *table) /*!< in: system table */ +void dict_load_sys_table(dict_table_t *table) /*!< in: system table */ { mem_heap_t *heap; @@ -2651,8 +2625,7 @@ void dict_load_sys_table( mem_heap_free(heap); } -/********************************************************************/ /** - Loads foreign key constraint col names (also for the referenced table). +/** Loads foreign key constraint col names (also for the referenced table). Members that must be set (and valid) in foreign: foreign->heap foreign->n_fields @@ -2662,7 +2635,6 @@ void dict_load_sys_table( foreign->referenced_col_names[i] (for i=0..foreign->n_fields-1) */ static void dict_load_foreign_cols( - /*===================*/ dict_foreign_t *foreign) /*!< in/out: foreign constraint object */ { dict_table_t *sys_foreign_cols; @@ -2765,28 +2737,26 @@ static void dict_load_foreign_cols( mtr_commit(&mtr); } -/***********************************************************************/ /** - Loads a foreign key constraint to the dictionary cache. If the referenced +/** Loads a foreign key constraint to the dictionary cache. If the referenced table is not yet loaded, it is added in the output parameter (fk_tables). @return DB_SUCCESS or error code */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t dict_load_foreign( - /*==============*/ - const char *id, - /*!< in: foreign constraint id, must be - '\0'-terminated */ - const char **col_names, - /*!< in: column names, or NULL - to use foreign->foreign_table->col_names */ - bool check_recursive, - /*!< in: whether to record the foreign table - parent count to avoid unlimited recursive - load of chained foreign tables */ - bool check_charsets, - /*!< in: whether to check charset - compatibility */ - dict_err_ignore_t ignore_err, - /*!< in: error to be ignored */ - dict_names_t &fk_tables) +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + dict_load_foreign(const char *id, + /*!< in: foreign constraint id, must be + '\0'-terminated */ + const char **col_names, + /*!< in: column names, or NULL + to use foreign->foreign_table->col_names */ + bool check_recursive, + /*!< in: whether to record the foreign table + parent count to avoid unlimited recursive + load of chained foreign tables */ + bool check_charsets, + /*!< in: whether to check charset + compatibility */ + dict_err_ignore_t ignore_err, + /*!< in: error to be ignored */ + dict_names_t &fk_tables) /*!< out: the foreign key constraint is added to the dictionary cache only if the referenced table is already in cache. Otherwise, the @@ -2945,8 +2915,7 @@ stack. */ true, ignore_err)); } -/***********************************************************************/ /** - Loads foreign key constraints where the table is either the foreign key +/** Loads foreign key constraints where the table is either the foreign key holder or where the table is referenced by a foreign key. Adds these constraints to the data dictionary. @@ -2956,7 +2925,6 @@ stack. */ @return DB_SUCCESS or error code */ dberr_t dict_load_foreigns( - /*===============*/ const char *table_name, /*!< in: table name */ const char **col_names, /*!< in: column names, or NULL to use table->col_names */ diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc index 3061d9e0305b..900822f55bcd 100644 --- a/storage/innobase/dict/dict0mem.cc +++ b/storage/innobase/dict/dict0mem.cc @@ -25,8 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file dict/dict0mem.cc +/** @file dict/dict0mem.cc Data dictionary memory object creation Created 1/8/1996 Heikki Tuuri @@ -183,10 +182,8 @@ void dict_mem_table_add_s_col(dict_table_t *table, ulint num_base) { table->s_cols->push_back(s_col); } -/**********************************************************************/ /** - Renames a column of a table in the data dictionary cache. */ +/** Renames a column of a table in the data dictionary cache. */ static void dict_mem_table_col_rename_low( - /*==========================*/ dict_table_t *table, /*!< in/out: table */ unsigned i, /*!< in: column offset corresponding to s */ const char *to, /*!< in: new column name */ @@ -322,15 +319,12 @@ static void dict_mem_table_col_rename_low( } } -/**********************************************************************/ /** - Renames a column of a table in the data dictionary cache. */ -void dict_mem_table_col_rename( - /*======================*/ - dict_table_t *table, /*!< in/out: table */ - ulint nth_col, /*!< in: column index */ - const char *from, /*!< in: old column name */ - const char *to, /*!< in: new column name */ - bool is_virtual) +/** Renames a column of a table in the data dictionary cache. */ +void dict_mem_table_col_rename(dict_table_t *table, /*!< in/out: table */ + ulint nth_col, /*!< in: column index */ + const char *from, /*!< in: old column name */ + const char *to, /*!< in: new column name */ + bool is_virtual) /*!< in: if this is a virtual column */ { const char *s = is_virtual ? table->v_col_names : table->col_names; @@ -352,12 +346,9 @@ void dict_mem_table_col_rename( is_virtual); } -/**********************************************************************/ /** - Creates and initializes a foreign constraint memory object. +/** Creates and initializes a foreign constraint memory object. @return own: foreign constraint struct */ -dict_foreign_t *dict_mem_foreign_create(void) -/*=========================*/ -{ +dict_foreign_t *dict_mem_foreign_create(void) { dict_foreign_t *foreign; mem_heap_t *heap; DBUG_ENTER("dict_mem_foreign_create"); @@ -376,13 +367,11 @@ dict_foreign_t *dict_mem_foreign_create(void) DBUG_RETURN(foreign); } -/**********************************************************************/ /** - Sets the foreign_table_name_lookup pointer based on the value of +/** Sets the foreign_table_name_lookup pointer based on the value of lower_case_table_names. If that is 0 or 1, foreign_table_name_lookup will point to foreign_table_name. If 2, then another string is allocated from foreign->heap and set to lower case. */ void dict_mem_foreign_table_name_lookup_set( - /*===================================*/ dict_foreign_t *foreign, /*!< in/out: foreign struct */ ibool do_alloc) /*!< in: is an alloc needed */ { @@ -402,13 +391,11 @@ void dict_mem_foreign_table_name_lookup_set( } } -/**********************************************************************/ /** - Sets the referenced_table_name_lookup pointer based on the value of +/** Sets the referenced_table_name_lookup pointer based on the value of lower_case_table_names. If that is 0 or 1, referenced_table_name_lookup will point to referenced_table_name. If 2, then another string is allocated from foreign->heap and set to lower case. */ void dict_mem_referenced_table_name_lookup_set( - /*======================================*/ dict_foreign_t *foreign, /*!< in/out: foreign struct */ ibool do_alloc) /*!< in: is an alloc needed */ { @@ -652,11 +639,8 @@ ulint dict_index_t::get_col_pos(ulint n, bool inc_prefix, return (ULINT_UNDEFINED); } -/**********************************************************************/ /** - Frees an index memory object. */ -void dict_mem_index_free( - /*================*/ - dict_index_t *index) /*!< in: index */ +/** Frees an index memory object. */ +void dict_mem_index_free(dict_index_t *index) /*!< in: index */ { ut_ad(index); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc index 0c2c797ee28a..2fb4feb95725 100644 --- a/storage/innobase/dict/dict0stats.cc +++ b/storage/innobase/dict/dict0stats.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2009, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2009, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -27,8 +27,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "my_dbug.h" #include "my_inttypes.h" -/**************************************************/ /** - @file dict/dict0stats.cc +/** @file dict/dict0stats.cc Code used for calculating and manipulating table statistics. Created Jan 06, 2010 Vasil Dimov @@ -155,16 +154,13 @@ typedef std::map index_map_t; -/*********************************************************************/ /** - Checks whether an index should be ignored in stats manipulations: +/** Checks whether an index should be ignored in stats manipulations: * stats fetch * stats recalc * stats save @return true if exists and all tables are ok */ UNIV_INLINE -bool dict_stats_should_ignore_index( - /*===========================*/ - const dict_index_t *index) /*!< in: index */ +bool dict_stats_should_ignore_index(const dict_index_t *index) /*!< in: index */ { return ((index->type & DICT_FTS) || index->is_corrupted() || dict_index_is_spatial(index) || index->to_be_dropped || @@ -228,8 +224,7 @@ static dberr_t dict_stats_exec_sql(pars_info_t *pinfo, const char *sql, return (err); } -/*********************************************************************/ /** - Duplicate a table object and its indexes. +/** Duplicate a table object and its indexes. This function creates a dummy dict_table_t object and initializes the following table and index members: dict_table_t::id (copied) @@ -258,7 +253,6 @@ static dberr_t dict_stats_exec_sql(pars_info_t *pinfo, const char *sql, when no longer needed. @return incomplete table object */ static dict_table_t *dict_stats_table_clone_create( - /*==========================*/ const dict_table_t *table) /*!< in: table whose stats to copy */ { size_t heap_size; @@ -370,25 +364,20 @@ static dict_table_t *dict_stats_table_clone_create( return (t); } -/*********************************************************************/ /** - Free the resources occupied by an object returned by +/** Free the resources occupied by an object returned by dict_stats_table_clone_create(). */ static void dict_stats_table_clone_free( - /*========================*/ dict_table_t *t) /*!< in: dummy table object to free */ { dict_table_stats_latch_destroy(t); mem_heap_free(t->heap); } -/*********************************************************************/ /** - Write all zeros (or 1 where it makes sense) into an index +/** Write all zeros (or 1 where it makes sense) into an index statistics members. The resulting stats correspond to an empty index. The caller must own index's table stats latch in X mode (dict_table_stats_lock(table, RW_X_LATCH)) */ -static void dict_stats_empty_index( - /*===================*/ - dict_index_t *index) /*!< in/out: index */ +static void dict_stats_empty_index(dict_index_t *index) /*!< in/out: index */ { ut_ad(!(index->type & DICT_FTS)); ut_ad(!dict_index_is_ibuf(index)); @@ -405,12 +394,9 @@ static void dict_stats_empty_index( index->stat_n_leaf_pages = 1; } -/*********************************************************************/ /** - Write all zeros (or 1 where it makes sense) into a table and its indexes' +/** Write all zeros (or 1 where it makes sense) into a table and its indexes' statistics members. The resulting stats correspond to an empty table. */ -static void dict_stats_empty_table( - /*===================*/ - dict_table_t *table) /*!< in/out: table */ +static void dict_stats_empty_table(dict_table_t *table) /*!< in/out: table */ { /* Zero the stats members */ @@ -439,10 +425,8 @@ static void dict_stats_empty_table( dict_table_stats_unlock(table, RW_X_LATCH); } -/*********************************************************************/ /** - Check whether index's stats are initialized (assert if they are not). */ +/** Check whether index's stats are initialized (assert if they are not). */ static void dict_stats_assert_initialized_index( - /*================================*/ const dict_index_t *index) /*!< in: index */ { UNIV_MEM_ASSERT_RW_ABORT( @@ -464,10 +448,8 @@ static void dict_stats_assert_initialized_index( sizeof(index->stat_n_leaf_pages)); } -/*********************************************************************/ /** - Check whether table's stats are initialized (assert if they are not). */ +/** Check whether table's stats are initialized (assert if they are not). */ static void dict_stats_assert_initialized( - /*==========================*/ const dict_table_t *table) /*!< in: table */ { ut_a(table->stat_initialized); @@ -509,14 +491,11 @@ static void dict_stats_assert_initialized( ((i1) != NULL && (i2) != NULL && (i1)->space == (i2)->space && \ (i1)->id == (i2)->id && strcmp((i1)->name, (i2)->name) == 0) -/*********************************************************************/ /** - Copy table and index statistics from one table to another, including index +/** Copy table and index statistics from one table to another, including index stats. Extra indexes in src are ignored and extra indexes in dst are initialized to correspond to an empty index. */ -static void dict_stats_copy( - /*============*/ - dict_table_t *dst, /*!< in/out: destination table */ - const dict_table_t *src) /*!< in: source table */ +static void dict_stats_copy(dict_table_t *dst, /*!< in/out: destination table */ + const dict_table_t *src) /*!< in: source table */ { dst->stats_last_recalc = src->stats_last_recalc; dst->stat_n_rows = src->stat_n_rows; @@ -629,23 +608,19 @@ static dict_table_t *dict_stats_snapshot_create(dict_table_t *table) { return (t); } -/*********************************************************************/ /** - Free the resources occupied by an object returned by +/** Free the resources occupied by an object returned by dict_stats_snapshot_create(). */ static void dict_stats_snapshot_free( - /*=====================*/ dict_table_t *t) /*!< in: dummy table object to free */ { dict_stats_table_clone_free(t); } -/*********************************************************************/ /** - Calculates new estimates for index statistics. This function is +/** Calculates new estimates for index statistics. This function is relatively quick and is used to calculate transient statistics that are not saved on disk. This was the only way to calculate statistics before the Persistent Statistics feature was introduced. */ static void dict_stats_update_transient_for_index( - /*==================================*/ dict_index_t *index) /*!< in/out: index */ { if (srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO && @@ -698,14 +673,12 @@ static void dict_stats_update_transient_for_index( } } -/*********************************************************************/ /** - Calculates new estimates for table and index statistics. This function +/** Calculates new estimates for table and index statistics. This function is relatively quick and is used to calculate transient statistics that are not saved on disk. This was the only way to calculate statistics before the Persistent Statistics feature was introduced. */ static void dict_stats_update_transient( - /*========================*/ dict_table_t *table) /*!< in/out: table */ { dict_index_t *index; @@ -782,8 +755,7 @@ dict_stats_analyze_index() dict_stats_analyze_index_below_cur() @} */ -/*********************************************************************/ /** - Find the total number and the number of distinct keys on a given level in +/** Find the total number and the number of distinct keys on a given level in an index. Each of the 1..n_uniq prefixes are looked up and the results are saved in the array n_diff[0] .. n_diff[n_uniq - 1]. The total number of records on the level is saved in total_recs. @@ -791,7 +763,6 @@ dict_stats_analyze_index() in n_diff_boundaries[0..n_uniq - 1], records indexing starts from the leftmost record on the level and continues cross pages boundaries, counting from 0. */ static void dict_stats_analyze_index_level( - /*===========================*/ dict_index_t *index, /*!< in: index */ ulint level, /*!< in: level */ ib_uint64_t *n_diff, /*!< out: array for number of @@ -1628,12 +1599,10 @@ void dict_stats_index_set_n_diff(const n_diff_data_t *n_diff_data, } } -/*********************************************************************/ /** - Calculates new statistics for a given index and saves them to the index +/** Calculates new statistics for a given index and saves them to the index members stat_n_diff_key_vals[], stat_n_sample_sizes[], stat_index_size and stat_n_leaf_pages. This function could be slow. */ static void dict_stats_analyze_index( - /*=====================*/ dict_index_t *index) /*!< in/out: index to analyze */ { ulint root_level; @@ -1914,13 +1883,11 @@ static void dict_stats_analyze_index( DBUG_VOID_RETURN; } -/*********************************************************************/ /** - Calculates new estimates for table and index statistics. This function +/** Calculates new estimates for table and index statistics. This function is relatively slow and is used to calculate persistent statistics that will be saved on disk. @return DB_SUCCESS or error code */ static dberr_t dict_stats_update_persistent( - /*=========================*/ dict_table_t *table) /*!< in/out: table */ { dict_index_t *index; @@ -2252,14 +2219,12 @@ static dberr_t dict_stats_save(dict_table_t *table_orig, return (ret); } -/*********************************************************************/ /** - Called for the row that is selected by +/** Called for the row that is selected by SELECT ... FROM mysql.innodb_table_stats WHERE table='...' The second argument is a pointer to the table and the fetched stats are written to it. @return non-NULL dummy */ static ibool dict_stats_fetch_table_stats_step( - /*==============================*/ void *node_void, /*!< in: select node */ void *table_void) /*!< out: table */ { @@ -2336,8 +2301,7 @@ struct index_fetch_t { least one index stats were modified */ }; -/*********************************************************************/ /** - Called for the rows that are selected by +/** Called for the rows that are selected by SELECT ... FROM mysql.innodb_index_stats WHERE table='...' The second argument is a pointer to the table and the fetched stats are written to its indexes. @@ -2354,7 +2318,6 @@ struct index_fetch_t { simpler N^2 algorithm. @return non-NULL dummy */ static ibool dict_stats_fetch_index_stats_step( - /*==============================*/ void *node_void, /*!< in: select node */ void *arg_void) /*!< out: table + a flag that tells if we modified anything */ @@ -2569,11 +2532,9 @@ static ibool dict_stats_fetch_index_stats_step( return (TRUE); } -/*********************************************************************/ /** - Read table's statistics from the persistent statistics storage. +/** Read table's statistics from the persistent statistics storage. @return DB_SUCCESS or error code */ static dberr_t dict_stats_fetch_from_ps( - /*=====================*/ dict_table_t *table) /*!< in/out: table */ { index_fetch_t index_fetch_arg; @@ -2692,11 +2653,8 @@ static dberr_t dict_stats_fetch_from_ps( return (ret); } -/*********************************************************************/ /** - Fetches or calculates new estimates for index statistics. */ -void dict_stats_update_for_index( - /*========================*/ - dict_index_t *index) /*!< in/out: index */ +/** Fetches or calculates new estimates for index statistics. */ +void dict_stats_update_for_index(dict_index_t *index) /*!< in/out: index */ { DBUG_ENTER("dict_stats_update_for_index"); @@ -2718,14 +2676,11 @@ void dict_stats_update_for_index( DBUG_VOID_RETURN; } -/*********************************************************************/ /** - Calculates new estimates for table and index statistics. The statistics +/** Calculates new estimates for table and index statistics. The statistics are used in query optimization. @return DB_SUCCESS or error code */ -dberr_t dict_stats_update( - /*==============*/ - dict_table_t *table, /*!< in/out: table */ - dict_stats_upd_option_t stats_upd_option) +dberr_t dict_stats_update(dict_table_t *table, /*!< in/out: table */ + dict_stats_upd_option_t stats_upd_option) /*!< in: whether to (re) calc the stats or to fetch them from the persistent statistics @@ -2880,8 +2835,7 @@ storage */ return (DB_SUCCESS); } -/*********************************************************************/ /** - Removes the information for a particular index's stats from the persistent +/** Removes the information for a particular index's stats from the persistent storage if it exists and if there is data stored for this index. This function creates its own trx and commits it. A note from Marko why we cannot edit user and sys_* tables in one trx: @@ -2892,7 +2846,6 @@ storage */ transactions and opened the SYS_* records for the *.ibd files. @return DB_SUCCESS or error code */ dberr_t dict_stats_drop_index( - /*==================*/ const char *db_and_table, /*!< in: db and table, e.g. 'db/table' */ const char *iname, /*!< in: index name */ char *errstr, /*!< out: error message if != DB_SUCCESS @@ -2962,15 +2915,13 @@ dberr_t dict_stats_drop_index( return (ret); } -/*********************************************************************/ /** - Executes +/** Executes DELETE FROM mysql.innodb_table_stats WHERE database_name = '...' AND table_name = '...'; Creates its own transaction and commits it. @return DB_SUCCESS or error code */ UNIV_INLINE dberr_t dict_stats_delete_from_table_stats( - /*===============================*/ const char *database_name, /*!< in: database name, e.g. 'db' */ const char *table_name) /*!< in: table name, e.g. 'table' */ { @@ -2997,15 +2948,13 @@ dberr_t dict_stats_delete_from_table_stats( return (ret); } -/*********************************************************************/ /** - Executes +/** Executes DELETE FROM mysql.innodb_index_stats WHERE database_name = '...' AND table_name = '...'; Creates its own transaction and commits it. @return DB_SUCCESS or error code */ UNIV_INLINE dberr_t dict_stats_delete_from_index_stats( - /*===============================*/ const char *database_name, /*!< in: database name, e.g. 'db' */ const char *table_name) /*!< in: table name, e.g. 'table' */ { @@ -3032,13 +2981,11 @@ dberr_t dict_stats_delete_from_index_stats( return (ret); } -/*********************************************************************/ /** - Removes the statistics for a table and all of its indexes from the +/** Removes the statistics for a table and all of its indexes from the persistent statistics storage if it exists and if there is data stored for the table. This function creates its own transaction and commits it. @return DB_SUCCESS or error code */ dberr_t dict_stats_drop_table( - /*==================*/ const char *db_and_table, /*!< in: db and table, e.g. 'db/table' */ char *errstr, /*!< out: error message if != DB_SUCCESS is returned */ @@ -3105,8 +3052,7 @@ dberr_t dict_stats_drop_table( return (ret); } -/*********************************************************************/ /** - Executes +/** Executes UPDATE mysql.innodb_table_stats SET database_name = '...', table_name = '...' WHERE database_name = '...' AND table_name = '...'; @@ -3114,7 +3060,6 @@ dberr_t dict_stats_drop_table( @return DB_SUCCESS or error code */ UNIV_INLINE dberr_t dict_stats_rename_table_in_table_stats( - /*===================================*/ const char *old_dbname_utf8, /*!< in: database name, e.g. 'olddb' */ const char *old_tablename_utf8, /*!< in: table name, e.g. 'oldtable' */ const char *new_dbname_utf8, /*!< in: database name, e.g. 'newdb' */ @@ -3148,8 +3093,7 @@ dberr_t dict_stats_rename_table_in_table_stats( return (ret); } -/*********************************************************************/ /** - Executes +/** Executes UPDATE mysql.innodb_index_stats SET database_name = '...', table_name = '...' WHERE database_name = '...' AND table_name = '...'; @@ -3157,7 +3101,6 @@ dberr_t dict_stats_rename_table_in_table_stats( @return DB_SUCCESS or error code */ UNIV_INLINE dberr_t dict_stats_rename_table_in_index_stats( - /*===================================*/ const char *old_dbname_utf8, /*!< in: database name, e.g. 'olddb' */ const char *old_tablename_utf8, /*!< in: table name, e.g. 'oldtable' */ const char *new_dbname_utf8, /*!< in: database name, e.g. 'newdb' */ @@ -3191,12 +3134,10 @@ dberr_t dict_stats_rename_table_in_index_stats( return (ret); } -/*********************************************************************/ /** - Renames a table in InnoDB persistent stats storage. +/** Renames a table in InnoDB persistent stats storage. This function creates its own transaction and commits it. @return DB_SUCCESS or error code */ dberr_t dict_stats_rename_table( - /*====================*/ const char *old_name, /*!< in: old name, e.g. 'db/table' */ const char *new_name, /*!< in: new name, e.g. 'db/table' */ char *errstr, /*!< out: error string if != DB_SUCCESS @@ -3323,13 +3264,11 @@ dberr_t dict_stats_rename_table( return (ret); } -/*********************************************************************/ /** - Renames an index in InnoDB persistent stats storage. +/** Renames an index in InnoDB persistent stats storage. This function creates its own transaction and commits it. @return DB_SUCCESS or error code. DB_STATS_DO_NOT_EXIST will be returned if the persistent stats do not exist. */ dberr_t dict_stats_rename_index( - /*====================*/ const dict_table_t *table, /*!< in: table whose index is renamed */ const char *old_index_name, /*!< in: old index name */ diff --git a/storage/innobase/dict/dict0stats_bg.cc b/storage/innobase/dict/dict0stats_bg.cc index 3d9ef54fa9ff..52cebc64110c 100644 --- a/storage/innobase/dict/dict0stats_bg.cc +++ b/storage/innobase/dict/dict0stats_bg.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2012, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2012, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file dict/dict0stats_bg.cc +/** @file dict/dict0stats_bg.cc Code used for background table and index stats gathering. Created Apr 25, 2012 Vasil Dimov @@ -92,11 +91,8 @@ static bool dict_stats_start_shutdown; /** Event to wait for shutdown of the dict stats thread */ static os_event_t dict_stats_shutdown_event; -/*****************************************************************/ /** - Initialize the recalc pool, called once during thread initialization. */ -static void dict_stats_recalc_pool_init() -/*=========================*/ -{ +/** Initialize the recalc pool, called once during thread initialization. */ +static void dict_stats_recalc_pool_init() { ut_ad(!srv_read_only_mode); const PSI_memory_key key = mem_key_dict_stats_bg_recalc_pool_t; @@ -106,12 +102,9 @@ static void dict_stats_recalc_pool_init() recalc_pool->reserve(RECALC_POOL_INITIAL_SLOTS); } -/*****************************************************************/ /** - Free the resources occupied by the recalc pool, called once during +/** Free the resources occupied by the recalc pool, called once during thread de-initialization. */ -static void dict_stats_recalc_pool_deinit() -/*===========================*/ -{ +static void dict_stats_recalc_pool_deinit() { ut_ad(!srv_read_only_mode); recalc_pool->clear(); @@ -120,14 +113,12 @@ static void dict_stats_recalc_pool_deinit() recalc_pool = NULL; } -/*****************************************************************/ /** - Add a table to the recalc pool, which is processed by the +/** Add a table to the recalc pool, which is processed by the background stats gathering thread. Only the table id is added to the list, so the table can be closed after being enqueued and it will be opened when needed. If the table does not exist later (has been DROPped), then it will be removed from the pool and skipped. */ void dict_stats_recalc_pool_add( - /*=======================*/ const dict_table_t *table) /*!< in: table to add */ { ut_ad(!srv_read_only_mode); @@ -150,12 +141,10 @@ void dict_stats_recalc_pool_add( os_event_set(dict_stats_event); } -/*****************************************************************/ /** - Get a table from the auto recalc pool. The returned table id is removed +/** Get a table from the auto recalc pool. The returned table id is removed from the pool. @return true if the pool was non-empty and "id" was set, false otherwise */ static bool dict_stats_recalc_pool_get( - /*=======================*/ table_id_t *id) /*!< out: table id, or unmodified if list is empty */ { @@ -177,11 +166,9 @@ static bool dict_stats_recalc_pool_get( return (true); } -/*****************************************************************/ /** - Delete a given table from the auto recalc pool. +/** Delete a given table from the auto recalc pool. dict_stats_recalc_pool_del() */ void dict_stats_recalc_pool_del( - /*=======================*/ const dict_table_t *table) /*!< in: table to remove */ { ut_ad(!srv_read_only_mode); @@ -203,8 +190,7 @@ void dict_stats_recalc_pool_del( mutex_exit(&recalc_pool_mutex); } -/*****************************************************************/ /** - Wait until background stats thread has stopped using the specified table. +/** Wait until background stats thread has stopped using the specified table. The caller must have locked the data dictionary using row_mysql_lock_data_dictionary() and this function may unlock it temporarily and restore the lock before it exits. @@ -213,7 +199,6 @@ void dict_stats_recalc_pool_del( dictionary because it sets the BG_STAT_IN_PROGRESS bit in table->stats_bg_flag under dict_sys->mutex. */ void dict_stats_wait_bg_to_stop_using_table( - /*===================================*/ dict_table_t *table, /*!< in/out: table */ trx_t *trx) /*!< in/out: transaction to use for unlocking/locking the data dict */ @@ -223,12 +208,9 @@ void dict_stats_wait_bg_to_stop_using_table( } } -/*****************************************************************/ /** - Initialize global variables needed for the operation of dict_stats_thread() +/** Initialize global variables needed for the operation of dict_stats_thread() Must be called before dict_stats_thread() is started. */ -void dict_stats_thread_init() -/*====================*/ -{ +void dict_stats_thread_init() { ut_a(!srv_read_only_mode); dict_stats_event = os_event_create(0); @@ -255,12 +237,9 @@ void dict_stats_thread_init() dict_stats_recalc_pool_init(); } -/*****************************************************************/ /** - Free resources allocated by dict_stats_thread_init(), must be called +/** Free resources allocated by dict_stats_thread_init(), must be called after dict_stats_thread() has exited. */ -void dict_stats_thread_deinit() -/*======================*/ -{ +void dict_stats_thread_deinit() { ut_a(!srv_read_only_mode); ut_ad(!srv_dict_stats_thread_active); diff --git a/storage/innobase/dict/mem.cc b/storage/innobase/dict/mem.cc index fd023c06b009..5580d01826c2 100644 --- a/storage/innobase/dict/mem.cc +++ b/storage/innobase/dict/mem.cc @@ -25,8 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file dict/mem.cc +/** @file dict/mem.cc Data dictionary memory object creation Created 1/8/1996 Heikki Tuuri @@ -44,11 +43,9 @@ external tools. */ #endif /* !UNIV_HOTBACKUP */ #include "my_inttypes.h" -/****************************************************************/ /** - Append 'name' to 'col_names'. @see dict_table_t::col_names +/** Append 'name' to 'col_names'. @see dict_table_t::col_names @return new column names array */ const char *dict_add_col_name( - /*==============*/ const char *col_names, /*!< in: existing column names, or NULL */ ulint cols, /*!< in: number of existing columns */ @@ -90,11 +87,8 @@ const char *dict_add_col_name( return (res); } -/****************************************************************/ /** - Free a table memory object. */ -void dict_mem_table_free( - /*================*/ - dict_table_t *table) /*!< in: table */ +/** Free a table memory object. */ +void dict_mem_table_free(dict_table_t *table) /*!< in: table */ { ut_ad(table); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); @@ -152,11 +146,9 @@ void dict_mem_table_free( mem_heap_free(table->heap); } -/**********************************************************************/ /** - Creates a table memory object. +/** Creates a table memory object. @return own: table object */ dict_table_t *dict_mem_table_create( - /*==================*/ const char *name, /*!< in: table name */ space_id_t space, /*!< in: space where the clustered index of the table is placed */ @@ -256,11 +248,9 @@ dict_table_t *dict_mem_table_create( return (table); } -/**********************************************************************/ /** - Creates an index memory object. +/** Creates an index memory object. @return own: index object */ dict_index_t *dict_mem_index_create( - /*==================*/ const char *table_name, /*!< in: table name */ const char *index_name, /*!< in: index name */ ulint space, /*!< in: space where the index tree is @@ -300,10 +290,8 @@ dict_index_t *dict_mem_index_create( return (index); } -/**********************************************************************/ /** - Adds a column definition to a table. */ +/** Adds a column definition to a table. */ void dict_mem_table_add_col( - /*===================*/ dict_table_t *table, /*!< in: table */ mem_heap_t *heap, /*!< in: temporary memory heap, or NULL */ const char *name, /*!< in: column name, or NULL */ @@ -343,11 +331,9 @@ void dict_mem_table_add_col( dict_mem_fill_column_struct(col, i, mtype, prtype, len); } -/**********************************************************************/ /** - This function populates a dict_col_t memory structure with +/** This function populates a dict_col_t memory structure with supplied information. */ void dict_mem_fill_column_struct( - /*========================*/ dict_col_t *column, /*!< out: column struct to be filled */ ulint col_pos, /*!< in: column position */ diff --git a/storage/innobase/dict/mem.h b/storage/innobase/dict/mem.h index 676fafebc3e3..65b106d5bb91 100644 --- a/storage/innobase/dict/mem.h +++ b/storage/innobase/dict/mem.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -25,8 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file dict/mem.h +/** @file dict/mem.h Data dictionary memory object creation Created 1/8/1996 Heikki Tuuri @@ -34,11 +33,9 @@ this program; if not, write to the Free Software Foundation, Inc., #ifndef dict_mem_h #define dict_mem_h -/**********************************************************************/ /** - Creates a table memory object. +/** Creates a table memory object. @return own: table object */ dict_table_t *dict_mem_table_create( - /*==================*/ const char *name, /*!< in: table name */ space_id_t space, /*!< in: space where the clustered index of the table is placed */ @@ -48,17 +45,12 @@ dict_table_t *dict_mem_table_create( ulint n_v_cols, /*!< in: number of virtual columns */ ulint flags, /*!< in: table flags */ ulint flags2); /*!< in: table flags2 */ -/****************************************************************/ /** - Free a table memory object. */ -void dict_mem_table_free( - /*================*/ - dict_table_t *table); /*!< in: table */ +/** Free a table memory object. */ +void dict_mem_table_free(dict_table_t *table); /*!< in: table */ -/**********************************************************************/ /** - Creates an index memory object. +/** Creates an index memory object. @return own: index object */ dict_index_t *dict_mem_index_create( - /*==================*/ const char *table_name, /*!< in: table name */ const char *index_name, /*!< in: index name */ ulint space, /*!< in: space where the index tree is @@ -68,10 +60,8 @@ dict_index_t *dict_mem_index_create( DICT_CLUSTERED, ... ORed */ ulint n_fields); /*!< in: number of fields */ -/**********************************************************************/ /** - Adds a column definition to a table. */ +/** Adds a column definition to a table. */ void dict_mem_table_add_col( - /*===================*/ dict_table_t *table, /*!< in: table */ mem_heap_t *heap, /*!< in: temporary memory heap, or NULL */ const char *name, /*!< in: column name, or NULL */ @@ -79,22 +69,18 @@ void dict_mem_table_add_col( ulint prtype, /*!< in: precise type */ ulint len); /*!< in: precision */ -/**********************************************************************/ /** - This function populates a dict_col_t memory structure with +/** This function populates a dict_col_t memory structure with supplied information. */ void dict_mem_fill_column_struct( - /*========================*/ dict_col_t *column, /*!< out: column struct to be filled */ ulint col_pos, /*!< in: column position */ ulint mtype, /*!< in: main data type */ ulint prtype, /*!< in: precise type */ ulint col_len); /*!< in: column length */ -/****************************************************************/ /** - Append 'name' to 'col_names'. @see dict_table_t::col_names +/** Append 'name' to 'col_names'. @see dict_table_t::col_names @return new column names array */ const char *dict_add_col_name( - /*==============*/ const char *col_names, /*!< in: existing column names, or NULL */ ulint cols, /*!< in: number of existing columns */ diff --git a/storage/innobase/eval/eval0eval.cc b/storage/innobase/eval/eval0eval.cc index af2d9db25f1e..882cf03f7d6a 100644 --- a/storage/innobase/eval/eval0eval.cc +++ b/storage/innobase/eval/eval0eval.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file eval/eval0eval.cc +/** @file eval/eval0eval.cc SQL evaluator: evaluates simple data structures, like expressions, in a query graph @@ -48,22 +47,19 @@ static byte eval_dummy; Gets the like node from the node */ UNIV_INLINE que_node_t *que_node_get_like_node( - /*===================*/ /* out: next node in a list of nodes */ que_node_t *node) /* in: node in a list */ { return (((sym_node_t *)node)->like_node); } -/*****************************************************************/ /** - Allocate a buffer from global dynamic memory for a value of a que_node. +/** Allocate a buffer from global dynamic memory for a value of a que_node. NOTE that this memory must be explicitly freed when the query graph is freed. If the node already has an allocated buffer, that buffer is freed here. NOTE that this is the only function where dynamic memory should be allocated for a query node val field. @return pointer to allocated buffer */ byte *eval_node_alloc_val_buf( - /*====================*/ que_node_t *node, /*!< in: query graph node; sets the val field data field to point to the new buffer, and len field equal to size */ @@ -96,13 +92,10 @@ byte *eval_node_alloc_val_buf( return (data); } -/*****************************************************************/ /** - Free the buffer from global dynamic memory for a value of a que_node, +/** Free the buffer from global dynamic memory for a value of a que_node, if it has been allocated in the above function. The freeing for pushed column values is done in sel_col_prefetch_buf_free. */ -void eval_node_free_val_buf( - /*===================*/ - que_node_t *node) /*!< in: query graph node */ +void eval_node_free_val_buf(que_node_t *node) /*!< in: query graph node */ { dfield_t *dfield; byte *data; @@ -125,10 +118,8 @@ void eval_node_free_val_buf( Evaluates a LIKE comparison node. @return the result of the comparison */ UNIV_INLINE -ibool eval_cmp_like( - /*==========*/ - que_node_t *arg1, /* !< in: left operand */ - que_node_t *arg2) /* !< in: right operand */ +ibool eval_cmp_like(que_node_t *arg1, /* !< in: left operand */ + que_node_t *arg2) /* !< in: right operand */ { ib_like_t op; que_node_t *arg3; @@ -162,9 +153,7 @@ ibool eval_cmp_like( /********************************************************************* Evaluates a comparison node. @return the result of the comparison */ -ibool eval_cmp( - /*=====*/ - func_node_t *cmp_node) /*!< in: comparison node */ +ibool eval_cmp(func_node_t *cmp_node) /*!< in: comparison node */ { que_node_t *arg1; que_node_t *arg2; @@ -217,12 +206,9 @@ ibool eval_cmp( return (val); } -/*****************************************************************/ /** - Evaluates a logical operation node. */ +/** Evaluates a logical operation node. */ UNIV_INLINE -void eval_logical( - /*=========*/ - func_node_t *logical_node) /*!< in: logical operation node */ +void eval_logical(func_node_t *logical_node) /*!< in: logical operation node */ { que_node_t *arg1; que_node_t *arg2; @@ -257,12 +243,9 @@ void eval_logical( eval_node_set_ibool_val(logical_node, val); } -/*****************************************************************/ /** - Evaluates an arithmetic operation node. */ +/** Evaluates an arithmetic operation node. */ UNIV_INLINE -void eval_arith( - /*=======*/ - func_node_t *arith_node) /*!< in: arithmetic operation node */ +void eval_arith(func_node_t *arith_node) /*!< in: arithmetic operation node */ { que_node_t *arg1; que_node_t *arg2; @@ -300,12 +283,9 @@ void eval_arith( eval_node_set_int_val(arith_node, val); } -/*****************************************************************/ /** - Evaluates an aggregate operation node. */ +/** Evaluates an aggregate operation node. */ UNIV_INLINE -void eval_aggregate( - /*===========*/ - func_node_t *node) /*!< in: aggregate operation node */ +void eval_aggregate(func_node_t *node) /*!< in: aggregate operation node */ { que_node_t *arg; lint val; @@ -332,12 +312,9 @@ void eval_aggregate( eval_node_set_int_val(node, val); } -/*****************************************************************/ /** - Evaluates a notfound-function node. */ +/** Evaluates a notfound-function node. */ UNIV_INLINE -void eval_notfound( - /*==========*/ - func_node_t *func_node) /*!< in: function node */ +void eval_notfound(func_node_t *func_node) /*!< in: function node */ { sym_node_t *cursor; sel_node_t *sel_node; @@ -366,12 +343,9 @@ void eval_notfound( eval_node_set_ibool_val(func_node, ibool_val); } -/*****************************************************************/ /** - Evaluates a substr-function node. */ +/** Evaluates a substr-function node. */ UNIV_INLINE -void eval_substr( - /*========*/ - func_node_t *func_node) /*!< in: function node */ +void eval_substr(func_node_t *func_node) /*!< in: function node */ { que_node_t *arg1; que_node_t *arg2; @@ -398,11 +372,8 @@ void eval_substr( dfield_set_data(dfield, str1 + len1, len2); } -/*****************************************************************/ /** - Evaluates an instr-function node. */ -static void eval_instr( - /*=======*/ - func_node_t *func_node) /*!< in: function node */ +/** Evaluates an instr-function node. */ +static void eval_instr(func_node_t *func_node) /*!< in: function node */ { que_node_t *arg1; que_node_t *arg2; @@ -465,11 +436,8 @@ static void eval_instr( eval_node_set_int_val(func_node, int_val); } -/*****************************************************************/ /** - Evaluates a predefined function node. */ -static void eval_concat( - /*========*/ - func_node_t *func_node) /*!< in: function node */ +/** Evaluates a predefined function node. */ +static void eval_concat(func_node_t *func_node) /*!< in: function node */ { que_node_t *arg; dfield_t *dfield; @@ -505,16 +473,13 @@ static void eval_concat( } } -/*****************************************************************/ /** - Evaluates a predefined function node. If the first argument is an integer, +/** Evaluates a predefined function node. If the first argument is an integer, this function looks at the second argument which is the integer length in bytes, and converts the integer to a VARCHAR. If the first argument is of some other type, this function converts it to BINARY. */ UNIV_INLINE -void eval_to_binary( - /*===========*/ - func_node_t *func_node) /*!< in: function node */ +void eval_to_binary(func_node_t *func_node) /*!< in: function node */ { que_node_t *arg1; que_node_t *arg2; @@ -559,11 +524,8 @@ void eval_length(func_node_t *func_node) /*!< in: function node */ func_node, (lint)dfield_get_len(que_node_get_val(func_node->args))); } -/*****************************************************************/ /** - Evaluates a function node. */ -void eval_func( - /*======*/ - func_node_t *func_node) /*!< in: function node */ +/** Evaluates a function node. */ +void eval_func(func_node_t *func_node) /*!< in: function node */ { que_node_t *arg; ulint fclass; diff --git a/storage/innobase/eval/eval0proc.cc b/storage/innobase/eval/eval0proc.cc index b1225f9238fb..35950be8f5f9 100644 --- a/storage/innobase/eval/eval0proc.cc +++ b/storage/innobase/eval/eval0proc.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1998, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1998, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file eval/eval0proc.cc +/** @file eval/eval0proc.cc Executes SQL stored procedures and their control structures Created 1/20/1998 Heikki Tuuri @@ -35,12 +34,9 @@ this program; if not, write to the Free Software Foundation, Inc., #include -/**********************************************************************/ /** - Performs an execution step of an if-statement node. +/** Performs an execution step of an if-statement node. @return query thread to run next or NULL */ -que_thr_t *if_step( - /*====*/ - que_thr_t *thr) /*!< in: query thread */ +que_thr_t *if_step(que_thr_t *thr) /*!< in: query thread */ { if_node_t *node; elsif_node_t *elsif_node; @@ -105,12 +101,9 @@ que_thr_t *if_step( return (thr); } -/**********************************************************************/ /** - Performs an execution step of a while-statement node. +/** Performs an execution step of a while-statement node. @return query thread to run next or NULL */ -que_thr_t *while_step( - /*=======*/ - que_thr_t *thr) /*!< in: query thread */ +que_thr_t *while_step(que_thr_t *thr) /*!< in: query thread */ { while_node_t *node; @@ -138,12 +131,9 @@ que_thr_t *while_step( return (thr); } -/**********************************************************************/ /** - Performs an execution step of an assignment statement node. +/** Performs an execution step of an assignment statement node. @return query thread to run next or NULL */ -que_thr_t *assign_step( - /*========*/ - que_thr_t *thr) /*!< in: query thread */ +que_thr_t *assign_step(que_thr_t *thr) /*!< in: query thread */ { assign_node_t *node; @@ -163,12 +153,9 @@ que_thr_t *assign_step( return (thr); } -/**********************************************************************/ /** - Performs an execution step of a for-loop node. +/** Performs an execution step of a for-loop node. @return query thread to run next or NULL */ -que_thr_t *for_step( - /*=====*/ - que_thr_t *thr) /*!< in: query thread */ +que_thr_t *for_step(que_thr_t *thr) /*!< in: query thread */ { for_node_t *node; que_node_t *parent; @@ -219,12 +206,9 @@ que_thr_t *for_step( return (thr); } -/**********************************************************************/ /** - Performs an execution step of an exit statement node. +/** Performs an execution step of an exit statement node. @return query thread to run next or NULL */ -que_thr_t *exit_step( - /*======*/ - que_thr_t *thr) /*!< in: query thread */ +que_thr_t *exit_step(que_thr_t *thr) /*!< in: query thread */ { exit_node_t *node; que_node_t *loop_node; @@ -249,12 +233,9 @@ que_thr_t *exit_step( return (thr); } -/**********************************************************************/ /** - Performs an execution step of a return-statement node. +/** Performs an execution step of a return-statement node. @return query thread to run next or NULL */ -que_thr_t *return_step( - /*========*/ - que_thr_t *thr) /*!< in: query thread */ +que_thr_t *return_step(que_thr_t *thr) /*!< in: query thread */ { return_node_t *node; que_node_t *parent; diff --git a/storage/innobase/fsp/fsp0file.cc b/storage/innobase/fsp/fsp0file.cc index a922216b74be..3f1190f53991 100644 --- a/storage/innobase/fsp/fsp0file.cc +++ b/storage/innobase/fsp/fsp0file.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file fsp/fsp0file.cc +/** @file fsp/fsp0file.cc Tablespace data file implementation Created 2013-7-26 by Kevin Lewis diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index 1d0f1423e6fc..a221f67a74d9 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file fsp/fsp0fsp.cc +/** @file fsp/fsp0fsp.cc File space management Created 11/29/1995 Heikki Tuuri @@ -77,11 +76,9 @@ static void fsp_free_extent(const page_id_t &page_id, @return true if extent is part of the segment, false otherwise */ static bool xdes_in_segment(const xdes_t *descr, ib_id_t seg_id, mtr_t *mtr); -/********************************************************************/ /** - Marks a page used. The page must reside within the extents of the given +/** Marks a page used. The page must reside within the extents of the given segment. */ static void fseg_mark_page_used( - /*================*/ fseg_inode_t *seg_inode, /*!< in: segment inode */ page_no_t page, /*!< in: page offset */ xdes_t *descr, /*!< in: extent descriptor */ @@ -270,17 +267,14 @@ bool fsp_skip_sanity_check(space_id_t space_id) { #endif /* UNIV_DEBUG */ -/**********************************************************************/ /** - Gets a descriptor bit of a page. +/** Gets a descriptor bit of a page. @return true if free */ UNIV_INLINE -ibool xdes_mtr_get_bit( - /*=============*/ - const xdes_t *descr, /*!< in: descriptor */ - ulint bit, /*!< in: XDES_FREE_BIT or XDES_CLEAN_BIT */ - page_no_t offset, /*!< in: page offset within extent: - 0 ... FSP_EXTENT_SIZE - 1 */ - mtr_t *mtr) /*!< in: mini-transaction */ +ibool xdes_mtr_get_bit(const xdes_t *descr, /*!< in: descriptor */ + ulint bit, /*!< in: XDES_FREE_BIT or XDES_CLEAN_BIT */ + page_no_t offset, /*!< in: page offset within extent: + 0 ... FSP_EXTENT_SIZE - 1 */ + mtr_t *mtr) /*!< in: mini-transaction */ { ut_ad(mtr->is_active()); ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_SX_FIX)); @@ -288,17 +282,14 @@ ibool xdes_mtr_get_bit( return (xdes_get_bit(descr, bit, offset)); } -/**********************************************************************/ /** - Sets a descriptor bit of a page. */ +/** Sets a descriptor bit of a page. */ UNIV_INLINE -void xdes_set_bit( - /*=========*/ - xdes_t *descr, /*!< in: descriptor */ - ulint bit, /*!< in: XDES_FREE_BIT or XDES_CLEAN_BIT */ - page_no_t offset, /*!< in: page offset within extent: - 0 ... FSP_EXTENT_SIZE - 1 */ - ibool val, /*!< in: bit value */ - mtr_t *mtr) /*!< in/out: mini-transaction */ +void xdes_set_bit(xdes_t *descr, /*!< in: descriptor */ + ulint bit, /*!< in: XDES_FREE_BIT or XDES_CLEAN_BIT */ + page_no_t offset, /*!< in: page offset within extent: + 0 ... FSP_EXTENT_SIZE - 1 */ + ibool val, /*!< in: bit value */ + mtr_t *mtr) /*!< in/out: mini-transaction */ { ulint index; ulint byte_index; @@ -321,14 +312,12 @@ void xdes_set_bit( mtr); } -/**********************************************************************/ /** - Looks for a descriptor bit having the desired value. Starts from hint +/** Looks for a descriptor bit having the desired value. Starts from hint and scans upward; at the end of the extent the search is wrapped to the start of the extent. @return bit index of the bit, ULINT_UNDEFINED if not found */ UNIV_INLINE page_no_t xdes_find_bit( - /*==========*/ xdes_t *descr, /*!< in: descriptor */ ulint bit, /*!< in: XDES_FREE_BIT or XDES_CLEAN_BIT */ ibool val, /*!< in: desired bit value */ @@ -357,14 +346,11 @@ page_no_t xdes_find_bit( return (FIL_NULL); } -/**********************************************************************/ /** - Returns the number of used pages in a descriptor. +/** Returns the number of used pages in a descriptor. @return number of pages used */ UNIV_INLINE -page_no_t xdes_get_n_used( - /*============*/ - const xdes_t *descr, /*!< in: descriptor */ - mtr_t *mtr) /*!< in/out: mini-transaction */ +page_no_t xdes_get_n_used(const xdes_t *descr, /*!< in: descriptor */ + mtr_t *mtr) /*!< in/out: mini-transaction */ { page_no_t count = 0; @@ -397,14 +383,11 @@ bool xdes_state_is_valid(ulint state) { } #endif /* UNIV_DEBUG */ -/**********************************************************************/ /** - Returns true if extent contains no used pages. +/** Returns true if extent contains no used pages. @return true if totally free */ UNIV_INLINE -ibool xdes_is_free( - /*=========*/ - const xdes_t *descr, /*!< in: descriptor */ - mtr_t *mtr) /*!< in/out: mini-transaction */ +ibool xdes_is_free(const xdes_t *descr, /*!< in: descriptor */ + mtr_t *mtr) /*!< in/out: mini-transaction */ { if (0 == xdes_get_n_used(descr, mtr)) { ut_ad(xdes_get_state(descr, mtr) != XDES_FSEG_FRAG); @@ -415,14 +398,11 @@ ibool xdes_is_free( return (FALSE); } -/**********************************************************************/ /** - Returns true if extent contains no free pages. +/** Returns true if extent contains no free pages. @return true if full */ UNIV_INLINE -ibool xdes_is_full( - /*=========*/ - const xdes_t *descr, /*!< in: descriptor */ - mtr_t *mtr) /*!< in/out: mini-transaction */ +ibool xdes_is_full(const xdes_t *descr, /*!< in: descriptor */ + mtr_t *mtr) /*!< in/out: mini-transaction */ { if (FSP_EXTENT_SIZE == xdes_get_n_used(descr, mtr)) { return (TRUE); @@ -431,14 +411,11 @@ ibool xdes_is_full( return (FALSE); } -/**********************************************************************/ /** - Sets the state of an xdes. */ +/** Sets the state of an xdes. */ UNIV_INLINE -void xdes_set_state( - /*===========*/ - xdes_t *descr, /*!< in/out: descriptor */ - xdes_state_t state, /*!< in: state to set */ - mtr_t *mtr) /*!< in/out: mini-transaction */ +void xdes_set_state(xdes_t *descr, /*!< in/out: descriptor */ + xdes_state_t state, /*!< in: state to set */ + mtr_t *mtr) /*!< in/out: mini-transaction */ { ut_ad(descr && mtr); ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_SX_FIX)); @@ -484,13 +461,10 @@ inline void xdes_set_segment_id(xdes_t *descr, const ib_id_t seg_id, xdes_set_state(descr, state, mtr); } -/**********************************************************************/ /** - Inits an extent descriptor to the free and clean state. */ +/** Inits an extent descriptor to the free and clean state. */ UNIV_INLINE -void xdes_init( - /*======*/ - xdes_t *descr, /*!< in: descriptor */ - mtr_t *mtr) /*!< in/out: mini-transaction */ +void xdes_init(xdes_t *descr, /*!< in: descriptor */ + mtr_t *mtr) /*!< in/out: mini-transaction */ { ulint i; @@ -628,13 +602,10 @@ xdes_t *xdes_lst_get_descriptor(space_id_t space, const page_size_t &page_size, return (descr); } -/********************************************************************/ /** - Returns page offset of the first page in extent described by a descriptor. +/** Returns page offset of the first page in extent described by a descriptor. @return offset of the first page in extent */ UNIV_INLINE -page_no_t xdes_get_offset( - /*============*/ - const xdes_t *descr) /*!< in: extent descriptor */ +page_no_t xdes_get_offset(const xdes_t *descr) /*!< in: extent descriptor */ { ut_ad(descr); @@ -645,10 +616,8 @@ page_no_t xdes_get_offset( } #endif /* !UNIV_HOTBACKUP */ -/***********************************************************/ /** - Inits a file page whose prior contents should be ignored. */ +/** Inits a file page whose prior contents should be ignored. */ static void fsp_init_file_page_low( - /*===================*/ buf_block_t *block) /*!< in: pointer to a page */ { page_t *page = buf_block_get_frame(block); @@ -725,11 +694,9 @@ static void fsp_init_file_page(buf_block_t *block, mtr_t *mtr) { } #endif /* !UNIV_HOTBACKUP */ -/***********************************************************/ /** - Parses a redo log record of a file page init. +/** Parses a redo log record of a file page init. @return end of log record or NULL */ byte *fsp_parse_init_file_page( - /*=====================*/ byte *ptr, /*!< in: buffer */ byte *end_ptr MY_ATTRIBUTE((unused)), /*!< in: buffer end */ buf_block_t *block) /*!< in: block or NULL */ @@ -759,12 +726,10 @@ void fsp_init() { /* Does nothing at the moment */ } -/**********************************************************************/ /** - Writes the space id and flags to a tablespace header. The flags contain +/** Writes the space id and flags to a tablespace header. The flags contain row type, physical/compressed page size, and logical/uncompressed page size of the tablespace. */ void fsp_header_init_fields( - /*===================*/ page_t *page, /*!< in/out: first page in the space */ space_id_t space_id, /*!< in: space id */ ulint flags) /*!< in: tablespace flags @@ -968,11 +933,9 @@ bool fsp_header_init(space_id_t space_id, page_no_t size, mtr_t *mtr, } #endif /* !UNIV_HOTBACKUP */ -/**********************************************************************/ /** - Reads the space id from the first page of a tablespace. +/** Reads the space id from the first page of a tablespace. @return space id, ULINT UNDEFINED if error */ space_id_t fsp_header_get_space_id( - /*====================*/ const page_t *page) /*!< in: first page of a tablespace */ { space_id_t fsp_id; @@ -1020,13 +983,10 @@ bool fsp_header_get_encryption_key(ulint fsp_flags, byte *key, byte *iv, } #ifndef UNIV_HOTBACKUP -/**********************************************************************/ /** - Increases the space size field of a space. */ -void fsp_header_inc_size( - /*================*/ - space_id_t space_id, /*!< in: space id */ - page_no_t size_inc, /*!< in: size increment in pages */ - mtr_t *mtr) /*!< in/out: mini-transaction */ +/** Increases the space size field of a space. */ +void fsp_header_inc_size(space_id_t space_id, /*!< in: space id */ + page_no_t size_inc, /*!< in: size increment in pages */ + mtr_t *mtr) /*!< in/out: mini-transaction */ { fil_space_t *space = fil_space_get(space_id); @@ -1049,15 +1009,12 @@ void fsp_header_inc_size( space->size_in_header = size; } -/**********************************************************************/ /** - Gets the size of the system tablespace from the tablespace header. If +/** Gets the size of the system tablespace from the tablespace header. If we do not have an auto-extending data file, this should be equal to the size of the data files. If there is an auto-extending data file, this can be smaller. @return size in pages */ -page_no_t fsp_header_get_tablespace_size(void) -/*================================*/ -{ +page_no_t fsp_header_get_tablespace_size(void) { fil_space_t *space = fil_space_get_sys_space(); mtr_t mtr; @@ -1437,10 +1394,8 @@ static xdes_t *fsp_alloc_free_extent(space_id_t space_id, return (descr); } -/**********************************************************************/ /** - Allocates a single free page from a space. */ +/** Allocates a single free page from a space. */ static void fsp_alloc_from_free_frag( - /*=====================*/ fsp_header_t *header, /*!< in/out: tablespace header */ xdes_t *descr, /*!< in/out: extent descriptor */ page_no_t bit, /*!< in: slot to allocate in the extent */ @@ -1828,11 +1783,9 @@ static page_no_t fsp_seg_inode_page_find_free(page_t *page, page_no_t i, return (FIL_NULL); } -/**********************************************************************/ /** - Allocates a new file segment inode page. +/** Allocates a new file segment inode page. @return true if could be allocated */ static ibool fsp_alloc_seg_inode_page( - /*=====================*/ fsp_header_t *space_header, /*!< in: space header */ mtr_t *mtr) /*!< in/out: mini-transaction */ { @@ -1872,11 +1825,9 @@ static ibool fsp_alloc_seg_inode_page( return (TRUE); } -/**********************************************************************/ /** - Allocates a new file segment inode. +/** Allocates a new file segment inode. @return segment inode, or NULL if not enough space */ static fseg_inode_t *fsp_alloc_seg_inode( - /*================*/ fsp_header_t *space_header, /*!< in: space header */ mtr_t *mtr) /*!< in/out: mini-transaction */ { @@ -2012,12 +1963,10 @@ static fseg_inode_t *fseg_inode_get(fseg_header_t *header, space_id_t space, return (inode); } -/**********************************************************************/ /** - Gets the page number from the nth fragment page slot. +/** Gets the page number from the nth fragment page slot. @return page number, FIL_NULL if not in use */ UNIV_INLINE page_no_t fseg_get_nth_frag_page_no( - /*======================*/ fseg_inode_t *inode, /*!< in: segment inode */ ulint n, /*!< in: slot index */ mtr_t *mtr MY_ATTRIBUTE((unused))) @@ -2030,15 +1979,12 @@ page_no_t fseg_get_nth_frag_page_no( return (mach_read_from_4(inode + FSEG_FRAG_ARR + n * FSEG_FRAG_SLOT_SIZE)); } -/**********************************************************************/ /** - Sets the page number in the nth fragment page slot. */ +/** Sets the page number in the nth fragment page slot. */ UNIV_INLINE -void fseg_set_nth_frag_page_no( - /*======================*/ - fseg_inode_t *inode, /*!< in: segment inode */ - ulint n, /*!< in: slot index */ - page_no_t page_no, /*!< in: page number to set */ - mtr_t *mtr) /*!< in/out: mini-transaction */ +void fseg_set_nth_frag_page_no(fseg_inode_t *inode, /*!< in: segment inode */ + ulint n, /*!< in: slot index */ + page_no_t page_no, /*!< in: page number to set */ + mtr_t *mtr) /*!< in/out: mini-transaction */ { ut_ad(inode && mtr); ut_ad(n < FSEG_FRAG_ARR_N_SLOTS); @@ -2049,11 +1995,9 @@ void fseg_set_nth_frag_page_no( MLOG_4BYTES, mtr); } -/**********************************************************************/ /** - Finds a fragment page slot which is free. +/** Finds a fragment page slot which is free. @return slot index; ULINT_UNDEFINED if none found */ static ulint fseg_find_free_frag_page_slot( - /*==========================*/ fseg_inode_t *inode, /*!< in: segment inode */ mtr_t *mtr) /*!< in/out: mini-transaction */ { @@ -2073,11 +2017,9 @@ static ulint fseg_find_free_frag_page_slot( return (ULINT_UNDEFINED); } -/**********************************************************************/ /** - Finds a fragment page slot which is used and last in the array. +/** Finds a fragment page slot which is used and last in the array. @return slot index; ULINT_UNDEFINED if none found */ static ulint fseg_find_last_used_frag_page_slot( - /*===============================*/ fseg_inode_t *inode, /*!< in: segment inode */ mtr_t *mtr) /*!< in/out: mini-transaction */ { @@ -2098,11 +2040,9 @@ static ulint fseg_find_last_used_frag_page_slot( return (ULINT_UNDEFINED); } -/**********************************************************************/ /** - Calculates reserved fragment page slots. +/** Calculates reserved fragment page slots. @return number of fragment pages */ static ulint fseg_get_n_frag_pages( - /*==================*/ fseg_inode_t *inode, /*!< in: segment inode */ mtr_t *mtr) /*!< in/out: mini-transaction */ { @@ -2120,12 +2060,10 @@ static ulint fseg_get_n_frag_pages( return (count); } -/**********************************************************************/ /** - Creates a new segment. +/** Creates a new segment. @return the block where the segment header is placed, x-latched, NULL if could not create segment because of lack of space */ buf_block_t *fseg_create_general( - /*================*/ space_id_t space_id, /*!< in: space id */ page_no_t page, /*!< in: page where the segment header is placed: if this is != 0, the page must belong @@ -2258,12 +2196,10 @@ buf_block_t *fseg_create_general( DBUG_RETURN(block); } -/**********************************************************************/ /** - Creates a new segment. +/** Creates a new segment. @return the block where the segment header is placed, x-latched, NULL if could not create segment because of lack of space */ buf_block_t *fseg_create( - /*========*/ space_id_t space, /*!< in: space id */ page_no_t page, /*!< in: page where the segment header is placed: if this is != 0, the page must belong @@ -2277,12 +2213,10 @@ buf_block_t *fseg_create( return (fseg_create_general(space, page, byte_offset, FALSE, mtr)); } -/**********************************************************************/ /** - Calculates the number of pages reserved by a segment, and how many pages are +/** Calculates the number of pages reserved by a segment, and how many pages are currently used. @return number of reserved pages */ static ulint fseg_n_reserved_pages_low( - /*======================*/ fseg_inode_t *inode, /*!< in: segment inode */ ulint *used, /*!< out: number of pages used (not more than reserved) */ @@ -2305,12 +2239,10 @@ static ulint fseg_n_reserved_pages_low( return (ret); } -/**********************************************************************/ /** - Calculates the number of pages reserved by a segment, and how many pages are +/** Calculates the number of pages reserved by a segment, and how many pages are currently used. @return number of reserved pages */ ulint fseg_n_reserved_pages( - /*==================*/ fseg_header_t *header, /*!< in: segment header */ ulint *used, /*!< out: number of pages used (<= reserved) */ mtr_t *mtr) /*!< in/out: mini-transaction */ @@ -2807,8 +2739,7 @@ static buf_block_t *fseg_alloc_free_page_low(fil_space_t *space, mtr, init_mtr)); } -/**********************************************************************/ /** - Allocates a single free page from a segment. This function implements +/** Allocates a single free page from a segment. This function implements the intelligent allocation strategy which tries to minimize file space fragmentation. @retval NULL if no page could be allocated @@ -2816,7 +2747,6 @@ static buf_block_t *fseg_alloc_free_page_low(fil_space_t *space, (init_mtr == mtr, or the page was not previously freed in mtr) @retval block (not allocated or initialized) otherwise */ buf_block_t *fseg_alloc_free_page_general( - /*=========================*/ fseg_header_t *seg_header, /*!< in/out: segment header */ page_no_t hint, /*!< in: hint of which page would be desirable */ @@ -3110,11 +3040,9 @@ uintmax_t fsp_get_available_space_in_free_extents(const fil_space_t *space) { (page_size.physical() / 1024)); } -/********************************************************************/ /** - Marks a page used. The page must reside within the extents of the given +/** Marks a page used. The page must reside within the extents of the given segment. */ static void fseg_mark_page_used( - /*================*/ fseg_inode_t *seg_inode, /*!< in: segment inode */ page_no_t page, /*!< in: page offset */ xdes_t *descr, /*!< in: extent descriptor */ @@ -3292,16 +3220,13 @@ static void fseg_free_page_low(fseg_inode_t *seg_inode, DBUG_VOID_RETURN; } -/**********************************************************************/ /** - Frees a single page of a segment. */ -void fseg_free_page( - /*===========*/ - fseg_header_t *seg_header, /*!< in: segment header */ - space_id_t space_id, /*!< in: space id */ - page_no_t page, /*!< in: page offset */ - bool ahi, /*!< in: whether we may need to drop - the adaptive hash index */ - mtr_t *mtr) /*!< in/out: mini-transaction */ +/** Frees a single page of a segment. */ +void fseg_free_page(fseg_header_t *seg_header, /*!< in: segment header */ + space_id_t space_id, /*!< in: space id */ + page_no_t page, /*!< in: page offset */ + bool ahi, /*!< in: whether we may need to drop + the adaptive hash index */ + mtr_t *mtr) /*!< in/out: mini-transaction */ { DBUG_ENTER("fseg_free_page"); fseg_inode_t *seg_inode; @@ -3327,14 +3252,11 @@ void fseg_free_page( DBUG_VOID_RETURN; } -/**********************************************************************/ /** - Checks if a single page of a segment is free. +/** Checks if a single page of a segment is free. @return true if free */ -bool fseg_page_is_free( - /*==============*/ - fseg_header_t *seg_header, /*!< in: segment header */ - space_id_t space_id, /*!< in: space id */ - page_no_t page) /*!< in: page offset */ +bool fseg_page_is_free(fseg_header_t *seg_header, /*!< in: segment header */ + space_id_t space_id, /*!< in: space id */ + page_no_t page) /*!< in: page offset */ { mtr_t mtr; ibool is_free; @@ -3436,14 +3358,12 @@ static void fseg_free_extent(fseg_inode_t *seg_inode, space_id_t space, #endif /* UNIV_DEBUG */ } -/**********************************************************************/ /** - Frees part of a segment. This function can be used to free a segment by +/** Frees part of a segment. This function can be used to free a segment by repeatedly calling this function in different mini-transactions. Doing the freeing in a single mini-transaction might result in too big a mini-transaction. @return true if freeing completed */ ibool fseg_free_step( - /*===========*/ fseg_header_t *header, /*!< in, own: segment header; NOTE: if the header resides on the first page of the frag list of the segment, this pointer becomes obsolete @@ -3525,12 +3445,10 @@ ibool fseg_free_step( DBUG_RETURN(FALSE); } -/**********************************************************************/ /** - Frees part of a segment. Differs from fseg_free_step because this function +/** Frees part of a segment. Differs from fseg_free_step because this function leaves the header page unfreed. @return true if freeing completed, except the header page */ ibool fseg_free_step_not_header( - /*======================*/ fseg_header_t *header, /*!< in: segment header which must reside on the first fragment page of the segment */ bool ahi, /*!< in: whether we may need to drop @@ -3624,12 +3542,9 @@ static xdes_t *fseg_get_first_extent(fseg_inode_t *inode, space_id_t space_id, } #ifdef UNIV_BTR_PRINT -/*******************************************************************/ /** - Writes info of a segment. */ -static void fseg_print_low( - /*===========*/ - fseg_inode_t *inode, /*!< in: segment inode */ - mtr_t *mtr) /*!< in/out: mini-transaction */ +/** Writes info of a segment. */ +static void fseg_print_low(fseg_inode_t *inode, /*!< in: segment inode */ + mtr_t *mtr) /*!< in/out: mini-transaction */ { space_id_t space; ulint n_used; @@ -3667,12 +3582,9 @@ static void fseg_print_low( ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE); } -/*******************************************************************/ /** - Writes info of a segment. */ -void fseg_print( - /*=======*/ - fseg_header_t *header, /*!< in: segment header */ - mtr_t *mtr) /*!< in/out: mini-transaction */ +/** Writes info of a segment. */ +void fseg_print(fseg_header_t *header, /*!< in: segment header */ + mtr_t *mtr) /*!< in/out: mini-transaction */ { fseg_inode_t *inode; space_id_t space_id; diff --git a/storage/innobase/fsp/fsp0space.cc b/storage/innobase/fsp/fsp0space.cc index 7b4b2a666bf0..3cfb6b3a0289 100644 --- a/storage/innobase/fsp/fsp0space.cc +++ b/storage/innobase/fsp/fsp0space.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2013, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file fsp/fsp0space.cc +/** @file fsp/fsp0space.cc General shared tablespace implementation. Created 2012-11-16 by Sunny Bains as srv/srv0space.cc diff --git a/storage/innobase/fsp/fsp0sysspace.cc b/storage/innobase/fsp/fsp0sysspace.cc index fc3a396085dd..7dbc0f944f6f 100644 --- a/storage/innobase/fsp/fsp0sysspace.cc +++ b/storage/innobase/fsp/fsp0sysspace.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2013, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file fsp/fsp0space.cc +/** @file fsp/fsp0space.cc Multi file, shared, system tablespace implementation. Created 2012-11-16 by Sunny Bains as srv/srv0space.cc diff --git a/storage/innobase/fts/fts0ast.cc b/storage/innobase/fts/fts0ast.cc index 6c297286df95..7183ab2a8d0a 100644 --- a/storage/innobase/fts/fts0ast.cc +++ b/storage/innobase/fts/fts0ast.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file fts/fts0ast.cc +/** @file fts/fts0ast.cc Full Text Search parser helper file. Created 2007/3/16 Sunny Bains. @@ -50,12 +49,9 @@ enum fts_ast_visit_pass_t { process operator FTS_IGNORE */ }; -/******************************************************************/ /** - Create an empty fts_ast_node_t. +/** Create an empty fts_ast_node_t. @return Create a new node */ -static fts_ast_node_t *fts_ast_node_create(void) -/*=====================*/ -{ +static fts_ast_node_t *fts_ast_node_create(void) { fts_ast_node_t *node; node = (fts_ast_node_t *)ut_zalloc_nokey(sizeof(*node)); @@ -78,11 +74,9 @@ static void fts_ast_state_add_node( } } -/******************************************************************/ /** - Create a operator fts_ast_node_t. +/** Create a operator fts_ast_node_t. @return new node */ fts_ast_node_t *fts_ast_create_node_oper( - /*=====================*/ void *arg, /*!< in: ast state instance */ fts_ast_oper_t oper) /*!< in: ast operator */ { @@ -96,12 +90,10 @@ fts_ast_node_t *fts_ast_create_node_oper( return (node); } -/******************************************************************/ /** - This function takes ownership of the ptr and is responsible +/** This function takes ownership of the ptr and is responsible for free'ing it @return new node or a node list with tokenized words */ fts_ast_node_t *fts_ast_create_node_term( - /*=====================*/ void *arg, /*!< in: ast state instance */ const fts_ast_string_t *ptr) /*!< in: ast term string */ { @@ -163,11 +155,9 @@ fts_ast_node_t *fts_ast_create_node_term( return ((node_list != NULL) ? node_list : first_node); } -/******************************************************************/ /** - Create an AST term node, makes a copy of ptr for plugin parser +/** Create an AST term node, makes a copy of ptr for plugin parser @return node */ fts_ast_node_t *fts_ast_create_node_term_for_parser( - /*================================*/ void *arg, /*!< in: ast state */ const char *ptr, /*!< in: term string */ const ulint len) /*!< in: term string length */ @@ -193,12 +183,10 @@ fts_ast_node_t *fts_ast_create_node_term_for_parser( return (node); } -/******************************************************************/ /** - This function takes ownership of the ptr and is responsible +/** This function takes ownership of the ptr and is responsible for free'ing it. @return new node */ fts_ast_node_t *fts_ast_create_node_text( - /*=====================*/ void *arg, /*!< in: ast state instance */ const fts_ast_string_t *ptr) /*!< in: ast text string */ { @@ -233,12 +221,9 @@ fts_ast_node_t *fts_ast_create_node_text( return (node); } -/******************************************************************/ /** - Create an AST phrase list node for plugin parser +/** Create an AST phrase list node for plugin parser @return node */ -fts_ast_node_t *fts_ast_create_node_phrase_list( - /*============================*/ - void *arg) /*!< in: ast state */ +fts_ast_node_t *fts_ast_create_node_phrase_list(void *arg) /*!< in: ast state */ { fts_ast_node_t *node = fts_ast_node_create(); @@ -252,12 +237,10 @@ fts_ast_node_t *fts_ast_create_node_phrase_list( return (node); } -/******************************************************************/ /** - This function takes ownership of the expr and is responsible +/** This function takes ownership of the expr and is responsible for free'ing it. @return new node */ fts_ast_node_t *fts_ast_create_node_list( - /*=====================*/ void *arg, /*!< in: ast state instance */ fts_ast_node_t *expr) /*!< in: ast expr instance */ { @@ -271,12 +254,10 @@ fts_ast_node_t *fts_ast_create_node_list( return (node); } -/******************************************************************/ /** - Create a sub-expression list node. This function takes ownership of +/** Create a sub-expression list node. This function takes ownership of expr and is responsible for deleting it. @return new node */ fts_ast_node_t *fts_ast_create_node_subexp_list( - /*============================*/ void *arg, /*!< in: ast state instance */ fts_ast_node_t *expr) /*!< in: ast expr instance */ { @@ -290,11 +271,8 @@ fts_ast_node_t *fts_ast_create_node_subexp_list( return (node); } -/******************************************************************/ /** - Free an expr list node elements. */ -static void fts_ast_free_list( - /*==============*/ - fts_ast_node_t *node) /*!< in: ast node to free */ +/** Free an expr list node elements. */ +static void fts_ast_free_list(fts_ast_node_t *node) /*!< in: ast node to free */ { ut_a(node->type == FTS_AST_LIST || node->type == FTS_AST_SUBEXP_LIST || node->type == FTS_AST_PARSER_PHRASE_LIST); @@ -304,11 +282,9 @@ static void fts_ast_free_list( } } -/********************************************************************/ /** - Free a fts_ast_node_t instance. +/** Free a fts_ast_node_t instance. @return next node to free */ fts_ast_node_t *fts_ast_free_node( - /*==============*/ fts_ast_node_t *node) /*!< in: the node to free */ { fts_ast_node_t *next_node; @@ -350,12 +326,10 @@ fts_ast_node_t *fts_ast_free_node( return (next_node); } -/******************************************************************/ /** - This AST takes ownership of the expr and is responsible +/** This AST takes ownership of the expr and is responsible for free'ing it. @return in param "list" */ fts_ast_node_t *fts_ast_add_node( - /*=============*/ fts_ast_node_t *node, /*!< in: list instance */ fts_ast_node_t *elem) /*!< in: node to add to list */ { @@ -381,10 +355,8 @@ fts_ast_node_t *fts_ast_add_node( return (node); } -/******************************************************************/ /** - Set the wildcard attribute of a term. */ +/** Set the wildcard attribute of a term. */ void fts_ast_term_set_wildcard( - /*======================*/ fts_ast_node_t *node) /*!< in/out: set attribute of a term node */ { @@ -404,13 +376,10 @@ void fts_ast_term_set_wildcard( node->term.wildcard = TRUE; } -/******************************************************************/ /** - Set the proximity attribute of a text node. */ -void fts_ast_text_set_distance( - /*======================*/ - fts_ast_node_t *node, /*!< in/out: text node */ - ulint distance) /*!< in: the text proximity - distance */ +/** Set the proximity attribute of a text node. */ +void fts_ast_text_set_distance(fts_ast_node_t *node, /*!< in/out: text node */ + ulint distance) /*!< in: the text proximity + distance */ { if (node == NULL) { return; @@ -422,11 +391,8 @@ void fts_ast_text_set_distance( node->text.distance = distance; } -/******************************************************************/ /** - Free node and expr allocations. */ -void fts_ast_state_free( - /*===============*/ - fts_ast_state_t *state) /*!< in: ast state to free */ +/** Free node and expr allocations. */ +void fts_ast_state_free(fts_ast_state_t *state) /*!< in: ast state to free */ { fts_ast_node_t *node = state->list.head; @@ -459,10 +425,8 @@ static void fts_ast_string_print(const fts_ast_string_t *ast_str) { printf("\n"); } -/******************************************************************/ /** - Print an ast node recursively. */ +/** Print an ast node recursively. */ static void fts_ast_node_print_recursive( - /*=========================*/ fts_ast_node_t *node, /*!< in: ast node to print */ ulint level) /*!< in: recursive level */ { @@ -515,11 +479,8 @@ static void fts_ast_node_print_recursive( } } -/******************************************************************/ /** - Print an ast node */ -void fts_ast_node_print( - /*===============*/ - fts_ast_node_t *node) /*!< in: ast node to print */ +/** Print an ast node */ +void fts_ast_node_print(fts_ast_node_t *node) /*!< in: ast node to print */ { fts_ast_node_print_recursive(node, 0); } @@ -547,21 +508,19 @@ bool fts_ast_node_check_union(fts_ast_node_t *node) { return (true); } -/******************************************************************/ /** - Traverse the AST - in-order traversal, except for the FTX_EXIST and FTS_IGNORE - nodes, which will be ignored in the first pass of each level, and visited in a - second and third pass after all other nodes in the same level are visited. +/** Traverse the AST - in-order traversal, except for the FTX_EXIST and + FTS_IGNORE nodes, which will be ignored in the first pass of each level, and + visited in a second and third pass after all other nodes in the same level are + visited. @return DB_SUCCESS if all went well */ -dberr_t fts_ast_visit( - /*==========*/ - fts_ast_oper_t oper, /*!< in: current operator */ - fts_ast_node_t *node, /*!< in: current root node */ - fts_ast_callback visitor, /*!< in: callback function */ - void *arg, /*!< in: arg for callback */ - bool *has_ignore) /*!< out: true, if the operator - was ignored during processing, - currently we ignore FTS_EXIST - and FTS_IGNORE operators */ +dberr_t fts_ast_visit(fts_ast_oper_t oper, /*!< in: current operator */ + fts_ast_node_t *node, /*!< in: current root node */ + fts_ast_callback visitor, /*!< in: callback function */ + void *arg, /*!< in: arg for callback */ + bool *has_ignore) /*!< out: true, if the operator + was ignored during processing, + currently we ignore FTS_EXIST + and FTS_IGNORE operators */ { dberr_t error = DB_SUCCESS; fts_ast_node_t *oper_node = NULL; diff --git a/storage/innobase/fts/fts0config.cc b/storage/innobase/fts/fts0config.cc index da72249bf9d1..0871431cf4a2 100644 --- a/storage/innobase/fts/fts0config.cc +++ b/storage/innobase/fts/fts0config.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file fts/fts0config.cc +/** @file fts/fts0config.cc Full Text Search configuration table. Created 2007/5/9 Sunny Bains @@ -38,14 +37,11 @@ this program; if not, write to the Free Software Foundation, Inc., #include "row0sel.h" #include "trx0roll.h" -/******************************************************************/ /** - Callback function for fetching the config value. +/** Callback function for fetching the config value. @return always returns true */ -static ibool fts_config_fetch_value( - /*===================*/ - void *row, /*!< in: sel_node_t* */ - void *user_arg) /*!< in: pointer to - ib_vector_t */ +static ibool fts_config_fetch_value(void *row, /*!< in: sel_node_t* */ + void *user_arg) /*!< in: pointer to + ib_vector_t */ { sel_node_t *node = static_cast(row); fts_string_t *value = static_cast(user_arg); @@ -68,19 +64,16 @@ static ibool fts_config_fetch_value( return (TRUE); } -/******************************************************************/ /** - Get value from the config table. The caller must ensure that enough +/** Get value from the config table. The caller must ensure that enough space is allocated for value to hold the column contents. @return DB_SUCCESS or error code */ -dberr_t fts_config_get_value( - /*=================*/ - trx_t *trx, /*!< transaction */ - fts_table_t *fts_table, /*!< in: the indexed - FTS table */ - const char *name, /*!< in: get config value for - this parameter name */ - fts_string_t *value) /*!< out: value read from - config table */ +dberr_t fts_config_get_value(trx_t *trx, /*!< transaction */ + fts_table_t *fts_table, /*!< in: the indexed + FTS table */ + const char *name, /*!< in: get config value for + this parameter name */ + fts_string_t *value) /*!< out: value read from + config table */ { pars_info_t *info; que_t *graph; @@ -128,11 +121,9 @@ dberr_t fts_config_get_value( return (error); } -/*********************************************************************/ /** - Create the config table name for retrieving index specific value. +/** Create the config table name for retrieving index specific value. @return index config parameter name */ char *fts_config_create_index_param_name( - /*===============================*/ const char *param, /*!< in: base name of param */ const dict_index_t *index) /*!< in: index for config */ { @@ -153,13 +144,11 @@ char *fts_config_create_index_param_name( return (name); } -/******************************************************************/ /** - Get value specific to an FTS index from the config table. The caller +/** Get value specific to an FTS index from the config table. The caller must ensure that enough space is allocated for value to hold the column contents. @return DB_SUCCESS or error code */ dberr_t fts_config_get_index_value( - /*=======================*/ trx_t *trx, /*!< transaction */ dict_index_t *index, /*!< in: index */ const char *param, /*!< in: get config value for @@ -184,11 +173,9 @@ dberr_t fts_config_get_index_value( return (error); } -/******************************************************************/ /** - Set the value in the config table for name. +/** Set the value in the config table for name. @return DB_SUCCESS or error code */ dberr_t fts_config_set_value( - /*=================*/ trx_t *trx, /*!< transaction */ fts_table_t *fts_table, /*!< in: the indexed FTS table */ @@ -252,11 +239,9 @@ dberr_t fts_config_set_value( return (error); } -/******************************************************************/ /** - Set the value specific to an FTS index in the config table. +/** Set the value specific to an FTS index in the config table. @return DB_SUCCESS or error code */ dberr_t fts_config_set_index_value( - /*=======================*/ trx_t *trx, /*!< transaction */ dict_index_t *index, /*!< in: index */ const char *param, /*!< in: get config value for @@ -282,15 +267,12 @@ dberr_t fts_config_set_index_value( } #ifdef FTS_OPTIMIZE_DEBUG -/******************************************************************/ /** - Get an ulint value from the config table. +/** Get an ulint value from the config table. @return DB_SUCCESS if all OK else error code */ -dberr_t fts_config_get_index_ulint( - /*=======================*/ - trx_t *trx, /*!< in: transaction */ - dict_index_t *index, /*!< in: FTS index */ - const char *name, /*!< in: param name */ - ulint *int_value) /*!< out: value */ +dberr_t fts_config_get_index_ulint(trx_t *trx, /*!< in: transaction */ + dict_index_t *index, /*!< in: FTS index */ + const char *name, /*!< in: param name */ + ulint *int_value) /*!< out: value */ { dberr_t error; fts_string_t value; @@ -313,15 +295,12 @@ dberr_t fts_config_get_index_ulint( return (error); } -/******************************************************************/ /** - Set an ulint value in the config table. +/** Set an ulint value in the config table. @return DB_SUCCESS if all OK else error code */ -dberr_t fts_config_set_index_ulint( - /*=======================*/ - trx_t *trx, /*!< in: transaction */ - dict_index_t *index, /*!< in: FTS index */ - const char *name, /*!< in: param name */ - ulint int_value) /*!< in: value */ +dberr_t fts_config_set_index_ulint(trx_t *trx, /*!< in: transaction */ + dict_index_t *index, /*!< in: FTS index */ + const char *name, /*!< in: param name */ + ulint int_value) /*!< in: value */ { dberr_t error; fts_string_t value; @@ -349,16 +328,13 @@ dberr_t fts_config_set_index_ulint( } #endif /* FTS_OPTIMIZE_DEBUG */ -/******************************************************************/ /** - Get an ulint value from the config table. +/** Get an ulint value from the config table. @return DB_SUCCESS if all OK else error code */ -dberr_t fts_config_get_ulint( - /*=================*/ - trx_t *trx, /*!< in: transaction */ - fts_table_t *fts_table, /*!< in: the indexed - FTS table */ - const char *name, /*!< in: param name */ - ulint *int_value) /*!< out: value */ +dberr_t fts_config_get_ulint(trx_t *trx, /*!< in: transaction */ + fts_table_t *fts_table, /*!< in: the indexed + FTS table */ + const char *name, /*!< in: param name */ + ulint *int_value) /*!< out: value */ { dberr_t error; fts_string_t value; @@ -381,16 +357,13 @@ dberr_t fts_config_get_ulint( return (error); } -/******************************************************************/ /** - Set an ulint value in the config table. +/** Set an ulint value in the config table. @return DB_SUCCESS if all OK else error code */ -dberr_t fts_config_set_ulint( - /*=================*/ - trx_t *trx, /*!< in: transaction */ - fts_table_t *fts_table, /*!< in: the indexed - FTS table */ - const char *name, /*!< in: param name */ - ulint int_value) /*!< in: value */ +dberr_t fts_config_set_ulint(trx_t *trx, /*!< in: transaction */ + fts_table_t *fts_table, /*!< in: the indexed + FTS table */ + const char *name, /*!< in: param name */ + ulint int_value) /*!< in: value */ { dberr_t error; fts_string_t value; diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index f12afaaf1cd9..563607f5a02e 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file fts/fts0fts.cc +/** @file fts/fts0fts.cc Full Text Search interface ***********************************************************************/ @@ -190,17 +189,11 @@ FTS auxiliary INDEX table and clear the cache at the end. static dberr_t fts_sync(fts_sync_t *sync, bool unlock_cache, bool wait, bool has_dict); -/****************************************************************/ /** - Release all resources help by the words rb tree e.g., the node ilist. */ -static void fts_words_free( - /*===========*/ - ib_rbt_t *words); /*!< in: rb tree of words */ +/** Release all resources help by the words rb tree e.g., the node ilist. */ +static void fts_words_free(ib_rbt_t *words); /*!< in: rb tree of words */ #ifdef FTS_CACHE_SIZE_DEBUG -/****************************************************************/ /** - Read the max cache size parameter from the config table. */ -static void fts_update_max_cache_size( - /*======================*/ - fts_sync_t *sync); /*!< in: sync state */ +/** Read the max cache size parameter from the config table. */ +static void fts_update_max_cache_size(fts_sync_t *sync); /*!< in: sync state */ #endif /** This function fetches the document just inserted right before @@ -213,12 +206,10 @@ and insert into FTS auxiliary table and its cache. static ulint fts_add_doc_by_id(fts_trx_table_t *ftt, doc_id_t doc_id, ib_vector_t *fts_indexes MY_ATTRIBUTE((unused))); -/******************************************************************/ /** - Update the last document id. This function could create a new +/** Update the last document id. This function could create a new transaction to update the last document id. @return DB_SUCCESS if OK */ static dberr_t fts_update_sync_doc_id( - /*===================*/ const dict_table_t *table, /*!< in: table */ const char *table_name, /*!< in: table name, or NULL */ doc_id_t doc_id, /*!< in: last document id */ @@ -297,10 +288,8 @@ CHARSET_INFO *fts_get_charset(ulint prtype) { return (NULL); } -/****************************************************************/ /** - This function loads the default InnoDB stopword list */ +/** This function loads the default InnoDB stopword list */ static void fts_load_default_stopword( - /*======================*/ fts_stopword_t *stopword_info) /*!< in: stopword info */ { fts_string_t str; @@ -341,11 +330,9 @@ static void fts_load_default_stopword( stopword_info->status = STOPWORD_FROM_DEFAULT; } -/****************************************************************/ /** - Callback function to read a single stopword value. +/** Callback function to read a single stopword value. @return Always return true */ static ibool fts_read_stopword( - /*==============*/ void *row, /*!< in: sel_node_t* */ void *user_arg) /*!< in: pointer to ib_vector_t */ { @@ -397,11 +384,9 @@ static ibool fts_read_stopword( return (TRUE); } -/******************************************************************/ /** - Load user defined stopword from designated user table +/** Load user defined stopword from designated user table @return true if load operation is successful */ static ibool fts_load_user_stopword( - /*===================*/ fts_t *fts, /*!< in: FTS struct */ const char *stopword_table_name, /*!< in: Stopword table name */ @@ -484,10 +469,8 @@ static ibool fts_load_user_stopword( return (ret); } -/******************************************************************/ /** - Initialize the index cache. */ +/** Initialize the index cache. */ static void fts_index_cache_init( - /*=================*/ ib_alloc_t *allocator, /*!< in: the allocator to use */ fts_index_cache_t *index_cache) /*!< in: index cache */ { @@ -510,11 +493,8 @@ static void fts_index_cache_init( } } -/*********************************************************************/ /** - Initialize FTS cache. */ -void fts_cache_init( - /*===========*/ - fts_cache_t *cache) /*!< in: cache to initialize */ +/** Initialize FTS cache. */ +void fts_cache_init(fts_cache_t *cache) /*!< in: cache to initialize */ { ulint i; @@ -541,10 +521,8 @@ void fts_cache_init( } } -/****************************************************************/ /** - Create a FTS cache. */ +/** Create a FTS cache. */ fts_cache_t *fts_cache_create( - /*=============*/ dict_table_t *table) /*!< in: table owns the FTS cache */ { mem_heap_t *heap; @@ -596,12 +574,9 @@ fts_cache_t *fts_cache_create( return (cache); } -/*******************************************************************/ /** - Add a newly create index into FTS cache */ -void fts_add_index( - /*==========*/ - dict_index_t *index, /*!< FTS index to be added */ - dict_table_t *table) /*!< table */ +/** Add a newly create index into FTS cache */ +void fts_add_index(dict_index_t *index, /*!< FTS index to be added */ + dict_table_t *table) /*!< table */ { fts_t *fts = table->fts; fts_cache_t *cache; @@ -624,11 +599,8 @@ void fts_add_index( rw_lock_x_unlock(&cache->init_lock); } -/*******************************************************************/ /** - recalibrate get_doc structure after index_cache in cache->indexes changed */ -static void fts_reset_get_doc( - /*==============*/ - fts_cache_t *cache) /*!< in: FTS index cache */ +/** recalibrate get_doc structure after index_cache in cache->indexes changed */ +static void fts_reset_get_doc(fts_cache_t *cache) /*!< in: FTS index cache */ { fts_get_doc_t *get_doc; ulint i; @@ -654,11 +626,9 @@ static void fts_reset_get_doc( ut_ad(ib_vector_size(cache->get_docs) == ib_vector_size(cache->indexes)); } -/*******************************************************************/ /** - Check an index is in the table->indexes list +/** Check an index is in the table->indexes list @return true if it exists */ static ibool fts_in_dict_index( - /*==============*/ dict_table_t *table, /*!< in: Table */ dict_index_t *index_check) /*!< in: index to be checked */ { @@ -673,11 +643,9 @@ static ibool fts_in_dict_index( return (FALSE); } -/*******************************************************************/ /** - Check an index is in the fts->cache->indexes list +/** Check an index is in the fts->cache->indexes list @return true if it exists */ static ibool fts_in_index_cache( - /*===============*/ dict_table_t *table, /*!< in: Table */ dict_index_t *index) /*!< in: index to be checked */ { @@ -697,12 +665,10 @@ static ibool fts_in_index_cache( return (FALSE); } -/*******************************************************************/ /** - Check indexes in the fts->indexes is also present in index cache and +/** Check indexes in the fts->indexes is also present in index cache and table->indexes list @return true if all indexes match */ ibool fts_check_cached_index( - /*===================*/ dict_table_t *table) /*!< in: Table where indexes are dropped */ { ulint i; @@ -812,11 +778,8 @@ dberr_t fts_drop_index(dict_table_t *table, dict_index_t *index, trx_t *trx, return (err); } -/****************************************************************/ /** - Create an FTS index cache. */ -CHARSET_INFO *fts_index_get_charset( - /*==================*/ - dict_index_t *index) /*!< in: FTS index */ +/** Create an FTS index cache. */ +CHARSET_INFO *fts_index_get_charset(dict_index_t *index) /*!< in: FTS index */ { CHARSET_INFO *charset = NULL; dict_field_t *field; @@ -849,11 +812,9 @@ CHARSET_INFO *fts_index_get_charset( return (charset); } -/****************************************************************/ /** - Create an FTS index cache. +/** Create an FTS index cache. @return Index Cache */ fts_index_cache_t *fts_cache_index_cache_create( - /*=========================*/ dict_table_t *table, /*!< in: table with FTS index */ dict_index_t *index) /*!< in: FTS index */ { @@ -919,11 +880,8 @@ void fts_cache_index_cache_remove(dict_table_t *table, dict_index_t *index) { rw_lock_x_unlock(&table->fts->cache->init_lock); } -/****************************************************************/ /** - Release all resources help by the words rb tree e.g., the node ilist. */ -static void fts_words_free( - /*===========*/ - ib_rbt_t *words) /*!< in: rb tree of words */ +/** Release all resources help by the words rb tree e.g., the node ilist. */ +static void fts_words_free(ib_rbt_t *words) /*!< in: rb tree of words */ { const ib_rbt_node_t *rbt_node; @@ -996,12 +954,10 @@ void fts_cache_clear(fts_cache_t *cache) { mutex_exit((ib_mutex_t *)&cache->deleted_lock); } -/*********************************************************************/ /** - Search the index specific cache for a particular FTS index. +/** Search the index specific cache for a particular FTS index. @return the index cache else NULL */ UNIV_INLINE fts_index_cache_t *fts_get_index_cache( - /*================*/ fts_cache_t *cache, /*!< in: cache to search */ const dict_index_t *index) /*!< in: index to search for */ { @@ -1025,11 +981,9 @@ fts_index_cache_t *fts_get_index_cache( } #ifdef FTS_DEBUG -/*********************************************************************/ /** - Search the index cache for a get_doc structure. +/** Search the index cache for a get_doc structure. @return the fts_get_doc_t item else NULL */ static fts_get_doc_t *fts_get_index_get_doc( - /*==================*/ fts_cache_t *cache, /*!< in: cache to search */ const dict_index_t *index) /*!< in: index to search for */ { @@ -1051,11 +1005,9 @@ static fts_get_doc_t *fts_get_index_get_doc( } #endif -/**********************************************************************/ /** - Find an existing word, or if not found, create one and return it. +/** Find an existing word, or if not found, create one and return it. @return specified word token */ static fts_tokenizer_word_t *fts_tokenizer_word_get( - /*===================*/ fts_cache_t *cache, /*!< in: cache */ fts_index_cache_t *index_cache, /*!< in: index cache */ fts_string_t *text) /*!< in: node text */ @@ -1097,10 +1049,8 @@ static fts_tokenizer_word_t *fts_tokenizer_word_get( return (word); } -/**********************************************************************/ /** - Add the given doc_id/word positions to the given node's ilist. */ +/** Add the given doc_id/word positions to the given node's ilist. */ void fts_cache_node_add_positions( - /*=========================*/ fts_cache_t *cache, /*!< in: cache */ fts_node_t *node, /*!< in: word node */ doc_id_t doc_id, /*!< in: doc id */ @@ -1207,10 +1157,8 @@ void fts_cache_node_add_positions( ++node->doc_count; } -/**********************************************************************/ /** - Add document to the cache. */ +/** Add document to the cache. */ static void fts_cache_add_doc( - /*==============*/ fts_cache_t *cache, /*!< in: cache */ fts_index_cache_t *index_cache, /*!< in: index cache */ doc_id_t doc_id, /*!< in: doc id to add */ @@ -1378,11 +1326,9 @@ static dberr_t fts_drop_table(trx_t *trx, const char *table_name, return (error); } -/****************************************************************/ /** - Rename a single auxiliary table due to database name change. +/** Rename a single auxiliary table due to database name change. @return DB_SUCCESS or error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_rename_one_aux_table( - /*=====================*/ const char *new_name, /*!< in: new parent tbl name */ const char *fts_table_old_name, /*!< in: old aux tbl name */ trx_t *trx) /*!< in: transaction */ @@ -1430,15 +1376,12 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_rename_one_aux_table( return (error); } -/****************************************************************/ /** - Rename auxiliary tables for all fts index for a table. This(rename) +/** Rename auxiliary tables for all fts index for a table. This(rename) is due to database name change @return DB_SUCCESS or error code */ -dberr_t fts_rename_aux_tables( - /*==================*/ - dict_table_t *table, /*!< in: user Table */ - const char *new_name, /*!< in: new table name */ - trx_t *trx) /*!< in: transaction */ +dberr_t fts_rename_aux_tables(dict_table_t *table, /*!< in: user Table */ + const char *new_name, /*!< in: new table name */ + trx_t *trx) /*!< in: transaction */ { ulint i; fts_table_t fts_table; @@ -2400,7 +2343,6 @@ Return string representation of state. */ static const char* fts_get_state_str( -/*==============*/ /* out: string representation of state */ fts_row_state state) /*!< in: state */ { @@ -2426,11 +2368,9 @@ fts_get_state_str( } #endif -/******************************************************************/ /** - Calculate the new state of a row given the existing state and a new event. +/** Calculate the new state of a row given the existing state and a new event. @return new state of row */ static fts_row_state fts_trx_row_get_new_state( - /*======================*/ fts_row_state old_state, /*!< in: existing state of row */ fts_row_state event) /*!< in: new event */ { @@ -2499,11 +2439,9 @@ static fts_row_state fts_trx_row_get_new_state( return (result); } -/******************************************************************/ /** - Create a savepoint instance. +/** Create a savepoint instance. @return savepoint instance */ static fts_savepoint_t *fts_savepoint_create( - /*=================*/ ib_vector_t *savepoints, /*!< out: InnoDB transaction */ const char *name, /*!< in: savepoint name */ mem_heap_t *heap) /*!< in: heap */ @@ -2559,11 +2497,9 @@ fts_trx_t *fts_trx_create(trx_t *trx) { return (ftt); } -/******************************************************************/ /** - Create an FTS trx table. +/** Create an FTS trx table. @return FTS trx table */ static fts_trx_table_t *fts_trx_table_create( - /*=================*/ fts_trx_t *fts_trx, /*!< in: FTS trx */ dict_table_t *table) /*!< in: table */ { @@ -2582,11 +2518,9 @@ static fts_trx_table_t *fts_trx_table_create( return (ftt); } -/******************************************************************/ /** - Clone an FTS trx table. +/** Clone an FTS trx table. @return FTS trx table */ static fts_trx_table_t *fts_trx_table_clone( - /*=================*/ const fts_trx_table_t *ftt_src) /*!< in: FTS trx */ { fts_trx_table_t *ftt; @@ -2611,11 +2545,9 @@ static fts_trx_table_t *fts_trx_table_clone( return (ftt); } -/******************************************************************/ /** - Initialize the FTS trx instance. +/** Initialize the FTS trx instance. @return FTS trx instance */ static fts_trx_table_t *fts_trx_init( - /*=========*/ trx_t *trx, /*!< in: transaction */ dict_table_t *table, /*!< in: FTS table instance */ ib_vector_t *savepoints) /*!< in: Savepoints */ @@ -2645,10 +2577,8 @@ static fts_trx_table_t *fts_trx_init( return (ftt); } -/******************************************************************/ /** - Notify the FTS system about an operation on an FTS-indexed table. */ +/** Notify the FTS system about an operation on an FTS-indexed table. */ static void fts_trx_table_add_op( - /*=================*/ fts_trx_table_t *ftt, /*!< in: FTS trx table */ doc_id_t doc_id, /*!< in: doc id */ fts_row_state state, /*!< in: state of the row */ @@ -2690,16 +2620,13 @@ static void fts_trx_table_add_op( } } -/******************************************************************/ /** - Notify the FTS system about an operation on an FTS-indexed table. */ -void fts_trx_add_op( - /*===========*/ - trx_t *trx, /*!< in: InnoDB transaction */ - dict_table_t *table, /*!< in: table */ - doc_id_t doc_id, /*!< in: new doc id */ - fts_row_state state, /*!< in: state of the row */ - ib_vector_t *fts_indexes) /*!< in: FTS indexes affected - (NULL=all) */ +/** Notify the FTS system about an operation on an FTS-indexed table. */ +void fts_trx_add_op(trx_t *trx, /*!< in: InnoDB transaction */ + dict_table_t *table, /*!< in: table */ + doc_id_t doc_id, /*!< in: new doc id */ + fts_row_state state, /*!< in: state of the row */ + ib_vector_t *fts_indexes) /*!< in: FTS indexes affected + (NULL=all) */ { fts_trx_table_t *tran_ftt; fts_trx_table_t *stmt_ftt; @@ -2715,15 +2642,12 @@ void fts_trx_add_op( fts_trx_table_add_op(stmt_ftt, doc_id, state, fts_indexes); } -/******************************************************************/ /** - Fetch callback that converts a textual document id to a binary value and +/** Fetch callback that converts a textual document id to a binary value and stores it in the given place. @return always returns NULL */ -static ibool fts_fetch_store_doc_id( - /*===================*/ - void *row, /*!< in: sel_node_t* */ - void *user_arg) /*!< in: doc_id_t* to store - doc_id in */ +static ibool fts_fetch_store_doc_id(void *row, /*!< in: sel_node_t* */ + void *user_arg) /*!< in: doc_id_t* to store + doc_id in */ { int n_parsed; sel_node_t *node = static_cast(row); @@ -2747,13 +2671,11 @@ static ibool fts_fetch_store_doc_id( } #ifdef FTS_CACHE_SIZE_DEBUG -/******************************************************************/ /** - Get the max cache size in bytes. If there is an error reading the +/** Get the max cache size in bytes. If there is an error reading the value we simply print an error message here and return the default value to the caller. @return max cache size in bytes */ static ulint fts_get_max_cache_size( - /*===================*/ trx_t *trx, /*!< in: transaction */ fts_table_t *fts_table) /*!< in: table instance */ { @@ -2811,12 +2733,10 @@ static ulint fts_get_max_cache_size( } #endif -/*********************************************************************/ /** - Update the next and last Doc ID in the CONFIG table to be the input +/** Update the next and last Doc ID in the CONFIG table to be the input "doc_id" value (+ 1). We would do so after each FTS index build or table truncate */ void fts_update_next_doc_id( - /*===================*/ trx_t *trx, /*!< in/out: transaction */ const dict_table_t *table, /*!< in: table */ const char *table_name, /*!< in: table name, or NULL */ @@ -2831,13 +2751,10 @@ void fts_update_next_doc_id( trx); } -/*********************************************************************/ /** - Get the next available document id. +/** Get the next available document id. @return DB_SUCCESS if OK */ -dberr_t fts_get_next_doc_id( - /*================*/ - const dict_table_t *table, /*!< in: table */ - doc_id_t *doc_id) /*!< out: new document id */ +dberr_t fts_get_next_doc_id(const dict_table_t *table, /*!< in: table */ + doc_id_t *doc_id) /*!< out: new document id */ { fts_cache_t *cache = table->fts->cache; @@ -2860,12 +2777,10 @@ dberr_t fts_get_next_doc_id( return (DB_SUCCESS); } -/*********************************************************************/ /** - This function fetch the Doc ID from CONFIG table, and compare with +/** This function fetch the Doc ID from CONFIG table, and compare with the Doc ID supplied. And store the larger one to the CONFIG table. @return DB_SUCCESS if OK */ static dberr_t fts_cmp_set_sync_doc_id( - /*====================*/ const dict_table_t *table, /*!< in: table */ doc_id_t doc_id_cmp, /*!< in: Doc ID to compare */ ibool read_only, /*!< in: TRUE if read the @@ -2977,12 +2892,10 @@ static dberr_t fts_cmp_set_sync_doc_id( return (error); } -/*********************************************************************/ /** - Update the last document id. This function could create a new +/** Update the last document id. This function could create a new transaction to update the last document id. @return DB_SUCCESS if OK */ static dberr_t fts_update_sync_doc_id( - /*===================*/ const dict_table_t *table, /*!< in: table */ const char *table_name, /*!< in: table name, or NULL */ doc_id_t doc_id, /*!< in: last document id */ @@ -3050,12 +2963,9 @@ static dberr_t fts_update_sync_doc_id( return (error); } -/*********************************************************************/ /** - Create a new fts_doc_ids_t. +/** Create a new fts_doc_ids_t. @return new fts_doc_ids_t */ -fts_doc_ids_t *fts_doc_ids_create(void) -/*====================*/ -{ +fts_doc_ids_t *fts_doc_ids_create(void) { fts_doc_ids_t *fts_doc_ids; mem_heap_t *heap = mem_heap_create(512); @@ -3070,11 +2980,8 @@ fts_doc_ids_t *fts_doc_ids_create(void) return (fts_doc_ids); } -/*********************************************************************/ /** - Free a fts_doc_ids_t. */ -void fts_doc_ids_free( - /*=============*/ - fts_doc_ids_t *fts_doc_ids) { +/** Free a fts_doc_ids_t. */ +void fts_doc_ids_free(fts_doc_ids_t *fts_doc_ids) { mem_heap_t *heap = static_cast(fts_doc_ids->self_heap->arg); memset(fts_doc_ids, 0, sizeof(*fts_doc_ids)); @@ -3104,13 +3011,11 @@ static void fts_add(fts_trx_table_t *ftt, fts_trx_row_t *row) { } } -/*********************************************************************/ /** - Do commit-phase steps necessary for the deletion of a row. +/** Do commit-phase steps necessary for the deletion of a row. @return DB_SUCCESS or error code */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_delete( - /*=======*/ - fts_trx_table_t *ftt, /*!< in: FTS trx table */ - fts_trx_row_t *row) /*!< in: row */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + fts_delete(fts_trx_table_t *ftt, /*!< in: FTS trx table */ + fts_trx_row_t *row) /*!< in: row */ { que_t *graph; fts_table_t fts_table; @@ -3195,13 +3100,11 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_delete( return (error); } -/*********************************************************************/ /** - Do commit-phase steps necessary for the modification of a row. +/** Do commit-phase steps necessary for the modification of a row. @return DB_SUCCESS or error code */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_modify( - /*=======*/ - fts_trx_table_t *ftt, /*!< in: FTS trx table */ - fts_trx_row_t *row) /*!< in: row */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + fts_modify(fts_trx_table_t *ftt, /*!< in: FTS trx table */ + fts_trx_row_t *row) /*!< in: row */ { dberr_t error; @@ -3216,16 +3119,13 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_modify( return (error); } -/*********************************************************************/ /** - Create a new document id. +/** Create a new document id. @return DB_SUCCESS if all went well else error */ -dberr_t fts_create_doc_id( - /*==============*/ - dict_table_t *table, /*!< in: row is of this table. */ - dtuple_t *row, /* in/out: add doc id value to this - row. This is the current row that is - being inserted. */ - mem_heap_t *heap) /*!< in: heap */ +dberr_t fts_create_doc_id(dict_table_t *table, /*!< in: row is of this table. */ + dtuple_t *row, /* in/out: add doc id value to this + row. This is the current row that is + being inserted. */ + mem_heap_t *heap) /*!< in: heap */ { doc_id_t doc_id; dberr_t error = DB_SUCCESS; @@ -3261,13 +3161,11 @@ dberr_t fts_create_doc_id( return (error); } -/*********************************************************************/ /** - The given transaction is about to be committed; do whatever is necessary +/** The given transaction is about to be committed; do whatever is necessary from the FTS system's POV. @return DB_SUCCESS or error code */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_commit_table( - /*=============*/ - fts_trx_table_t *ftt) /*!< in: FTS table to commit*/ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + fts_commit_table(fts_trx_table_t *ftt) /*!< in: FTS table to commit*/ { const ib_rbt_node_t *node; ib_rbt_t *rows; @@ -3316,13 +3214,10 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_commit_table( return (error); } -/*********************************************************************/ /** - The given transaction is about to be committed; do whatever is necessary +/** The given transaction is about to be committed; do whatever is necessary from the FTS system's POV. @return DB_SUCCESS or error code */ -dberr_t fts_commit( - /*=======*/ - trx_t *trx) /*!< in: transaction */ +dberr_t fts_commit(trx_t *trx) /*!< in: transaction */ { const ib_rbt_node_t *node; dberr_t error; @@ -3345,11 +3240,8 @@ dberr_t fts_commit( return (error); } -/*********************************************************************/ /** - Initialize a document. */ -void fts_doc_init( - /*=========*/ - fts_doc_t *doc) /*!< in: doc to initialize */ +/** Initialize a document. */ +void fts_doc_init(fts_doc_t *doc) /*!< in: doc to initialize */ { mem_heap_t *heap = mem_heap_create(32); @@ -3358,11 +3250,8 @@ void fts_doc_init( doc->self_heap = ib_heap_allocator_create(heap); } -/*********************************************************************/ /** - Free document. */ -void fts_doc_free( - /*=========*/ - fts_doc_t *doc) /*!< in: document */ +/** Free document. */ +void fts_doc_free(fts_doc_t *doc) /*!< in: document */ { mem_heap_t *heap = static_cast(doc->self_heap->arg); @@ -3375,14 +3264,11 @@ void fts_doc_free( mem_heap_free(heap); } -/*********************************************************************/ /** - Callback function for fetch that stores the text of an FTS document, +/** Callback function for fetch that stores the text of an FTS document, converting each column to UTF-16. @return always false */ -ibool fts_query_expansion_fetch_doc( - /*==========================*/ - void *row, /*!< in: sel_node_t* */ - void *user_arg) /*!< in: fts_doc_t* */ +ibool fts_query_expansion_fetch_doc(void *row, /*!< in: sel_node_t* */ + void *user_arg) /*!< in: fts_doc_t* */ { que_node_t *exp; sel_node_t *node = static_cast(row); @@ -3459,10 +3345,8 @@ ibool fts_query_expansion_fetch_doc( return (FALSE); } -/*********************************************************************/ /** - fetch and tokenize the document. */ +/** fetch and tokenize the document. */ static void fts_fetch_doc_from_rec( - /*===================*/ trx_t *trx, /*!< in: current transaction */ fts_get_doc_t *get_doc, /*!< in: FTS index's get_doc struct */ dict_index_t *clust_index, /*!< in: cluster index */ @@ -3837,13 +3721,10 @@ static ulint fts_add_doc_by_id(fts_trx_table_t *ftt, doc_id_t doc_id, return (TRUE); } -/*********************************************************************/ /** - Callback function to read a single ulint column. +/** Callback function to read a single ulint column. return always returns TRUE */ -static ibool fts_read_ulint( - /*===========*/ - void *row, /*!< in: sel_node_t* */ - void *user_arg) /*!< in: pointer to ulint */ +static ibool fts_read_ulint(void *row, /*!< in: sel_node_t* */ + void *user_arg) /*!< in: pointer to ulint */ { sel_node_t *sel_node = static_cast(row); ulint *value = static_cast(user_arg); @@ -3857,12 +3738,9 @@ static ibool fts_read_ulint( return (TRUE); } -/*********************************************************************/ /** - Get maximum Doc ID in a table if index "FTS_DOC_ID_INDEX" exists +/** Get maximum Doc ID in a table if index "FTS_DOC_ID_INDEX" exists @return max Doc ID or 0 if index "FTS_DOC_ID_INDEX" does not exist */ -doc_id_t fts_get_max_doc_id( - /*===============*/ - dict_table_t *table) /*!< in: user table */ +doc_id_t fts_get_max_doc_id(dict_table_t *table) /*!< in: user table */ { dict_index_t *index; dict_field_t *dfield MY_ATTRIBUTE((unused)) = NULL; @@ -3924,11 +3802,9 @@ doc_id_t fts_get_max_doc_id( return (doc_id); } -/*********************************************************************/ /** - Fetch document with the given document id. +/** Fetch document with the given document id. @return DB_SUCCESS if OK else error */ dberr_t fts_doc_fetch_by_doc_id( - /*====================*/ fts_get_doc_t *get_doc, /*!< in: state */ doc_id_t doc_id, /*!< in: id of document to fetch */ @@ -4046,16 +3922,13 @@ dberr_t fts_doc_fetch_by_doc_id( return (error); } -/*********************************************************************/ /** - Write out a single word's data as new entry/entries in the INDEX table. +/** Write out a single word's data as new entry/entries in the INDEX table. @return DB_SUCCESS if all OK. */ -dberr_t fts_write_node( - /*===========*/ - trx_t *trx, /*!< in: transaction */ - que_t **graph, /*!< in: query graph */ - fts_table_t *fts_table, /*!< in: aux table */ - fts_string_t *word, /*!< in: word in UTF-8 */ - fts_node_t *node) /*!< in: node columns */ +dberr_t fts_write_node(trx_t *trx, /*!< in: transaction */ + que_t **graph, /*!< in: query graph */ + fts_table_t *fts_table, /*!< in: aux table */ + fts_string_t *word, /*!< in: word in UTF-8 */ + fts_node_t *node) /*!< in: node columns */ { pars_info_t *info; dberr_t error; @@ -4113,13 +3986,11 @@ dberr_t fts_write_node( return (error); } -/*********************************************************************/ /** - Add rows to the DELETED_CACHE table. +/** Add rows to the DELETED_CACHE table. @return DB_SUCCESS if all went well else error code*/ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_sync_add_deleted_cache( - /*=======================*/ - fts_sync_t *sync, /*!< in: sync state */ - ib_vector_t *doc_ids) /*!< in: doc ids to add */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + fts_sync_add_deleted_cache(fts_sync_t *sync, /*!< in: sync state */ + ib_vector_t *doc_ids) /*!< in: doc ids to add */ { ulint i; pars_info_t *info; @@ -4249,11 +4120,8 @@ static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t return (error); } -/*********************************************************************/ /** - Begin Sync, create transaction, acquire locks, etc. */ -static void fts_sync_begin( - /*===========*/ - fts_sync_t *sync) /*!< in: sync state */ +/** Begin Sync, create transaction, acquire locks, etc. */ +static void fts_sync_begin(fts_sync_t *sync) /*!< in: sync state */ { fts_cache_t *cache = sync->table->fts->cache; @@ -4271,14 +4139,12 @@ static void fts_sync_begin( } } -/*********************************************************************/ /** - Run SYNC on the table, i.e., write out data from the index specific +/** Run SYNC on the table, i.e., write out data from the index specific cache to the FTS aux INDEX table and FTS aux doc id stats table. @return DB_SUCCESS if all OK */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_sync_index( - /*===========*/ - fts_sync_t *sync, /*!< in: sync state */ - fts_index_cache_t *index_cache) /*!< in: index cache */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + fts_sync_index(fts_sync_t *sync, /*!< in: sync state */ + fts_index_cache_t *index_cache) /*!< in: index cache */ { trx_t *trx = sync->trx; @@ -4387,11 +4253,8 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t return (error); } -/*********************************************************************/ /** - Rollback a sync operation */ -static void fts_sync_rollback( - /*==============*/ - fts_sync_t *sync) /*!< in: sync state */ +/** Rollback a sync operation */ +static void fts_sync_rollback(fts_sync_t *sync) /*!< in: sync state */ { trx_t *trx = sync->trx; fts_cache_t *cache = sync->table->fts->cache; @@ -4747,14 +4610,11 @@ static ulint fts_process_token(fts_doc_t *doc, fts_doc_t *result, return (ret); } -/*************************************************************/ /** - Get token char size by charset +/** Get token char size by charset @return token size */ -ulint fts_get_token_size( - /*===============*/ - const CHARSET_INFO *cs, /*!< in: Character set */ - const char *token, /*!< in: token */ - ulint len) /*!< in: token length */ +ulint fts_get_token_size(const CHARSET_INFO *cs, /*!< in: Character set */ + const char *token, /*!< in: token */ + ulint len) /*!< in: token length */ { char *start; char *end; @@ -4778,12 +4638,10 @@ ulint fts_get_token_size( return (size); } -/*************************************************************/ /** - FTS plugin parser 'myql_parser' callback function for document tokenize. +/** FTS plugin parser 'myql_parser' callback function for document tokenize. Refer to 'MYSQL_FTPARSER_PARAM' for more detail. @return always returns 0 */ int fts_tokenize_document_internal( - /*===========================*/ MYSQL_FTPARSER_PARAM *param, /*!< in: parser parameter */ char *doc, /*!< in/out: document */ int len) /*!< in: document length */ @@ -4818,12 +4676,10 @@ int fts_tokenize_document_internal( return (0); } -/******************************************************************/ /** - FTS plugin parser 'myql_add_word' callback function for document tokenize. +/** FTS plugin parser 'myql_add_word' callback function for document tokenize. Refer to 'MYSQL_FTPARSER_PARAM' for more detail. @return always returns 0 */ static int fts_tokenize_add_word_for_parser( - /*=============================*/ MYSQL_FTPARSER_PARAM *param, /* in: parser paramter */ char *word, /* in: token word */ int word_len, /* in: word len */ @@ -4851,10 +4707,8 @@ static int fts_tokenize_add_word_for_parser( return (0); } -/******************************************************************/ /** - Parse a document using an external / user supplied parser */ +/** Parse a document using an external / user supplied parser */ static void fts_tokenize_by_parser( - /*===================*/ fts_doc_t *doc, /* in/out: document to tokenize */ st_mysql_ftparser *parser, /* in: plugin fts parser */ fts_tokenize_param_t *fts_param) /* in: fts tokenize param */ @@ -4969,7 +4823,6 @@ static ib_vector_t *fts_get_docs_create(fts_cache_t *cache) { /******************************************************************** Release any resources held by the fts_get_doc_t instances. */ static void fts_get_docs_clear( - /*===============*/ ib_vector_t *get_docs) /*!< in: Doc retrieval vector */ { ulint i; @@ -4988,12 +4841,9 @@ static void fts_get_docs_clear( } } -/*********************************************************************/ /** - Get the initial Doc ID by consulting the CONFIG table +/** Get the initial Doc ID by consulting the CONFIG table @return initial Doc ID */ -doc_id_t fts_init_doc_id( - /*============*/ - const dict_table_t *table) /*!< in: table */ +doc_id_t fts_init_doc_id(const dict_table_t *table) /*!< in: table */ { doc_id_t max_doc_id = 0; @@ -5030,11 +4880,9 @@ doc_id_t fts_init_doc_id( } #ifdef FTS_MULT_INDEX -/*********************************************************************/ /** - Check if the index is in the affected set. +/** Check if the index is in the affected set. @return true if index is updated */ static ibool fts_is_index_updated( - /*=================*/ const ib_vector_t *fts_indexes, /*!< in: affected FTS indexes */ const fts_get_doc_t *get_doc) /*!< in: info for reading document */ @@ -5059,12 +4907,9 @@ static ibool fts_is_index_updated( } #endif -/*********************************************************************/ /** - Fetch COUNT(*) from specified table. +/** Fetch COUNT(*) from specified table. @return the number of rows in the table */ -ulint fts_get_rows_count( - /*===============*/ - fts_table_t *fts_table) /*!< in: fts table to read */ +ulint fts_get_rows_count(fts_table_t *fts_table) /*!< in: fts table to read */ { trx_t *trx; pars_info_t *info; @@ -5131,11 +4976,8 @@ ulint fts_get_rows_count( } #ifdef FTS_CACHE_SIZE_DEBUG -/*********************************************************************/ /** - Read the max cache size parameter from the config table. */ -static void fts_update_max_cache_size( - /*======================*/ - fts_sync_t *sync) /*!< in: sync state */ +/** Read the max cache size parameter from the config table. */ +static void fts_update_max_cache_size(fts_sync_t *sync) /*!< in: sync state */ { trx_t *trx; fts_table_t fts_table; @@ -5154,12 +4996,9 @@ static void fts_update_max_cache_size( } #endif /* FTS_CACHE_SIZE_DEBUG */ -/*********************************************************************/ /** - Free the modified rows of a table. */ +/** Free the modified rows of a table. */ UNIV_INLINE -void fts_trx_table_rows_free( - /*====================*/ - ib_rbt_t *rows) /*!< in: rbt of rows to free */ +void fts_trx_table_rows_free(ib_rbt_t *rows) /*!< in: rbt of rows to free */ { const ib_rbt_node_t *node; @@ -5184,11 +5023,9 @@ void fts_trx_table_rows_free( rbt_free(rows); } -/*********************************************************************/ /** - Free an FTS savepoint instance. */ +/** Free an FTS savepoint instance. */ UNIV_INLINE void fts_savepoint_free( - /*===============*/ fts_savepoint_t *savepoint) /*!< in: savepoint instance */ { const ib_rbt_node_t *node; @@ -5232,11 +5069,8 @@ void fts_savepoint_free( savepoint->tables = NULL; } -/*********************************************************************/ /** - Free an FTS trx. */ -void fts_trx_free( - /*=========*/ - fts_trx_t *fts_trx) /* in, own: FTS trx */ +/** Free an FTS trx. */ +void fts_trx_free(fts_trx_t *fts_trx) /* in, own: FTS trx */ { ulint i; @@ -5273,14 +5107,11 @@ void fts_trx_free( } } -/*********************************************************************/ /** - Extract the doc id from the FTS hidden column. +/** Extract the doc id from the FTS hidden column. @return doc id that was extracted from rec */ -doc_id_t fts_get_doc_id_from_row( - /*====================*/ - dict_table_t *table, /*!< in: table */ - dtuple_t *row) /*!< in: row whose FTS doc id we - want to extract.*/ +doc_id_t fts_get_doc_id_from_row(dict_table_t *table, /*!< in: table */ + dtuple_t *row) /*!< in: row whose FTS doc id we + want to extract.*/ { dfield_t *field; doc_id_t doc_id = 0; @@ -5336,11 +5167,9 @@ doc_id_t fts_get_doc_id_from_rec(dict_table_t *table, const rec_t *rec, return (doc_id); } -/*********************************************************************/ /** - Search the index specific cache for a particular FTS index. +/** Search the index specific cache for a particular FTS index. @return the index specific cache else NULL */ fts_index_cache_t *fts_find_index_cache( - /*=================*/ const fts_cache_t *cache, /*!< in: cache to search */ const dict_index_t *index) /*!< in: index to search for */ { @@ -5350,11 +5179,9 @@ fts_index_cache_t *fts_find_index_cache( fts_get_index_cache((fts_cache_t *)cache, index))); } -/*********************************************************************/ /** - Search cache for word. +/** Search cache for word. @return the word node vector if found else NULL */ const ib_vector_t *fts_cache_find_word( - /*================*/ const fts_index_cache_t *index_cache, /*!< in: cache to search */ const fts_string_t *text) /*!< in: word to search for */ { @@ -5379,10 +5206,8 @@ const ib_vector_t *fts_cache_find_word( return (nodes); } -/*********************************************************************/ /** - Append deleted doc ids to vector. */ +/** Append deleted doc ids to vector. */ void fts_cache_append_deleted_doc_ids( - /*=============================*/ const fts_cache_t *cache, /*!< in: cache to use */ ib_vector_t *vector) /*!< in: append to this vector */ { @@ -5405,13 +5230,11 @@ void fts_cache_append_deleted_doc_ids( mutex_exit((ib_mutex_t *)&cache->deleted_lock); } -/*********************************************************************/ /** - Wait for the background thread to start. We poll to detect change +/** Wait for the background thread to start. We poll to detect change of state, which is acceptable, since the wait should happen only once during startup. @return true if the thread started else false (i.e timed out) */ ibool fts_wait_for_background_thread_to_start( - /*====================================*/ dict_table_t *table, /*!< in: table to which the thread is attached */ ulint max_wait) /*!< in: time in microseconds, if @@ -5463,10 +5286,8 @@ ibool fts_wait_for_background_thread_to_start( return (done); } -/*********************************************************************/ /** - Add the FTS document id hidden column. */ +/** Add the FTS document id hidden column. */ void fts_add_doc_id_column( - /*==================*/ dict_table_t *table, /*!< in/out: Table with FTS index */ mem_heap_t *heap) /*!< in: temporary memory heap, or NULL */ { @@ -5567,12 +5388,9 @@ fts_t::~fts_t() { because it is stored in this->fts_heap. */ } -/*********************************************************************/ /** - Create an instance of fts_t. +/** Create an instance of fts_t. @return instance of fts_t */ -fts_t *fts_create( - /*=======*/ - dict_table_t *table) /*!< in/out: table with FTS indexes */ +fts_t *fts_create(dict_table_t *table) /*!< in/out: table with FTS indexes */ { fts_t *fts; mem_heap_t *heap; @@ -5586,11 +5404,8 @@ fts_t *fts_create( return (fts); } -/*********************************************************************/ /** - Free the FTS resources. */ -void fts_free( - /*=====*/ - dict_table_t *table) /*!< in/out: table with FTS indexes */ +/** Free the FTS resources. */ +void fts_free(dict_table_t *table) /*!< in/out: table with FTS indexes */ { fts_t *fts = table->fts; @@ -5606,7 +5421,6 @@ void fts_free( Signal FTS threads to initiate shutdown. */ void fts_start_shutdown( -/*===============*/ dict_table_t* table, /*!< in: table with FTS indexes */ fts_t* fts) /*!< in: fts instance that needs to be informed about shutdown */ @@ -5623,7 +5437,6 @@ fts_start_shutdown( Wait for FTS threads to shutdown. */ void fts_shutdown( -/*=========*/ dict_table_t* table, /*!< in: table with FTS indexes */ fts_t* fts) /*!< in: fts instance to shutdown */ { @@ -5637,13 +5450,10 @@ fts_shutdown( } #endif -/*********************************************************************/ /** - Take a FTS savepoint. */ +/** Take a FTS savepoint. */ UNIV_INLINE -void fts_savepoint_copy( - /*===============*/ - const fts_savepoint_t *src, /*!< in: source savepoint */ - fts_savepoint_t *dst) /*!< out: destination savepoint */ +void fts_savepoint_copy(const fts_savepoint_t *src, /*!< in: source savepoint */ + fts_savepoint_t *dst) /*!< out: destination savepoint */ { const ib_rbt_node_t *node; const ib_rbt_t *tables; @@ -5662,13 +5472,10 @@ void fts_savepoint_copy( } } -/*********************************************************************/ /** - Take a FTS savepoint. */ -void fts_savepoint_take( - /*===============*/ - trx_t *trx, /*!< in: transaction */ - fts_trx_t *fts_trx, /*!< in: fts transaction */ - const char *name) /*!< in: savepoint name */ +/** Take a FTS savepoint. */ +void fts_savepoint_take(trx_t *trx, /*!< in: transaction */ + fts_trx_t *fts_trx, /*!< in: fts transaction */ + const char *name) /*!< in: savepoint name */ { mem_heap_t *heap; fts_savepoint_t *savepoint; @@ -5690,14 +5497,11 @@ void fts_savepoint_take( } } -/*********************************************************************/ /** - Lookup a savepoint instance by name. +/** Lookup a savepoint instance by name. @return ULINT_UNDEFINED if not found */ UNIV_INLINE -ulint fts_savepoint_lookup( - /*==================*/ - ib_vector_t *savepoints, /*!< in: savepoints */ - const char *name) /*!< in: savepoint name */ +ulint fts_savepoint_lookup(ib_vector_t *savepoints, /*!< in: savepoints */ + const char *name) /*!< in: savepoint name */ { ulint i; @@ -5716,14 +5520,11 @@ ulint fts_savepoint_lookup( return (ULINT_UNDEFINED); } -/*********************************************************************/ /** - Release the savepoint data identified by name. All savepoints created +/** Release the savepoint data identified by name. All savepoints created after the named savepoint are kept. @return DB_SUCCESS or error code */ -void fts_savepoint_release( - /*==================*/ - trx_t *trx, /*!< in: transaction */ - const char *name) /*!< in: savepoint name */ +void fts_savepoint_release(trx_t *trx, /*!< in: transaction */ + const char *name) /*!< in: savepoint name */ { ut_a(name != NULL); @@ -5758,11 +5559,8 @@ void fts_savepoint_release( } } -/**********************************************************************/ /** - Refresh last statement savepoint. */ -void fts_savepoint_laststmt_refresh( - /*===========================*/ - trx_t *trx) /*!< in: transaction */ +/** Refresh last statement savepoint. */ +void fts_savepoint_laststmt_refresh(trx_t *trx) /*!< in: transaction */ { fts_trx_t *fts_trx; fts_savepoint_t *savepoint; @@ -5779,7 +5577,6 @@ void fts_savepoint_laststmt_refresh( /******************************************************************** Undo the Doc ID add/delete operations in last stmt */ static void fts_undo_last_stmt( - /*===============*/ fts_trx_table_t *s_ftt, /*!< in: Transaction FTS table */ fts_trx_table_t *l_ftt) /*!< in: last stmt FTS table */ { @@ -5823,12 +5620,9 @@ static void fts_undo_last_stmt( } } -/**********************************************************************/ /** - Rollback to savepoint indentified by name. +/** Rollback to savepoint indentified by name. @return DB_SUCCESS or error code */ -void fts_savepoint_rollback_last_stmt( - /*=============================*/ - trx_t *trx) /*!< in: transaction */ +void fts_savepoint_rollback_last_stmt(trx_t *trx) /*!< in: transaction */ { ib_vector_t *savepoints; fts_savepoint_t *savepoint; @@ -5867,13 +5661,10 @@ void fts_savepoint_rollback_last_stmt( } } -/**********************************************************************/ /** - Rollback to savepoint indentified by name. +/** Rollback to savepoint indentified by name. @return DB_SUCCESS or error code */ -void fts_savepoint_rollback( - /*===================*/ - trx_t *trx, /*!< in: transaction */ - const char *name) /*!< in: savepoint name */ +void fts_savepoint_rollback(trx_t *trx, /*!< in: transaction */ + const char *name) /*!< in: savepoint name */ { ulint i; ib_vector_t *savepoints; @@ -6029,12 +5820,10 @@ bool fts_is_aux_table_name(fts_aux_table_t *table, const char *name, return (false); } -/**********************************************************************/ /** - Check whether user supplied stopword table is of the right format. +/** Check whether user supplied stopword table is of the right format. Caller is responsible to hold dictionary locks. @return the stopword column charset if qualifies */ CHARSET_INFO *fts_valid_stopword_table( - /*=====================*/ const char *stopword_table_name) /*!< in: Stopword table name */ { @@ -6090,14 +5879,12 @@ CHARSET_INFO *fts_valid_stopword_table( return (fts_get_charset(col->prtype)); } -/**********************************************************************/ /** - This function loads the stopword into the FTS cache. It also +/** This function loads the stopword into the FTS cache. It also records/fetches stopword configuration to/from FTS configure table, depending on whether we are creating or reloading the FTS. @return true if load operation is successful */ ibool fts_load_stopword( - /*==============*/ const dict_table_t *table, /*!< in: Table with FTS */ trx_t *trx, /*!< in: Transactions */ const char *global_stopword_table, /*!< in: Global stopword table @@ -6213,14 +6000,11 @@ ibool fts_load_stopword( return (error == DB_SUCCESS); } -/**********************************************************************/ /** - Callback function when we initialize the FTS at the start up +/** Callback function when we initialize the FTS at the start up time. It recovers the maximum Doc IDs presented in the current table. @return: always returns true */ -static ibool fts_init_get_doc_id( - /*================*/ - void *row, /*!< in: sel_node_t* */ - void *user_arg) /*!< in: fts cache */ +static ibool fts_init_get_doc_id(void *row, /*!< in: sel_node_t* */ + void *user_arg) /*!< in: fts cache */ { doc_id_t doc_id = FTS_NULL_DOC_ID; sel_node_t *node = static_cast(row); @@ -6248,15 +6032,12 @@ static ibool fts_init_get_doc_id( return (TRUE); } -/**********************************************************************/ /** - Callback function when we initialize the FTS at the start up +/** Callback function when we initialize the FTS at the start up time. It recovers Doc IDs that have not sync-ed to the auxiliary table, and require to bring them back into FTS index. @return: always returns true */ -static ibool fts_init_recover_doc( - /*=================*/ - void *row, /*!< in: sel_node_t* */ - void *user_arg) /*!< in: fts cache */ +static ibool fts_init_recover_doc(void *row, /*!< in: sel_node_t* */ + void *user_arg) /*!< in: fts cache */ { fts_doc_t doc; ulint doc_len = 0; @@ -6348,17 +6129,14 @@ static ibool fts_init_recover_doc( return (TRUE); } -/**********************************************************************/ /** - This function brings FTS index in sync when FTS index is first +/** This function brings FTS index in sync when FTS index is first used. There are documents that have not yet sync-ed to auxiliary tables from last server abnormally shutdown, we will need to bring such document into FTS cache before any further operations @return true if all OK */ -ibool fts_init_index( - /*===========*/ - dict_table_t *table, /*!< in: Table with FTS */ - ibool has_cache_lock) /*!< in: Whether we already have - cache lock */ +ibool fts_init_index(dict_table_t *table, /*!< in: Table with FTS */ + ibool has_cache_lock) /*!< in: Whether we already have + cache lock */ { dict_index_t *index; doc_id_t start_doc; diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc index 0cbf83996d05..2ba93f2041a3 100644 --- a/storage/innobase/fts/fts0opt.cc +++ b/storage/innobase/fts/fts0opt.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file fts/fts0opt.cc +/** @file fts/fts0opt.cc Full Text Search optimize thread Created 2007/03/27 Sunny Bains @@ -277,10 +276,8 @@ static const char *fts_end_delete_sql = "DELETE FROM $being_deleted;\n" "DELETE FROM $being_deleted_cache;\n"; -/**********************************************************************/ /** - Initialize fts_zip_t. */ +/** Initialize fts_zip_t. */ static void fts_zip_initialize( - /*===============*/ fts_zip_t *zip) /*!< out: zip instance to initialize */ { zip->pos = 0; @@ -298,14 +295,11 @@ static void fts_zip_initialize( memset(zip->zp, 0, sizeof(*zip->zp)); } -/**********************************************************************/ /** - Create an instance of fts_zip_t. +/** Create an instance of fts_zip_t. @return a new instance of fts_zip_t */ -static fts_zip_t *fts_zip_create( - /*===========*/ - mem_heap_t *heap, /*!< in: heap */ - ulint block_sz, /*!< in: size of a zip block.*/ - ulint max_words) /*!< in: max words to read */ +static fts_zip_t *fts_zip_create(mem_heap_t *heap, /*!< in: heap */ + ulint block_sz, /*!< in: size of a zip block.*/ + ulint max_words) /*!< in: max words to read */ { fts_zip_t *zip; @@ -327,10 +321,8 @@ static fts_zip_t *fts_zip_create( return (zip); } -/**********************************************************************/ /** - Initialize an instance of fts_zip_t. */ +/** Initialize an instance of fts_zip_t. */ static void fts_zip_init( - /*=========*/ fts_zip_t *zip) /*!< in: zip instance to init */ { @@ -340,11 +332,9 @@ static void fts_zip_init( *zip->word.f_str = '\0'; } -/**********************************************************************/ /** - Create a fts_optimizer_word_t instance. +/** Create a fts_optimizer_word_t instance. @return new instance */ static fts_word_t *fts_word_init( - /*==========*/ fts_word_t *word, /*!< in: word to initialize */ byte *utf8, /*!< in: UTF-8 string */ ulint len) /*!< in: length of string in bytes */ @@ -368,13 +358,10 @@ static fts_word_t *fts_word_init( return (word); } -/**********************************************************************/ /** - Read the FTS INDEX row. +/** Read the FTS INDEX row. @return fts_node_t instance */ -static fts_node_t *fts_optimize_read_node( - /*===================*/ - fts_word_t *word, /*!< in: */ - que_node_t *exp) /*!< in: */ +static fts_node_t *fts_optimize_read_node(fts_word_t *word, /*!< in: */ + que_node_t *exp) /*!< in: */ { int i; fts_node_t *node = @@ -419,11 +406,9 @@ static fts_node_t *fts_optimize_read_node( return (node); } -/**********************************************************************/ /** - Callback function to fetch the rows in an FTS INDEX record. +/** Callback function to fetch the rows in an FTS INDEX record. @return always returns non-NULL */ ibool fts_optimize_index_fetch_node( - /*==========================*/ void *row, /*!< in: sel_node_t* */ void *user_arg) /*!< in: pointer to ib_vector_t */ { @@ -473,11 +458,9 @@ ibool fts_optimize_index_fetch_node( return (TRUE); } -/**********************************************************************/ /** - Read the rows from the FTS inde. +/** Read the rows from the FTS inde. @return DB_SUCCESS or error code */ dberr_t fts_index_fetch_nodes( - /*==================*/ trx_t *trx, /*!< in: transaction */ que_t **graph, /*!< in: prepared statement */ fts_table_t *fts_table, /*!< in: table of the FTS INDEX */ @@ -558,10 +541,8 @@ dberr_t fts_index_fetch_nodes( return (error); } -/**********************************************************************/ /** - Read a word */ +/** Read a word */ static byte *fts_zip_read_word( - /*==============*/ fts_zip_t *zip, /*!< in: Zip state + data */ fts_string_t *word) /*!< out: uncompressed word */ { @@ -650,12 +631,10 @@ static byte *fts_zip_read_word( return (zip->status == Z_OK || zip->status == Z_STREAM_END ? ptr : NULL); } -/**********************************************************************/ /** - Callback function to fetch and compress the word in an FTS +/** Callback function to fetch and compress the word in an FTS INDEX record. @return false on EOF */ static ibool fts_fetch_index_words( - /*==================*/ void *row, /*!< in: sel_node_t* */ void *user_arg) /*!< in: pointer to ib_vector_t */ { @@ -726,10 +705,8 @@ static ibool fts_fetch_index_words( return (zip->n_words >= zip->max_words ? FALSE : TRUE); } -/**********************************************************************/ /** - Finish Zip deflate. */ +/** Finish Zip deflate. */ static void fts_zip_deflate_end( - /*================*/ fts_zip_t *zip) /*!< in: instance that should be closed*/ { ut_a(zip->zp->avail_in == 0); @@ -765,12 +742,10 @@ static void fts_zip_deflate_end( memset(zip->zp, 0, sizeof(*zip->zp)); } -/**********************************************************************/ /** - Read the words from the FTS INDEX. +/** Read the words from the FTS INDEX. @return DB_SUCCESS if all OK, DB_TABLE_NOT_FOUND if no more indexes to search else error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_index_fetch_words( - /*==================*/ fts_optimize_t *optim, /*!< in: optimize scratch pad */ const fts_string_t *word, /*!< in: get words greater than this word */ @@ -885,11 +860,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_index_fetch_words( return (error); } -/**********************************************************************/ /** - Callback function to fetch the doc id from the record. +/** Callback function to fetch the doc id from the record. @return always returns true */ static ibool fts_fetch_doc_ids( - /*==============*/ void *row, /*!< in: sel_node_t* */ void *user_arg) /*!< in: pointer to ib_vector_t */ { @@ -922,11 +895,9 @@ static ibool fts_fetch_doc_ids( return (TRUE); } -/**********************************************************************/ /** - Read the rows from a FTS common auxiliary table. +/** Read the rows from a FTS common auxiliary table. @return DB_SUCCESS or error code */ dberr_t fts_table_fetch_doc_ids( - /*====================*/ trx_t *trx, /*!< in: transaction */ fts_table_t *fts_table, /*!< in: table */ fts_doc_ids_t *doc_ids) /*!< in: For collecting doc ids */ @@ -986,16 +957,13 @@ dberr_t fts_table_fetch_doc_ids( return (error); } -/**********************************************************************/ /** - Do a binary search for a doc id in the array +/** Do a binary search for a doc id in the array @return +ve index if found -ve index where it should be inserted if not found */ -int fts_bsearch( - /*========*/ - fts_update_t *array, /*!< in: array to sort */ - int lower, /*!< in: the array lower bound */ - int upper, /*!< in: the array upper bound */ - doc_id_t doc_id) /*!< in: the doc id to search for */ +int fts_bsearch(fts_update_t *array, /*!< in: array to sort */ + int lower, /*!< in: the array lower bound */ + int upper, /*!< in: the array upper bound */ + doc_id_t doc_id) /*!< in: the doc id to search for */ { int orig_size = upper; @@ -1028,13 +996,11 @@ int fts_bsearch( return ((lower == 0) ? -1 : -(lower)); } -/**********************************************************************/ /** - Search in the to delete array whether any of the doc ids within +/** Search in the to delete array whether any of the doc ids within the [first, last] range are to be deleted @return +ve index if found -ve index where it should be inserted if not found */ static int fts_optimize_lookup( - /*================*/ ib_vector_t *doc_ids, /*!< in: array to search */ ulint lower, /*!< in: lower limit of array */ doc_id_t first_doc_id, /*!< in: doc id to lookup */ @@ -1067,11 +1033,9 @@ static int fts_optimize_lookup( return (pos); } -/**********************************************************************/ /** - Encode the word pos list into the node +/** Encode the word pos list into the node @return DB_SUCCESS or error code*/ static dberr_t fts_optimize_encode_node( - /*=====================*/ fts_node_t *node, /*!< in: node to fill*/ doc_id_t doc_id, /*!< in: doc id to encode */ fts_encode_t *enc) /*!< in: encoding state.*/ @@ -1153,11 +1117,9 @@ static dberr_t fts_optimize_encode_node( return (error); } -/**********************************************************************/ /** - Optimize the data contained in a node. +/** Optimize the data contained in a node. @return DB_SUCCESS or error code*/ static dberr_t fts_optimize_node( - /*==============*/ ib_vector_t *del_vec, /*!< in: vector of doc ids to delete*/ int *del_pos, /*!< in: offset into above vector */ fts_node_t *dst_node, /*!< in: node to fill*/ @@ -1245,11 +1207,9 @@ static dberr_t fts_optimize_node( return (error); } -/**********************************************************************/ /** - Determine the starting pos within the deleted doc id vector for a word. +/** Determine the starting pos within the deleted doc id vector for a word. @return delete position */ static MY_ATTRIBUTE((warn_unused_result)) int fts_optimize_deleted_pos( - /*=====================*/ fts_optimize_t *optim, /*!< in: optimize state data */ fts_word_t *word) /*!< in: the word data to check */ { @@ -1285,12 +1245,10 @@ static MY_ATTRIBUTE((warn_unused_result)) int fts_optimize_deleted_pos( } #define FTS_DEBUG_PRINT -/**********************************************************************/ /** - Compact the nodes for a word, we also remove any doc ids during the +/** Compact the nodes for a word, we also remove any doc ids during the compaction pass. @return DB_SUCCESS or error code.*/ static ib_vector_t *fts_optimize_word( - /*==============*/ fts_optimize_t *optim, /*!< in: optimize state data */ fts_word_t *word) /*!< in: the word to optimize */ { @@ -1362,11 +1320,9 @@ static ib_vector_t *fts_optimize_word( return (nodes); } -/**********************************************************************/ /** - Update the FTS index table. This is a delete followed by an insert. +/** Update the FTS index table. This is a delete followed by an insert. @return DB_SUCCESS or error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_write_word( - /*====================*/ trx_t *trx, /*!< in: transaction */ fts_table_t *fts_table, /*!< in: table of FTS index */ fts_string_t *word, /*!< in: word data to write */ @@ -1443,11 +1399,8 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_write_word( return (error); } -/**********************************************************************/ /** - Free fts_optimizer_word_t instanace.*/ -void fts_word_free( - /*==========*/ - fts_word_t *word) /*!< in: instance to free.*/ +/** Free fts_optimizer_word_t instanace.*/ +void fts_word_free(fts_word_t *word) /*!< in: instance to free.*/ { mem_heap_t *heap = static_cast(word->heap_alloc->arg); @@ -1458,11 +1411,9 @@ void fts_word_free( mem_heap_free(heap); } -/**********************************************************************/ /** - Optimize the word ilist and rewrite data to the FTS index. +/** Optimize the word ilist and rewrite data to the FTS index. @return status one of RESTART, EXIT, ERROR */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_compact( - /*=================*/ fts_optimize_t *optim, /*!< in: optimize state data */ dict_index_t *index, /*!< in: current FTS being optimized */ ib_time_t start_time) /*!< in: optimize start time */ @@ -1506,11 +1457,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_compact( return (error); } -/**********************************************************************/ /** - Create an instance of fts_optimize_t. Also create a new +/** Create an instance of fts_optimize_t. Also create a new background transaction.*/ static fts_optimize_t *fts_optimize_create( - /*================*/ dict_table_t *table) /*!< in: table with FTS indexes */ { fts_optimize_t *optim; @@ -1545,12 +1494,10 @@ static fts_optimize_t *fts_optimize_create( } #ifdef FTS_OPTIMIZE_DEBUG -/**********************************************************************/ /** - Get optimize start time of an FTS index. +/** Get optimize start time of an FTS index. @return DB_SUCCESS if all OK else error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_get_index_start_time( - /*==============================*/ trx_t *trx, /*!< in: transaction */ dict_index_t *index, /*!< in: FTS index */ ib_time_t *start_time) /*!< out: time in secs */ @@ -1559,12 +1506,10 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t (ulint *)start_time)); } -/**********************************************************************/ /** - Set the optimize start time of an FTS index. +/** Set the optimize start time of an FTS index. @return DB_SUCCESS if all OK else error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_set_index_start_time( - /*==============================*/ trx_t *trx, /*!< in: transaction */ dict_index_t *index, /*!< in: FTS index */ ib_time_t start_time) /*!< in: start time */ @@ -1573,12 +1518,10 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t (ulint)start_time)); } -/**********************************************************************/ /** - Get optimize end time of an FTS index. +/** Get optimize end time of an FTS index. @return DB_SUCCESS if all OK else error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_get_index_end_time( - /*============================*/ trx_t *trx, /*!< in: transaction */ dict_index_t *index, /*!< in: FTS index */ ib_time_t *end_time) /*!< out: time in secs */ @@ -1587,25 +1530,20 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t (ulint *)end_time)); } -/**********************************************************************/ /** - Set the optimize end time of an FTS index. +/** Set the optimize end time of an FTS index. @return DB_SUCCESS if all OK else error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t - fts_optimize_set_index_end_time( - /*============================*/ - trx_t *trx, /*!< in: transaction */ - dict_index_t *index, /*!< in: FTS index */ - ib_time_t end_time) /*!< in: end time */ + fts_optimize_set_index_end_time(trx_t *trx, /*!< in: transaction */ + dict_index_t *index, /*!< in: FTS index */ + ib_time_t end_time) /*!< in: end time */ { return (fts_config_set_index_ulint(trx, index, FTS_OPTIMIZE_END_TIME, (ulint)end_time)); } #endif -/**********************************************************************/ /** - Free the optimize prepared statements.*/ +/** Free the optimize prepared statements.*/ static void fts_optimize_graph_free( - /*====================*/ fts_optimize_graph_t *graph) /*!< in/out: The graph instances to free */ { @@ -1630,10 +1568,8 @@ static void fts_optimize_graph_free( } } -/**********************************************************************/ /** - Free all optimize resources. */ +/** Free all optimize resources. */ static void fts_optimize_free( - /*==============*/ fts_optimize_t *optim) /*!< in: table with on FTS index */ { mem_heap_t *heap = static_cast(optim->self_heap->arg); @@ -1649,11 +1585,9 @@ static void fts_optimize_free( mem_heap_free(heap); } -/**********************************************************************/ /** - Get the max time optimize should run in millisecs. +/** Get the max time optimize should run in millisecs. @return max optimize time limit in millisecs. */ static ib_time_t fts_optimize_get_time_limit( - /*========================*/ trx_t *trx, /*!< in: transaction */ fts_table_t *fts_table) /*!< in: aux table */ { @@ -1665,11 +1599,9 @@ static ib_time_t fts_optimize_get_time_limit( return (time_limit * 1000); } -/**********************************************************************/ /** - Run OPTIMIZE on the given table. Note: this can take a very long time +/** Run OPTIMIZE on the given table. Note: this can take a very long time (hours). */ static void fts_optimize_words( - /*===============*/ fts_optimize_t *optim, /*!< in: optimize instance */ dict_index_t *index, /*!< in: current FTS being optimized */ fts_string_t *word) /*!< in: the starting word to optimize */ @@ -1753,12 +1685,10 @@ static void fts_optimize_words( } } -/**********************************************************************/ /** - Optimize is complete. Set the completion time, and reset the optimize +/** Optimize is complete. Set the completion time, and reset the optimize start string for this FTS index to "". @return DB_SUCCESS if all OK */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_index_completed( - /*=========================*/ fts_optimize_t *optim, /*!< in: optimize instance */ dict_index_t *index) /*!< in: table with one FTS index */ { @@ -1790,12 +1720,10 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_index_completed( return (error); } -/**********************************************************************/ /** - Read the list of words from the FTS auxiliary index that will be +/** Read the list of words from the FTS auxiliary index that will be optimized in this pass. @return DB_SUCCESS if all OK */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_index_read_words( - /*==========================*/ fts_optimize_t *optim, /*!< in: optimize instance */ dict_index_t *index, /*!< in: table with one FTS index */ fts_string_t *word) /*!< in: buffer to use */ @@ -1835,14 +1763,12 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_index_read_words( return (error); } -/**********************************************************************/ /** - Run OPTIMIZE on the given FTS index. Note: this can take a very long +/** Run OPTIMIZE on the given FTS index. Note: this can take a very long time (hours). @return DB_SUCCESS if all OK */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_index( - /*===============*/ - fts_optimize_t *optim, /*!< in: optimize instance */ - dict_index_t *index) /*!< in: table with one FTS index */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + fts_optimize_index(fts_optimize_t *optim, /*!< in: optimize instance */ + dict_index_t *index) /*!< in: table with one FTS index */ { fts_string_t word; dberr_t error; @@ -1903,12 +1829,10 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_index( return (error); } -/**********************************************************************/ /** - Delete the document ids in the delete, and delete cache tables. +/** Delete the document ids in the delete, and delete cache tables. @return DB_SUCCESS if all OK */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_purge_deleted_doc_ids( - /*===============================*/ fts_optimize_t *optim) /*!< in: optimize instance */ { ulint i; @@ -2001,12 +1925,10 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t return (error); } -/**********************************************************************/ /** - Delete the document ids in the pending delete, and delete tables. +/** Delete the document ids in the pending delete, and delete tables. @return DB_SUCCESS if all OK */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_purge_deleted_doc_id_snapshot( - /*=======================================*/ fts_optimize_t *optim) /*!< in: optimize instance */ { dberr_t error = DB_SUCCESS; @@ -2070,13 +1992,11 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t return (error); } -/**********************************************************************/ /** - Copy the deleted doc ids that will be purged during this optimize run +/** Copy the deleted doc ids that will be purged during this optimize run to the being deleted FTS auxiliary tables. The transaction is committed upon successfull copy and rolled back on DB_DUPLICATE_KEY error. @return DB_SUCCESS if all OK */ static ulint fts_optimize_being_deleted_count( - /*=============================*/ fts_optimize_t *optim) /*!< in: optimize instance */ { fts_table_t fts_table; @@ -2087,14 +2007,12 @@ static ulint fts_optimize_being_deleted_count( return (fts_get_rows_count(&fts_table)); } -/*********************************************************************/ /** - Copy the deleted doc ids that will be purged during this optimize run +/** Copy the deleted doc ids that will be purged during this optimize run to the being deleted FTS auxiliary tables. The transaction is committed upon successfull copy and rolled back on DB_DUPLICATE_KEY error. @return DB_SUCCESS if all OK */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_create_deleted_doc_id_snapshot( - /*========================================*/ fts_optimize_t *optim) /*!< in: optimize instance */ { dberr_t error = DB_SUCCESS; @@ -2200,13 +2118,11 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t return (error); } -/*********************************************************************/ /** - Read in the document ids that are to be purged during optimize. The +/** Read in the document ids that are to be purged during optimize. The transaction is committed upon successfully read. @return DB_SUCCESS if all OK */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_read_deleted_doc_id_snapshot( - /*======================================*/ fts_optimize_t *optim) /*!< in: optimize instance */ { dberr_t error; @@ -2233,14 +2149,12 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t return (error); } -/*********************************************************************/ /** - Optimze all the FTS indexes, skipping those that have already been +/** Optimze all the FTS indexes, skipping those that have already been optimized, since the FTS auxiliary indexes are not guaranteed to be of the same cardinality. @return DB_SUCCESS if all OK */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_indexes( - /*=================*/ - fts_optimize_t *optim) /*!< in: optimize instance */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + fts_optimize_indexes(fts_optimize_t *optim) /*!< in: optimize instance */ { ulint i; dberr_t error = DB_SUCCESS; @@ -2299,11 +2213,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_indexes( return (error); } -/*********************************************************************/ /** - Cleanup the snapshot tables and the master deleted table. +/** Cleanup the snapshot tables and the master deleted table. @return DB_SUCCESS if all OK */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_purge_snapshot( - /*========================*/ fts_optimize_t *optim) /*!< in: optimize instance */ { dberr_t error; @@ -2326,11 +2238,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_purge_snapshot( return (error); } -/*********************************************************************/ /** - Reset the start time to 0 so that a new optimize can be started. +/** Reset the start time to 0 so that a new optimize can be started. @return DB_SUCCESS if all OK */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_reset_start_time( - /*==========================*/ fts_optimize_t *optim) /*!< in: optimize instance */ { dberr_t error = DB_SUCCESS; @@ -2361,11 +2271,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_optimize_reset_start_time( return (error); } -/*********************************************************************/ /** - Run OPTIMIZE on the given table by a background thread. +/** Run OPTIMIZE on the given table by a background thread. @return DB_SUCCESS if all OK */ static dberr_t fts_optimize_table_bk( - /*==================*/ fts_slot_t *slot) /*!< in: table to optimiza */ { dberr_t error = DB_SUCCESS; @@ -2405,12 +2313,9 @@ static dberr_t fts_optimize_table_bk( return (error); } -/*********************************************************************/ /** - Run OPTIMIZE on the given table. +/** Run OPTIMIZE on the given table. @return DB_SUCCESS if all OK */ -dberr_t fts_optimize_table( - /*===============*/ - dict_table_t *table) /*!< in: table to optimiza */ +dberr_t fts_optimize_table(dict_table_t *table) /*!< in: table to optimiza */ { dberr_t error = DB_SUCCESS; fts_optimize_t *optim = NULL; @@ -2494,11 +2399,9 @@ dberr_t fts_optimize_table( return (error); } -/********************************************************************/ /** - Add the table to add to the OPTIMIZER's list. +/** Add the table to add to the OPTIMIZER's list. @return new message instance */ static fts_msg_t *fts_optimize_create_msg( - /*====================*/ fts_msg_type_t type, /*!< in: type of message */ void *ptr) /*!< in: message payload */ { @@ -2515,11 +2418,8 @@ static fts_msg_t *fts_optimize_create_msg( return (msg); } -/**********************************************************************/ /** - Add the table to add to the OPTIMIZER's list. */ -void fts_optimize_add_table( - /*===================*/ - dict_table_t *table) /*!< in: table to add */ +/** Add the table to add to the OPTIMIZER's list. */ +void fts_optimize_add_table(dict_table_t *table) /*!< in: table to add */ { fts_msg_t *msg; fts_msg_id_t *add; @@ -2547,7 +2447,6 @@ Optimize a table. */ static void fts_optimize_do_table( -/*==================*/ dict_table_t* table) /*!< in: table to optimize */ { fts_msg_t* msg; @@ -2563,12 +2462,9 @@ fts_optimize_do_table( } #endif -/**********************************************************************/ /** - Remove the table from the OPTIMIZER's list. We do wait for +/** Remove the table from the OPTIMIZER's list. We do wait for acknowledgement from the consumer of the message. */ -void fts_optimize_remove_table( - /*======================*/ - dict_table_t *table) /*!< in: table to remove */ +void fts_optimize_remove_table(dict_table_t *table) /*!< in: table to remove */ { fts_msg_t *msg; fts_msg_id_t *remove; @@ -2624,11 +2520,9 @@ void fts_optimize_request_sync_table(dict_table_t *table) { ib_wqueue_add(fts_optimize_wq, msg, msg->heap); } -/**********************************************************************/ /** - Find the slot for a particular table. +/** Find the slot for a particular table. @return slot if found else NULL. */ static fts_slot_t *fts_optimize_find_slot( - /*===================*/ ib_vector_t *tables, /*!< in: vector of tables */ table_id_t table_id) /*!< in: table id to find */ { @@ -2647,10 +2541,8 @@ static fts_slot_t *fts_optimize_find_slot( return (NULL); } -/**********************************************************************/ /** - Start optimizing table. */ +/** Start optimizing table. */ static void fts_optimize_start_table( - /*=====================*/ ib_vector_t *tables, /*!< in/out: vector of tables */ dict_table_t *table) /*!< in: table to optimize */ { @@ -2668,10 +2560,8 @@ static void fts_optimize_start_table( } } -/**********************************************************************/ /** - Add the table to the vector if it doesn't already exist. */ +/** Add the table to the vector if it doesn't already exist. */ static ibool fts_optimize_new_table( - /*===================*/ ib_vector_t *tables, /*!< in/out: vector of tables */ fts_msg_id_t *msg) /*!< in: table to delete */ { @@ -2712,10 +2602,8 @@ static ibool fts_optimize_new_table( return (TRUE); } -/**********************************************************************/ /** - Remove the table from the vector if it exists. */ +/** Remove the table from the vector if it exists. */ static ibool fts_optimize_del_table( - /*===================*/ ib_vector_t *tables, /*!< in/out: vector of tables */ fts_msg_id_t *msg) /*!< in: table to delete */ { @@ -2741,11 +2629,9 @@ static ibool fts_optimize_del_table( return (FALSE); } -/**********************************************************************/ /** - Calculate how many of the registered tables need to be optimized. +/** Calculate how many of the registered tables need to be optimized. @return no. of tables to optimize */ static ulint fts_optimize_how_many( - /*==================*/ const ib_vector_t *tables) /*!< in: registered tables vector*/ { @@ -2795,11 +2681,9 @@ static ulint fts_optimize_how_many( return (n_tables); } -/**********************************************************************/ /** - Check if the total memory used by all FTS table exceeds the maximum limit. +/** Check if the total memory used by all FTS table exceeds the maximum limit. @return true if a sync is needed, false otherwise */ static bool fts_is_sync_needed( - /*===============*/ const ib_vector_t *tables) /*!< in: registered tables vector*/ { @@ -2849,7 +2733,6 @@ Check whether a table needs to be optimized. */ static void fts_optimize_need_sync( -/*===================*/ ib_vector_t* tables) /*!< in: list of tables */ { dict_table_t* table = NULL; @@ -3052,11 +2935,8 @@ static void fts_optimize_thread(ib_wqueue_t *wq) { my_thread_end(); } -/**********************************************************************/ /** - Startup the optimize thread and create the work queue. */ -void fts_optimize_init(void) -/*===================*/ -{ +/** Startup the optimize thread and create the work queue. */ +void fts_optimize_init(void) { ut_ad(!srv_read_only_mode); /* For now we only support one optimize thread. */ diff --git a/storage/innobase/fts/fts0plugin.cc b/storage/innobase/fts/fts0plugin.cc index 6ba7cb305cd6..8478a54920ca 100644 --- a/storage/innobase/fts/fts0plugin.cc +++ b/storage/innobase/fts/fts0plugin.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2013, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file fts/fts0plugin.cc +/** @file fts/fts0plugin.cc Full Text Search plugin support. Created 2013/06/04 Shaohua Wang @@ -37,31 +36,25 @@ this program; if not, write to the Free Software Foundation, Inc., #include "fts0tokenize.h" #include "my_inttypes.h" -/******************************************************************/ /** - FTS default parser init +/** FTS default parser init @return 0 */ static int fts_default_parser_init( - /*====================*/ MYSQL_FTPARSER_PARAM *param) /*!< in: plugin parser param */ { return (0); } -/******************************************************************/ /** - FTS default parser deinit +/** FTS default parser deinit @return 0 */ static int fts_default_parser_deinit( - /*======================*/ MYSQL_FTPARSER_PARAM *param) /*!< in: plugin parser param */ { return (0); } -/******************************************************************/ /** - FTS default parser parse from ft_static.c in MYISAM. +/** FTS default parser parse from ft_static.c in MYISAM. @return 0 if parse successfully, or return non-zero */ static int fts_default_parser_parse( - /*=====================*/ MYSQL_FTPARSER_PARAM *param) /*!< in: plugin parser param */ { return (param->mysql_parse(param, param->doc, param->length)); @@ -72,11 +65,9 @@ struct st_mysql_ftparser fts_default_parser = { MYSQL_FTPARSER_INTERFACE_VERSION, fts_default_parser_parse, fts_default_parser_init, fts_default_parser_deinit}; -/******************************************************************/ /** - Get a operator node from token boolean info +/** Get a operator node from token boolean info @return node */ static fts_ast_node_t *fts_query_get_oper_node( - /*====================*/ MYSQL_FTPARSER_BOOLEAN_INFO *info, /*!< in: token info */ fts_ast_state_t *state) /*!< in/out: query parse state*/ { @@ -97,15 +88,13 @@ static fts_ast_node_t *fts_query_get_oper_node( return (oper_node); } -/******************************************************************/ /** - FTS plugin parser 'myql_add_word' callback function for query parse. +/** FTS plugin parser 'myql_add_word' callback function for query parse. Refer to 'MYSQL_FTPARSER_PARAM' for more detail. Note: a. Parse logic refers to 'ftb_query_add_word' from ft_boolean_search.c in MYISAM; b. Parse node or tree refers to fts0pars.y. @return 0 if add successfully, or return non-zero. */ static int fts_query_add_word_for_parser( - /*==========================*/ MYSQL_FTPARSER_PARAM *param, /*!< in: parser param */ char *word, /*!< in: token */ int word_len, /*!< in: token length */ @@ -215,12 +204,10 @@ static int fts_query_add_word_for_parser( return (0); } -/******************************************************************/ /** - FTS plugin parser 'myql_parser' callback function for query parse. +/** FTS plugin parser 'myql_parser' callback function for query parse. Refer to 'MYSQL_FTPARSER_PARAM' for more detail. @return 0 if parse successfully */ static int fts_parse_query_internal( - /*=====================*/ MYSQL_FTPARSER_PARAM *param, /*!< in: parser param */ char *query, /*!< in: query string */ int len) /*!< in: query length */ @@ -247,16 +234,13 @@ static int fts_parse_query_internal( return (0); } -/******************************************************************/ /** - fts parse query by plugin parser. +/** fts parse query by plugin parser. @return 0 if parse successfully, or return non-zero. */ -int fts_parse_by_parser( - /*================*/ - ibool mode, /*!< in: parse boolean mode */ - uchar *query_str, /*!< in: query string */ - ulint query_len, /*!< in: query string length */ - st_mysql_ftparser *parser, /*!< in: fts plugin parser */ - fts_ast_state_t *state) /*!< in/out: parser state */ +int fts_parse_by_parser(ibool mode, /*!< in: parse boolean mode */ + uchar *query_str, /*!< in: query string */ + ulint query_len, /*!< in: query string length */ + st_mysql_ftparser *parser, /*!< in: fts plugin parser */ + fts_ast_state_t *state) /*!< in/out: parser state */ { MYSQL_FTPARSER_PARAM param; int ret; diff --git a/storage/innobase/fts/fts0que.cc b/storage/innobase/fts/fts0que.cc index 959ad87d130e..df8cee9aecb9 100644 --- a/storage/innobase/fts/fts0que.cc +++ b/storage/innobase/fts/fts0que.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file fts/fts0que.cc +/** @file fts/fts0que.cc Full Text Search functionality. Created 2007/03/27 Sunny Bains @@ -289,7 +288,6 @@ struct fts_word_freq_t { Callback function to fetch the rows in an FTS INDEX record. @return always true */ static ibool fts_query_index_fetch_nodes( - /*========================*/ void *row, /*!< in: sel_node_t* */ void *user_arg); /*!< in: pointer to ib_vector_t */ @@ -297,7 +295,6 @@ static ibool fts_query_index_fetch_nodes( Read and filter nodes. @return fts_node_t instance */ static dberr_t fts_query_filter_doc_ids( - /*=====================*/ fts_query_t *query, /*!< in: query instance */ const fts_string_t *word, /*!< in: the current word */ fts_word_freq_t *word_freq, /*!< in/out: word frequency */ @@ -324,46 +321,39 @@ Find a doc_id in a word's ilist. static ibool fts_query_find_doc_id( -/*==================*/ fts_select_t* select, /*!< in/out: search the doc id selected, update the frequency if found. */ void* data, /*!< in: doc id ilist */ ulint len); /*!< in: doc id ilist size */ #endif -/*************************************************************/ /** - This function implements a simple "blind" query expansion search: +/** This function implements a simple "blind" query expansion search: words in documents found in the first search pass will be used as search arguments to search the document again, thus "expand" the search result set. @return DB_SUCCESS if success, otherwise the error code */ static dberr_t fts_expand_query( - /*=============*/ dict_index_t *index, /*!< in: FTS index to search */ fts_query_t *query) /*!< in: query result, to be freed by the client */ MY_ATTRIBUTE((warn_unused_result)); -/*************************************************************/ /** - This function finds documents that contain all words in a +/** This function finds documents that contain all words in a phrase or proximity search. And if proximity search, verify the words are close enough to each other, as in specified distance. This function is called for phrase and proximity search. @return true if documents are found, false if otherwise */ static ibool fts_phrase_or_proximity_search( - /*===========================*/ fts_query_t *query, /*!< in/out: query instance query->doc_ids might be instantiated with qualified doc IDs */ ib_vector_t *tokens); /*!< in: Tokens contain words */ -/*************************************************************/ /** - This function checks whether words in result documents are close to +/** This function checks whether words in result documents are close to each other (within proximity range as specified by "distance"). If "distance" is MAX_ULINT, then it will find all combinations of positions of matching words and store min and max positions in the "qualified_pos" for later verification. @return true if words are close to each other, false if otherwise */ static bool fts_proximity_get_positions( - /*========================*/ fts_match_t **match, /*!< in: query instance */ ulint num_match, /*!< in: number of matching items */ @@ -378,7 +368,6 @@ Get the total number of words in a documents. */ static ulint fts_query_terms_in_document( -/*========================*/ /*!< out: DB_SUCCESS if all go well else error code */ fts_query_t* query, /*!< in: FTS query state */ @@ -390,10 +379,8 @@ fts_query_terms_in_document( Compare two fts_doc_freq_t doc_ids. @return < 0 if n1 < n2, 0 if n1 == n2, > 0 if n1 > n2 */ UNIV_INLINE -int fts_freq_doc_id_cmp( - /*================*/ - const void *p1, /*!< in: id1 */ - const void *p2) /*!< in: id2 */ +int fts_freq_doc_id_cmp(const void *p1, /*!< in: id1 */ + const void *p2) /*!< in: id2 */ { const fts_doc_freq_t *fq1 = (const fts_doc_freq_t *)p1; const fts_doc_freq_t *fq2 = (const fts_doc_freq_t *)p2; @@ -407,7 +394,6 @@ Print the table used for calculating LCS. */ static void fts_print_lcs_table( -/*================*/ const ulint* table, /*!< in: array to print */ ulint n_rows, /*!< in: total no. of rows */ ulint n_cols) /*!< in: total no. of cols */ @@ -432,7 +418,6 @@ the document. */ static ulint fts_query_lcs( -/*==========*/ /*!< out: LCS (length) between two ilists */ const ulint* p1, /*!< in: word positions of query */ @@ -489,14 +474,11 @@ fts_query_lcs( } #endif -/*******************************************************************/ /** - Compare two fts_ranking_t instance on their rank value and doc ids in +/** Compare two fts_ranking_t instance on their rank value and doc ids in descending order on the rank and ascending order on doc id. @return 0 if p1 == p2, < 0 if p1 < p2, > 0 if p1 > p2 */ -static int fts_query_compare_rank( - /*===================*/ - const void *p1, /*!< in: pointer to elem */ - const void *p2) /*!< in: pointer to elem */ +static int fts_query_compare_rank(const void *p1, /*!< in: pointer to elem */ + const void *p2) /*!< in: pointer to elem */ { const fts_ranking_t *r1 = (const fts_ranking_t *)p1; const fts_ranking_t *r2 = (const fts_ranking_t *)p2; @@ -516,10 +498,8 @@ static int fts_query_compare_rank( return (1); } -/*******************************************************************/ /** - Create words in ranking */ +/** Create words in ranking */ static void fts_ranking_words_create( - /*=====================*/ fts_query_t *query, /*!< in: query instance */ fts_ranking_t *ranking) /*!< in: ranking instance */ { @@ -547,10 +527,8 @@ two functions, we need to scan the bitmap 'words', and get a word when a bit is '1', then we get word_freq by the word. */ -/*******************************************************************/ /** - Add a word into ranking */ +/** Add a word into ranking */ static void fts_ranking_words_add( - /*==================*/ fts_query_t *query, /*!< in: query instance */ fts_ranking_t *ranking, /*!< in: ranking instance */ const fts_string_t *word) /*!< in: term/word to add */ @@ -606,11 +584,9 @@ static void fts_ranking_words_add( ranking->words[byte_offset] |= 1 << bit_offset; } -/*******************************************************************/ /** - Get a word from a ranking +/** Get a word from a ranking @return true if it's successful */ static bool fts_ranking_words_get_next( - /*=======================*/ const fts_query_t *query, /*!< in: query instance */ fts_ranking_t *ranking, /*!< in: ranking instance */ ulint *pos, /*!< in/out: word start pos */ @@ -642,12 +618,10 @@ static bool fts_ranking_words_get_next( return ret; } -/*******************************************************************/ /** - Add a word if it doesn't exist, to the term freq RB tree. We store +/** Add a word if it doesn't exist, to the term freq RB tree. We store a pointer to the word that is passed in as the argument. @return pointer to word */ static fts_word_freq_t *fts_query_add_word_freq( - /*====================*/ fts_query_t *query, /*!< in: query instance */ const fts_string_t *word) /*!< in: term/word to add */ { @@ -675,11 +649,9 @@ static fts_word_freq_t *fts_query_add_word_freq( return (rbt_value(fts_word_freq_t, parent.last)); } -/*******************************************************************/ /** - Add a doc id if it doesn't exist, to the doc freq RB tree. +/** Add a doc id if it doesn't exist, to the doc freq RB tree. @return pointer to word */ static fts_doc_freq_t *fts_query_add_doc_freq( - /*===================*/ fts_query_t *query, /*!< in: query instance */ ib_rbt_t *doc_freqs, /*!< in: rb tree of fts_doc_freq_t */ doc_id_t doc_id) /*!< in: doc id to add */ @@ -703,11 +675,9 @@ static fts_doc_freq_t *fts_query_add_doc_freq( return (rbt_value(fts_doc_freq_t, parent.last)); } -/*******************************************************************/ /** - Add the doc id to the query set only if it's not in the +/** Add the doc id to the query set only if it's not in the deleted array. */ static void fts_query_union_doc_id( - /*===================*/ fts_query_t *query, /*!< in: query instance */ doc_id_t doc_id, /*!< in: the doc id to add */ fts_rank_t rank) /*!< in: if non-zero, it is the @@ -733,11 +703,9 @@ static void fts_query_union_doc_id( } } -/*******************************************************************/ /** - Remove the doc id from the query set only if it's not in the +/** Remove the doc id from the query set only if it's not in the deleted set. */ static void fts_query_remove_doc_id( - /*====================*/ fts_query_t *query, /*!< in: query instance */ doc_id_t doc_id) /*!< in: the doc id to add */ { @@ -755,14 +723,12 @@ static void fts_query_remove_doc_id( } } -/*******************************************************************/ /** - Find the doc id in the query set but not in the deleted set, artificialy +/** Find the doc id in the query set but not in the deleted set, artificialy downgrade or upgrade its ranking by a value and make/initialize its ranking under or above its normal range 0 to 1. This is used for Boolean Search operator such as Negation operator, which makes word's contribution to the row's relevance to be negative */ static void fts_query_change_ranking( - /*====================*/ fts_query_t *query, /*!< in: query instance */ doc_id_t doc_id, /*!< in: the doc id to add */ ibool downgrade) /*!< in: Whether to downgrade ranking */ @@ -790,12 +756,10 @@ static void fts_query_change_ranking( } } -/*******************************************************************/ /** - Check the doc id in the query set only if it's not in the +/** Check the doc id in the query set only if it's not in the deleted array. The doc ids that were found are stored in another rb tree (fts_query_t::intersect). */ static void fts_query_intersect_doc_id( - /*=======================*/ fts_query_t *query, /*!< in: query instance */ doc_id_t doc_id, /*!< in: the doc id to add */ fts_rank_t rank) /*!< in: if non-zero, it is the @@ -867,10 +831,8 @@ static void fts_query_intersect_doc_id( } } -/*******************************************************************/ /** - Free the document ranking rb tree. */ +/** Free the document ranking rb tree. */ static void fts_query_free_doc_ids( - /*===================*/ fts_query_t *query, /*!< in: query instance */ ib_rbt_t *doc_ids) /*!< in: rb tree to free */ { @@ -897,11 +859,9 @@ static void fts_query_free_doc_ids( query->total_size -= SIZEOF_RBT_CREATE; } -/*******************************************************************/ /** - Add the word to the documents "list" of matching words from +/** Add the word to the documents "list" of matching words from the query. We make a copy of the word from the query heap. */ static void fts_query_add_word_to_document( - /*===========================*/ fts_query_t *query, /*!< in: query to update */ doc_id_t doc_id, /*!< in: the document to update */ const fts_string_t *word) /*!< in: the token to add */ @@ -929,10 +889,8 @@ static void fts_query_add_word_to_document( } } -/*******************************************************************/ /** - Check the node ilist. */ +/** Check the node ilist. */ static void fts_query_check_node( - /*=================*/ fts_query_t *query, /*!< in: query to update */ const fts_string_t *token, /*!< in: the token to search */ const fts_node_t *node) /*!< in: node to check */ @@ -960,11 +918,9 @@ static void fts_query_check_node( } } -/*****************************************************************/ /** - Search index cache for word with wildcard match. +/** Search index cache for word with wildcard match. @return number of words matched */ static ulint fts_cache_find_wildcard( - /*====================*/ fts_query_t *query, /*!< in: query instance */ const fts_index_cache_t *index_cache, /*!< in: cache to search */ const fts_string_t *token) /*!< in: token to search */ @@ -1046,13 +1002,11 @@ static ulint fts_cache_find_wildcard( return (num_word); } -/*****************************************************************/ /** - Set difference. +/** Set difference. @return DB_SUCCESS if all go well */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_query_difference( - /*=================*/ - fts_query_t *query, /*!< in: query instance */ - const fts_string_t *token) /*!< in: token to search */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + fts_query_difference(fts_query_t *query, /*!< in: query instance */ + const fts_string_t *token) /*!< in: token to search */ { ulint n_doc_ids = 0; trx_t *trx = query->trx; @@ -1139,11 +1093,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_query_difference( return (query->error); } -/*****************************************************************/ /** - Intersect the token doc ids with the current set. +/** Intersect the token doc ids with the current set. @return DB_SUCCESS if all go well */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_query_intersect( - /*================*/ fts_query_t *query, /*!< in: query instance */ const fts_string_t *token) /*!< in: the token to search */ { @@ -1269,11 +1221,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_query_intersect( return (query->error); } -/*****************************************************************/ /** - Query index cache. +/** Query index cache. @return DB_SUCCESS if all go well */ static dberr_t fts_query_cache( - /*============*/ fts_query_t *query, /*!< in/out: query instance */ const fts_string_t *token) /*!< in: token to search */ { @@ -1316,13 +1266,11 @@ static dberr_t fts_query_cache( return (query->error); } -/*****************************************************************/ /** - Set union. +/** Set union. @return DB_SUCCESS if all go well */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_query_union( - /*============*/ - fts_query_t *query, /*!< in: query instance */ - fts_string_t *token) /*!< in: token to search */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + fts_query_union(fts_query_t *query, /*!< in: query instance */ + fts_string_t *token) /*!< in: token to search */ { fts_fetch_t fetch; ulint n_doc_ids = 0; @@ -1383,12 +1331,10 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_query_union( return (query->error); } -/*****************************************************************/ /** - Depending upon the current query operator process the doc id. +/** Depending upon the current query operator process the doc id. return DB_SUCCESS if all go well or return DB_FTS_EXCEED_RESULT_CACHE_LIMIT */ static dberr_t fts_query_process_doc_id( - /*=====================*/ fts_query_t *query, /*!< in: query instance */ doc_id_t doc_id, /*!< in: doc id to process */ fts_rank_t rank) /*!< in: if non-zero, it is the @@ -1436,10 +1382,8 @@ static dberr_t fts_query_process_doc_id( } } -/*****************************************************************/ /** - Merge two result sets. */ +/** Merge two result sets. */ static dberr_t fts_merge_doc_ids( - /*==============*/ fts_query_t *query, /*!< in,out: query instance */ const ib_rbt_t *doc_ids) /*!< in: result set to merge */ { @@ -1491,14 +1435,11 @@ static dberr_t fts_merge_doc_ids( DBUG_RETURN(DB_SUCCESS); } -/*****************************************************************/ /** - Skip non-whitespace in a string. Move ptr to the next word boundary. +/** Skip non-whitespace in a string. Move ptr to the next word boundary. @return pointer to first whitespace character or end */ UNIV_INLINE -byte *fts_query_skip_word( - /*================*/ - byte *ptr, /*!< in: start of scan */ - const byte *end) /*!< in: pointer to end of string */ +byte *fts_query_skip_word(byte *ptr, /*!< in: start of scan */ + const byte *end) /*!< in: pointer to end of string */ { /* TODO: Does this have to be UTF-8 too ? */ while (ptr < end && !(ispunct(*ptr) || isspace(*ptr))) { @@ -1508,11 +1449,9 @@ byte *fts_query_skip_word( return (ptr); } -/*****************************************************************/ /** - Check whether the remaining terms in the phrase match the text. +/** Check whether the remaining terms in the phrase match the text. @return true if matched else false */ static ibool fts_query_match_phrase_terms( - /*=========================*/ fts_phrase_t *phrase, /*!< in: phrase to match */ byte **start, /*!< in/out: text to search, we can't make this const becase we need to @@ -1589,12 +1528,10 @@ static ibool fts_query_match_phrase_terms( return (phrase->found); } -/*****************************************************************/ /** - Callback function to count the number of words in position ranges, +/** Callback function to count the number of words in position ranges, and see whether the word count is in specified "phrase->distance" @return true if the number of characters is less than the "distance" */ static bool fts_proximity_is_word_in_range( - /*===========================*/ const fts_phrase_t *phrase, /*!< in: phrase with the search info */ byte *start, /*!< in: text to search */ ulint total_len) /*!< in: length of text */ @@ -1647,12 +1584,10 @@ static bool fts_proximity_is_word_in_range( return (false); } -/*****************************************************************/ /** - FTS plugin parser 'myql_add_word' callback function for phrase match +/** FTS plugin parser 'myql_add_word' callback function for phrase match Refer to 'MYSQL_FTPARSER_PARAM' for more detail. @return 0 if match, or return non-zero */ static int fts_query_match_phrase_add_word_for_parser( - /*=======================================*/ MYSQL_FTPARSER_PARAM *param, /*!< in: parser param */ char *word, /*!< in: token */ int word_len, /*!< in: token length */ @@ -1709,11 +1644,9 @@ static int fts_query_match_phrase_add_word_for_parser( return (static_cast(phrase->found)); } -/*****************************************************************/ /** - Check whether the terms in the phrase match the text. +/** Check whether the terms in the phrase match the text. @return true if matched else false */ static ibool fts_query_match_phrase_terms_by_parser( - /*===================================*/ fts_phrase_param_t *phrase_param, /* in/out: phrase param */ st_mysql_ftparser *parser, /* in: plugin fts parser */ byte *text, /* in: text to check */ @@ -1839,13 +1772,10 @@ static ibool fts_query_match_phrase(fts_phrase_t *phrase, byte *start, return (phrase->found); } -/*****************************************************************/ /** - Callback function to fetch and search the document. +/** Callback function to fetch and search the document. @return whether the phrase is found */ -static ibool fts_query_fetch_document( - /*=====================*/ - void *row, /*!< in: sel_node_t* */ - void *user_arg) /*!< in: fts_doc_t* */ +static ibool fts_query_fetch_document(void *row, /*!< in: sel_node_t* */ + void *user_arg) /*!< in: fts_doc_t* */ { que_node_t *exp; sel_node_t *node = static_cast(row); @@ -1948,7 +1878,6 @@ Callback function to check whether a record was found or not. */ static ibool fts_query_select( -/*=============*/ void* row, /*!< in: sel_node_t* */ void* user_arg) /*!< in: fts_doc_t* */ { @@ -2000,7 +1929,6 @@ doc id is between first and last doc id. static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_query_find_term( -/*================*/ fts_query_t* query, /*!< in: FTS query state */ que_t** graph, /*!< in: prepared statement */ const fts_string_t* word, /*!< in: the word to fetch */ @@ -2109,7 +2037,6 @@ Callback aggregator for int columns. */ static ibool fts_query_sum( -/*==========*/ /*!< out: always returns TRUE */ void* row, /*!< in: sel_node_t* */ void* user_arg) /*!< in: ulint* */ @@ -2142,7 +2069,6 @@ Calculate the total documents that contain a particular word (term). static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_query_total_docs_containing_term( -/*=================================*/ fts_query_t* query, /*!< in: FTS query state */ const fts_string_t* word, /*!< in: the word to check */ ulint* total) /*!< out: documents containing word */ @@ -2224,7 +2150,6 @@ Get the total number of words in a documents. static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_query_terms_in_document( -/*========================*/ fts_query_t* query, /*!< in: FTS query state */ doc_id_t doc_id, /*!< in: the word to check */ ulint* total) /*!< out: total words in document */ @@ -2301,11 +2226,9 @@ fts_query_terms_in_document( } #endif -/*****************************************************************/ /** - Retrieve the document and match the phrase tokens. +/** Retrieve the document and match the phrase tokens. @return DB_SUCCESS or error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_query_match_document( - /*=====================*/ ib_vector_t *tokens, /*!< in: phrase tokens */ fts_get_doc_t *get_doc, /*!< in: table and prepared statements */ fts_match_t *match, /*!< in: doc id and positions */ @@ -2340,12 +2263,10 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_query_match_document( return (error); } -/*****************************************************************/ /** - This function fetches the original documents and count the +/** This function fetches the original documents and count the words in between matching words to see that is in specified distance @return DB_SUCCESS if all OK */ static MY_ATTRIBUTE((warn_unused_result)) bool fts_query_is_in_proximity_range( - /*============================*/ const fts_query_t *query, /*!< in: query instance */ fts_match_t **match, /*!< in: query instance */ fts_proximity_t *qualified_pos) /*!< in: position info for @@ -2391,20 +2312,18 @@ static MY_ATTRIBUTE((warn_unused_result)) bool fts_query_is_in_proximity_range( return (err == DB_SUCCESS && phrase.found); } -/*****************************************************************/ /** - Iterate over the matched document ids and search the for the +/** Iterate over the matched document ids and search the for the actual phrase in the text. @return DB_SUCCESS if all OK */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_query_search_phrase( - /*====================*/ - fts_query_t *query, /*!< in: query instance */ - ib_vector_t *orig_tokens, /*!< in: tokens to search, - with any stopwords in the - original phrase */ - ib_vector_t *tokens) /*!< in: tokens that does - not include stopwords and - can be used to calculate - ranking */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + fts_query_search_phrase(fts_query_t *query, /*!< in: query instance */ + ib_vector_t *orig_tokens, /*!< in: tokens to search, + with any stopwords in the + original phrase */ + ib_vector_t *tokens) /*!< in: tokens that does + not include stopwords and + can be used to calculate + ranking */ { ulint i; fts_get_doc_t get_doc; @@ -2565,11 +2484,9 @@ static void fts_query_phrase_split(fts_query_t *query, } } -/*****************************************************************/ /** - Text/Phrase search. +/** Text/Phrase search. @return DB_SUCCESS or error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_query_phrase_search( - /*====================*/ fts_query_t *query, /*!< in: query instance */ const fts_ast_node_t *node) /*!< in: node to search */ { @@ -2738,13 +2655,11 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_query_phrase_search( return (query->error); } -/*****************************************************************/ /** - Find the word and evaluate. +/** Find the word and evaluate. @return DB_SUCCESS if all go well */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_query_execute( - /*==============*/ - fts_query_t *query, /*!< in: query instance */ - fts_string_t *token) /*!< in: token to search */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + fts_query_execute(fts_query_t *query, /*!< in: query instance */ + fts_string_t *token) /*!< in: token to search */ { switch (query->oper) { case FTS_NONE: @@ -2769,12 +2684,10 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_query_execute( return (query->error); } -/*****************************************************************/ /** - Create a wildcard string. It's the responsibility of the caller to +/** Create a wildcard string. It's the responsibility of the caller to free the byte* pointer. It's allocated using ut_malloc_nokey(). @return ptr to allocated memory */ static byte *fts_query_get_token( - /*================*/ fts_ast_node_t *node, /*!< in: the current sub tree */ fts_string_t *token) /*!< in: token to create */ { @@ -2803,10 +2716,8 @@ static byte *fts_query_get_token( return (new_ptr); } -/*****************************************************************/ /** - Visit every node of the AST. */ +/** Visit every node of the AST. */ static dberr_t fts_query_visitor( - /*==============*/ fts_ast_oper_t oper, /*!< in: current operator */ fts_ast_node_t *node, /*!< in: The root of the current subtree*/ void *arg) /*!< in: callback arg*/ @@ -2959,7 +2870,6 @@ Check if the doc id exists in the ilist. static ulint fts_query_find_doc_id( -/*==================*/ fts_select_t* select, /*!< in/out: contains the doc id to find, we update the word freq if document found */ @@ -3024,12 +2934,10 @@ fts_query_find_doc_id( } #endif -/*****************************************************************/ /** - Read and filter nodes. +/** Read and filter nodes. @return DB_SUCCESS if all go well, or return DB_FTS_EXCEED_RESULT_CACHE_LIMIT */ static dberr_t fts_query_filter_doc_ids( - /*=====================*/ fts_query_t *query, /*!< in: query instance */ const fts_string_t *word, /*!< in: the current word */ fts_word_freq_t *word_freq, /*!< in/out: word frequency */ @@ -3149,11 +3057,9 @@ static dberr_t fts_query_filter_doc_ids( } } -/*****************************************************************/ /** - Read the FTS INDEX row. +/** Read the FTS INDEX row. @return DB_SUCCESS if all go well. */ static dberr_t fts_query_read_node( - /*================*/ fts_query_t *query, /*!< in: query instance */ const fts_string_t *word, /*!< in: current word */ que_node_t *exp) /*!< in: query graph node */ @@ -3255,11 +3161,9 @@ static dberr_t fts_query_read_node( return error; } -/*****************************************************************/ /** - Callback function to fetch the rows in an FTS INDEX record. +/** Callback function to fetch the rows in an FTS INDEX record. @return always returns true */ static ibool fts_query_index_fetch_nodes( - /*========================*/ void *row, /*!< in: sel_node_t* */ void *user_arg) /*!< in: pointer to fts_fetch_t */ { @@ -3288,11 +3192,8 @@ static ibool fts_query_index_fetch_nodes( } } -/*****************************************************************/ /** - Calculate the inverse document frequency (IDF) for all the terms. */ -static void fts_query_calculate_idf( - /*====================*/ - fts_query_t *query) /*!< in: Query state */ +/** Calculate the inverse document frequency (IDF) for all the terms. */ +static void fts_query_calculate_idf(fts_query_t *query) /*!< in: Query state */ { const ib_rbt_node_t *node; ib_uint64_t total_docs = query->total_docs; @@ -3326,10 +3227,8 @@ static void fts_query_calculate_idf( } } -/*****************************************************************/ /** - Calculate the ranking of the document. */ +/** Calculate the ranking of the document. */ static void fts_query_calculate_ranking( - /*========================*/ const fts_query_t *query, /*!< in: query state */ fts_ranking_t *ranking) /*!< in: Document to rank */ { @@ -3368,10 +3267,8 @@ static void fts_query_calculate_ranking( } } -/*****************************************************************/ /** - Add ranking to the result set. */ +/** Add ranking to the result set. */ static void fts_query_add_ranking( - /*==================*/ fts_query_t *query, /*!< in: query state */ ib_rbt_t *ranking_tree, /*!< in: ranking tree */ const fts_ranking_t *new_ranking) /*!< in: ranking of a document */ @@ -3394,12 +3291,10 @@ static void fts_query_add_ranking( } } -/*****************************************************************/ /** - Retrieve the FTS Relevance Ranking result for doc with doc_id +/** Retrieve the FTS Relevance Ranking result for doc with doc_id @return the relevance ranking value, 0 if no ranking value present. */ float fts_retrieve_ranking( - /*=================*/ fts_result_t *result, /*!< in: FTS result structure */ doc_id_t doc_id) /*!< in: doc_id of the item to retrieve */ { @@ -3426,10 +3321,8 @@ float fts_retrieve_ranking( DBUG_RETURN(0); } -/*****************************************************************/ /** - Create the result and copy the data to it. */ +/** Create the result and copy the data to it. */ static fts_result_t *fts_query_prepare_result( - /*=====================*/ fts_query_t *query, /*!< in: Query state */ fts_result_t *result) /*!< in: result this can contain data from a previous search on @@ -3544,10 +3437,8 @@ static fts_result_t *fts_query_prepare_result( DBUG_RETURN(result); } -/*****************************************************************/ /** - Get the result of the query. Calculate the similarity coefficient. */ +/** Get the result of the query. Calculate the similarity coefficient. */ static fts_result_t *fts_query_get_result( - /*=================*/ fts_query_t *query, /*!< in: query instance */ fts_result_t *result) /*!< in: result */ { @@ -3564,11 +3455,8 @@ static fts_result_t *fts_query_get_result( DBUG_RETURN(result); } -/*****************************************************************/ /** - FTS Query free resources and reset. */ -static void fts_query_free( - /*===========*/ - fts_query_t *query) /*!< in: query instance to free*/ +/** FTS Query free resources and reset. */ +static void fts_query_free(fts_query_t *query) /*!< in: query instance to free*/ { if (query->read_nodes_graph) { fts_que_graph_free(query->read_nodes_graph); @@ -3630,11 +3518,9 @@ static void fts_query_free( memset(query, 0, sizeof(*query)); } -/*****************************************************************/ /** - Parse the query using flex/bison or plugin parser. +/** Parse the query using flex/bison or plugin parser. @return parse tree node. */ static fts_ast_node_t *fts_query_parse( - /*============*/ fts_query_t *query, /*!< in: query instance */ byte *query_str, /*!< in: query string */ ulint query_len) /*!< in: query string length */ @@ -3678,11 +3564,9 @@ static fts_ast_node_t *fts_query_parse( DBUG_RETURN(state.root); } -/*******************************************************************/ /** - FTS Query optimization +/** FTS Query optimization Set FTS_OPT_RANKING if it is a simple term query */ static void fts_query_can_optimize( - /*===================*/ fts_query_t *query, /*!< in/out: query instance */ uint flags) /*!< In: FTS search mode */ { @@ -3905,10 +3789,8 @@ dberr_t fts_query(trx_t *trx, dict_index_t *index, uint flags, return (error); } -/*****************************************************************/ /** - FTS Query free result, returned by fts_query(). */ +/** FTS Query free result, returned by fts_query(). */ void fts_query_free_result( - /*==================*/ fts_result_t *result) /*!< in: result instance to free.*/ { if (result) { @@ -3926,10 +3808,8 @@ void fts_query_free_result( } } -/*****************************************************************/ /** - FTS Query sort result, returned by fts_query() on fts_ranking_t::rank. */ +/** FTS Query sort result, returned by fts_query() on fts_ranking_t::rank. */ void fts_query_sort_result_on_rank( - /*==========================*/ fts_result_t *result) /*!< out: result instance to sort.*/ { const ib_rbt_node_t *node; @@ -3960,10 +3840,8 @@ void fts_query_sort_result_on_rank( result->rankings_by_rank = ranked; } -/*******************************************************************/ /** - A debug function to print result doc_id set. */ +/** A debug function to print result doc_id set. */ static void fts_print_doc_id( - /*=============*/ fts_query_t *query) /*!< in : tree that stores doc_ids.*/ { const ib_rbt_node_t *node; @@ -3985,16 +3863,14 @@ static void fts_print_doc_id( } } -/*************************************************************/ /** - This function implements a simple "blind" query expansion search: +/** This function implements a simple "blind" query expansion search: words in documents found in the first search pass will be used as search arguments to search the document again, thus "expand" the search result set. @return DB_SUCCESS if success, otherwise the error code */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_expand_query( - /*=============*/ - dict_index_t *index, /*!< in: FTS index to search */ - fts_query_t *query) /*!< in: FTS query instance */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + fts_expand_query(dict_index_t *index, /*!< in: FTS index to search */ + fts_query_t *query) /*!< in: FTS query instance */ { const ib_rbt_node_t *node; const ib_rbt_node_t *token_node; @@ -4109,14 +3985,12 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t fts_expand_query( return (error); } -/*************************************************************/ /** - This function finds documents that contain all words in a +/** This function finds documents that contain all words in a phrase or proximity search. And if proximity search, verify the words are close enough to each other, as in specified distance. This function is called for phrase and proximity search. @return true if documents are found, false if otherwise */ static ibool fts_phrase_or_proximity_search( - /*===========================*/ fts_query_t *query, /*!< in/out: query instance. query->doc_ids might be instantiated with qualified doc IDs */ @@ -4233,15 +4107,13 @@ static ibool fts_phrase_or_proximity_search( return (matched); } -/*************************************************************/ /** - This function checks whether words in result documents are close to +/** This function checks whether words in result documents are close to each other (within proximity range as specified by "distance"). If "distance" is MAX_ULINT, then it will find all combinations of positions of matching words and store min and max positions in the "qualified_pos" for later verification. @return true if words are close to each other, false if otherwise */ static bool fts_proximity_get_positions( - /*========================*/ fts_match_t **match, /*!< in: query instance */ ulint num_match, /*!< in: number of matching items */ diff --git a/storage/innobase/fts/fts0sql.cc b/storage/innobase/fts/fts0sql.cc index 4c3aa56ccd6b..06331dcce5e4 100644 --- a/storage/innobase/fts/fts0sql.cc +++ b/storage/innobase/fts/fts0sql.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file fts/fts0sql.cc +/** @file fts/fts0sql.cc Full Text Search functionality. Created 2007-03-27 Sunny Bains @@ -55,11 +54,9 @@ static const char *fts_sql_end = "\n" "END;\n"; -/******************************************************************/ /** - Get the table id. +/** Get the table id. @return number of bytes written */ int fts_get_table_id( - /*=============*/ const fts_table_t *fts_table, /*!< in: FTS Auxiliary table */ char *table_id) /*!< out: table id, must be at least FTS_AUX_MIN_TABLE_ID_LENGTH bytes @@ -131,11 +128,9 @@ static char *fts_get_table_name_prefix_low(const fts_table_t *fts_table, return (prefix_name); } -/******************************************************************/ /** - Construct the prefix name of an FTS table. +/** Construct the prefix name of an FTS table. @return own: table name, must be freed with ut_free() */ char *fts_get_table_name_prefix( - /*======================*/ const fts_table_t *fts_table) /*!< in: Auxiliary table type */ { return (fts_get_table_name_prefix_low(fts_table, false)); @@ -171,15 +166,12 @@ static void fts_get_table_name_low(const fts_table_t *fts_table, ut_free(prefix_name); } -/******************************************************************/ /** - Construct the name of an ancillary FTS table for the given table. +/** Construct the name of an ancillary FTS table for the given table. Caller must allocate enough memory(usually size of MAX_FULL_NAME_LEN) for param 'table_name'. */ -void fts_get_table_name( - /*===============*/ - const fts_table_t *fts_table, - /*!< in: Auxiliary table type */ - char *table_name) +void fts_get_table_name(const fts_table_t *fts_table, + /*!< in: Auxiliary table type */ + char *table_name) /*!< in/out: aux table name */ { fts_get_table_name_low(fts_table, table_name, false); @@ -194,11 +186,9 @@ void fts_get_table_name_5_7(const fts_table_t *fts_table, char *table_name) { fts_get_table_name_low(fts_table, table_name, true); } -/******************************************************************/ /** - Parse an SQL string. +/** Parse an SQL string. @return query graph */ que_t *fts_parse_sql( - /*==========*/ fts_table_t *fts_table, /*!< in: FTS auxiliarry table info */ pars_info_t *info, /*!< in: info struct, or NULL */ const char *sql) /*!< in: SQL string to evaluate */ @@ -244,13 +234,10 @@ que_t *fts_parse_sql( return (graph); } -/******************************************************************/ /** - Evaluate an SQL query graph. +/** Evaluate an SQL query graph. @return DB_SUCCESS or error code */ -dberr_t fts_eval_sql( - /*=========*/ - trx_t *trx, /*!< in: transaction */ - que_t *graph) /*!< in: Query graph to evaluate */ +dberr_t fts_eval_sql(trx_t *trx, /*!< in: transaction */ + que_t *graph) /*!< in: Query graph to evaluate */ { que_thr_t *thr; @@ -264,8 +251,7 @@ dberr_t fts_eval_sql( return (trx->error_state); } -/******************************************************************/ /** - Construct the column specification part of the SQL string for selecting the +/** Construct the column specification part of the SQL string for selecting the indexed FTS columns for the given table. Adds the necessary bound ids to the given 'info' and returns the SQL string. Examples: @@ -280,7 +266,6 @@ dberr_t fts_eval_sql( info/ids: sel0 -> "subject", sel1 -> "content", @return heap-allocated WHERE string */ const char *fts_get_select_columns_str( - /*=======================*/ dict_index_t *index, /*!< in: index */ pars_info_t *info, /*!< in/out: parser info */ mem_heap_t *heap) /*!< in: memory heap */ @@ -304,12 +289,9 @@ const char *fts_get_select_columns_str( return (str); } -/******************************************************************/ /** - Commit a transaction. +/** Commit a transaction. @return DB_SUCCESS or error code */ -dberr_t fts_sql_commit( - /*===========*/ - trx_t *trx) /*!< in: transaction */ +dberr_t fts_sql_commit(trx_t *trx) /*!< in: transaction */ { dberr_t error; @@ -321,12 +303,9 @@ dberr_t fts_sql_commit( return (DB_SUCCESS); } -/******************************************************************/ /** - Rollback a transaction. +/** Rollback a transaction. @return DB_SUCCESS or error code */ -dberr_t fts_sql_rollback( - /*=============*/ - trx_t *trx) /*!< in: transaction */ +dberr_t fts_sql_rollback(trx_t *trx) /*!< in: transaction */ { return (trx_rollback_to_savepoint(trx, NULL)); } diff --git a/storage/innobase/fut/fut0lst.cc b/storage/innobase/fut/fut0lst.cc index 2e24db9f1b2b..40a2be06dd10 100644 --- a/storage/innobase/fut/fut0lst.cc +++ b/storage/innobase/fut/fut0lst.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file fut/fut0lst.cc +/** @file fut/fut0lst.cc File-based list utilities Created 11/28/1995 Heikki Tuuri @@ -37,10 +36,8 @@ this program; if not, write to the Free Software Foundation, Inc., #include "my_inttypes.h" #include "page0page.h" -/********************************************************************/ /** - Adds a node to an empty list. */ +/** Adds a node to an empty list. */ static void flst_add_to_empty( - /*==============*/ flst_base_node_t *base, /*!< in: pointer to base node of empty list */ flst_node_t *node, /*!< in: node to add */ @@ -73,27 +70,21 @@ static void flst_add_to_empty( mlog_write_ulint(base + FLST_LEN, len + 1, MLOG_4BYTES, mtr); } -/********************************************************************/ /** - Inserts a node after another in a list. */ +/** Inserts a node after another in a list. */ void flst_insert_after( - /*==============*/ flst_base_node_t *base, /*!< in: pointer to base node of list */ flst_node_t *node1, /*!< in: node to insert after */ flst_node_t *node2, /*!< in: node to add */ mtr_t *mtr); /*!< in: mini-transaction handle */ -/********************************************************************/ /** - Inserts a node before another in a list. */ +/** Inserts a node before another in a list. */ void flst_insert_before( - /*===============*/ flst_base_node_t *base, /*!< in: pointer to base node of list */ flst_node_t *node2, /*!< in: node to insert */ flst_node_t *node3, /*!< in: node to insert before */ mtr_t *mtr); /*!< in: mini-transaction handle */ -/********************************************************************/ /** - Adds a node as the last node in a list. */ +/** Adds a node as the last node in a list. */ void flst_add_last( - /*==========*/ flst_base_node_t *base, /*!< in: pointer to base node of list */ flst_node_t *node, /*!< in: node to add */ mtr_t *mtr) /*!< in: mini-transaction handle */ @@ -136,10 +127,8 @@ void flst_add_last( } } -/********************************************************************/ /** - Adds a node as the first node in a list. */ +/** Adds a node as the first node in a list. */ void flst_add_first( - /*===========*/ flst_base_node_t *base, /*!< in: pointer to base node of list */ flst_node_t *node, /*!< in: node to add */ mtr_t *mtr) /*!< in: mini-transaction handle */ @@ -181,10 +170,8 @@ void flst_add_first( } } -/********************************************************************/ /** - Inserts a node after another in a list. */ +/** Inserts a node after another in a list. */ void flst_insert_after( - /*==============*/ flst_base_node_t *base, /*!< in: pointer to base node of list */ flst_node_t *node1, /*!< in: node to insert after */ flst_node_t *node2, /*!< in: node to add */ @@ -239,10 +226,8 @@ void flst_insert_after( mlog_write_ulint(base + FLST_LEN, len + 1, MLOG_4BYTES, mtr); } -/********************************************************************/ /** - Inserts a node before another in a list. */ +/** Inserts a node before another in a list. */ void flst_insert_before( - /*===============*/ flst_base_node_t *base, /*!< in: pointer to base node of list */ flst_node_t *node2, /*!< in: node to insert */ flst_node_t *node3, /*!< in: node to insert before */ @@ -297,10 +282,8 @@ void flst_insert_before( mlog_write_ulint(base + FLST_LEN, len + 1, MLOG_4BYTES, mtr); } -/********************************************************************/ /** - Removes a node. */ +/** Removes a node. */ void flst_remove( - /*========*/ flst_base_node_t *base, /*!< in: pointer to base node of list */ flst_node_t *node2, /*!< in: node to remove */ mtr_t *mtr) /*!< in: mini-transaction handle */ @@ -370,11 +353,9 @@ void flst_remove( mlog_write_ulint(base + FLST_LEN, len - 1, MLOG_4BYTES, mtr); } -/********************************************************************/ /** - Validates a file-based list. +/** Validates a file-based list. @return true if ok */ ibool flst_validate( - /*==========*/ const flst_base_node_t *base, /*!< in: pointer to base node of list */ mtr_t *mtr1) /*!< in: mtr */ { diff --git a/storage/innobase/gis/gis0geo.cc b/storage/innobase/gis/gis0geo.cc index 2108fa81f100..3c54bfd5d4c2 100644 --- a/storage/innobase/gis/gis0geo.cc +++ b/storage/innobase/gis/gis0geo.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2013, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file gis/gis0geo.cc +/** @file gis/gis0geo.cc InnoDB R-tree related functions. Created 2013/03/27 Allen Lai and Jimmy Yang @@ -38,21 +37,16 @@ namespace dd { class Spatial_reference_system; } -/*************************************************************/ /** - Copy mbr of dimension n_dim from src to dst. */ -inline static void copy_coords( - /*========*/ - double *dst, /*!< in/out: destination. */ - const double *src, /*!< in: source. */ - int n_dim) /*!< in: dimensions. */ +/** Copy mbr of dimension n_dim from src to dst. */ +inline static void copy_coords(double *dst, /*!< in/out: destination. */ + const double *src, /*!< in: source. */ + int n_dim) /*!< in: dimensions. */ { memcpy(dst, src, DATA_MBR_LEN); } -/*************************************************************/ /** - Select two nodes to collect group upon */ +/** Select two nodes to collect group upon */ static void pick_seeds( - /*=======*/ rtr_split_node_t *node, /*!< in: split nodes. */ int n_entries, /*!< in: entries number. */ rtr_split_node_t **seed_a, /*!< out: seed 1. */ @@ -84,12 +78,9 @@ static void pick_seeds( } } -/*********************************************************/ /** - Generates a random iboolean value. +/** Generates a random iboolean value. @return the random value */ -static ibool ut_rnd_gen_ibool(void) -/*=================*/ -{ +static ibool ut_rnd_gen_ibool(void) { ulint x; x = ut_rnd_gen_ulint(); @@ -101,10 +92,8 @@ static ibool ut_rnd_gen_ibool(void) return (FALSE); } -/*************************************************************/ /** - Select next node and group where to add. */ +/** Select next node and group where to add. */ static void pick_next( - /*======*/ rtr_split_node_t *node, /*!< in: split nodes. */ int n_entries, /*!< in: entries number. */ double *g1, /*!< in: mbr of group 1. */ @@ -145,10 +134,8 @@ static void pick_next( } } -/*************************************************************/ /** - Mark not-in-group entries as n_group. */ +/** Mark not-in-group entries as n_group. */ static void mark_all_entries( - /*=============*/ rtr_split_node_t *node, /*!< in/out: split nodes. */ int n_entries, /*!< in: entries number. */ int n_group) /*!< in: group number. */ @@ -163,11 +150,9 @@ static void mark_all_entries( } } -/*************************************************************/ /** - Split rtree node. +/** Split rtree node. Return which group the first rec is in. */ int split_rtree_node( - /*=============*/ rtr_split_node_t *node, /*!< in: split nodes. */ int n_entries, /*!< in: entries number. */ int all_size, /*!< in: total key's size. */ diff --git a/storage/innobase/gis/gis0rtree.cc b/storage/innobase/gis/gis0rtree.cc index 10f652cb716f..9fcd44ee9bb9 100644 --- a/storage/innobase/gis/gis0rtree.cc +++ b/storage/innobase/gis/gis0rtree.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2016, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2016, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file gis/gis0rtree.cc +/** @file gis/gis0rtree.cc InnoDB R-tree interfaces Created 2013/03/27 Allen Lai and Jimmy Yang @@ -53,11 +52,9 @@ this program; if not, write to the Free Software Foundation, Inc., #include "srv0mon.h" #include "trx0trx.h" -/*************************************************************/ /** - Initial split nodes info for R-tree split. +/** Initial split nodes info for R-tree split. @return initialized split nodes array */ static rtr_split_node_t *rtr_page_split_initialize_nodes( - /*============================*/ mem_heap_t *heap, /*!< in: pointer to memory heap, or NULL */ btr_cur_t *cursor, /*!< in: cursor at which to insert; when the function returns, the cursor is positioned @@ -128,13 +125,11 @@ static rtr_split_node_t *rtr_page_split_initialize_nodes( return split_node_array; } -/**********************************************************************/ /** - Builds a Rtree node pointer out of a physical record and a page number. +/** Builds a Rtree node pointer out of a physical record and a page number. Note: For Rtree, we just keep the mbr and page no field in non-leaf level page. It's different with Btree, Btree still keeps PK fields so far. @return own: node pointer */ dtuple_t *rtr_index_build_node_ptr( - /*=====================*/ const dict_index_t *index, /*!< in: index */ const rtr_mbr_t *mbr, /*!< in: mbr of lower page */ const rec_t *rec, /*!< in: record for which to build node @@ -192,11 +187,9 @@ dtuple_t *rtr_index_build_node_ptr( return (tuple); } -/**************************************************************/ /** - In-place update the mbr field of a spatial index row. +/** In-place update the mbr field of a spatial index row. @return true if update is successful */ static bool rtr_update_mbr_field_in_place( - /*==========================*/ dict_index_t *index, /*!< in: spatial index. */ rec_t *rec, /*!< in/out: rec to be modified.*/ ulint *offsets, /*!< in/out: offsets on rec. */ @@ -264,11 +257,9 @@ static bool rtr_update_mbr_field_in_place( return (true); } -/**************************************************************/ /** - Update the mbr field of a spatial index row. +/** Update the mbr field of a spatial index row. @return true if update is successful */ bool rtr_update_mbr_field( - /*=================*/ btr_cur_t *cursor, /*!< in/out: cursor pointed to rec.*/ ulint *offsets, /*!< in/out: offsets on rec. */ btr_cur_t *cursor2, /*!< in/out: cursor pointed to rec @@ -576,10 +567,8 @@ bool rtr_update_mbr_field( return (true); } -/**************************************************************/ /** - Update parent page's MBR and Predicate lock information during a split */ +/** Update parent page's MBR and Predicate lock information during a split */ static void rtr_adjust_upper_level( - /*===================*/ btr_cur_t *sea_cur, /*!< in: search cursor */ ulint flags, /*!< in: undo logging and locking flags */ @@ -736,8 +725,7 @@ static void rtr_adjust_upper_level( btr_page_set_next(new_page, new_page_zip, next_page_no, mtr); } -/*************************************************************/ /** - Moves record list to another page for rtree splitting. +/** Moves record list to another page for rtree splitting. IMPORTANT: The caller will have to update IBUF_BITMAP_FREE if new_block is a compressed leaf page in a secondary index. @@ -746,7 +734,6 @@ static void rtr_adjust_upper_level( @return true on success; false on compression failure */ static ibool rtr_split_page_move_rec_list( - /*=========================*/ rtr_split_node_t *node_array, /*!< in: split node array. */ int first_rec_group, /*!< in: group number of the first rec. */ @@ -891,8 +878,7 @@ static ibool rtr_split_page_move_rec_list( return (true); } -/*************************************************************/ /** - Splits an R-tree index page to halves and inserts the tuple. It is assumed +/** Splits an R-tree index page to halves and inserts the tuple. It is assumed that mtr holds an x-latch to the index tree. NOTE: the tree x-latch is released within this function! NOTE that the operation of this function must always succeed, we cannot reverse it: therefore enough @@ -900,7 +886,6 @@ static ibool rtr_split_page_move_rec_list( this function is called. @return inserted record */ rec_t *rtr_page_split_and_insert( - /*======================*/ ulint flags, /*!< in: undo logging and locking flags */ btr_cur_t *cursor, /*!< in/out: cursor at which to insert; when the function returns, the cursor is positioned @@ -1218,14 +1203,11 @@ rec_t *rtr_page_split_and_insert( return (rec); } -/****************************************************************/ /** - Following the right link to find the proper block for insert. +/** Following the right link to find the proper block for insert. @return the proper block.*/ -dberr_t rtr_ins_enlarge_mbr( - /*================*/ - btr_cur_t *btr_cur, /*!< in: btr cursor */ - que_thr_t *thr, /*!< in: query thread */ - mtr_t *mtr) /*!< in: mtr */ +dberr_t rtr_ins_enlarge_mbr(btr_cur_t *btr_cur, /*!< in: btr cursor */ + que_thr_t *thr, /*!< in: query thread */ + mtr_t *mtr) /*!< in: mtr */ { dberr_t err = DB_SUCCESS; rtr_mbr_t new_mbr; @@ -1290,8 +1272,7 @@ dberr_t rtr_ins_enlarge_mbr( return (err); } -/*************************************************************/ /** - Copy recs from a page to new_block of rtree. +/** Copy recs from a page to new_block of rtree. Differs from page_copy_rec_list_end, because this function does not touch the lock table and max trx id on page or compress the page. @@ -1300,7 +1281,6 @@ dberr_t rtr_ins_enlarge_mbr( This has to be done either within the same mini-transaction, or by invoking ibuf_reset_free_bits() before mtr_commit(). */ void rtr_page_copy_rec_list_end_no_locks( - /*================================*/ buf_block_t *new_block, /*!< in: index page to copy to */ buf_block_t *block, /*!< in: index page of rec */ rec_t *rec, /*!< in: record on page */ @@ -1417,10 +1397,8 @@ void rtr_page_copy_rec_list_end_no_locks( *num_moved = moved; } -/*************************************************************/ /** - Copy recs till a specified rec from a page to new_block of rtree. */ +/** Copy recs till a specified rec from a page to new_block of rtree. */ void rtr_page_copy_rec_list_start_no_locks( - /*==================================*/ buf_block_t *new_block, /*!< in: index page to copy to */ buf_block_t *block, /*!< in: index page of rec */ rec_t *rec, /*!< in: record on page */ @@ -1529,18 +1507,15 @@ void rtr_page_copy_rec_list_start_no_locks( *num_moved = moved; } -/****************************************************************/ /** - Check two MBRs are identical or need to be merged */ -bool rtr_merge_mbr_changed( - /*==================*/ - btr_cur_t *cursor, /*!< in/out: cursor */ - btr_cur_t *cursor2, /*!< in: the other cursor */ - ulint *offsets, /*!< in: rec offsets */ - ulint *offsets2, /*!< in: rec offsets */ - rtr_mbr_t *new_mbr, /*!< out: MBR to update */ - buf_block_t *merge_block, /*!< in: page to merge */ - buf_block_t *block, /*!< in: page be merged */ - dict_index_t *index) /*!< in: index */ +/** Check two MBRs are identical or need to be merged */ +bool rtr_merge_mbr_changed(btr_cur_t *cursor, /*!< in/out: cursor */ + btr_cur_t *cursor2, /*!< in: the other cursor */ + ulint *offsets, /*!< in: rec offsets */ + ulint *offsets2, /*!< in: rec offsets */ + rtr_mbr_t *new_mbr, /*!< out: MBR to update */ + buf_block_t *merge_block, /*!< in: page to merge */ + buf_block_t *block, /*!< in: page be merged */ + dict_index_t *index) /*!< in: index */ { double *mbr; double mbr1[SPDIMS * 2]; @@ -1575,10 +1550,8 @@ bool rtr_merge_mbr_changed( return (changed); } -/****************************************************************/ /** - Merge 2 mbrs and update the the mbr that cursor is on. */ +/** Merge 2 mbrs and update the the mbr that cursor is on. */ dberr_t rtr_merge_and_update_mbr( - /*=====================*/ btr_cur_t *cursor, /*!< in/out: cursor */ btr_cur_t *cursor2, /*!< in: the other cursor */ ulint *offsets, /*!< in: rec offsets */ @@ -1612,10 +1585,8 @@ dberr_t rtr_merge_and_update_mbr( return (err); } -/*************************************************************/ /** - Deletes on the upper level the node pointer to a page. */ +/** Deletes on the upper level the node pointer to a page. */ void rtr_node_ptr_delete( - /*================*/ dict_index_t *index, /*!< in: index tree */ btr_cur_t *cursor, /*!< in: search cursor, contains information about parent nodes in search */ @@ -1634,11 +1605,9 @@ void rtr_node_ptr_delete( } } -/**************************************************************/ /** - Check whether a Rtree page is child of a parent page +/** Check whether a Rtree page is child of a parent page @return true if there is child/parent relationship */ bool rtr_check_same_block( - /*================*/ dict_index_t *index, /*!< in: index tree */ btr_cur_t *cursor, /*!< in/out: position at the parent entry pointing to the child if successful */ @@ -1666,11 +1635,9 @@ bool rtr_check_same_block( return (false); } -/****************************************************************/ /** - Calculate the area increased for a new record +/** Calculate the area increased for a new record @return area increased */ double rtr_rec_cal_increase( - /*=================*/ const dtuple_t *dtuple, /*!< in: data tuple to insert, which cause area increase */ const rec_t *rec, /*!< in: physical record which differs from diff --git a/storage/innobase/gis/gis0sea.cc b/storage/innobase/gis/gis0sea.cc index 3c618a090f96..a159ae164436 100644 --- a/storage/innobase/gis/gis0sea.cc +++ b/storage/innobase/gis/gis0sea.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file gis/gis0sea.cc +/** @file gis/gis0sea.cc InnoDB R-tree search interfaces Created 2014/01/16 Jimmy Yang @@ -57,11 +56,9 @@ static bool rtr_cur_restore_position( ulint level, /*!< in: index level */ mtr_t *mtr); /*!< in: mtr */ -/*************************************************************/ /** - Pop out used parent path entry, until we find the parent with matching +/** Pop out used parent path entry, until we find the parent with matching page number */ static void rtr_adjust_parent_path( - /*===================*/ rtr_info_t *rtr_info, /* R-Tree info struct */ page_no_t page_no) /* page number to look for */ { @@ -79,12 +76,10 @@ static void rtr_adjust_parent_path( } } -/*************************************************************/ /** - Find the next matching record. This function is used by search +/** Find the next matching record. This function is used by search or record locating during index delete/update. @return true if there is suitable record found, otherwise false */ static bool rtr_pcur_getnext_from_path( - /*=======================*/ const dtuple_t *tuple, /*!< in: data tuple */ page_cur_mode_t mode, /*!< in: cursor search mode */ btr_cur_t *btr_cur, /*!< in: persistent cursor; NOTE that the @@ -475,11 +470,9 @@ bool rtr_pcur_move_to_next(const dtuple_t *tuple, page_cur_mode_t mode, cursor->latch_mode, false, mtr)); } -/*************************************************************/ /** - Check if the cursor holds record pointing to the specified child page +/** Check if the cursor holds record pointing to the specified child page @return true if it is (pointing to the child page) false otherwise */ static bool rtr_compare_cursor_rec( - /*===================*/ dict_index_t *index, /*!< in: index */ btr_cur_t *cursor, /*!< in: Cursor to check */ page_no_t page_no, /*!< in: desired child page number */ @@ -495,11 +488,9 @@ static bool rtr_compare_cursor_rec( return (btr_node_ptr_get_child_page_no(rec, offsets) == page_no); } -/**************************************************************/ /** - Initializes and opens a persistent cursor to an index tree. It should be +/** Initializes and opens a persistent cursor to an index tree. It should be closed with btr_pcur_close. Mainly called by row_search_index_entry() */ void rtr_pcur_open_low( - /*==============*/ dict_index_t *index, /*!< in: index */ ulint level, /*!< in: level in the rtree */ const dtuple_t *tuple, /*!< in: tuple on which search done */ @@ -710,12 +701,10 @@ void rtr_page_get_father(dict_index_t *index, buf_block_t *block, mtr_t *mtr, mem_heap_free(heap); } -/************************************************************/ /** - Returns the father block to a page. It is assumed that mtr holds +/** Returns the father block to a page. It is assumed that mtr holds an X or SX latch on the tree. @return rec_get_offsets() of the node pointer record */ ulint *rtr_page_get_father_block( - /*======================*/ ulint *offsets, /*!< in: work area for the return value */ mem_heap_t *heap, /*!< in: memory heap to use */ dict_index_t *index, /*!< in: b-tree index */ @@ -733,11 +722,9 @@ ulint *rtr_page_get_father_block( return (rtr_page_get_father_node_ptr(offsets, heap, sea_cur, cursor, mtr)); } -/********************************************************************/ /** - Returns the upper level node pointer to a R-Tree page. It is assumed +/** Returns the upper level node pointer to a R-Tree page. It is assumed that mtr holds an x-latch on the tree. */ void rtr_get_father_node( - /*================*/ dict_index_t *index, /*!< in: index */ ulint level, /*!< in: the tree level of search */ const dtuple_t *tuple, /*!< in: data tuple; NOTE: n_fields_cmp in @@ -836,8 +823,7 @@ void rtr_get_father_node( } } -/*******************************************************************/ /** - Create a RTree search info structure */ +/** Create a RTree search info structure */ rtr_info_t *rtr_create_rtr_info( /******************/ bool need_prdt, /*!< in: Whether predicate lock @@ -884,8 +870,7 @@ rtr_info_t *rtr_create_rtr_info( return (rtr_info); } -/*******************************************************************/ /** - Update a btr_cur_t with rtr_info */ +/** Update a btr_cur_t with rtr_info */ void rtr_info_update_btr( /******************/ btr_cur_t *cursor, /*!< in/out: tree cursor */ @@ -897,8 +882,7 @@ void rtr_info_update_btr( cursor->rtr_info = rtr_info; } -/*******************************************************************/ /** - Initialize a R-Tree Search structure */ +/** Initialize a R-Tree Search structure */ void rtr_init_rtr_info( /****************/ rtr_info_t *rtr_info, /*!< in: rtr_info to set to the @@ -951,12 +935,9 @@ void rtr_init_rtr_info( mutex_exit(&index->rtr_track->rtr_active_mutex); } -/**************************************************************/ /** - Clean up R-Tree search structure */ -void rtr_clean_rtr_info( - /*===============*/ - rtr_info_t *rtr_info, /*!< in: RTree search info */ - bool free_all) /*!< in: need to free rtr_info itself */ +/** Clean up R-Tree search structure */ +void rtr_clean_rtr_info(rtr_info_t *rtr_info, /*!< in: RTree search info */ + bool free_all) /*!< in: need to free rtr_info itself */ { dict_index_t *index; bool initialized = false; @@ -1027,10 +1008,8 @@ void rtr_clean_rtr_info( } } -/**************************************************************/ /** - Rebuilt the "path" to exclude the removing page no */ +/** Rebuilt the "path" to exclude the removing page no */ static void rtr_rebuild_path( - /*=============*/ rtr_info_t *rtr_info, /*!< in: RTree search info */ page_no_t page_no) /*!< in: need to free rtr_info itself */ { @@ -1086,10 +1065,8 @@ static void rtr_rebuild_path( } } -/**************************************************************/ /** - Check whether a discarding page is in anyone's search path */ +/** Check whether a discarding page is in anyone's search path */ void rtr_check_discard_page( - /*===================*/ dict_index_t *index, /*!< in: index */ btr_cur_t *cursor, /*!< in: cursor on the page to discard: not on the root page */ @@ -1287,10 +1264,8 @@ static bool rtr_cur_restore_position( return (ret); } -/****************************************************************/ /** - Copy the leaf level R-tree record, and push it to matched_rec in rtr_info */ +/** Copy the leaf level R-tree record, and push it to matched_rec in rtr_info */ static void rtr_leaf_push_match_rec( - /*====================*/ const rec_t *rec, /*!< in: record to copy */ rtr_info_t *rtr_info, /*!< in/out: search stack */ ulint *offsets, /*!< in: offsets */ @@ -1324,11 +1299,9 @@ static void rtr_leaf_push_match_rec( ut_ad(match_rec->used < UNIV_PAGE_SIZE); } -/**************************************************************/ /** - Store the parent path cursor +/** Store the parent path cursor @return number of cursor stored */ ulint rtr_store_parent_path( - /*==================*/ const buf_block_t *block, /*!< in: block of the page */ btr_cur_t *btr_cur, /*!< in/out: persistent cursor */ ulint latch_mode, @@ -1365,10 +1338,8 @@ ulint rtr_store_parent_path( return (num_stored); } -/**************************************************************/ /** - push a nonleaf index node to the search path for insertion */ +/** push a nonleaf index node to the search path for insertion */ static void rtr_non_leaf_insert_stack_push( - /*===========================*/ dict_index_t *index, /*!< in: index descriptor */ rtr_node_path_t *path, /*!< in/out: search path */ ulint level, /*!< in: index page level */ @@ -1431,11 +1402,9 @@ static void rtr_copy_buf(matched_rec_t *matches, const buf_block_t *block) { ut_d(new (&matches->block.debug_latch) rw_lock_t(block->debug_latch)); } -/****************************************************************/ /** - Generate a shadow copy of the page block header to save the +/** Generate a shadow copy of the page block header to save the matched records */ static void rtr_init_match( - /*===========*/ matched_rec_t *matches, /*!< in/out: match to initialize */ const buf_block_t *block, /*!< in: buffer block */ const page_t *page) /*!< in: buffer page */ @@ -1458,13 +1427,10 @@ static void rtr_init_match( #endif /* RTR_SEARCH_DIAGNOSTIC */ } -/****************************************************************/ /** - Get the bounding box content from an index record */ -void rtr_get_mbr_from_rec( - /*=================*/ - const rec_t *rec, /*!< in: data tuple */ - const ulint *offsets, /*!< in: offsets array */ - rtr_mbr_t *mbr) /*!< out MBR */ +/** Get the bounding box content from an index record */ +void rtr_get_mbr_from_rec(const rec_t *rec, /*!< in: data tuple */ + const ulint *offsets, /*!< in: offsets array */ + rtr_mbr_t *mbr) /*!< out MBR */ { ulint rec_f_len; const byte *data; @@ -1474,12 +1440,9 @@ void rtr_get_mbr_from_rec( rtr_read_mbr(data, mbr); } -/****************************************************************/ /** - Get the bounding box content from a MBR data record */ -void rtr_get_mbr_from_tuple( - /*===================*/ - const dtuple_t *dtuple, /*!< in: data tuple */ - rtr_mbr *mbr) /*!< out: mbr to fill */ +/** Get the bounding box content from a MBR data record */ +void rtr_get_mbr_from_tuple(const dtuple_t *dtuple, /*!< in: data tuple */ + rtr_mbr *mbr) /*!< out: mbr to fill */ { const dfield_t *dtuple_field; ulint dtuple_f_len; @@ -1494,10 +1457,8 @@ void rtr_get_mbr_from_tuple( rtr_read_mbr(data, mbr); } -/****************************************************************/ /** - Searches the right position in rtree for a page cursor. */ +/** Searches the right position in rtree for a page cursor. */ bool rtr_cur_search_with_match( - /*======================*/ const buf_block_t *block, /*!< in: buffer block */ dict_index_t *index, /*!< in: index descriptor */ const dtuple_t *tuple, /*!< in: data tuple */ diff --git a/storage/innobase/ha/ha0ha.cc b/storage/innobase/ha/ha0ha.cc index 75e03debb4db..f3c50dfb57d9 100644 --- a/storage/innobase/ha/ha0ha.cc +++ b/storage/innobase/ha/ha0ha.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file ha/ha0ha.cc +/** @file ha/ha0ha.cc The hash table with external chains Created 8/22/1994 Heikki Tuuri @@ -48,19 +47,16 @@ this program; if not, write to the Free Software Foundation, Inc., static const ulint MAX_N_POINTERS = UNIV_PAGE_SIZE_MAX / REC_N_NEW_EXTRA_BYTES; #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ -/*************************************************************/ /** - Creates a hash table with at least n array cells. The actual number +/** Creates a hash table with at least n array cells. The actual number of cells is chosen to be a prime number slightly bigger than n. @return own: created table */ -hash_table_t *ib_create( - /*======*/ - ulint n, /*!< in: number of array cells */ - latch_id_t id, /*!< in: latch ID */ - ulint n_sync_obj, - /*!< in: number of mutexes to protect the - hash table: must be a power of 2, or 0 */ - ulint type) /*!< in: type of datastructure for which - MEM_HEAP_FOR_PAGE_HASH */ +hash_table_t *ib_create(ulint n, /*!< in: number of array cells */ + latch_id_t id, /*!< in: latch ID */ + ulint n_sync_obj, + /*!< in: number of mutexes to protect the + hash table: must be a power of 2, or 0 */ + ulint type) /*!< in: type of datastructure for which + MEM_HEAP_FOR_PAGE_HASH */ { hash_table_t *table; @@ -144,11 +140,8 @@ hash_table_t *ib_recreate(hash_table_t *table, ulint n) { return (new_table); } -/*************************************************************/ /** - Empties a hash table and frees the memory heaps. */ -void ha_clear( - /*=====*/ - hash_table_t *table) /*!< in, own: hash table */ +/** Empties a hash table and frees the memory heaps. */ +void ha_clear(hash_table_t *table) /*!< in, own: hash table */ { ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); ut_ad(!table->adaptive || btr_search_own_all(RW_LOCK_X)); @@ -193,14 +186,12 @@ void ha_clear( } } -/*************************************************************/ /** - Inserts an entry into a hash table. If an entry with the same fold number +/** Inserts an entry into a hash table. If an entry with the same fold number is found, its node is updated to point to the new data, and no new node is inserted. If btr_search_enabled is set to FALSE, we will only allow updating existing nodes, but no new node is allowed to be added. @return true if succeed, false if no more memory could be allocated */ ibool ha_insert_for_fold_func( - /*====================*/ hash_table_t *table, /*!< in: hash table */ ulint fold, /*!< in: folded value of data; if a node with the same fold value already exists, it is @@ -311,12 +302,9 @@ static void ha_btr_search_latch_x_locked(const hash_table_t *table) { } #endif /* UNIV_DEBUG */ -/***********************************************************/ /** - Deletes a hash node. */ -void ha_delete_hash_node( - /*================*/ - hash_table_t *table, /*!< in: hash table */ - ha_node_t *del_node) /*!< in: node to be deleted */ +/** Deletes a hash node. */ +void ha_delete_hash_node(hash_table_t *table, /*!< in: hash table */ + ha_node_t *del_node) /*!< in: node to be deleted */ { ut_ad(table); ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); @@ -333,12 +321,10 @@ void ha_delete_hash_node( HASH_DELETE_AND_COMPACT(ha_node_t, next, table, del_node); } -/*********************************************************/ /** - Looks for an element when we know the pointer to the data, and updates +/** Looks for an element when we know the pointer to the data, and updates the pointer to data, if found. @return true if found */ ibool ha_search_and_update_if_found_func( - /*===============================*/ hash_table_t *table, /*!< in/out: hash table */ ulint fold, /*!< in: folded value of the searched data */ const rec_t *data, /*!< in: pointer to the data */ @@ -383,14 +369,11 @@ ibool ha_search_and_update_if_found_func( return (FALSE); } -/*****************************************************************/ /** - Removes from the chain determined by fold all nodes whose data pointer +/** Removes from the chain determined by fold all nodes whose data pointer points to the page given. */ -void ha_remove_all_nodes_to_page( - /*========================*/ - hash_table_t *table, /*!< in: hash table */ - ulint fold, /*!< in: fold value */ - const page_t *page) /*!< in: buffer page */ +void ha_remove_all_nodes_to_page(hash_table_t *table, /*!< in: hash table */ + ulint fold, /*!< in: fold value */ + const page_t *page) /*!< in: buffer page */ { ha_node_t *node; @@ -430,14 +413,11 @@ void ha_remove_all_nodes_to_page( } #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG -/*************************************************************/ /** - Validates a given range of the cells in hash table. +/** Validates a given range of the cells in hash table. @return true if ok */ -ibool ha_validate( - /*========*/ - hash_table_t *table, /*!< in: hash table */ - ulint start_index, /*!< in: start index */ - ulint end_index) /*!< in: end index */ +ibool ha_validate(hash_table_t *table, /*!< in: hash table */ + ulint start_index, /*!< in: start index */ + ulint end_index) /*!< in: end index */ { ibool ok = TRUE; ulint i; @@ -471,12 +451,9 @@ ibool ha_validate( } #endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */ -/*************************************************************/ /** - Prints info of a hash table. */ -void ha_print_info( - /*==========*/ - FILE *file, /*!< in: file where to print */ - hash_table_t *table) /*!< in: hash table */ +/** Prints info of a hash table. */ +void ha_print_info(FILE *file, /*!< in: file where to print */ + hash_table_t *table) /*!< in: hash table */ { #ifdef UNIV_DEBUG /* Some of the code here is disabled for performance reasons in production diff --git a/storage/innobase/ha/ha0storage.cc b/storage/innobase/ha/ha0storage.cc index 4c6cbe98e41f..fc3dbe469abd 100644 --- a/storage/innobase/ha/ha0storage.cc +++ b/storage/innobase/ha/ha0storage.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file ha/ha0storage.cc +/** @file ha/ha0storage.cc Hash storage. Provides a data structure that stores chunks of data in its own storage, avoiding duplicates. @@ -39,11 +38,9 @@ this program; if not, write to the Free Software Foundation, Inc., #include "mem0mem.h" #include "ut0rnd.h" -/*******************************************************************/ /** - Retrieves a data from a storage. If it is present, a pointer to the +/** Retrieves a data from a storage. If it is present, a pointer to the stored copy of data is returned, otherwise NULL is returned. */ static const void *ha_storage_get( - /*===========*/ ha_storage_t *storage, /*!< in: hash storage */ const void *data, /*!< in: data to check for */ ulint data_len) /*!< in: data length */ @@ -74,8 +71,7 @@ static const void *ha_storage_get( return (node->data); } -/*******************************************************************/ /** - Copies data into the storage and returns a pointer to the copy. If the +/** Copies data into the storage and returns a pointer to the copy. If the same data chunk is already present, then pointer to it is returned. Data chunks are considered to be equal if len1 == len2 and memcmp(data1, data2, len1) == 0. If "data" is not present (and thus @@ -84,7 +80,6 @@ static const void *ha_storage_get( To disable this behavior "memlim" can be set to 0, which stands for "no limit". */ const void *ha_storage_put_memlim( - /*==================*/ ha_storage_t *storage, /*!< in/out: hash storage */ const void *data, /*!< in: data to store */ ulint data_len, /*!< in: data length */ diff --git a/storage/innobase/ha/hash0hash.cc b/storage/innobase/ha/hash0hash.cc index 9fd91dabf8d2..7d0b26f94321 100644 --- a/storage/innobase/ha/hash0hash.cc +++ b/storage/innobase/ha/hash0hash.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file ha/hash0hash.cc +/** @file ha/hash0hash.cc The simple hash table utility Created 5/20/1997 Heikki Tuuri @@ -39,11 +38,8 @@ this program; if not, write to the Free Software Foundation, Inc., #ifndef UNIV_HOTBACKUP -/************************************************************/ /** - Reserves all the locks of a hash table, in an ascending order. */ -void hash_lock_x_all( - /*============*/ - hash_table_t *table) /*!< in: hash table */ +/** Reserves all the locks of a hash table, in an ascending order. */ +void hash_lock_x_all(hash_table_t *table) /*!< in: hash table */ { ut_ad(table->type == HASH_TABLE_SYNC_RW_LOCK); @@ -57,11 +53,8 @@ void hash_lock_x_all( } } -/************************************************************/ /** - Releases all the locks of a hash table, in an ascending order. */ -void hash_unlock_x_all( - /*==============*/ - hash_table_t *table) /*!< in: hash table */ +/** Releases all the locks of a hash table, in an ascending order. */ +void hash_unlock_x_all(hash_table_t *table) /*!< in: hash table */ { ut_ad(table->type == HASH_TABLE_SYNC_RW_LOCK); @@ -74,12 +67,9 @@ void hash_unlock_x_all( } } -/************************************************************/ /** - Releases all but passed in lock of a hash table, */ -void hash_unlock_x_all_but( - /*==================*/ - hash_table_t *table, /*!< in: hash table */ - rw_lock_t *keep_lock) /*!< in: lock to keep */ +/** Releases all but passed in lock of a hash table, */ +void hash_unlock_x_all_but(hash_table_t *table, /*!< in: hash table */ + rw_lock_t *keep_lock) /*!< in: lock to keep */ { ut_ad(table->type == HASH_TABLE_SYNC_RW_LOCK); @@ -96,13 +86,10 @@ void hash_unlock_x_all_but( #endif /* !UNIV_HOTBACKUP */ -/*************************************************************/ /** - Creates a hash table with >= n array cells. The actual number of cells is +/** Creates a hash table with >= n array cells. The actual number of cells is chosen to be a prime number slightly bigger than n. @return own: created table */ -hash_table_t *hash_create( - /*========*/ - ulint n) /*!< in: number of array cells */ +hash_table_t *hash_create(ulint n) /*!< in: number of array cells */ { hash_cell_t *array; ulint prime; @@ -137,11 +124,8 @@ hash_table_t *hash_create( return (table); } -/*************************************************************/ /** - Frees a hash table. */ -void hash_table_free( - /*============*/ - hash_table_t *table) /*!< in, own: hash table */ +/** Frees a hash table. */ +void hash_table_free(hash_table_t *table) /*!< in, own: hash table */ { ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 2cd238adf1c6..e2b6603ae619 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -777,12 +777,10 @@ static ib_cb_t innodb_api_cb[] = {(ib_cb_t)ib_cursor_open_table, (ib_cb_t)ib_trx_read_only, (ib_cb_t)ib_is_virtual_table}; -/*************************************************************/ /** - Check whether valid argument given to innodb_ft_*_stopword_table. +/** Check whether valid argument given to innodb_ft_*_stopword_table. This function is registered as a callback with MySQL. @return 0 for valid stopword table */ static int innodb_stopword_table_validate( - /*===========================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ @@ -871,11 +869,9 @@ static int innodb_tmpdir_validate(THD *thd, SYS_VAR *var, void *save, return (0); } -/******************************************************************/ /** - Maps a MySQL trx isolation level code to the InnoDB isolation level code +/** Maps a MySQL trx isolation level code to the InnoDB isolation level code @return InnoDB isolation level */ static inline ulint innobase_map_isolation_level( - /*=========================*/ enum_tx_isolation iso); /*!< in: MySQL isolation level code */ /** Gets field offset for a field in a table. @@ -1046,56 +1042,42 @@ static SHOW_VAR innodb_status_variables[] = { #endif /* UNIV_DEBUG */ {NullS, NullS, SHOW_LONG, SHOW_SCOPE_GLOBAL}}; -/************************************************************************/ /** - Handling the shared INNOBASE_SHARE structure that is needed to provide table +/** Handling the shared INNOBASE_SHARE structure that is needed to provide table locking. Register the table name if it doesn't exist in the hash table. */ static INNOBASE_SHARE *get_share( - /*======*/ const char *table_name); /*!< in: table to lookup */ -/************************************************************************/ /** - Free the shared object that was registered with get_share(). */ -static void free_share( - /*=======*/ - INNOBASE_SHARE *share); /*!< in/own: share to free */ +/** Free the shared object that was registered with get_share(). */ +static void free_share(INNOBASE_SHARE *share); /*!< in/own: share to free */ -/*****************************************************************/ /** - Frees a possible InnoDB trx object associated with the current THD. +/** Frees a possible InnoDB trx object associated with the current THD. @return 0 or error number */ static int innobase_close_connection( - /*======================*/ handlerton *hton, /*!< in/out: InnoDB handlerton */ THD *thd); /*!< in: MySQL thread handle for which to close the connection */ -/*****************************************************************/ /** - Cancel any pending lock request associated with the current THD. */ +/** Cancel any pending lock request associated with the current THD. */ static void innobase_kill_connection( - /*=====================*/ handlerton *hton, /*!< in/out: InnoDB handlerton */ THD *thd); /*!< in: MySQL thread handle for which to close the connection */ -/*****************************************************************/ /** - Commits a transaction in an InnoDB database or marks an SQL statement +/** Commits a transaction in an InnoDB database or marks an SQL statement ended. @return 0 */ -static int innobase_commit( - /*============*/ - handlerton *hton, /*!< in/out: InnoDB handlerton */ - THD *thd, /*!< in: MySQL thread handle of the - user for whom the transaction should - be committed */ - bool commit_trx); /*!< in: true - commit transaction - false - the current SQL statement - ended */ - -/*****************************************************************/ /** - Rolls back a transaction to a savepoint. +static int innobase_commit(handlerton *hton, /*!< in/out: InnoDB handlerton */ + THD *thd, /*!< in: MySQL thread handle of the + user for whom the transaction should + be committed */ + bool commit_trx); /*!< in: true - commit transaction + false - the current SQL statement + ended */ + +/** Rolls back a transaction to a savepoint. @return 0 if success, HA_ERR_NO_SAVEPOINT if no savepoint with the given name */ static int innobase_rollback( - /*==============*/ handlerton *hton, /*!< in/out: InnoDB handlerton */ THD *thd, /*!< in: handle to the MySQL thread of the user whose transaction should @@ -1104,46 +1086,38 @@ static int innobase_rollback( transaction FALSE - rollback the current statement only */ -/*****************************************************************/ /** - Rolls back a transaction to a savepoint. +/** Rolls back a transaction to a savepoint. @return 0 if success, HA_ERR_NO_SAVEPOINT if no savepoint with the given name */ static int innobase_rollback_to_savepoint( - /*===========================*/ handlerton *hton, /*!< in/out: InnoDB handlerton */ THD *thd, /*!< in: handle to the MySQL thread of the user whose XA transaction should be rolled back to savepoint */ void *savepoint); /*!< in: savepoint data */ -/*****************************************************************/ /** - Check whether innodb state allows to safely release MDL locks after +/** Check whether innodb state allows to safely release MDL locks after rollback to savepoint. @return true if it is safe, false if its not safe. */ static bool innobase_rollback_to_savepoint_can_release_mdl( - /*===========================================*/ handlerton *hton, /*!< in/out: InnoDB handlerton */ THD *thd); /*!< in: handle to the MySQL thread of the user whose XA transaction should be rolled back to savepoint */ -/*****************************************************************/ /** - Sets a transaction savepoint. +/** Sets a transaction savepoint. @return always 0, that is, always succeeds */ static int innobase_savepoint( - /*===============*/ handlerton *hton, /*!< in/out: InnoDB handlerton */ THD *thd, /*!< in: handle to the MySQL thread of the user's XA transaction for which we need to take a savepoint */ void *savepoint); /*!< in: savepoint data */ -/*****************************************************************/ /** - Release transaction savepoint name. +/** Release transaction savepoint name. @return 0 if success, HA_ERR_NO_SAVEPOINT if no savepoint with the given name */ static int innobase_release_savepoint( - /*=======================*/ handlerton *hton, /*!< in/out: handlerton for InnoDB */ THD *thd, /*!< in: handle to the MySQL thread of the user whose transaction's @@ -1216,41 +1190,32 @@ to 0, even if it was initially set to nonzero at the command line or configuration file. */ static void innobase_commit_concurrency_init_default(); -/*******************************************************************/ /** - This function is used to prepare an X/Open XA distributed transaction. +/** This function is used to prepare an X/Open XA distributed transaction. @return 0 or error number */ -static int innobase_xa_prepare( - /*================*/ - handlerton *hton, /*!< in: InnoDB handlerton */ - THD *thd, /*!< in: handle to the MySQL thread of - the user whose XA transaction should - be prepared */ - bool all); /*!< in: true - prepare transaction - false - the current SQL statement - ended */ -/*******************************************************************/ /** - This function is used to recover X/Open XA distributed transactions. +static int innobase_xa_prepare(handlerton *hton, /*!< in: InnoDB handlerton */ + THD *thd, /*!< in: handle to the MySQL thread of + the user whose XA transaction should + be prepared */ + bool all); /*!< in: true - prepare transaction + false - the current SQL statement + ended */ +/** This function is used to recover X/Open XA distributed transactions. @return number of prepared transactions stored in xid_list */ static int innobase_xa_recover( - /*================*/ handlerton *hton, /*!< in: InnoDB handlerton */ XID *xid_list, /*!< in/out: prepared transactions */ uint len); /*!< in: number of slots in xid_list */ -/*******************************************************************/ /** - This function is used to commit one X/Open XA distributed transaction +/** This function is used to commit one X/Open XA distributed transaction which is in the prepared state @return 0 or error number */ static xa_status_code innobase_commit_by_xid( - /*===================*/ handlerton *hton, /*!< in: InnoDB handlerton */ XID *xid); /*!< in: X/Open XA transaction identification */ -/*******************************************************************/ /** - This function is used to rollback one X/Open XA distributed transaction +/** This function is used to rollback one X/Open XA distributed transaction which is in the prepared state @return 0 or error number */ static xa_status_code innobase_rollback_by_xid( - /*=====================*/ handlerton *hton, /*!< in: InnoDB handlerton */ XID *xid); /*!< in: X/Open XA transaction identification */ @@ -1332,14 +1297,12 @@ static void innodb_pre_dd_shutdown(handlerton *) { } } -/*****************************************************************/ /** - Creates an InnoDB transaction struct for the thd if it does not yet have one. - Starts a new InnoDB transaction if a transaction is not yet started. And +/** Creates an InnoDB transaction struct for the thd if it does not yet have + one. Starts a new InnoDB transaction if a transaction is not yet started. And assigns a new snapshot for a consistent read if the transaction does not yet have one. @return 0 */ static int innobase_start_trx_and_assign_read_view( - /*====================================*/ handlerton *hton, /* in: InnoDB handlerton */ THD *thd); /* in: MySQL thread handle of the user for whom the transaction should @@ -1386,13 +1349,11 @@ static bool innobase_show_status(handlerton *hton, THD *thd, stat_print_fn *stat_print, enum ha_stat_type stat_type); -/****************************************************************/ /** - Parse and enable InnoDB monitor counters during server startup. +/** Parse and enable InnoDB monitor counters during server startup. User can enable monitor counters/groups by specifying "loose-innodb_monitor_enable = monitor_name1;monitor_name2..." in server configuration file or at the command line. */ static void innodb_enable_monitor_at_startup( - /*=============================*/ char *str); /*!< in: monitor counter enable list */ /** Fill handlerton based INFORMATION_SCHEMA tables. @@ -1422,11 +1383,9 @@ static void innobase_fts_store_docid(TABLE *tbl, ulonglong doc_id) { dbug_tmp_restore_column_map(tbl->write_set, old_map); } -/*************************************************************/ /** - Check for a valid value of innobase_commit_concurrency. +/** Check for a valid value of innobase_commit_concurrency. @return 0 for valid innodb_commit_concurrency */ static int innobase_commit_concurrency_validate( - /*=================================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ @@ -1473,37 +1432,29 @@ static handler *innobase_create_handler(handlerton *hton, TABLE_SHARE *table, /* General functions */ -/******************************************************************/ /** - Returns true if the thread is the replication thread on the slave +/** Returns true if the thread is the replication thread on the slave server. Used in srv_conc_enter_innodb() to determine if the thread should be allowed to enter InnoDB - the replication thread is treated differently than other threads. Also used in srv_conc_force_exit_innodb(). @return true if thd is the replication thread */ -ibool thd_is_replication_slave_thread( - /*============================*/ - THD *thd) /*!< in: thread handle */ +ibool thd_is_replication_slave_thread(THD *thd) /*!< in: thread handle */ { return (thd != nullptr && (ibool)thd_slave_thread(thd)); } -/******************************************************************/ /** - Gets information on the durability property requested by thread. +/** Gets information on the durability property requested by thread. Used when writing either a prepare or commit record to the log buffer. @return the durability property. */ enum durability_properties thd_requested_durability( - /*=====================*/ const THD *thd) /*!< in: thread handle */ { return (thd_get_durability_property(thd)); } -/******************************************************************/ /** - Returns true if transaction should be flagged as read-only. +/** Returns true if transaction should be flagged as read-only. @return true if the thd is marked as read-only */ -bool thd_trx_is_read_only( - /*=================*/ - THD *thd) /*!< in: thread handle */ +bool thd_trx_is_read_only(THD *thd) /*!< in: thread handle */ { return (thd != 0 && thd_tx_is_read_only(thd)); } @@ -1537,13 +1488,10 @@ int thd_trx_priority(THD *thd) { return (thd == NULL ? 0 : thd_tx_priority(thd)); } -/******************************************************************/ /** - Check if the transaction is an auto-commit transaction. TRUE also +/** Check if the transaction is an auto-commit transaction. TRUE also implies that it is a SELECT (read-only) transaction. @return true if the transaction is an auto commit read-only transaction. */ -ibool thd_trx_is_auto_commit( - /*===================*/ - THD *thd) /*!< in: thread handle, can be NULL */ +ibool thd_trx_is_auto_commit(THD *thd) /*!< in: thread handle, can be NULL */ { return (thd != NULL && !thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN) && @@ -1552,12 +1500,9 @@ ibool thd_trx_is_auto_commit( extern "C" time_t thd_start_time(const THD *thd); -/******************************************************************/ /** - Get the thread start time. +/** Get the thread start time. @return the thread start time in seconds since the epoch. */ -ulint thd_start_time_in_secs( - /*===================*/ - THD *thd) /*!< in: thread handle, or NULL */ +ulint thd_start_time_in_secs(THD *thd) /*!< in: thread handle, or NULL */ { // FIXME: This function should be added to the server code. // return(thd_start_time(thd)); @@ -1627,10 +1572,8 @@ static inline void innobase_srv_conc_exit_innodb(row_prebuilt_t *prebuilt) { } } -/******************************************************************/ /** - Force a thread to leave InnoDB even if it has spare tickets. */ +/** Force a thread to leave InnoDB even if it has spare tickets. */ static inline void innobase_srv_conc_force_exit_innodb( - /*================================*/ trx_t *trx) /*!< in: transaction handle */ { #ifdef UNIV_DEBUG @@ -1645,57 +1588,40 @@ static inline void innobase_srv_conc_force_exit_innodb( } } -/******************************************************************/ /** - Returns the NUL terminated value of glob_hostname. +/** Returns the NUL terminated value of glob_hostname. @return pointer to glob_hostname. */ -const char *server_get_hostname() -/*=================*/ -{ - return (glob_hostname); -} +const char *server_get_hostname() { return (glob_hostname); } -/******************************************************************/ /** - Returns true if the transaction this thread is processing has edited +/** Returns true if the transaction this thread is processing has edited non-transactional tables. Used by the deadlock detector when deciding which transaction to rollback in case of a deadlock - we try to avoid rolling back transactions that have edited non-transactional tables. @return true if non-transactional tables have been edited */ -ibool thd_has_edited_nontrans_tables( - /*===========================*/ - THD *thd) /*!< in: thread handle */ +ibool thd_has_edited_nontrans_tables(THD *thd) /*!< in: thread handle */ { return ((ibool)thd_non_transactional_update(thd)); } -/******************************************************************/ /** - Returns true if the thread is executing a SELECT statement. +/** Returns true if the thread is executing a SELECT statement. @return true if thd is executing SELECT */ -ibool thd_is_select( - /*==========*/ - const THD *thd) /*!< in: thread handle */ +ibool thd_is_select(const THD *thd) /*!< in: thread handle */ { return (thd_sql_command(thd) == SQLCOM_SELECT); } -/******************************************************************/ /** - Returns the lock wait timeout for the current connection. +/** Returns the lock wait timeout for the current connection. @return the lock wait timeout, in seconds */ -ulong thd_lock_wait_timeout( - /*==================*/ - THD *thd) /*!< in: thread handle, or NULL to query - the global innodb_lock_wait_timeout */ +ulong thd_lock_wait_timeout(THD *thd) /*!< in: thread handle, or NULL to query + the global innodb_lock_wait_timeout */ { /* According to , passing thd == NULL returns the global value of the session variable. */ return (THDVAR(thd, lock_wait_timeout)); } -/******************************************************************/ /** - Set the time waited for the lock for the current query. */ -void thd_set_lock_wait_time( - /*===================*/ - THD *thd, /*!< in/out: thread handle */ - ulint value) /*!< in: time waited for the lock */ +/** Set the time waited for the lock for the current query. */ +void thd_set_lock_wait_time(THD *thd, /*!< in/out: thread handle */ + ulint value) /*!< in: time waited for the lock */ { if (thd) { thd_storage_lock_wait(thd, value); @@ -1782,14 +1708,11 @@ static inline void add_table_to_thread_cache(dict_table_t *table, priv->register_table_handler(table->name.m_name, table); } -/********************************************************************/ /** - Increments innobase_active_counter and every INNOBASE_WAKE_INTERVALth +/** Increments innobase_active_counter and every INNOBASE_WAKE_INTERVALth time calls srv_active_wake_master_thread. This function should be used when a single database operation may introduce a small need for server utility activity, like checkpointing. */ -inline void innobase_active_small(void) -/*=======================*/ -{ +inline void innobase_active_small(void) { innobase_active_counter++; if ((innobase_active_counter % INNOBASE_WAKE_INTERVAL) == 0) { @@ -1797,13 +1720,11 @@ inline void innobase_active_small(void) } } -/********************************************************************/ /** - Converts an InnoDB error code to a MySQL error code and also tells to MySQL +/** Converts an InnoDB error code to a MySQL error code and also tells to MySQL about a possible transaction rollback inside InnoDB caused by a lock wait timeout or a deadlock. @return MySQL error code */ int convert_error_code_to_mysql( - /*========================*/ dberr_t error, /*!< in: InnoDB error code */ ulint flags, /*!< in: InnoDB table flags, or 0 */ THD *thd) /*!< in: user thread handle or NULL */ @@ -1992,10 +1913,8 @@ int convert_error_code_to_mysql( } } -/*************************************************************/ /** - Prints info of a THD object (== user session thread) to the given file. */ +/** Prints info of a THD object (== user session thread) to the given file. */ void innobase_mysql_print_thd( - /*=====================*/ FILE *f, /*!< in: output stream */ THD *thd, /*!< in: MySQL THD object */ uint max_query_len) /*!< in: max query length to print, or 0 to @@ -2007,20 +1926,15 @@ void innobase_mysql_print_thd( putc('\n', f); } -/******************************************************************/ /** - Get the error message format string. +/** Get the error message format string. @return the format string or 0 if not found. */ -const char *innobase_get_err_msg( - /*=================*/ - int error_code) /*!< in: MySQL error code */ +const char *innobase_get_err_msg(int error_code) /*!< in: MySQL error code */ { return (my_get_err_msg(error_code)); } -/******************************************************************/ /** - Get the variable length bounds of the given character set. */ +/** Get the variable length bounds of the given character set. */ void innobase_get_cset_width( - /*====================*/ ulint cset, /*!< in: MySQL charset-collation code */ ulint *mbminlen, /*!< out: minimum length of a char (in bytes) */ ulint *mbmaxlen) /*!< out: maximum length of a char (in bytes) */ @@ -2053,10 +1967,8 @@ void innobase_get_cset_width( } } -/******************************************************************/ /** - Converts an identifier to a table name. */ +/** Converts an identifier to a table name. */ void innobase_convert_from_table_id( - /*===========================*/ const CHARSET_INFO *cs, /*!< in: the 'from' character set */ char *to, /*!< out: converted identifier */ const char *from, /*!< in: identifier to convert */ @@ -2071,7 +1983,6 @@ void innobase_convert_from_table_id( Check if the length of the identifier exceeds the maximum allowed. return true when length of identifier is too long. */ bool innobase_check_identifier_length( - /*=============================*/ const char *id) /* in: FK identifier to check excluding the database portion. */ { @@ -2089,10 +2000,8 @@ bool innobase_check_identifier_length( DBUG_RETURN(false); } -/******************************************************************/ /** - Converts an identifier to UTF-8. */ +/** Converts an identifier to UTF-8. */ void innobase_convert_from_id( - /*=====================*/ const CHARSET_INFO *cs, /*!< in: the 'from' character set */ char *to, /*!< out: converted identifier */ const char *from, /*!< in: identifier to convert */ @@ -2104,13 +2013,10 @@ void innobase_convert_from_id( } #endif /* !UNIV_HOTBACKUP */ -/******************************************************************/ /** - Compares NUL-terminated UTF-8 strings case insensitively. +/** Compares NUL-terminated UTF-8 strings case insensitively. @return 0 if a=b, <0 if a1 if a>b */ -int innobase_strcasecmp( - /*================*/ - const char *a, /*!< in: first string to compare */ - const char *b) /*!< in: second string to compare */ +int innobase_strcasecmp(const char *a, /*!< in: first string to compare */ + const char *b) /*!< in: second string to compare */ { if (!a) { if (!b) { @@ -2126,12 +2032,10 @@ int innobase_strcasecmp( } #ifndef UNIV_HOTBACKUP -/******************************************************************/ /** - Compares NUL-terminated UTF-8 strings case insensitively. The +/** Compares NUL-terminated UTF-8 strings case insensitively. The second string contains wildcards. @return 0 if a match is found, 1 if not */ static int innobase_wildcasecmp( - /*=================*/ const char *a, /*!< in: string to compare */ const char *b) /*!< in: wildcard string to compare */ { @@ -2149,20 +2053,15 @@ const char *innobase_basename(const char *path_name) { } #ifndef UNIV_HOTBACKUP -/******************************************************************/ /** - Makes all characters in a NUL-terminated UTF-8 string lower case. */ -void innobase_casedn_str( - /*================*/ - char *a) /*!< in/out: string to put in lower case */ +/** Makes all characters in a NUL-terminated UTF-8 string lower case. */ +void innobase_casedn_str(char *a) /*!< in/out: string to put in lower case */ { my_casedn_str(system_charset_info, a); } -/**********************************************************************/ /** - Determines the connection character set. +/** Determines the connection character set. @return connection character set */ const CHARSET_INFO *innobase_get_charset( - /*=================*/ THD *mysql_thd) /*!< in: MySQL thread handle */ { return (thd_charset(mysql_thd)); @@ -2173,9 +2072,7 @@ Thread unsafe, can only be called from the thread owning the THD. @param[in] thd MySQL thread handle @param[out] length Length of the SQL statement @return SQL statement string */ -const char *innobase_get_stmt_unsafe( - /*==============*/ - THD *thd, size_t *length) { +const char *innobase_get_stmt_unsafe(THD *thd, size_t *length) { LEX_CSTRING stmt; stmt = thd_query_unsafe(thd); @@ -2190,32 +2087,22 @@ into the provided buffer. @param[out] buf Buffer containing SQL statement @param[in] buflen Length of provided buffer @return Length of the SQL statement */ -size_t innobase_get_stmt_safe( - /*==============*/ - THD *thd, char *buf, size_t buflen) { +size_t innobase_get_stmt_safe(THD *thd, char *buf, size_t buflen) { return (thd_query_safe(thd, buf, buflen)); } -/**********************************************************************/ /** - Get the current setting of the table_def_size global parameter. We do +/** Get the current setting of the table_def_size global parameter. We do a dirty read because for one there is no synchronization object and secondly there is little harm in doing so even if we get a torn read. @return value of table_def_size */ -ulint innobase_get_table_cache_size(void) -/*===============================*/ -{ - return (table_def_size); -} +ulint innobase_get_table_cache_size(void) { return (table_def_size); } -/**********************************************************************/ /** - Get the current setting of the lower_case_table_names global parameter from +/** Get the current setting of the lower_case_table_names global parameter from mysqld.cc. We do a dirty read because for one there is no synchronization object and secondly there is little harm in doing so even if we get a torn read. @return value of lower_case_table_names */ -ulint innobase_get_lower_case_table_names(void) -/*=====================================*/ -{ +ulint innobase_get_lower_case_table_names(void) { return (lower_case_table_names); } @@ -2278,11 +2165,9 @@ int innobase_mysql_tmpfile(const char *path) { return (fd2); } -/*********************************************************************/ /** - Wrapper around MySQL's copy_and_convert function. +/** Wrapper around MySQL's copy_and_convert function. @return number of bytes copied to 'to' */ static ulint innobase_convert_string( - /*====================*/ void *to, /*!< out: converted string */ ulint to_length, /*!< in: number of bytes reserved for the converted string */ @@ -2299,8 +2184,7 @@ static ulint innobase_convert_string( errors)); } -/*******************************************************************/ /** - Formats the raw data in "data" (in InnoDB on-disk format) that is of +/** Formats the raw data in "data" (in InnoDB on-disk format) that is of type DATA_(CHAR|VARCHAR|MYSQL|VARMYSQL) using "charset_coll" and writes the result to "buf". The result is converted to "system_charset_info". Not more than "buf_size" bytes are written to "buf". @@ -2308,15 +2192,13 @@ static ulint innobase_convert_string( number of bytes that were written to "buf" is returned (including the terminating NUL). @return number of bytes that were written */ -ulint innobase_raw_format( - /*================*/ - const char *data, /*!< in: raw data */ - ulint data_len, /*!< in: raw data length - in bytes */ - ulint charset_coll, /*!< in: charset collation */ - char *buf, /*!< out: output buffer */ - ulint buf_size) /*!< in: output buffer size - in bytes */ +ulint innobase_raw_format(const char *data, /*!< in: raw data */ + ulint data_len, /*!< in: raw data length + in bytes */ + ulint charset_coll, /*!< in: charset collation */ + char *buf, /*!< out: output buffer */ + ulint buf_size) /*!< in: output buffer size + in bytes */ { /* XXX we use a hard limit instead of allocating but_size bytes from the heap */ @@ -2418,8 +2300,7 @@ dberr_t Encryption::validate(const char *option) { return (encryption.set_algorithm(option, &encryption)); } -/*********************************************************************/ /** - Compute the next autoinc value. +/** Compute the next autoinc value. For MySQL replication the autoincrement values can be partitioned among the nodes. The offset is the start or origin of the autoincrement value @@ -2437,7 +2318,6 @@ dberr_t Encryption::validate(const char *option) { the multi-value INSERT above. @return the next value */ ulonglong innobase_next_autoinc( - /*==================*/ ulonglong current, /*!< in: Current value */ ulonglong need, /*!< in: count of values needed */ ulonglong step, /*!< in: AUTOINC increment step */ @@ -2513,10 +2393,8 @@ ulonglong innobase_next_autoinc( return (next_value); } -/*********************************************************************/ /** - Initializes some fields in an InnoDB transaction object. */ +/** Initializes some fields in an InnoDB transaction object. */ static void innobase_trx_init( - /*==============*/ THD *thd, /*!< in: user thread handle */ trx_t *trx) /*!< in/out: InnoDB transaction handle */ { @@ -2532,12 +2410,9 @@ static void innobase_trx_init( DBUG_VOID_RETURN; } -/*********************************************************************/ /** - Allocates an InnoDB transaction for a MySQL handler object for DML. +/** Allocates an InnoDB transaction for a MySQL handler object for DML. @return InnoDB transaction handle */ -trx_t *innobase_trx_allocate( - /*==================*/ - THD *thd) /*!< in: user thread handle */ +trx_t *innobase_trx_allocate(THD *thd) /*!< in: user thread handle */ { trx_t *trx; @@ -2554,14 +2429,11 @@ trx_t *innobase_trx_allocate( DBUG_RETURN(trx); } -/*********************************************************************/ /** - Gets the InnoDB transaction handle for a MySQL handler object, creates +/** Gets the InnoDB transaction handle for a MySQL handler object, creates an InnoDB transaction struct if the corresponding MySQL thread struct still lacks one. @return InnoDB transaction handle */ -trx_t *check_trx_exists( - /*=============*/ - THD *thd) /*!< in: user thread handle */ +trx_t *check_trx_exists(THD *thd) /*!< in: user thread handle */ { trx_t *&trx = thd_to_trx(thd); @@ -2616,31 +2488,23 @@ static void innodb_replace_trx_in_thd(THD *thd, void *new_trx_arg, trx = static_cast(new_trx_arg); } -/*********************************************************************/ /** - Note that a transaction has been registered with MySQL 2PC coordinator. */ -static inline void trx_register_for_2pc( - /*==================*/ - trx_t *trx) /* in: transaction */ +/** Note that a transaction has been registered with MySQL 2PC coordinator. */ +static inline void trx_register_for_2pc(trx_t *trx) /* in: transaction */ { trx->is_registered = 1; } -/*********************************************************************/ /** - Note that a transaction has been deregistered. */ -static inline void trx_deregister_from_2pc( - /*====================*/ - trx_t *trx) /* in: transaction */ +/** Note that a transaction has been deregistered. */ +static inline void trx_deregister_from_2pc(trx_t *trx) /* in: transaction */ { trx->is_registered = 0; } -/*********************************************************************/ /** - Copy table flags from MySQL's HA_CREATE_INFO into an InnoDB table object. +/** Copy table flags from MySQL's HA_CREATE_INFO into an InnoDB table object. Those flags are stored in .frm file and end up in the MySQL table object, but are frequently used inside InnoDB so we keep their copies into the InnoDB table object. */ static void innobase_copy_frm_flags_from_create_info( - /*=====================================*/ dict_table_t *innodb_table, /*!< in/out: InnoDB table */ const HA_CREATE_INFO *create_info) /*!< in: create info */ { @@ -2665,13 +2529,11 @@ static void innobase_copy_frm_flags_from_create_info( innodb_table->stats_sample_pages = create_info->stats_sample_pages; } -/*********************************************************************/ /** - Copy table flags from MySQL's TABLE_SHARE into an InnoDB table object. +/** Copy table flags from MySQL's TABLE_SHARE into an InnoDB table object. Those flags are stored in .frm file and end up in the MySQL table object, but are frequently used inside InnoDB so we keep their copies into the InnoDB table object. */ void innobase_copy_frm_flags_from_table_share( - /*=====================================*/ dict_table_t *innodb_table, /*!< in/out: InnoDB table */ const TABLE_SHARE *table_share) /*!< in: table share */ { @@ -2696,12 +2558,9 @@ void innobase_copy_frm_flags_from_table_share( innodb_table->stats_sample_pages = table_share->stats_sample_pages; } -/*********************************************************************/ /** - Construct ha_innobase handler. */ +/** Construct ha_innobase handler. */ -ha_innobase::ha_innobase( - /*=====================*/ - handlerton *hton, TABLE_SHARE *table_arg) +ha_innobase::ha_innobase(handlerton *hton, TABLE_SHARE *table_arg) : handler(hton, table_arg), m_ds_mrr(this), m_prebuilt(), @@ -2723,20 +2582,14 @@ ha_innobase::ha_innobase( m_stored_select_lock_type(LOCK_NONE_UNSET), m_mysql_has_locked() {} -/*********************************************************************/ /** - Destruct ha_innobase handler. */ +/** Destruct ha_innobase handler. */ -ha_innobase::~ha_innobase() -/*======================*/ -{} +ha_innobase::~ha_innobase() {} -/*********************************************************************/ /** - Updates the user_thd field in a handle and also allocates a new InnoDB +/** Updates the user_thd field in a handle and also allocates a new InnoDB transaction handle if needed, and updates the transaction fields in the m_prebuilt struct. */ -void ha_innobase::update_thd( - /*====================*/ - THD *thd) /*!< in: thd to use the handle */ +void ha_innobase::update_thd(THD *thd) /*!< in: thd to use the handle */ { DBUG_ENTER("ha_innobase::update_thd"); DBUG_PRINT("ha_innobase::update_thd", @@ -2761,32 +2614,26 @@ void ha_innobase::update_thd( DBUG_VOID_RETURN; } -/*********************************************************************/ /** - Updates the user_thd field in a handle and also allocates a new InnoDB +/** Updates the user_thd field in a handle and also allocates a new InnoDB transaction handle if needed, and updates the transaction fields in the m_prebuilt struct. */ -void ha_innobase::update_thd() -/*=====================*/ -{ +void ha_innobase::update_thd() { THD *thd = ha_thd(); ut_ad(EQ_CURRENT_THD(thd)); update_thd(thd); } -/*********************************************************************/ /** - Registers an InnoDB transaction with the MySQL 2PC coordinator, so that +/** Registers an InnoDB transaction with the MySQL 2PC coordinator, so that the MySQL XA code knows to call the InnoDB prepare and commit, or rollback for the transaction. This MUST be called for every transaction for which the user may call commit or rollback. Calling this several times to register the same transaction is allowed, too. This function also registers the current SQL statement. */ -void innobase_register_trx( - /*==================*/ - handlerton *hton, /* in: Innobase handlerton */ - THD *thd, /* in: MySQL thd (connection) object */ - trx_t *trx) /* in: transaction to register */ +void innobase_register_trx(handlerton *hton, /* in: Innobase handlerton */ + THD *thd, /* in: MySQL thd (connection) object */ + trx_t *trx) /* in: transaction to register */ { const ulonglong trx_id = static_cast(trx_get_id_for_print(trx)); @@ -2859,11 +2706,9 @@ static char *innobase_convert_identifier(char *buf, ulint buflen, return (buf + idlen); } -/*****************************************************************/ /** - Convert a table name to the MySQL system_charset_info (UTF-8). +/** Convert a table name to the MySQL system_charset_info (UTF-8). @return pointer to the end of buf */ char *innobase_convert_name( - /*==================*/ char *buf, /*!< out: buffer for converted identifier */ ulint buflen, /*!< in: length of buf, in bytes */ const char *id, /*!< in: table name to convert */ @@ -2890,12 +2735,10 @@ char *innobase_convert_name( return (s); } -/*****************************************************************/ /** - A wrapper function of innobase_convert_name(), convert a table name +/** A wrapper function of innobase_convert_name(), convert a table name to the MySQL system_charset_info (UTF-8) and quote it if needed. @return pointer to the end of buf */ void innobase_format_name( - /*==================*/ char *buf, /*!< out: buffer for converted identifier */ ulint buflen, /*!< in: length of buf, in bytes */ const char *name) /*!< in: table name to format */ @@ -2909,34 +2752,25 @@ void innobase_format_name( buf[bufend - buf] = '\0'; } -/**********************************************************************/ /** - Determines if the currently running transaction has been interrupted. +/** Determines if the currently running transaction has been interrupted. @return true if interrupted */ -ibool trx_is_interrupted( - /*===============*/ - const trx_t *trx) /*!< in: transaction */ +ibool trx_is_interrupted(const trx_t *trx) /*!< in: transaction */ { return (trx && trx->mysql_thd && thd_killed(trx->mysql_thd)); } -/**********************************************************************/ /** - Determines if the currently running transaction is in strict mode. +/** Determines if the currently running transaction is in strict mode. @return true if strict */ -ibool trx_is_strict( - /*==========*/ - trx_t *trx) /*!< in: transaction */ +ibool trx_is_strict(trx_t *trx) /*!< in: transaction */ { /* Relax strict check if table is in truncate create table */ return (trx && trx->mysql_thd && THDVAR(trx->mysql_thd, strict_mode) && (!trx->in_truncate)); } -/**************************************************************/ /** - Resets some fields of a m_prebuilt struct. The template is used in fast +/** Resets some fields of a m_prebuilt struct. The template is used in fast retrieval of just those column values MySQL needs in its processing. */ -void ha_innobase::reset_template(void) -/*=============================*/ -{ +void ha_innobase::reset_template(void) { ut_ad(m_prebuilt->magic_n == ROW_PREBUILT_ALLOCATED); ut_ad(m_prebuilt->magic_n2 == m_prebuilt->magic_n); @@ -2960,16 +2794,13 @@ void ha_innobase::reset_template(void) } } -/*****************************************************************/ /** - Call this when you have opened a new table handle in HANDLER, before you +/** Call this when you have opened a new table handle in HANDLER, before you call index_read_map() etc. Actually, we can let the cursor stay open even over a transaction commit! Then you should call this before every operation, fetch next etc. This function inits the necessary things even after a transaction commit. */ -void ha_innobase::init_table_handle_for_HANDLER(void) -/*============================================*/ -{ +void ha_innobase::init_table_handle_for_HANDLER(void) { /* If current thd does not yet have a trx struct, create one. If the current handle does not yet have a m_prebuilt struct, create one. Update the trx pointers in the m_prebuilt struct. Normally @@ -3596,12 +3427,10 @@ static bool innobase_is_dict_readonly() { DBUG_RETURN(srv_read_only_mode || srv_force_recovery > 0); } -/****************************************************************/ /** - Gives the file extension of an InnoDB single-table tablespace. */ +/** Gives the file extension of an InnoDB single-table tablespace. */ static const char *ha_innobase_exts[] = {dot_ext[IBD], NullS}; -/*****************************************************************/ /** - This function checks if the given db.tablename is a system table +/** This function checks if the given db.tablename is a system table supported by Innodb and is used as an initializer for the data member is_supported_system_table of InnoDB storage engine handlerton. Currently we support only columns_priv, db, plugin, procs_priv, @@ -4739,11 +4568,8 @@ static bool innobase_flush_logs(handlerton *hton, bool binlog_group_flush) { DBUG_RETURN(false); } -/*****************************************************************/ /** - Commits a transaction in an InnoDB database. */ -void innobase_commit_low( - /*================*/ - trx_t *trx) /*!< in: transaction handle */ +/** Commits a transaction in an InnoDB database. */ +void innobase_commit_low(trx_t *trx) /*!< in: transaction handle */ { if (trx_is_started(trx)) { trx_commit_for_mysql(trx); @@ -4751,14 +4577,12 @@ void innobase_commit_low( trx->will_lock = 0; } -/*****************************************************************/ /** - Creates an InnoDB transaction struct for the thd if it does not yet have one. - Starts a new InnoDB transaction if a transaction is not yet started. And +/** Creates an InnoDB transaction struct for the thd if it does not yet have + one. Starts a new InnoDB transaction if a transaction is not yet started. And assigns a new snapshot for a consistent read if the transaction does not yet have one. @return 0 */ static int innobase_start_trx_and_assign_read_view( - /*====================================*/ handlerton *hton, /*!< in: InnoDB handlerton */ THD *thd) /*!< in: MySQL thread handle of the user for whom the transaction should be committed */ @@ -4803,20 +4627,17 @@ static int innobase_start_trx_and_assign_read_view( DBUG_RETURN(0); } -/*****************************************************************/ /** - Commits a transaction in an InnoDB database or marks an SQL statement +/** Commits a transaction in an InnoDB database or marks an SQL statement ended. @return 0 or deadlock error if the transaction was aborted by another higher priority transaction. */ -static int innobase_commit( - /*============*/ - handlerton *hton, /*!< in: InnoDB handlerton */ - THD *thd, /*!< in: MySQL thread handle of the - user for whom the transaction should - be committed */ - bool commit_trx) /*!< in: true - commit transaction - false - the current SQL statement - ended */ +static int innobase_commit(handlerton *hton, /*!< in: InnoDB handlerton */ + THD *thd, /*!< in: MySQL thread handle of the + user for whom the transaction should + be committed */ + bool commit_trx) /*!< in: true - commit transaction + false - the current SQL statement + ended */ { DBUG_ENTER("innobase_commit"); DBUG_ASSERT(hton == innodb_hton_ptr); @@ -4947,11 +4768,9 @@ static int innobase_commit( DBUG_RETURN(0); } -/*****************************************************************/ /** - Rolls back a transaction or the latest SQL statement. +/** Rolls back a transaction or the latest SQL statement. @return 0 or error number */ static int innobase_rollback( - /*==============*/ handlerton *hton, /*!< in: InnoDB handlerton */ THD *thd, /*!< in: handle to the MySQL thread of the user whose transaction should @@ -5015,12 +4834,9 @@ static int innobase_rollback( DBUG_RETURN(convert_error_code_to_mysql(error, 0, trx->mysql_thd)); } -/*****************************************************************/ /** - Rolls back a transaction +/** Rolls back a transaction @return 0 or error number */ -static int innobase_rollback_trx( - /*==================*/ - trx_t *trx) /*!< in: transaction */ +static int innobase_rollback_trx(trx_t *trx) /*!< in: transaction */ { dberr_t error = DB_SUCCESS; @@ -5045,12 +4861,10 @@ static int innobase_rollback_trx( DBUG_RETURN(convert_error_code_to_mysql(error, 0, trx->mysql_thd)); } -/*****************************************************************/ /** - Rolls back a transaction to a savepoint. +/** Rolls back a transaction to a savepoint. @return 0 if success, HA_ERR_NO_SAVEPOINT if no savepoint with the given name */ static int innobase_rollback_to_savepoint( - /*===========================*/ handlerton *hton, /*!< in: InnoDB handlerton */ THD *thd, /*!< in: handle to the MySQL thread of the user whose transaction should @@ -5084,14 +4898,12 @@ static int innobase_rollback_to_savepoint( DBUG_RETURN(convert_error_code_to_mysql(error, 0, NULL)); } -/*****************************************************************/ /** - Check whether innodb state allows to safely release MDL locks after +/** Check whether innodb state allows to safely release MDL locks after rollback to savepoint. When binlog is on, MDL locks acquired after savepoint unit are not released if there are any locks held in InnoDB. @return true if it is safe, false if its not safe. */ static bool innobase_rollback_to_savepoint_can_release_mdl( - /*===========================================*/ handlerton *hton, /*!< in: InnoDB handlerton */ THD *thd) /*!< in: handle to the MySQL thread of the user whose transaction should @@ -5113,12 +4925,10 @@ static bool innobase_rollback_to_savepoint_can_release_mdl( DBUG_RETURN(false); } -/*****************************************************************/ /** - Release transaction savepoint name. +/** Release transaction savepoint name. @return 0 if success, HA_ERR_NO_SAVEPOINT if no savepoint with the given name */ static int innobase_release_savepoint( - /*=======================*/ handlerton *hton, /*!< in: handlerton for InnoDB */ THD *thd, /*!< in: handle to the MySQL thread of the user whose transaction's @@ -5149,11 +4959,9 @@ static int innobase_release_savepoint( DBUG_RETURN(convert_error_code_to_mysql(error, 0, NULL)); } -/*****************************************************************/ /** - Sets a transaction savepoint. +/** Sets a transaction savepoint. @return always 0, that is, always succeeds */ static int innobase_savepoint( - /*===============*/ handlerton *hton, /*!< in: handle to the InnoDB handlerton */ THD *thd, /*!< in: handle to the MySQL thread */ void *savepoint) /*!< in: savepoint data */ @@ -5188,11 +4996,9 @@ static int innobase_savepoint( DBUG_RETURN(convert_error_code_to_mysql(error, 0, NULL)); } -/*****************************************************************/ /** - Frees a possible InnoDB trx object associated with the current THD. +/** Frees a possible InnoDB trx object associated with the current THD. @return 0 or error number */ static int innobase_close_connection( - /*======================*/ handlerton *hton, /*!< in: innobase handlerton */ THD *thd) /*!< in: handle to the MySQL thread of the user whose resources should be free'd */ @@ -5271,10 +5077,8 @@ static int innobase_close_connection( DBUG_RETURN(0); } -/*****************************************************************/ /** - Cancel any pending lock request associated with the current THD. */ +/** Cancel any pending lock request associated with the current THD. */ static void innobase_kill_connection( - /*======================*/ handlerton *hton, /*!< in: innobase handlerton */ THD *thd) /*!< in: handle to the MySQL thread being killed */ @@ -5292,12 +5096,8 @@ static void innobase_kill_connection( DBUG_VOID_RETURN; } -/*************************************************************************/ /** - ** - *InnoDB - *database - *tables - *****************************************************************************/ +/** ** InnoDB database tables + *****************************************************************************/ /** The requested compressed page size (key_block_size) is given in kilobytes. If it is a valid number, store @@ -5373,13 +5173,10 @@ enum row_type ha_innobase::get_real_row_type( } } -/****************************************************************/ /** - Get the table flags to use for the statement. +/** Get the table flags to use for the statement. @return table flags */ -handler::Table_flags ha_innobase::table_flags() const -/*============================*/ -{ +handler::Table_flags ha_innobase::table_flags() const { THD *thd = ha_thd(); handler::Table_flags flags = m_int_table_flags; @@ -5410,23 +5207,15 @@ handler::Table_flags ha_innobase::table_flags() const return (flags | HA_BINLOG_STMT_CAPABLE); } -/****************************************************************/ /** - Returns the table type (storage engine name). +/** Returns the table type (storage engine name). @return table type */ -const char *ha_innobase::table_type() const -/*===========================*/ -{ - return (innobase_hton_name); -} +const char *ha_innobase::table_type() const { return (innobase_hton_name); } -/****************************************************************/ /** - Returns the operations supported for indexes. +/** Returns the operations supported for indexes. @return flags of supported operations */ -ulong ha_innobase::index_flags( - /*=====================*/ - uint key, uint, bool) const { +ulong ha_innobase::index_flags(uint key, uint, bool) const { if (table_share->key_info[key].algorithm == HA_KEY_ALG_FULLTEXT) { return (0); } @@ -5456,23 +5245,15 @@ ulong ha_innobase::index_flags( return (flags); } -/****************************************************************/ /** - Returns the maximum number of keys. +/** Returns the maximum number of keys. @return MAX_KEY */ -uint ha_innobase::max_supported_keys() const -/*===================================*/ -{ - return (MAX_KEY); -} +uint ha_innobase::max_supported_keys() const { return (MAX_KEY); } -/****************************************************************/ /** - Returns the maximum key length. +/** Returns the maximum key length. @return maximum supported key length, in bytes */ -uint ha_innobase::max_supported_key_length() const -/*=========================================*/ -{ +uint ha_innobase::max_supported_key_length() const { /* An InnoDB page must store >= 2 keys; a secondary key record must also contain the primary key value. Therefore, if both the primary key and the secondary key are at this maximum length, @@ -5495,15 +5276,10 @@ uint ha_innobase::max_supported_key_length() const } } -/****************************************************************/ /** - Determines if the primary key is clustered index. +/** Determines if the primary key is clustered index. @return true */ -bool ha_innobase::primary_key_is_clustered() const -/*=========================================*/ -{ - return (true); -} +bool ha_innobase::primary_key_is_clustered() const { return (true); } /** Normalizes a table name string. A normalized name consists of the database name catenated to '/' @@ -5570,9 +5346,7 @@ void create_table_info_t::normalize_table_name_low(char *norm_name, #ifdef UNIV_DEBUG /********************************************************************* Test normalize_table_name_low(). */ -static void test_normalize_table_name_low() -/*===========================*/ -{ +static void test_normalize_table_name_low() { char norm_name[FN_REFLEN]; const char *test_data[][2] = { /* input, expected result */ @@ -5634,9 +5408,7 @@ static void test_normalize_table_name_low() /********************************************************************* Test ut_format_name(). */ -static void test_ut_format_name() -/*=================*/ -{ +static void test_ut_format_name() { char buf[NAME_LEN * 3]; struct { @@ -5979,8 +5751,7 @@ void innobase_build_v_templ(const TABLE *table, const dict_table_t *ib_table, } } -/*******************************************************************/ /** - This function builds a translation table in INNOBASE_SHARE +/** This function builds a translation table in INNOBASE_SHARE structure for fast index location with mysql array number from its table->key_info structure. This also provides the necessary translation between the key order in mysql key_info and InnoDB ib_table->indexes if @@ -5991,7 +5762,6 @@ void innobase_build_v_templ(const TABLE *table, const dict_table_t *ib_table, handle will be closed before the index creation/drop. @return true if index translation table built successfully */ static bool innobase_build_index_translation( - /*=============================*/ const TABLE *table, /*!< in: table in MySQL data dictionary */ dict_table_t *ib_table, /*!< in: table in InnoDB data @@ -6091,8 +5861,7 @@ static bool innobase_build_index_translation( DBUG_RETURN(ret); } -/*******************************************************************/ /** - This function uses index translation table to quickly locate the +/** This function uses index translation table to quickly locate the requested index structure. Note we do not have mutex protection for the index translatoin table access, it is based on the assumption that there is no concurrent @@ -6101,7 +5870,6 @@ static bool innobase_build_index_translation( @return dict_index_t structure for requested index. NULL if fail to locate the index structure. */ static dict_index_t *innobase_index_lookup( - /*==================*/ INNOBASE_SHARE *share, /*!< in: share structure for index translation table. */ uint keynr) /*!< in: index number for the requested @@ -6774,10 +6542,8 @@ dict_table_t *ha_innobase::open_dict_table(const char *table_name, DBUG_RETURN(ib_table); } -handler *ha_innobase::clone( - /*===============*/ - const char *name, /*!< in: table name */ - MEM_ROOT *mem_root) /*!< in: memory context */ +handler *ha_innobase::clone(const char *name, /*!< in: table name */ + MEM_ROOT *mem_root) /*!< in: memory context */ { DBUG_ENTER("ha_innobase::clone"); @@ -6793,21 +6559,16 @@ handler *ha_innobase::clone( DBUG_RETURN(new_handler); } -uint ha_innobase::max_supported_key_part_length() const -/*==============================================*/ -{ +uint ha_innobase::max_supported_key_part_length() const { /* A table format specific index column length check will be performed at ha_innobase::add_index() and row_create_index_for_mysql() */ return (REC_VERSION_56_MAX_INDEX_COL_LEN); } -/******************************************************************/ /** - Closes a handle to an InnoDB table. +/** Closes a handle to an InnoDB table. @return 0 */ -int ha_innobase::close() -/*================*/ -{ +int ha_innobase::close() { DBUG_ENTER("ha_innobase::close"); if (m_prebuilt->m_temp_read_shared) { @@ -6847,13 +6608,10 @@ static inline uint get_field_offset(const TABLE *table, const Field *field) { return (static_cast((field->ptr - table->record[0]))); } -/******************************************************************/ /** - compare two character string according to their charset. */ -int innobase_fts_text_cmp( - /*==================*/ - const void *cs, /*!< in: Character set */ - const void *p1, /*!< in: key */ - const void *p2) /*!< in: node */ +/** compare two character string according to their charset. */ +int innobase_fts_text_cmp(const void *cs, /*!< in: Character set */ + const void *p1, /*!< in: key */ + const void *p2) /*!< in: node */ { const CHARSET_INFO *charset = (const CHARSET_INFO *)cs; const fts_string_t *s1 = (const fts_string_t *)p1; @@ -6863,13 +6621,11 @@ int innobase_fts_text_cmp( s2->f_str, static_cast(s2->f_len), 0)); } -/******************************************************************/ /** - compare two character string case insensitively according to their charset. */ -int innobase_fts_text_case_cmp( - /*=======================*/ - const void *cs, /*!< in: Character set */ - const void *p1, /*!< in: key */ - const void *p2) /*!< in: node */ +/** compare two character string case insensitively according to their charset. + */ +int innobase_fts_text_case_cmp(const void *cs, /*!< in: Character set */ + const void *p1, /*!< in: key */ + const void *p2) /*!< in: node */ { const CHARSET_INFO *charset = (const CHARSET_INFO *)cs; const fts_string_t *s1 = (const fts_string_t *)p1; @@ -6884,13 +6640,10 @@ int innobase_fts_text_case_cmp( s2->f_str, static_cast(newlen), 0)); } -/******************************************************************/ /** - Get the first character's code position for FTS index partition. */ -ulint innobase_strnxfrm( - /*==============*/ - const CHARSET_INFO *cs, /*!< in: Character set */ - const uchar *str, /*!< in: string */ - const ulint len) /*!< in: string length */ +/** Get the first character's code position for FTS index partition. */ +ulint innobase_strnxfrm(const CHARSET_INFO *cs, /*!< in: Character set */ + const uchar *str, /*!< in: string */ + const ulint len) /*!< in: string length */ { uchar mystr[2]; ulint value; @@ -6910,13 +6663,10 @@ ulint innobase_strnxfrm( return (value); } -/******************************************************************/ /** - compare two character string according to their charset. */ -int innobase_fts_text_cmp_prefix( - /*=========================*/ - const void *cs, /*!< in: Character set */ - const void *p1, /*!< in: prefix key */ - const void *p2) /*!< in: value to compare */ +/** compare two character string according to their charset. */ +int innobase_fts_text_cmp_prefix(const void *cs, /*!< in: Character set */ + const void *p1, /*!< in: prefix key */ + const void *p2) /*!< in: value to compare */ { const CHARSET_INFO *charset = (const CHARSET_INFO *)cs; const fts_string_t *s1 = (const fts_string_t *)p1; @@ -6931,10 +6681,8 @@ int innobase_fts_text_cmp_prefix( return (-result); } -/******************************************************************/ /** - Makes all characters in a string lower case. */ +/** Makes all characters in a string lower case. */ size_t innobase_fts_casedn_str( - /*====================*/ CHARSET_INFO *cs, /*!< in: Character set */ char *src, /*!< in: string to put in lower case */ size_t src_len, /*!< in: input string length */ @@ -6956,12 +6704,10 @@ size_t innobase_fts_casedn_str( #define misc_word_char(X) 0 -/*************************************************************/ /** - Get the next token from the given string and store it in *token. +/** Get the next token from the given string and store it in *token. It is mostly copied from MyISAM's doc parsing function ft_simple_get_word() @return length of string processed */ ulint innobase_mysql_fts_get_token( - /*=========================*/ CHARSET_INFO *cs, /*!< in: Character set */ const byte *start, /*!< in: start of text */ const byte *end, /*!< in: one character past end of @@ -7132,22 +6878,18 @@ ulint get_innobase_type_from_mysql_type(ulint *unsigned_flag, const void *f) { return (0); } -/*******************************************************************/ /** - Reads an unsigned integer value < 64k from 2 bytes, in the little-endian +/** Reads an unsigned integer value < 64k from 2 bytes, in the little-endian storage format. @return value */ static inline uint innobase_read_from_2_little_endian( - /*===============================*/ const uchar *buf) /*!< in: from where to read */ { return ((uint)((ulint)(buf[0]) + 256 * ((ulint)(buf[1])))); } -/**************************************************************/ /** - Determines if a field is needed in a m_prebuilt struct 'template'. +/** Determines if a field is needed in a m_prebuilt struct 'template'. @return field to use, or NULL if the field is not needed */ static const Field *build_template_needs_field( - /*=======================*/ ibool index_contains, /*!< in: dict_index_contains_col_or_prefix( index, i) */ @@ -7203,11 +6945,9 @@ static const Field *build_template_needs_field( return (NULL); } -/**************************************************************/ /** - Determines if a field is needed in a m_prebuilt struct 'template'. +/** Determines if a field is needed in a m_prebuilt struct 'template'. @return whether the field is needed for index condition pushdown */ inline bool build_template_needs_field_in_icp( - /*==============================*/ const dict_index_t *index, /*!< in: InnoDB index */ const row_prebuilt_t *prebuilt, /*!< in: row fetch template */ bool contains, /*!< in: whether the index contains @@ -7223,11 +6963,9 @@ inline bool build_template_needs_field_in_icp( prebuilt->index, i, is_virtual)); } -/**************************************************************/ /** - Adds a field to a m_prebuilt struct 'template'. +/** Adds a field to a m_prebuilt struct 'template'. @return the field template */ static mysql_row_templ_t *build_template_field( - /*=================*/ row_prebuilt_t *prebuilt, /*!< in/out: template */ dict_index_t *clust_index, /*!< in: InnoDB clustered index */ dict_index_t *index, /*!< in: InnoDB index to use */ @@ -7332,12 +7070,10 @@ static mysql_row_templ_t *build_template_field( return (templ); } -/**************************************************************/ /** - Builds a 'template' to the m_prebuilt struct. The template is used in fast +/** Builds a 'template' to the m_prebuilt struct. The template is used in fast retrieval of just those column values MySQL needs in its processing. */ void ha_innobase::build_template( - /*========================*/ bool whole_row) /*!< in: true=ROW_MYSQL_WHOLE_ROW, false=ROW_MYSQL_REC_FIELDS */ { @@ -7648,17 +7384,14 @@ void ha_innobase::build_template( } } -/********************************************************************/ /** - This special handling is really to overcome the limitations of MySQL's +/** This special handling is really to overcome the limitations of MySQL's binlogging. We need to eliminate the non-determinism that will arise in INSERT ... SELECT type of statements, since MySQL binlog only stores the min value of the autoinc interval. Once that is fixed we can get rid of the special lock handling. @return DB_SUCCESS if all OK else error code */ -dberr_t ha_innobase::innobase_lock_autoinc(void) -/*====================================*/ -{ +dberr_t ha_innobase::innobase_lock_autoinc(void) { DBUG_ENTER("ha_innobase::innobase_lock_autoinc"); dberr_t error = DB_SUCCESS; long lock_mode = innobase_autoinc_lock_mode; @@ -7719,13 +7452,11 @@ dberr_t ha_innobase::innobase_lock_autoinc(void) DBUG_RETURN(error); } -/********************************************************************/ /** - Store the autoinc value in the table. The autoinc value is only set if +/** Store the autoinc value in the table. The autoinc value is only set if it's greater than the existing autoinc value in the table. @return DB_SUCCESS if all went well else error code */ dberr_t ha_innobase::innobase_set_max_autoinc( - /*==================================*/ ulonglong auto_inc) /*!< in: value to store */ { dberr_t error; @@ -7763,14 +7494,11 @@ int ha_innobase::intrinsic_table_write_row(uchar *record) { convert_error_code_to_mysql(err, m_prebuilt->table->flags, m_user_thd)); } -/********************************************************************/ /** - Stores a row in an InnoDB database, to the table specified in this +/** Stores a row in an InnoDB database, to the table specified in this handle. @return error code */ -int ha_innobase::write_row( - /*===================*/ - uchar *record) /*!< in: a row in MySQL format */ +int ha_innobase::write_row(uchar *record) /*!< in: a row in MySQL format */ { dberr_t error; int error_result = 0; @@ -7993,12 +7721,10 @@ static byte *innodb_fill_old_vcol_val(row_prebuilt_t *prebuilt, return (buf); } -/**********************************************************************/ /** - Checks which fields have changed in a row and stores information +/** Checks which fields have changed in a row and stores information of them to an update vector. @return DB_SUCCESS or error code */ static dberr_t calc_row_difference( - /*================*/ upd_t *uvect, /*!< in/out: update vector */ const uchar *old_row, /*!< in: old row in MySQL format */ uchar *new_row, /*!< in: new row in MySQL format */ @@ -8510,12 +8236,10 @@ int ha_innobase::update_row(const uchar *old_row, uchar *new_row) { DBUG_RETURN(err); } -/**********************************************************************/ /** - Deletes a row given as the parameter. +/** Deletes a row given as the parameter. @return error number or 0 */ int ha_innobase::delete_row( - /*====================*/ const uchar *record) /*!< in: a row in MySQL format */ { dberr_t error; @@ -8582,14 +8306,11 @@ int ha_innobase::delete_all_rows() { DBUG_RETURN(0); } -/**********************************************************************/ /** - Removes a new lock set on a row, if it was not read optimistically. This can +/** Removes a new lock set on a row, if it was not read optimistically. This can be called after a row has been read in the processing of an UPDATE or a DELETE query, when trx_t::allow_semi_consistent() is true. */ -void ha_innobase::unlock_row(void) -/*=========================*/ -{ +void ha_innobase::unlock_row(void) { DBUG_ENTER("ha_innobase::unlock_row"); /* Consistent read does not take any locks, thus there is @@ -8635,17 +8356,13 @@ void ha_innobase::unlock_row(void) /* See handler.h and row0mysql.h for docs on this function. */ -bool ha_innobase::was_semi_consistent_read(void) -/*=======================================*/ -{ +bool ha_innobase::was_semi_consistent_read(void) { return (m_prebuilt->row_read_type == ROW_READ_DID_SEMI_CONSISTENT); } /* See handler.h and row0mysql.h for docs on this function. */ -void ha_innobase::try_semi_consistent_read(bool yes) -/*===========================================*/ -{ +void ha_innobase::try_semi_consistent_read(bool yes) { ut_a(m_prebuilt->trx == thd_to_trx(ha_thd())); if (yes && m_prebuilt->trx->allow_semi_consistent()) { @@ -8656,28 +8373,22 @@ void ha_innobase::try_semi_consistent_read(bool yes) } } -/******************************************************************/ /** - Initializes a handle to use an index. +/** Initializes a handle to use an index. @return 0 or error number */ -int ha_innobase::index_init( - /*====================*/ - uint keynr, /*!< in: key (index) number */ - bool sorted) /*!< in: 1 if result MUST be sorted - according to index */ +int ha_innobase::index_init(uint keynr, /*!< in: key (index) number */ + bool sorted) /*!< in: 1 if result MUST be sorted + according to index */ { DBUG_ENTER("index_init"); DBUG_RETURN(change_active_index(keynr)); } -/******************************************************************/ /** - Currently does nothing. +/** Currently does nothing. @return 0 */ -int ha_innobase::index_end(void) -/*========================*/ -{ +int ha_innobase::index_end(void) { DBUG_ENTER("index_end"); if (m_prebuilt->index->last_sel_cur) { @@ -8693,12 +8404,9 @@ int ha_innobase::index_end(void) DBUG_RETURN(0); } -/*********************************************************************/ /** - Converts a search mode flag understood by MySQL to a flag understood +/** Converts a search mode flag understood by MySQL to a flag understood by InnoDB. */ -page_cur_mode_t convert_search_mode_to_innobase( - /*============================*/ - ha_rkey_function find_flag) { +page_cur_mode_t convert_search_mode_to_innobase(ha_rkey_function find_flag) { switch (find_flag) { case HA_READ_KEY_EXACT: /* this does not require the index to be UNIQUE */ @@ -8784,13 +8492,11 @@ start of a new SQL statement. Since the query id can theoretically overwrap, we use this test only as a secondary way of determining the start of a new SQL statement. */ -/**********************************************************************/ /** - Positions an index cursor to the index specified in the handle. Fetches the +/** Positions an index cursor to the index specified in the handle. Fetches the row if any. @return 0, HA_ERR_KEY_NOT_FOUND, or error number */ int ha_innobase::index_read( - /*====================*/ uchar *buf, /*!< in/out: buffer for the returned row */ const uchar *key_ptr, /*!< in: key value; if this is NULL @@ -8944,13 +8650,11 @@ int ha_innobase::index_read( DBUG_RETURN(error); } -/*******************************************************************/ /** - The following functions works like index_read, but it find the last +/** The following functions works like index_read, but it find the last row with the current key value or prefix. @return 0, HA_ERR_KEY_NOT_FOUND, or an error code */ int ha_innobase::index_read_last( - /*=========================*/ uchar *buf, /*!< out: fetched row */ const uchar *key_ptr, /*!< in: key value, or a prefix of a full key value */ @@ -8960,12 +8664,10 @@ int ha_innobase::index_read_last( return (index_read(buf, key_ptr, key_len, HA_READ_PREFIX_LAST)); } -/********************************************************************/ /** - Get the index for a handle. Does not change active index. +/** Get the index for a handle. Does not change active index. @return NULL or index instance. */ dict_index_t *ha_innobase::innobase_get_index( - /*============================*/ uint keynr) /*!< in: use this index; MAX_KEY means always clustered index, even if it was internally generated by InnoDB */ @@ -9007,12 +8709,10 @@ dict_index_t *ha_innobase::innobase_get_index( DBUG_RETURN(index); } -/********************************************************************/ /** - Changes the active index of a handle. +/** Changes the active index of a handle. @return 0 or error code */ int ha_innobase::change_active_index( - /*=============================*/ uint keynr) /*!< in: use this index; MAX_KEY means always clustered index, even if it was internally generated by InnoDB */ @@ -9110,13 +8810,11 @@ int ha_innobase::change_active_index( DBUG_RETURN(0); } -/***********************************************************************/ /** - Reads the next or previous row from a cursor, which must have previously been - positioned using index_read. +/** Reads the next or previous row from a cursor, which must have previously + been positioned using index_read. @return 0, HA_ERR_END_OF_FILE, or error number */ int ha_innobase::general_fetch( - /*=======================*/ uchar *buf, /*!< in/out: buffer for next row in MySQL format */ uint direction, /*!< in: ROW_SEL_NEXT or ROW_SEL_PREV */ @@ -9188,13 +8886,11 @@ int ha_innobase::general_fetch( DBUG_RETURN(error); } -/***********************************************************************/ /** - Reads the next row from a cursor, which must have previously been +/** Reads the next row from a cursor, which must have previously been positioned using index_read. @return 0, HA_ERR_END_OF_FILE, or error number */ int ha_innobase::index_next( - /*====================*/ uchar *buf) /*!< in/out: buffer for next row in MySQL format */ { @@ -9203,28 +8899,23 @@ int ha_innobase::index_next( return (general_fetch(buf, ROW_SEL_NEXT, 0)); } -/*******************************************************************/ /** - Reads the next row matching to the key value given as the parameter. +/** Reads the next row matching to the key value given as the parameter. @return 0, HA_ERR_END_OF_FILE, or error number */ -int ha_innobase::index_next_same( - /*=========================*/ - uchar *buf, /*!< in/out: buffer for the row */ - const uchar *key, /*!< in: key value */ - uint keylen) /*!< in: key value length */ +int ha_innobase::index_next_same(uchar *buf, /*!< in/out: buffer for the row */ + const uchar *key, /*!< in: key value */ + uint keylen) /*!< in: key value length */ { ha_statistic_increment(&System_status_var::ha_read_next_count); return (general_fetch(buf, ROW_SEL_NEXT, m_last_match_mode)); } -/***********************************************************************/ /** - Reads the previous row from a cursor, which must have previously been +/** Reads the previous row from a cursor, which must have previously been positioned using index_read. @return 0, HA_ERR_END_OF_FILE, or error number */ int ha_innobase::index_prev( - /*====================*/ uchar *buf) /*!< in/out: buffer for previous row in MySQL format */ { ha_statistic_increment(&System_status_var::ha_read_prev_count); @@ -9232,14 +8923,11 @@ int ha_innobase::index_prev( return (general_fetch(buf, ROW_SEL_PREV, 0)); } -/********************************************************************/ /** - Positions a cursor on the first record in an index and reads the +/** Positions a cursor on the first record in an index and reads the corresponding row to buf. @return 0, HA_ERR_END_OF_FILE, or error code */ -int ha_innobase::index_first( - /*=====================*/ - uchar *buf) /*!< in/out: buffer for the row */ +int ha_innobase::index_first(uchar *buf) /*!< in/out: buffer for the row */ { DBUG_ENTER("index_first"); @@ -9256,14 +8944,11 @@ int ha_innobase::index_first( DBUG_RETURN(error); } -/********************************************************************/ /** - Positions a cursor on the last record in an index and reads the +/** Positions a cursor on the last record in an index and reads the corresponding row to buf. @return 0, HA_ERR_END_OF_FILE, or error code */ -int ha_innobase::index_last( - /*====================*/ - uchar *buf) /*!< in/out: buffer for the row */ +int ha_innobase::index_last(uchar *buf) /*!< in/out: buffer for the row */ { DBUG_ENTER("index_last"); @@ -9302,23 +8987,16 @@ int ha_innobase::rnd_init(bool scan) { DBUG_RETURN(err); } -/*****************************************************************/ /** - Ends a table scan. +/** Ends a table scan. @return 0 or error number */ -int ha_innobase::rnd_end(void) -/*======================*/ -{ - return (index_end()); -} +int ha_innobase::rnd_end(void) { return (index_end()); } -/*****************************************************************/ /** - Reads the next row in a table scan (also used to read the FIRST row +/** Reads the next row in a table scan (also used to read the FIRST row in a table scan). @return 0, HA_ERR_END_OF_FILE, or error number */ int ha_innobase::rnd_next( - /*==================*/ uchar *buf) /*!< in/out: returns the row in this buffer, in MySQL format */ { @@ -9343,12 +9021,10 @@ int ha_innobase::rnd_next( DBUG_RETURN(error); } -/**********************************************************************/ /** - Fetches a row from the table based on a row reference. +/** Fetches a row from the table based on a row reference. @return 0, HA_ERR_KEY_NOT_FOUND, or error code */ int ha_innobase::rnd_pos( - /*=================*/ uchar *buf, /*!< in/out: buffer for the row */ uchar *pos) /*!< in: primary key value of the row in the MySQL format, or the row id if the clustered @@ -9376,13 +9052,10 @@ int ha_innobase::rnd_pos( DBUG_RETURN(error); } -/**********************************************************************/ /** - Initialize FT index scan +/** Initialize FT index scan @return 0 or error number */ -int ha_innobase::ft_init() -/*==================*/ -{ +int ha_innobase::ft_init() { DBUG_ENTER("ft_init"); trx_t *trx = check_trx_exists(ha_thd()); @@ -9399,15 +9072,12 @@ int ha_innobase::ft_init() DBUG_RETURN(rnd_init(false)); } -/**********************************************************************/ /** - Initialize FT index scan +/** Initialize FT index scan @return FT_INFO structure if successful or NULL */ -FT_INFO *ha_innobase::ft_init_ext( - /*=====================*/ - uint flags, /* in: */ - uint keynr, /* in: */ - String *key) /* in: */ +FT_INFO *ha_innobase::ft_init_ext(uint flags, /* in: */ + uint keynr, /* in: */ + String *key) /* in: */ { NEW_FT_INFO *fts_hdl = NULL; dict_index_t *index; @@ -9530,15 +9200,12 @@ FT_INFO *ha_innobase::ft_init_ext( return (reinterpret_cast(fts_hdl)); } -/**********************************************************************/ /** - Initialize FT index scan +/** Initialize FT index scan @return FT_INFO structure if successful or NULL */ -FT_INFO *ha_innobase::ft_init_ext_with_hints( - /*================================*/ - uint keynr, /* in: key num */ - String *key, /* in: key */ - Ft_hints *hints) /* in: hints */ +FT_INFO *ha_innobase::ft_init_ext_with_hints(uint keynr, /* in: key num */ + String *key, /* in: key */ + Ft_hints *hints) /* in: hints */ { /* TODO Implement function properly working with FT hint. */ if (hints->get_flags() & FT_NO_RANKING) { @@ -9550,12 +9217,10 @@ FT_INFO *ha_innobase::ft_init_ext_with_hints( return (ft_init_ext(hints->get_flags(), keynr, key)); } -/*****************************************************************/ /** - Set up search tuple for a query through FTS_DOC_ID_INDEX on +/** Set up search tuple for a query through FTS_DOC_ID_INDEX on supplied Doc ID. This is used by MySQL to retrieve the documents once the search result (Doc IDs) is available */ static void innobase_fts_create_doc_id_key( - /*===========================*/ dtuple_t *tuple, /* in/out: m_prebuilt->search_tuple */ const dict_index_t *index, /* in: index (FTS_DOC_ID_INDEX) */ doc_id_t *doc_id) /* in/out: doc id to search, value @@ -9591,13 +9256,10 @@ static void innobase_fts_create_doc_id_key( } } -/**********************************************************************/ /** - Fetch next result from the FT result set +/** Fetch next result from the FT result set @return error code */ -int ha_innobase::ft_read( - /*=================*/ - uchar *buf) /*!< in/out: buf contain result row */ +int ha_innobase::ft_read(uchar *buf) /*!< in/out: buf contain result row */ { TrxInInnoDB trx_in_innodb(m_prebuilt->trx); @@ -10298,10 +9960,8 @@ const dd::Index *get_my_dd_index( return (dd_index != nullptr) ? &dd_index->index() : nullptr; } -/*****************************************************************/ /** - Creates an index in an InnoDB database. */ +/** Creates an index in an InnoDB database. */ inline int create_index( - /*=========*/ trx_t *trx, /*!< in: InnoDB transaction handle */ const TABLE *form, /*!< in: information on table columns and indexes */ @@ -10503,11 +10163,9 @@ inline int create_index( DBUG_RETURN(error); } -/*****************************************************************/ /** - Creates an index to an InnoDB table when the user has defined no +/** Creates an index to an InnoDB table when the user has defined no primary index. */ inline int create_clustered_index_when_no_primary( - /*===================================*/ trx_t *trx, /*!< in: InnoDB transaction handle */ ulint flags, /*!< in: InnoDB table flags */ const char *table_name) /*!< in: table name */ @@ -11029,11 +10687,9 @@ const char *create_table_info_t::create_options_are_invalid() { return (ret); } -/*****************************************************************/ /** - Update create_info. Used in SHOW CREATE TABLE et al. */ +/** Update create_info. Used in SHOW CREATE TABLE et al. */ void ha_innobase::update_create_info( - /*============================*/ HA_CREATE_INFO *create_info) /*!< in/out: create info */ { if (!(create_info->used_fields & HA_CREATE_USED_AUTO)) { @@ -11061,11 +10717,9 @@ void ha_innobase::update_create_info( } } -/*****************************************************************/ /** - Initialize the table FTS stopword list +/** Initialize the table FTS stopword list @return true if success */ ibool innobase_fts_load_stopword( - /*=======================*/ dict_table_t *table, /*!< in: Table has the FTS */ trx_t *trx, /*!< in: transaction */ THD *thd) /*!< in: current thread */ @@ -13719,8 +13373,7 @@ static int innobase_alter_tablespace(handlerton *hton, THD *thd, DBUG_RETURN(error); } -/*********************************************************************/ /** - Renames an InnoDB table. +/** Renames an InnoDB table. @param[in] from Old name of the table. @param[in] to New name of the table. @param[in] from_table_def dd::Table object describing old version @@ -13756,8 +13409,7 @@ int ha_innobase::rename_table(const char *from, const char *to, thd, from, to, from_table_def, to_table_def)); } -/*********************************************************************/ /** - Returns the exact number of records that this client can see using this +/** Returns the exact number of records that this client can see using this handler object. @return Error code in case something goes wrong. These errors will abort the current query: @@ -13767,9 +13419,7 @@ int ha_innobase::rename_table(const char *from, const char *to, case HA_ERR_QUERY_INTERRUPTED: For other error codes, the server will fall back to counting records. */ -int ha_innobase::records( - /*==================*/ - ha_rows *num_rows) /*!< out: number of rows */ +int ha_innobase::records(ha_rows *num_rows) /*!< out: number of rows */ { DBUG_ENTER("ha_innobase::records()"); @@ -13855,12 +13505,10 @@ int ha_innobase::records( DBUG_RETURN(0); } -/*********************************************************************/ /** - Estimates the number of index records in a range. +/** Estimates the number of index records in a range. @return estimated number of rows */ ha_rows ha_innobase::records_in_range( - /*==========================*/ uint keynr, /*!< in: index number */ key_range *min_key, /*!< in: start key value of the range, may also be 0 */ @@ -13975,14 +13623,11 @@ ha_rows ha_innobase::records_in_range( DBUG_RETURN((ha_rows)n_rows); } -/*********************************************************************/ /** - Gives an UPPER BOUND to the number of rows in a table. This is used in +/** Gives an UPPER BOUND to the number of rows in a table. This is used in filesort.cc. @return upper bound of rows */ -ha_rows ha_innobase::estimate_rows_upper_bound() -/*====================================*/ -{ +ha_rows ha_innobase::estimate_rows_upper_bound() { const dict_index_t *index; ulonglong estimate; ulonglong local_data_file_length; @@ -14024,15 +13669,12 @@ ha_rows ha_innobase::estimate_rows_upper_bound() DBUG_RETURN((ha_rows)estimate); } -/*********************************************************************/ /** - How many seeks it will take to read through the table. This is to be +/** How many seeks it will take to read through the table. This is to be comparable to the number returned by records_in_range so that we can decide if we should scan the table or use keys. @return estimated time measured in disk seeks */ -double ha_innobase::scan_time() -/*====================*/ -{ +double ha_innobase::scan_time() { /* Since MySQL seems to favor table scans too much over index searches, we pretend that a sequential read takes the same time as a random disk read, that is, we do not divide the following @@ -14062,13 +13704,11 @@ double ha_innobase::scan_time() return ((double)stat_clustered_index_size); } -/******************************************************************/ /** - Calculate the time it takes to read a set of ranges through an index +/** Calculate the time it takes to read a set of ranges through an index This enables us to optimise reads for clustered indexes. @return estimated time measured in disk seeks */ double ha_innobase::read_time( - /*===================*/ uint index, /*!< in: key number */ uint ranges, /*!< in: how many ranges */ ha_rows rows) /*!< in: estimated number of rows in the ranges */ @@ -14096,12 +13736,9 @@ double ha_innobase::read_time( return (ranges + (double)rows / (double)total_rows * time_for_scan); } -/******************************************************************/ /** - Return the size of the InnoDB memory buffer. */ +/** Return the size of the InnoDB memory buffer. */ -longlong ha_innobase::get_memory_buffer_size() const -/*=======================================*/ -{ +longlong ha_innobase::get_memory_buffer_size() const { return (srv_buf_pool_curr_size); } @@ -14112,8 +13749,7 @@ void innodb_set_buf_pool_size(long long buf_pool_size) { srv_buf_pool_curr_size = buf_pool_size; } -/*********************************************************************/ /** - Calculates the key number used inside MySQL for an Innobase index. We will +/** Calculates the key number used inside MySQL for an Innobase index. We will first check the "index translation table" for a match of the index to get the index number. If there does not exist an "index translation table", or not able to find the index in the translation table, then we will fall back @@ -14122,7 +13758,6 @@ void innodb_set_buf_pool_size(long long buf_pool_size) { default clustered index for the table @return the key number used inside MySQL */ static int innobase_get_mysql_key_number_for_index( - /*====================================*/ INNOBASE_SHARE *share, /*!< in: share structure for index translation table. */ const TABLE *table, /*!< in: table in MySQL data @@ -14697,14 +14332,11 @@ int ha_innobase::info_low(uint flag, bool is_analyze) { DBUG_RETURN(0); } -/*********************************************************************/ /** - Returns statistics information of the table to the MySQL interpreter, +/** Returns statistics information of the table to the MySQL interpreter, in various fields of the handle object. @return HA_ERR_* error code or 0 */ -int ha_innobase::info( - /*==============*/ - uint flag) /*!< in: what information is requested */ +int ha_innobase::info(uint flag) /*!< in: what information is requested */ { return (info_low(flag, false /* not ANALYZE */)); } @@ -15190,10 +14822,8 @@ Updates index cardinalities of the table, based on random dives into each index tree. This does NOT calculate exact statistics on the table. @return HA_ADMIN_* error code or HA_ADMIN_OK */ -int ha_innobase::analyze( - /*=================*/ - THD *thd, /*!< in: connection thread handle */ - HA_CHECK_OPT *check_opt) /*!< in: currently ignored */ +int ha_innobase::analyze(THD *thd, /*!< in: connection thread handle */ + HA_CHECK_OPT *check_opt) /*!< in: currently ignored */ { /* Simply call info_low() with all the flags and request recalculation of the statistics */ @@ -15207,14 +14837,11 @@ int ha_innobase::analyze( return (HA_ADMIN_OK); } -/**********************************************************************/ /** - This is mapped to "ALTER TABLE tablename ENGINE=InnoDB", which rebuilds +/** This is mapped to "ALTER TABLE tablename ENGINE=InnoDB", which rebuilds the table in MySQL. */ -int ha_innobase::optimize( - /*==================*/ - THD *thd, /*!< in: connection thread handle */ - HA_CHECK_OPT *check_opt) /*!< in: currently ignored */ +int ha_innobase::optimize(THD *thd, /*!< in: connection thread handle */ + HA_CHECK_OPT *check_opt) /*!< in: currently ignored */ { TrxInInnoDB trx_in_innodb(m_prebuilt->trx); @@ -15239,16 +14866,13 @@ int ha_innobase::optimize( } } -/*******************************************************************/ /** - Tries to check that an InnoDB table is not corrupted. If corruption is +/** Tries to check that an InnoDB table is not corrupted. If corruption is noticed, prints to stderr information about it. In case of corruption may also assert a failure and crash the server. @return HA_ADMIN_CORRUPT or HA_ADMIN_OK */ -int ha_innobase::check( - /*===============*/ - THD *thd, /*!< in: user thread handle */ - HA_CHECK_OPT *check_opt) /*!< in: check options */ +int ha_innobase::check(THD *thd, /*!< in: user thread handle */ + HA_CHECK_OPT *check_opt) /*!< in: check options */ { dict_index_t *index; ulint n_rows; @@ -15432,15 +15056,12 @@ int ha_innobase::check( DBUG_RETURN(is_ok ? HA_ADMIN_OK : HA_ADMIN_CORRUPT); } -/*******************************************************************/ /** - Gets the foreign key create info for a table stored in InnoDB. +/** Gets the foreign key create info for a table stored in InnoDB. @return own: character string in the form which can be inserted to the CREATE TABLE statement, MUST be freed with ha_innobase::free_foreign_key_create_info */ -char *ha_innobase::get_foreign_key_create_info(void) -/*==========================================*/ -{ +char *ha_innobase::get_foreign_key_create_info(void) { ut_a(m_prebuilt != NULL); /* We do not know if MySQL can call this function before calling @@ -15492,11 +15113,9 @@ char *ha_innobase::get_foreign_key_create_info(void) return (NULL); } -/***********************************************************************/ /** - Maps a InnoDB foreign key constraint to a equivalent MySQL foreign key info. +/** Maps a InnoDB foreign key constraint to a equivalent MySQL foreign key info. @return pointer to foreign key info */ static FOREIGN_KEY_INFO *get_foreign_key_info( - /*=================*/ THD *thd, /*!< in: user thread handle */ dict_foreign_t *foreign) /*!< in: foreign key constraint */ { @@ -15627,12 +15246,10 @@ static FOREIGN_KEY_INFO *get_foreign_key_info( return (pf_key_info); } -/*******************************************************************/ /** - Gets the list of foreign keys in this table. +/** Gets the list of foreign keys in this table. @return always 0, that is, always succeeds */ int ha_innobase::get_foreign_key_list( - /*==============================*/ THD *thd, /*!< in: user thread handle */ List *f_key_list) /*!< out: foreign key list */ { @@ -15663,12 +15280,10 @@ int ha_innobase::get_foreign_key_list( return (0); } -/*******************************************************************/ /** - Gets the set of foreign keys where this table is the referenced table. +/** Gets the set of foreign keys where this table is the referenced table. @return always 0, that is, always succeeds */ int ha_innobase::get_parent_foreign_key_list( - /*=====================================*/ THD *thd, /*!< in: user thread handle */ List *f_key_list) /*!< out: foreign key list */ { @@ -15851,15 +15466,12 @@ int ha_innobase::get_cascade_foreign_key_table_list( return (0); } -/*****************************************************************/ /** - Checks if ALTER TABLE may change the storage engine of the table. +/** Checks if ALTER TABLE may change the storage engine of the table. Changing storage engines is not allowed for tables for which there are foreign key constraints (parent or child tables). @return true if can switch engines */ -bool ha_innobase::can_switch_engines(void) -/*=================================*/ -{ +bool ha_innobase::can_switch_engines(void) { DBUG_ENTER("ha_innobase::can_switch_engines"); update_thd(); @@ -15877,16 +15489,13 @@ bool ha_innobase::can_switch_engines(void) DBUG_RETURN(can_switch); } -/*******************************************************************/ /** - Checks if a table is referenced by a foreign key. The MySQL manual states that - a REPLACE is either equivalent to an INSERT, or DELETE(s) + INSERT. Only a +/** Checks if a table is referenced by a foreign key. The MySQL manual states + that a REPLACE is either equivalent to an INSERT, or DELETE(s) + INSERT. Only a delete is then allowed internally to resolve a duplicate key conflict in REPLACE, not an update. @return > 0 if referenced by a FOREIGN KEY */ -uint ha_innobase::referenced_by_foreign_key(void) -/*========================================*/ -{ +uint ha_innobase::referenced_by_foreign_key(void) { if (dict_table_is_referenced_by_foreign_key(m_prebuilt->table)) { return (1); } @@ -15894,12 +15503,10 @@ uint ha_innobase::referenced_by_foreign_key(void) return (0); } -/*******************************************************************/ /** - Frees the foreign key create info for a table stored in InnoDB, if it is +/** Frees the foreign key create info for a table stored in InnoDB, if it is non-NULL. */ void ha_innobase::free_foreign_key_create_info( - /*======================================*/ char *str) /*!< in, own: create info string to free */ { if (str != NULL) { @@ -15907,13 +15514,10 @@ void ha_innobase::free_foreign_key_create_info( } } -/*******************************************************************/ /** - Tells something additional to the handler about how to do things. +/** Tells something additional to the handler about how to do things. @return 0 or error number */ -int ha_innobase::extra( - /*===============*/ - enum ha_extra_function operation) +int ha_innobase::extra(enum ha_extra_function operation) /*!< in: HA_EXTRA_FLUSH or some other flag */ { check_trx_exists(ha_thd()); @@ -16133,11 +15737,9 @@ int ha_innobase::start_stmt(THD *thd, thr_lock_type lock_type) { DBUG_RETURN(0); } -/******************************************************************/ /** - Maps a MySQL trx isolation level code to the InnoDB isolation level code +/** Maps a MySQL trx isolation level code to the InnoDB isolation level code @return InnoDB isolation level */ static inline ulint innobase_map_isolation_level( - /*=========================*/ enum_tx_isolation iso) /*!< in: MySQL isolation level code */ { switch (iso) { @@ -16156,8 +15758,7 @@ static inline ulint innobase_map_isolation_level( return (0); } -/******************************************************************/ /** - As MySQL will execute an external lock for every new table it uses when it +/** As MySQL will execute an external lock for every new table it uses when it starts to process an SQL statement (an exception is when MySQL calls start_stmt for the handle) we can use this function to store the pointer to the THD in the handle. We will also use this function to communicate @@ -16166,10 +15767,8 @@ static inline ulint innobase_map_isolation_level( the SQL statement in case of an error. @return 0 */ -int ha_innobase::external_lock( - /*=======================*/ - THD *thd, /*!< in: handle to the user thread */ - int lock_type) /*!< in: lock type */ +int ha_innobase::external_lock(THD *thd, /*!< in: handle to the user thread */ + int lock_type) /*!< in: lock type */ { DBUG_ENTER("ha_innobase::external_lock"); DBUG_PRINT("enter", ("lock_type: %d", lock_type)); @@ -16408,11 +16007,8 @@ int ha_innobase::external_lock( DBUG_RETURN(0); } -/************************************************************************/ /** - Here we export InnoDB status variables to MySQL. */ -static void innodb_export_status() -/*==================*/ -{ +/** Here we export InnoDB status variables to MySQL. */ +static void innodb_export_status() { if (innodb_inited) { srv_export_innodb_status(); } @@ -16862,12 +16458,9 @@ static bool innobase_show_status(handlerton *hton, THD *thd, return (false); } -/************************************************************************/ /** - Handling the shared INNOBASE_SHARE structure that is needed to provide table +/** Handling the shared INNOBASE_SHARE structure that is needed to provide table locking. Register the table name if it doesn't exist in the hash table. */ -static INNOBASE_SHARE *get_share( - /*======*/ - const char *table_name) { +static INNOBASE_SHARE *get_share(const char *table_name) { INNOBASE_SHARE *share; mysql_mutex_lock(&innobase_share_mutex); @@ -16907,10 +16500,8 @@ static INNOBASE_SHARE *get_share( return (share); } -/************************************************************************/ /** - Free the shared object that was registered with get_share(). */ +/** Free the shared object that was registered with get_share(). */ static void free_share( - /*=======*/ INNOBASE_SHARE *share) /*!< in/own: table share to free */ { mysql_mutex_lock(&innobase_share_mutex); @@ -16946,8 +16537,7 @@ static void free_share( mysql_mutex_unlock(&innobase_share_mutex); } -/*********************************************************************/ /** - Returns number of THR_LOCK locks used for one instance of InnoDB table. +/** Returns number of THR_LOCK locks used for one instance of InnoDB table. InnoDB no longer relies on THR_LOCK locks so 0 value is returned. Instead of THR_LOCK locks InnoDB relies on combination of metadata locks (e.g. for LOCK TABLES and DDL) and its own locking subsystem. @@ -16955,14 +16545,9 @@ static void free_share( "::store_lock()", "::start_stmt()" and "::external_lock()" methods for InnoDB tables. */ -uint ha_innobase::lock_count(void) const -/*===============================*/ -{ - return 0; -} +uint ha_innobase::lock_count(void) const { return 0; } -/*****************************************************************/ /** - Supposed to convert a MySQL table lock stored in the 'lock' field of the +/** Supposed to convert a MySQL table lock stored in the 'lock' field of the handle to a proper type before storing pointer to the lock into an array of pointers. In practice, since InnoDB no longer relies on THR_LOCK locks and its @@ -16977,7 +16562,6 @@ uint ha_innobase::lock_count(void) const @return pointer to the current element in the 'to' array. */ THR_LOCK_DATA **ha_innobase::store_lock( - /*====================*/ THD *thd, /*!< in: user thread handle */ THR_LOCK_DATA **to, /*!< in: pointer to the current element in an array of pointers @@ -17148,14 +16732,12 @@ THR_LOCK_DATA **ha_innobase::store_lock( return (to); } -/*********************************************************************/ /** - Read the next autoinc value. Acquire the relevant locks before reading +/** Read the next autoinc value. Acquire the relevant locks before reading the AUTOINC value. If SUCCESS then the table AUTOINC mutex will be locked on return and all relevant locks acquired. @return DB_SUCCESS or error code */ dberr_t ha_innobase::innobase_get_autoinc( - /*==============================*/ ulonglong *value) /*!< out: autoinc value */ { *value = 0; @@ -17176,11 +16758,10 @@ dberr_t ha_innobase::innobase_get_autoinc( return (m_prebuilt->autoinc_error); } -/*********************************************************************/ /** - Returns the value of the auto-inc counter in *first_value and ~0 on failure. */ +/** Returns the value of the auto-inc counter in *first_value and ~0 on failure. + */ void ha_innobase::get_auto_increment( - /*============================*/ ulonglong offset, /*!< in: table autoinc offset */ ulonglong increment, /*!< in: table autoinc increment */ @@ -17328,12 +16909,9 @@ void ha_innobase::get_auto_increment( dict_table_autoinc_unlock(m_prebuilt->table); } -/*******************************************************************/ /** - See comment in handler.cc */ +/** See comment in handler.cc */ -bool ha_innobase::get_error_message( - /*===========================*/ - int error, String *buf) { +bool ha_innobase::get_error_message(int error, String *buf) { trx_t *trx = check_trx_exists(ha_thd()); buf->copy(trx->detailed_error, (uint)strlen(trx->detailed_error), @@ -17357,10 +16935,10 @@ false and will not change any of child_table_name or child_key_name. corresponding out parameters. @retval false table and key names were not available, the out parameters were not touched. */ -bool ha_innobase::get_foreign_dup_key( - /*=============================*/ - char *child_table_name, uint child_table_name_len, char *child_key_name, - uint child_key_name_len) { +bool ha_innobase::get_foreign_dup_key(char *child_table_name, + uint child_table_name_len, + char *child_key_name, + uint child_key_name_len) { const dict_index_t *err_index; ut_a(m_prebuilt->trx != NULL); @@ -17396,14 +16974,12 @@ bool ha_innobase::get_foreign_dup_key( return (true); } -/*******************************************************************/ /** - Compares two 'refs'. A 'ref' is the (internal) primary key value of the row. +/** Compares two 'refs'. A 'ref' is the (internal) primary key value of the row. If there is no explicitly declared non-null unique key or a primary key, then InnoDB internally uses the row id as the primary key. @return < 0 if ref1 < ref2, 0 if equal, else > 0 */ int ha_innobase::cmp_ref( - /*=================*/ const uchar *ref1, /*!< in: an (internal) primary key value in the MySQL key value format */ const uchar *ref2) /*!< in: an (internal) primary key value in the @@ -17460,14 +17036,12 @@ int ha_innobase::cmp_ref( return (0); } -/******************************************************************/ /** - This function is used to find the storage length in bytes of the first n +/** This function is used to find the storage length in bytes of the first n characters for prefix indexes using a multibyte character set. The function finds charset information and returns length of prefix_len characters in the index field in bytes. @return number of bytes occupied by the first n characters */ ulint innobase_get_at_most_n_mbchars( - /*===========================*/ ulint charset_id, /*!< in: character set id */ ulint prefix_len, /*!< in: prefix length in bytes of the index (this has to be divided by mbmaxlen to get the @@ -17526,11 +17100,9 @@ ulint innobase_get_at_most_n_mbchars( return (char_length); } -/*******************************************************************/ /** - This function is used to prepare an X/Open XA distributed transaction. +/** This function is used to prepare an X/Open XA distributed transaction. @return 0 or error number */ static int innobase_xa_prepare( - /*================*/ handlerton *hton, /*!< in: InnoDB handlerton */ THD *thd, /*!< in: handle to the MySQL thread of the user whose XA transaction should @@ -17612,11 +17184,9 @@ static int innobase_xa_prepare( return (0); } -/*******************************************************************/ /** - This function is used to recover X/Open XA distributed transactions. +/** This function is used to recover X/Open XA distributed transactions. @return number of prepared transactions stored in xid_list */ static int innobase_xa_recover( - /*================*/ handlerton *hton, /*!< in: InnoDB handlerton */ XID *xid_list, /*!< in/out: prepared transactions */ uint len) /*!< in: number of slots in xid_list */ @@ -17630,12 +17200,10 @@ static int innobase_xa_recover( return (trx_recover_for_mysql(xid_list, len)); } -/*******************************************************************/ /** - This function is used to commit one X/Open XA distributed transaction +/** This function is used to commit one X/Open XA distributed transaction which is in the prepared state @return 0 or error number */ static xa_status_code innobase_commit_by_xid( - /*===================*/ handlerton *hton, XID *xid) /*!< in: X/Open XA transaction identification */ { DBUG_ASSERT(hton == innodb_hton_ptr); @@ -17658,12 +17226,10 @@ static xa_status_code innobase_commit_by_xid( } } -/*******************************************************************/ /** - This function is used to rollback one X/Open XA distributed transaction +/** This function is used to rollback one X/Open XA distributed transaction which is in the prepared state @return 0 or error number */ static xa_status_code innobase_rollback_by_xid( - /*=====================*/ handlerton *hton, /*!< in: InnoDB handlerton */ XID *xid) /*!< in: X/Open XA transaction identification */ @@ -17687,12 +17253,10 @@ static xa_status_code innobase_rollback_by_xid( } } -/*******************************************************************/ /** - */ +/** */ -bool ha_innobase::check_if_incompatible_data( - /*====================================*/ - HA_CREATE_INFO *info, uint table_changes) { +bool ha_innobase::check_if_incompatible_data(HA_CREATE_INFO *info, + uint table_changes) { innobase_copy_frm_flags_from_create_info(m_prebuilt->table, info); if (table_changes != IS_EQUAL_YES) { @@ -17719,11 +17283,9 @@ bool ha_innobase::check_if_incompatible_data( return (COMPATIBLE_DATA_YES); } -/****************************************************************/ /** - Update the system variable innodb_io_capacity_max using the "saved" +/** Update the system variable innodb_io_capacity_max using the "saved" value. This function is registered as a callback with MySQL. */ static void innodb_io_capacity_max_update( - /*===========================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ @@ -17747,11 +17309,9 @@ static void innodb_io_capacity_max_update( srv_max_io_capacity = in_val; } -/****************************************************************/ /** - Update the system variable innodb_io_capacity using the "saved" +/** Update the system variable innodb_io_capacity using the "saved" value. This function is registered as a callback with MySQL. */ static void innodb_io_capacity_update( - /*======================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ @@ -17774,11 +17334,9 @@ static void innodb_io_capacity_update( srv_io_capacity = in_val; } -/****************************************************************/ /** - Update the system variable innodb_max_dirty_pages_pct using the "saved" +/** Update the system variable innodb_max_dirty_pages_pct using the "saved" value. This function is registered as a callback with MySQL. */ static void innodb_max_dirty_pages_pct_update( - /*==============================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ @@ -17804,11 +17362,9 @@ static void innodb_max_dirty_pages_pct_update( srv_max_buf_pool_modified_pct = in_val; } -/****************************************************************/ /** - Update the system variable innodb_max_dirty_pages_pct_lwm using the +/** Update the system variable innodb_max_dirty_pages_pct_lwm using the "saved" value. This function is registered as a callback with MySQL. */ static void innodb_max_dirty_pages_pct_lwm_update( - /*==================================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ @@ -17833,12 +17389,10 @@ static void innodb_max_dirty_pages_pct_lwm_update( srv_max_dirty_pages_pct_lwm = in_val; } -/*************************************************************/ /** - Check whether valid argument given to innobase_*_stopword_table. +/** Check whether valid argument given to innobase_*_stopword_table. This function is registered as a callback with MySQL. @return 0 for valid stopword table */ static int innodb_stopword_table_validate( - /*===========================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ @@ -17888,12 +17442,10 @@ static void innodb_buffer_pool_size_update(THD *thd, SYS_VAR *var, *static_cast(var_ptr) = in_val; } -/*************************************************************/ /** - Check whether valid argument given to "innodb_fts_internal_tbl_name" +/** Check whether valid argument given to "innodb_fts_internal_tbl_name" This function is registered as a callback with MySQL. @return 0 for valid stopword table */ static int innodb_internal_table_validate( - /*===========================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ @@ -17942,12 +17494,10 @@ static int innodb_internal_table_validate( return (ret); } -/****************************************************************/ /** - Update global variable "fts_internal_tbl_name" with the "saved" +/** Update global variable "fts_internal_tbl_name" with the "saved" stopword table name value. This function is registered as a callback with MySQL. */ static void innodb_internal_table_update( - /*=========================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ @@ -17983,11 +17533,9 @@ static void innodb_internal_table_update( } } -/****************************************************************/ /** - Update the system variable innodb_adaptive_hash_index using the "saved" +/** Update the system variable innodb_adaptive_hash_index using the "saved" value. This function is registered as a callback with MySQL. */ static void innodb_adaptive_hash_index_update( - /*==============================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ @@ -18003,11 +17551,9 @@ static void innodb_adaptive_hash_index_update( } } -/****************************************************************/ /** - Update the system variable innodb_cmp_per_index using the "saved" +/** Update the system variable innodb_cmp_per_index using the "saved" value. This function is registered as a callback with MySQL. */ static void innodb_cmp_per_index_update( - /*========================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ @@ -18025,11 +17571,9 @@ static void innodb_cmp_per_index_update( srv_cmp_per_index_enabled = !!(*(bool *)save); } -/****************************************************************/ /** - Update the system variable innodb_old_blocks_pct using the "saved" +/** Update the system variable innodb_old_blocks_pct using the "saved" value. This function is registered as a callback with MySQL. */ static void innodb_old_blocks_pct_update( - /*=========================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ @@ -18042,11 +17586,9 @@ static void innodb_old_blocks_pct_update( buf_LRU_old_ratio_update(*static_cast(save), TRUE)); } -/****************************************************************/ /** - Update the system variable innodb_old_blocks_pct using the "saved" +/** Update the system variable innodb_old_blocks_pct using the "saved" value. This function is registered as a callback with MySQL. */ static void innodb_change_buffer_max_size_update( - /*=================================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ @@ -18063,27 +17605,22 @@ static void innodb_change_buffer_max_size_update( static ulong srv_fil_make_page_dirty_debug = 0; static ulong srv_saved_page_number_debug = 0; -/****************************************************************/ /** - Save an InnoDB page number. */ -static void innodb_save_page_no( - /*================*/ - THD *thd, /*!< in: thread handle */ - SYS_VAR *var, /*!< in: pointer to - system variable */ - void *var_ptr, /*!< out: where the - formal string goes */ - const void *save) /*!< in: immediate result - from check function */ +/** Save an InnoDB page number. */ +static void innodb_save_page_no(THD *thd, /*!< in: thread handle */ + SYS_VAR *var, /*!< in: pointer to + system variable */ + void *var_ptr, /*!< out: where the + formal string goes */ + const void *save) /*!< in: immediate result + from check function */ { srv_saved_page_number_debug = *static_cast(save); ib::info() << "Saving InnoDB page number: " << srv_saved_page_number_debug; } -/****************************************************************/ /** - Make the first page of given user tablespace dirty. */ +/** Make the first page of given user tablespace dirty. */ static void innodb_make_page_dirty( - /*===================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ @@ -18125,11 +17662,9 @@ static void innodb_make_page_dirty( } #endif // UNIV_DEBUG -/****************************************************************/ /** - Update the monitor counter according to the "set_option", turn +/** Update the monitor counter according to the "set_option", turn on/off or reset specified monitor counter. */ static void innodb_monitor_set_option( - /*======================*/ const monitor_info_t *monitor_info, /*!< in: monitor info for the monitor to set */ mon_option_t set_option) /*!< in: Turn on/off reset the @@ -18192,12 +17727,10 @@ static void innodb_monitor_set_option( } } -/****************************************************************/ /** - Find matching InnoDB monitor counters and update their status +/** Find matching InnoDB monitor counters and update their status according to the "set_option", turn on/off or reset specified monitor counter. */ static void innodb_monitor_update_wildcard( - /*===========================*/ const char *name, /*!< in: monitor name to match */ mon_option_t set_option) /*!< in: the set option, whether to turn on/off or reset the counter */ @@ -18246,12 +17779,10 @@ static void innodb_monitor_update_wildcard( } } -/*************************************************************/ /** - Given a configuration variable name, find corresponding monitor counter +/** Given a configuration variable name, find corresponding monitor counter and return its monitor ID if found. @return monitor ID if found, MONITOR_NO_MATCH if there is no match */ static ulint innodb_monitor_id_by_name_get( - /*==========================*/ const char *name) /*!< in: monitor counter namer */ { ut_a(name); @@ -18275,12 +17806,10 @@ static ulint innodb_monitor_id_by_name_get( return (MONITOR_NO_MATCH); } -/*************************************************************/ /** - Validate that the passed in monitor name matches at least one +/** Validate that the passed in monitor name matches at least one monitor counter name with wildcard compare. @return true if at least one monitor name matches */ static ibool innodb_monitor_validate_wildcard_name( - /*==================================*/ const char *name) /*!< in: monitor counter namer */ { for (ulint i = 0; i < NUM_MONITOR; i++) { @@ -18292,12 +17821,10 @@ static ibool innodb_monitor_validate_wildcard_name( return (FALSE); } -/*************************************************************/ /** - Validate the passed in monitor name, find and save the +/** Validate the passed in monitor name, find and save the corresponding monitor name in the function parameter "save". @return 0 if monitor name is valid */ static int innodb_monitor_valid_byname( - /*========================*/ void *save, /*!< out: immediate result for update function */ const char *name) /*!< in: incoming monitor name */ @@ -18346,12 +17873,10 @@ static int innodb_monitor_valid_byname( return (0); } -/*************************************************************/ /** - Validate passed-in "value" is a valid monitor counter name. +/** Validate passed-in "value" is a valid monitor counter name. This function is registered as a callback with MySQL. @return 0 for valid name */ static int innodb_monitor_validate( - /*====================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ @@ -18402,12 +17927,10 @@ static int innodb_monitor_validate( return (ret); } -/****************************************************************/ /** - Update the system variable innodb_enable(disable/reset/reset_all)_monitor +/** Update the system variable innodb_enable(disable/reset/reset_all)_monitor according to the "set_option" and turn on/off or reset specified monitor counter. */ static void innodb_monitor_update( - /*==================*/ THD *thd, /*!< in: thread handle */ void *var_ptr, /*!< out: where the formal string goes */ @@ -18502,14 +18025,12 @@ static void innodb_monitor_update( } #ifdef _WIN32 -/*************************************************************/ /** - Validate if passed-in "value" is a valid value for +/** Validate if passed-in "value" is a valid value for innodb_buffer_pool_filename. On Windows, file names with colon (:) are not allowed. @return 0 for valid name */ static int innodb_srv_buf_dump_filename_validate( - /*==================================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ @@ -18582,13 +18103,11 @@ static MY_ATTRIBUTE( return (all_evicted); } -/****************************************************************/ /** - Called on SET GLOBAL innodb_buffer_pool_evict=... +/** Called on SET GLOBAL innodb_buffer_pool_evict=... Handles some values specially, to evict pages from the buffer pool. SET GLOBAL innodb_buffer_pool_evict='uncompressed' evicts all uncompressed page frames of compressed tablespaces. */ static void innodb_buffer_pool_evict_update( - /*============================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ void *var_ptr, /*!< out: ignored */ @@ -18612,12 +18131,10 @@ static void innodb_buffer_pool_evict_update( } #endif /* UNIV_DEBUG */ -/****************************************************************/ /** - Update the system variable innodb_monitor_enable and enable +/** Update the system variable innodb_monitor_enable and enable specified monitor counter. This function is registered as a callback with MySQL. */ static void innodb_enable_monitor_update( - /*=========================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ @@ -18629,11 +18146,9 @@ static void innodb_enable_monitor_update( innodb_monitor_update(thd, var_ptr, save, MONITOR_TURN_ON, TRUE); } -/****************************************************************/ /** - Update the system variable innodb_monitor_disable and turn +/** Update the system variable innodb_monitor_disable and turn off specified monitor counter. */ static void innodb_disable_monitor_update( - /*==========================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ @@ -18645,12 +18160,10 @@ static void innodb_disable_monitor_update( innodb_monitor_update(thd, var_ptr, save, MONITOR_TURN_OFF, TRUE); } -/****************************************************************/ /** - Update the system variable innodb_monitor_reset and reset +/** Update the system variable innodb_monitor_reset and reset specified monitor counter(s). This function is registered as a callback with MySQL. */ static void innodb_reset_monitor_update( - /*========================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ @@ -18662,12 +18175,10 @@ static void innodb_reset_monitor_update( innodb_monitor_update(thd, var_ptr, save, MONITOR_RESET_VALUE, TRUE); } -/****************************************************************/ /** - Update the system variable innodb_monitor_reset_all and reset +/** Update the system variable innodb_monitor_reset_all and reset all value related monitor counter. This function is registered as a callback with MySQL. */ static void innodb_reset_all_monitor_update( - /*============================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ @@ -18749,14 +18260,12 @@ static void innodb_rollback_segments_update(THD *thd, SYS_VAR *var, srv_rollback_segments = target; } -/****************************************************************/ /** - Parse and enable InnoDB monitor counters during server startup. +/** Parse and enable InnoDB monitor counters during server startup. User can list the monitor counters/groups to be enable by specifying "loose-innodb_monitor_enable=monitor_name1;monitor_name2..." in server configuration file or at the command line. The string separate could be ";", "," or empty space. */ static void innodb_enable_monitor_at_startup( - /*=============================*/ char *str) /*!< in/out: monitor counter enable list */ { static const char *sep = " ;,"; @@ -18784,12 +18293,9 @@ static void innodb_enable_monitor_at_startup( } } -/****************************************************************/ /** - Callback function for accessing the InnoDB variables from MySQL: +/** Callback function for accessing the InnoDB variables from MySQL: SHOW VARIABLES. */ -static int show_innodb_vars( - /*=============*/ - THD *thd, SHOW_VAR *var, char *buff) { +static int show_innodb_vars(THD *thd, SHOW_VAR *var, char *buff) { innodb_export_status(); var->type = SHOW_ARRAY; var->value = (char *)&innodb_status_variables; @@ -18798,14 +18304,12 @@ static int show_innodb_vars( return (0); } -/****************************************************************/ /** - This function checks each index name for a table against reserved +/** This function checks each index name for a table against reserved system default primary index name 'GEN_CLUST_INDEX'. If a name matches, this function pushes an warning message to the client, and returns true. @return true if the index name matches the reserved name */ bool innobase_index_name_is_reserved( - /*============================*/ THD *thd, /*!< in/out: MySQL connection */ const KEY *key_info, /*!< in: Indexes to be created */ ulint num_of_keys) /*!< in: Number of indexes to @@ -18908,62 +18412,53 @@ static void wait_background_drop_list_empty( row_wait_for_background_drop_list_empty(); } -/****************************************************************/ /** - Set the purge state to RUN. If purge is disabled then it +/** Set the purge state to RUN. If purge is disabled then it is a no-op. This function is registered as a callback with MySQL. */ -static void purge_run_now_set( - /*==============*/ - THD *thd /*!< in: thread handle */ - MY_ATTRIBUTE((unused)), - SYS_VAR *var /*!< in: pointer to system - variable */ - MY_ATTRIBUTE((unused)), - void *var_ptr /*!< out: where the formal - string goes */ - MY_ATTRIBUTE((unused)), - const void *save) /*!< in: immediate result from - check function */ +static void purge_run_now_set(THD *thd /*!< in: thread handle */ + MY_ATTRIBUTE((unused)), + SYS_VAR *var /*!< in: pointer to system + variable */ + MY_ATTRIBUTE((unused)), + void *var_ptr /*!< out: where the formal + string goes */ + MY_ATTRIBUTE((unused)), + const void *save) /*!< in: immediate result from + check function */ { if (*(bool *)save && trx_purge_state() != PURGE_STATE_DISABLED) { trx_purge_run(); } } -/****************************************************************/ /** - Set the purge state to STOP. If purge is disabled then it +/** Set the purge state to STOP. If purge is disabled then it is a no-op. This function is registered as a callback with MySQL. */ -static void purge_stop_now_set( - /*===============*/ - THD *thd /*!< in: thread handle */ - MY_ATTRIBUTE((unused)), - SYS_VAR *var /*!< in: pointer to system - variable */ - MY_ATTRIBUTE((unused)), - void *var_ptr /*!< out: where the formal - string goes */ - MY_ATTRIBUTE((unused)), - const void *save) /*!< in: immediate result from - check function */ +static void purge_stop_now_set(THD *thd /*!< in: thread handle */ + MY_ATTRIBUTE((unused)), + SYS_VAR *var /*!< in: pointer to system + variable */ + MY_ATTRIBUTE((unused)), + void *var_ptr /*!< out: where the formal + string goes */ + MY_ATTRIBUTE((unused)), + const void *save) /*!< in: immediate result from + check function */ { if (*(bool *)save && trx_purge_state() != PURGE_STATE_DISABLED) { trx_purge_stop(); } } -/****************************************************************/ /** - Force innodb to checkpoint. */ -static void checkpoint_now_set( - /*===============*/ - THD *thd /*!< in: thread handle */ - MY_ATTRIBUTE((unused)), - SYS_VAR *var /*!< in: pointer to system - variable */ - MY_ATTRIBUTE((unused)), - void *var_ptr /*!< out: where the formal - string goes */ - MY_ATTRIBUTE((unused)), - const void *save) /*!< in: immediate result from - check function */ +/** Force innodb to checkpoint. */ +static void checkpoint_now_set(THD *thd /*!< in: thread handle */ + MY_ATTRIBUTE((unused)), + SYS_VAR *var /*!< in: pointer to system + variable */ + MY_ATTRIBUTE((unused)), + void *var_ptr /*!< out: where the formal + string goes */ + MY_ATTRIBUTE((unused)), + const void *save) /*!< in: immediate result from + check function */ { if (*(bool *)save && !srv_checkpoint_disabled) { while (log_sys->last_checkpoint_lsn < log_sys->lsn) { @@ -18978,10 +18473,8 @@ static void checkpoint_now_set( } } -/****************************************************************/ /** - Force a dirty pages flush now. */ +/** Force a dirty pages flush now. */ static void buf_flush_list_now_set( - /*===================*/ THD *thd /*!< in: thread handle */ MY_ATTRIBUTE((unused)), SYS_VAR *var /*!< in: pointer to system @@ -19047,11 +18540,9 @@ static bool innodb_buffer_pool_dump_now = FALSE; static bool innodb_buffer_pool_load_now = FALSE; static bool innodb_buffer_pool_load_abort = FALSE; -/****************************************************************/ /** - Trigger a dump of the buffer pool if innodb_buffer_pool_dump_now is set +/** Trigger a dump of the buffer pool if innodb_buffer_pool_dump_now is set to ON. This function is registered as a callback with MySQL. */ static void buffer_pool_dump_now( - /*=================*/ THD *thd /*!< in: thread handle */ MY_ATTRIBUTE((unused)), SYS_VAR *var /*!< in: pointer to system @@ -19068,11 +18559,9 @@ static void buffer_pool_dump_now( } } -/****************************************************************/ /** - Trigger a load of the buffer pool if innodb_buffer_pool_load_now is set +/** Trigger a load of the buffer pool if innodb_buffer_pool_load_now is set to ON. This function is registered as a callback with MySQL. */ static void buffer_pool_load_now( - /*=================*/ THD *thd /*!< in: thread handle */ MY_ATTRIBUTE((unused)), SYS_VAR *var /*!< in: pointer to system @@ -19089,11 +18578,9 @@ static void buffer_pool_load_now( } } -/****************************************************************/ /** - Abort a load of the buffer pool if innodb_buffer_pool_load_abort +/** Abort a load of the buffer pool if innodb_buffer_pool_load_abort is set to ON. This function is registered as a callback with MySQL. */ static void buffer_pool_load_abort( - /*===================*/ THD *thd /*!< in: thread handle */ MY_ATTRIBUTE((unused)), SYS_VAR *var /*!< in: pointer to system @@ -19110,11 +18597,9 @@ static void buffer_pool_load_abort( } } -/****************************************************************/ /** - Update the system variable innodb_log_write_ahead_size using the "saved" +/** Update the system variable innodb_log_write_ahead_size using the "saved" value. This function is registered as a callback with MySQL. */ static void innodb_log_write_ahead_size_update( - /*===============================*/ THD *thd, /*!< in: thread handle */ SYS_VAR *var, /*!< in: pointer to system variable */ @@ -20336,9 +19821,7 @@ The initial default value is 0, and without this extra initialization, SET GLOBAL innodb_commit_concurrency=DEFAULT would set the parameter to 0, even if it was initially set to nonzero at the command line or configuration file. */ -static void innobase_commit_concurrency_init_default() -/*======================================*/ -{ +static void innobase_commit_concurrency_init_default() { MYSQL_SYSVAR_NAME(commit_concurrency).def_val = innobase_commit_concurrency; } @@ -20383,13 +19866,10 @@ ha_rows ha_innobase::multi_range_read_info(uint keyno, uint n_ranges, uint keys, /** Index Condition Pushdown interface implementation */ -/*************************************************************/ /** - InnoDB index push-down condition check +/** InnoDB index push-down condition check @return ICP_NO_MATCH, ICP_MATCH, or ICP_OUT_OF_RANGE */ ICP_RESULT -innobase_index_cond( - /*================*/ - ha_innobase *h) /*!< in/out: pointer to ha_innobase */ +innobase_index_cond(ha_innobase *h) /*!< in/out: pointer to ha_innobase */ { DBUG_ENTER("innobase_index_cond"); @@ -20771,8 +20251,7 @@ bool ha_innobase::is_record_buffer_wanted(ha_rows *const max_rows) const { return true; } -/******************************************************************/ /** - Use this when the args are passed to the format string from +/** Use this when the args are passed to the format string from errmsg-utf8.txt directly as is. Push a warning message to the client, it is a wrapper around: @@ -20781,12 +20260,10 @@ bool ha_innobase::is_record_buffer_wanted(ha_rows *const max_rows) const { THD *thd, Sql_condition::enum_condition_level level, uint code, const char *format, ...); */ -void ib_senderrf( - /*========*/ - THD *thd, /*!< in/out: session */ - ib_log_level_t level, /*!< in: warning level */ - ib_uint32_t code, /*!< MySQL error code */ - ...) /*!< Args */ +void ib_senderrf(THD *thd, /*!< in/out: session */ + ib_log_level_t level, /*!< in: warning level */ + ib_uint32_t code, /*!< MySQL error code */ + ...) /*!< Args */ { va_list args; char *str = NULL; @@ -20865,8 +20342,7 @@ void ib_senderrf( } } -/******************************************************************/ /** - Use this when the args are first converted to a formatted string and then +/** Use this when the args are first converted to a formatted string and then passed to the format string from errmsg-utf8.txt. The error message format must be: "Some string ... %s". @@ -20876,13 +20352,11 @@ void ib_senderrf( THD *thd, Sql_condition::enum_condition_level level, uint code, const char *format, ...); */ -void ib_errf( - /*====*/ - THD *thd, /*!< in/out: session */ - ib_log_level_t level, /*!< in: warning level */ - ib_uint32_t code, /*!< MySQL error code */ - const char *format, /*!< printf format */ - ...) /*!< Args */ +void ib_errf(THD *thd, /*!< in/out: session */ + ib_log_level_t level, /*!< in: warning level */ + ib_uint32_t code, /*!< MySQL error code */ + const char *format, /*!< printf format */ + ...) /*!< Args */ { char *str = NULL; va_list args; @@ -20967,7 +20441,6 @@ const char *INNODB_PARAMETERS_MSG = Converts an identifier from my_charset_filename to UTF-8 charset. @return result string length, as returned by strconvert() */ uint innobase_convert_to_filename_charset( - /*=================================*/ char *to, /* out: converted identifier */ const char *from, /* in: identifier to convert */ ulint len) /* in: length of 'to', in bytes */ @@ -20984,7 +20457,6 @@ uint innobase_convert_to_filename_charset( Converts an identifier from my_charset_filename to UTF-8 charset. @return result string length, as returned by strconvert() */ uint innobase_convert_to_system_charset( - /*===============================*/ char *to, /* out: converted identifier */ const char *from, /* in: identifier to convert */ ulint len, /* in: length of 'to', in bytes */ diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index f4dea07a5683..6e56296ccf01 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -664,8 +664,7 @@ is consistent between KEY info from mysql and that from innodb index. bool innobase_match_index_columns(const KEY *key_info, const dict_index_t *index_info); -/*********************************************************************/ /** - This function checks each index name for a table against reserved +/** This function checks each index name for a table against reserved system default primary index name 'GEN_CLUST_INDEX'. If a name matches, this function pushes an warning message to the client, and returns true. @@ -973,7 +972,6 @@ class innobase_basic_ddl { Initialize the table FTS stopword list @return true if success */ ibool innobase_fts_load_stopword( - /*=======================*/ dict_table_t *table, /*!< in: Table has the FTS */ trx_t *trx, /*!< in: transaction */ THD *thd) /*!< in: current thread */ diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index b0b1c9581404..37cdb020f839 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file handler/handler0alter.cc +/** @file handler/handler0alter.cc Smart ALTER TABLE *******************************************************/ @@ -317,7 +316,6 @@ struct alter_table_old_info_t { /* Report an InnoDB error to the client by invoking my_error(). */ static UNIV_COLD void my_error_innodb( - /*============*/ dberr_t error, /*!< in: InnoDB error code */ const char *table, /*!< in: table name */ ulint flags) /*!< in: table flags */ @@ -400,9 +398,7 @@ static UNIV_COLD void my_error_innodb( /** Determine if fulltext indexes exist in a given table. @param table MySQL table @return whether fulltext indexes exist on the table */ -static bool innobase_fulltext_exist( - /*====================*/ - const TABLE *table) { +static bool innobase_fulltext_exist(const TABLE *table) { for (uint i = 0; i < table->s->keys; i++) { if (table->key_info[i].flags & HA_FULLTEXT) { return (true); @@ -415,9 +411,7 @@ static bool innobase_fulltext_exist( /** Determine if spatial indexes exist in a given table. @param table MySQL table @return whether spatial indexes exist on the table */ -static bool innobase_spatial_exist( - /*===================*/ - const TABLE *table) { +static bool innobase_spatial_exist(const TABLE *table) { for (uint i = 0; i < table->s->keys; i++) { if (table->key_info[i].flags & HA_SPATIAL) { return (true); @@ -427,12 +421,10 @@ static bool innobase_spatial_exist( return (false); } -/*******************************************************************/ /** - Determine if ALTER TABLE needs to rebuild the table. +/** Determine if ALTER TABLE needs to rebuild the table. @param ha_alter_info the DDL operation @return whether it is necessary to rebuild the table */ static MY_ATTRIBUTE((warn_unused_result)) bool innobase_need_rebuild( - /*==================*/ const Alter_inplace_info *ha_alter_info) { Alter_inplace_info::HA_ALTER_FLAGS alter_inplace_flags = ha_alter_info->handler_flags & ~(INNOBASE_INPLACE_IGNORE); @@ -573,7 +565,6 @@ while prepare_inplace_alter_table() is executing) */ enum_alter_inplace_result ha_innobase::check_if_supported_inplace_alter( - /*==========================================*/ TABLE *altered_table, Alter_inplace_info *ha_alter_info) { DBUG_ENTER("check_if_supported_inplace_alter"); @@ -1069,11 +1060,9 @@ bool ha_innobase::commit_inplace_alter_table(TABLE *altered_table, DBUG_RETURN(res); } -/*************************************************************/ /** - Initialize the dict_foreign_t structure with supplied info +/** Initialize the dict_foreign_t structure with supplied info @return true if added, false if duplicate foreign->id */ static bool innobase_init_foreign( - /*==================*/ dict_foreign_t *foreign, /*!< in/out: structure to initialize */ const char *constraint_name, /*!< in/out: constraint name if @@ -1153,11 +1142,9 @@ static bool innobase_init_foreign( return (true); } -/*************************************************************/ /** - Check whether the foreign key options is legit +/** Check whether the foreign key options is legit @return true if it is */ static MY_ATTRIBUTE((warn_unused_result)) bool innobase_check_fk_option( - /*=====================*/ const dict_foreign_t *foreign) /*!< in: foreign key */ { if (!foreign->foreign_index) { @@ -1179,11 +1166,9 @@ static MY_ATTRIBUTE((warn_unused_result)) bool innobase_check_fk_option( return (true); } -/*************************************************************/ /** - Set foreign key options +/** Set foreign key options @return true if successfully set */ static MY_ATTRIBUTE((warn_unused_result)) bool innobase_set_foreign_key_option( - /*============================*/ dict_foreign_t *foreign, /*!< in:InnoDB Foreign key */ const Foreign_key_spec *fk_key) /*!< in: Foreign key info from MySQL */ @@ -1225,12 +1210,10 @@ static MY_ATTRIBUTE((warn_unused_result)) bool innobase_set_foreign_key_option( return (innobase_check_fk_option(foreign)); } -/*******************************************************************/ /** - Check if a foreign key constraint can make use of an index +/** Check if a foreign key constraint can make use of an index that is being created. @return useable index, or NULL if none found */ static MY_ATTRIBUTE((warn_unused_result)) const KEY *innobase_find_equiv_index( - /*======================*/ const char *const *col_names, /*!< in: column names */ uint n_cols, /*!< in: number of columns */ @@ -1282,12 +1265,10 @@ static MY_ATTRIBUTE((warn_unused_result)) const KEY *innobase_find_equiv_index( return (NULL); } -/*************************************************************/ /** - Find an index whose first fields are the columns in the array +/** Find an index whose first fields are the columns in the array in the same order and is not marked for deletion @return matching index, NULL if not found */ static MY_ATTRIBUTE((warn_unused_result)) dict_index_t *innobase_find_fk_index( - /*===================*/ Alter_inplace_info *ha_alter_info, /*!< in: alter table info */ dict_table_t *table, /*!< in: table */ @@ -1603,11 +1584,9 @@ static MY_ATTRIBUTE((warn_unused_result)) bool innobase_get_foreign_key_info( DBUG_RETURN(false); } -/*************************************************************/ /** - Copies an InnoDB column to a MySQL field. This function is +/** Copies an InnoDB column to a MySQL field. This function is adapted from row_sel_field_store_in_mysql_format(). */ static void innobase_col_to_mysql( - /*==================*/ const dict_col_t *col, /*!< in: InnoDB column */ const uchar *data, /*!< in: InnoDB column data */ ulint len, /*!< in: length of data, in bytes */ @@ -1692,15 +1671,12 @@ static void innobase_col_to_mysql( } } -/*************************************************************/ /** - Copies an InnoDB record to table->record[0]. */ -void innobase_rec_to_mysql( - /*==================*/ - struct TABLE *table, /*!< in/out: MySQL table */ - const rec_t *rec, /*!< in: record */ - const dict_index_t *index, /*!< in: index */ - const ulint *offsets) /*!< in: rec_get_offsets( - rec, index, ...) */ +/** Copies an InnoDB record to table->record[0]. */ +void innobase_rec_to_mysql(struct TABLE *table, /*!< in/out: MySQL table */ + const rec_t *rec, /*!< in: record */ + const dict_index_t *index, /*!< in: index */ + const ulint *offsets) /*!< in: rec_get_offsets( + rec, index, ...) */ { uint n_fields = table->s->fields; @@ -1738,10 +1714,8 @@ void innobase_rec_to_mysql( } } -/*************************************************************/ /** - Copies an InnoDB index entry to table->record[0]. */ +/** Copies an InnoDB index entry to table->record[0]. */ void innobase_fields_to_mysql( - /*=====================*/ struct TABLE *table, /*!< in/out: MySQL table */ const dict_index_t *index, /*!< in: InnoDB index */ const dfield_t *fields) /*!< in: InnoDB index fields */ @@ -1785,13 +1759,10 @@ void innobase_fields_to_mysql( } } -/*************************************************************/ /** - Copies an InnoDB row to table->record[0]. */ -void innobase_row_to_mysql( - /*==================*/ - struct TABLE *table, /*!< in/out: MySQL table */ - const dict_table_t *itab, /*!< in: InnoDB table */ - const dtuple_t *row) /*!< in: InnoDB row */ +/** Copies an InnoDB row to table->record[0]. */ +void innobase_row_to_mysql(struct TABLE *table, /*!< in/out: MySQL table */ + const dict_table_t *itab, /*!< in: InnoDB table */ + const dtuple_t *row) /*!< in: InnoDB row */ { uint n_fields = table->s->fields; ulint num_v = 0; @@ -1828,11 +1799,8 @@ void innobase_row_to_mysql( } } -/*************************************************************/ /** - Resets table->record[0]. */ -void innobase_rec_reset( - /*===============*/ - TABLE *table) /*!< in/out: MySQL table */ +/** Resets table->record[0]. */ +void innobase_rec_reset(TABLE *table) /*!< in/out: MySQL table */ { uint n_fields = table->s->fields; uint i; @@ -1842,11 +1810,9 @@ void innobase_rec_reset( } } -/*******************************************************************/ /** - This function checks that index keys are sensible. +/** This function checks that index keys are sensible. @return 0 or error number */ static MY_ATTRIBUTE((warn_unused_result)) int innobase_check_index_keys( - /*======================*/ const Alter_inplace_info *info, /*!< in: indexes to be created or dropped */ const dict_table_t *innodb_table) @@ -2187,11 +2153,9 @@ static void innobase_create_index_def(const TABLE *altered_table, DBUG_VOID_RETURN; } -/*******************************************************************/ /** - Check whether the table has the FTS_DOC_ID column +/** Check whether the table has the FTS_DOC_ID column @return whether there exists an FTS_DOC_ID column */ bool innobase_fts_check_doc_id_col( - /*==========================*/ const dict_table_t *table, /*!< in: InnoDB table with fulltext index */ const TABLE *altered_table, @@ -2267,12 +2231,10 @@ bool innobase_fts_check_doc_id_col( return (false); } -/*******************************************************************/ /** - Check whether the table has a unique index with FTS_DOC_ID_INDEX_NAME +/** Check whether the table has a unique index with FTS_DOC_ID_INDEX_NAME on the Doc ID column. @return the status of the FTS_DOC_ID index */ enum fts_doc_id_index_enum innobase_fts_check_doc_id_index( - /*============================*/ const dict_table_t *table, /*!< in: table definition */ const TABLE *altered_table, /*!< in: MySQL table that is being altered */ @@ -2354,13 +2316,11 @@ enum fts_doc_id_index_enum innobase_fts_check_doc_id_index( /* Not found */ return (FTS_NOT_EXIST_DOC_ID_INDEX); } -/*******************************************************************/ /** - Check whether the table has a unique index with FTS_DOC_ID_INDEX_NAME +/** Check whether the table has a unique index with FTS_DOC_ID_INDEX_NAME on the Doc ID column in MySQL create index definition. @return FTS_EXIST_DOC_ID_INDEX if there exists the FTS_DOC_ID index, FTS_INCORRECT_DOC_ID_INDEX if the FTS_DOC_ID index is of wrong format */ enum fts_doc_id_index_enum innobase_fts_check_doc_id_index_in_def( - /*===================================*/ ulint n_key, /*!< in: Number of keys */ const KEY *key_info) /*!< in: Key definition */ { @@ -2392,8 +2352,7 @@ enum fts_doc_id_index_enum innobase_fts_check_doc_id_index_in_def( return (FTS_NOT_EXIST_DOC_ID_INDEX); } -/*******************************************************************/ /** - Create an index table where indexes are ordered as follows: +/** Create an index table where indexes are ordered as follows: IF a new primary key is defined for the table THEN @@ -2408,30 +2367,28 @@ enum fts_doc_id_index_enum innobase_fts_check_doc_id_index_in_def( @return key definitions */ template -static MY_ATTRIBUTE((warn_unused_result, malloc)) - index_def_t *innobase_create_key_defs( - /*=====================*/ - mem_heap_t *heap, - /*!< in/out: memory heap where space for key - definitions are allocated */ - const Alter_inplace_info *ha_alter_info, - /*!< in: alter operation */ - const TABLE *altered_table, - /*!< in: MySQL table that is being altered */ - const Table *new_dd_table, - /*!< in: new dd table */ - ulint &n_add, - /*!< in/out: number of indexes to be created */ - ulint &n_fts_add, - /*!< out: number of FTS indexes to be created */ - bool got_default_clust, - /*!< in: whether the table lacks a primary key */ - ulint &fts_doc_id_col, - /*!< in: The column number for Doc ID */ - bool &add_fts_doc_id, - /*!< in: whether we need to add new DOC ID - column for FTS index */ - bool &add_fts_doc_idx) +static MY_ATTRIBUTE((warn_unused_result, malloc)) index_def_t + *innobase_create_key_defs(mem_heap_t *heap, + /*!< in/out: memory heap where space for key + definitions are allocated */ + const Alter_inplace_info *ha_alter_info, + /*!< in: alter operation */ + const TABLE *altered_table, + /*!< in: MySQL table that is being altered */ + const Table *new_dd_table, + /*!< in: new dd table */ + ulint &n_add, + /*!< in/out: number of indexes to be created */ + ulint &n_fts_add, + /*!< out: number of FTS indexes to be created */ + bool got_default_clust, + /*!< in: whether the table lacks a primary key */ + ulint &fts_doc_id_col, + /*!< in: The column number for Doc ID */ + bool &add_fts_doc_id, + /*!< in: whether we need to add new DOC ID + column for FTS index */ + bool &add_fts_doc_idx) /*!< in: whether we need to add new DOC ID index for FTS index */ { @@ -2598,11 +2555,9 @@ index for FTS index */ DBUG_RETURN(indexdefs); } -/*******************************************************************/ /** - Check each index column size, make sure they do not exceed the max limit +/** Check each index column size, make sure they do not exceed the max limit @return true if index column size exceeds limit */ static MY_ATTRIBUTE((warn_unused_result)) bool innobase_check_column_length( - /*=========================*/ ulint max_col_len, /*!< in: maximum column length */ const KEY *key_info) /*!< in: Indexes to be created */ { @@ -2647,7 +2602,6 @@ static void online_retry_drop_dict_indexes(dict_table_t *table, bool locked) { @param n_drop_fk number of constraints that are being dropped @return whether the constraint is being dropped */ inline MY_ATTRIBUTE((warn_unused_result)) bool innobase_dropping_foreign( - /*======================*/ const dict_foreign_t *foreign, dict_foreign_t **drop_fk, ulint n_drop_fk) { while (n_drop_fk--) { if (*drop_fk++ == foreign) { @@ -2669,7 +2623,6 @@ column that is being dropped or modified to NOT NULL. @retval false Allowed */ static MY_ATTRIBUTE((warn_unused_result)) bool innobase_check_foreigns_low( - /*========================*/ const dict_table_t *user_table, dict_foreign_t **drop_fk, ulint n_drop_fk, const char *col_name, bool drop) { dict_foreign_t *foreign; @@ -2750,7 +2703,6 @@ column that is being dropped or modified to NOT NULL. @retval false Allowed */ static MY_ATTRIBUTE((warn_unused_result)) bool innobase_check_foreigns( - /*====================*/ Alter_inplace_info *ha_alter_info, const TABLE *altered_table, const TABLE *old_table, const dict_table_t *user_table, dict_foreign_t **drop_fk, ulint n_drop_fk) { @@ -2786,9 +2738,8 @@ static MY_ATTRIBUTE((warn_unused_result)) bool innobase_check_foreigns( @param dfield InnoDB data field to copy to @param field MySQL value for the column @param comp nonzero if in compact format */ -static void innobase_build_col_map_add( - /*=======================*/ - mem_heap_t *heap, dfield_t *dfield, const Field *field, ulint comp) { +static void innobase_build_col_map_add(mem_heap_t *heap, dfield_t *dfield, + const Field *field, ulint comp) { if (field->is_real_null()) { dfield_set_null(dfield); return; @@ -2817,7 +2768,6 @@ adding columns. @return array of integers, mapping column numbers in the table to column numbers in altered_table */ static MY_ATTRIBUTE((warn_unused_result)) const ulint *innobase_build_col_map( - /*===================*/ Alter_inplace_info *ha_alter_info, const TABLE *altered_table, const TABLE *table, const dict_table_t *new_table, const dict_table_t *old_table, dtuple_t *add_cols, mem_heap_t *heap) { @@ -2929,9 +2879,7 @@ FIC create index process, before fts_add_index is called @param trx transaction @return DB_SUCCESS if successful, otherwise last error code */ -static dberr_t innobase_drop_fts_index_table( - /*==========================*/ - dict_table_t *table, trx_t *trx) { +static dberr_t innobase_drop_fts_index_table(dict_table_t *table, trx_t *trx) { dberr_t ret_err = DB_SUCCESS; for (dict_index_t *index = table->first_index(); index != NULL; @@ -4548,7 +4496,6 @@ static MY_ATTRIBUTE((warn_unused_result)) bool prepare_inplace_alter_table_dict( If so, if it is dropped, is there an equivalent index can play its role. @return true if the index is needed and can't be dropped */ static MY_ATTRIBUTE((warn_unused_result)) bool innobase_check_foreign_key_index( - /*=============================*/ Alter_inplace_info *ha_alter_info, /*!< in: Structure describing changes to be done by ALTER TABLE */ @@ -4665,10 +4612,8 @@ specified in ha_alter_info. @param ctx alter context, used to fetch the list of indexes to rename @param ha_alter_info fetch the new names from here */ -static void rename_indexes_in_cache( - /*====================*/ - const ha_innobase_inplace_ctx *ctx, - const Alter_inplace_info *ha_alter_info) { +static void rename_indexes_in_cache(const ha_innobase_inplace_ctx *ctx, + const Alter_inplace_info *ha_alter_info) { DBUG_ENTER("rename_indexes_in_cache"); ut_ad(ctx->num_to_rename == ha_alter_info->index_rename_count); @@ -5651,9 +5596,7 @@ bool ha_innobase::inplace_alter_table_impl(TABLE *altered_table, /** Free the modification log for online table rebuild. @param table table that was being rebuilt online */ -static void innobase_online_rebuild_log_free( - /*=============================*/ - dict_table_t *table) { +static void innobase_online_rebuild_log_free(dict_table_t *table) { dict_index_t *clust_index = table->first_index(); ut_ad(mutex_own(&dict_sys->mutex)); @@ -5723,9 +5666,9 @@ temparary index prefix @param locked TRUE=table locked, FALSE=may need to do a lazy drop @param trx the transaction */ -static void innobase_rollback_sec_index( - /*========================*/ - dict_table_t *user_table, const TABLE *table, ibool locked, trx_t *trx) { +static void innobase_rollback_sec_index(dict_table_t *user_table, + const TABLE *table, ibool locked, + trx_t *trx) { row_merge_drop_indexes(trx, user_table, locked); /* Free the table->fts only if there is no FTS_DOC_ID @@ -5860,7 +5803,6 @@ as part of commit_cache_norebuild(). @param table the TABLE @param user_table InnoDB table that was being altered */ static void innobase_rename_or_enlarge_columns_cache( - /*=====================================*/ Alter_inplace_info *ha_alter_info, const TABLE *table, dict_table_t *user_table) { if (!(ha_alter_info->handler_flags & @@ -5915,7 +5857,6 @@ static void innobase_rename_or_enlarge_columns_cache( @retval true Failure @retval false Success*/ static MY_ATTRIBUTE((warn_unused_result)) bool commit_get_autoinc( - /*===============*/ Alter_inplace_info *ha_alter_info, ha_innobase_inplace_ctx *ctx, const TABLE *altered_table, const TABLE *old_table) { DBUG_ENTER("commit_get_autoinc"); @@ -6008,7 +5949,6 @@ but do not touch the data dictionary cache. @retval false Success */ static MY_ATTRIBUTE((warn_unused_result)) bool innobase_update_foreign_try( - /*========================*/ ha_innobase_inplace_ctx *ctx, trx_t *trx, const char *table_name) { ulint foreign_id; ulint i; @@ -6166,7 +6106,6 @@ when rebuilding the table. @retval false Success */ inline MY_ATTRIBUTE((warn_unused_result)) bool commit_try_rebuild( - /*===============*/ Alter_inplace_info *ha_alter_info, ha_innobase_inplace_ctx *ctx, TABLE *altered_table, const TABLE *old_table, trx_t *trx, const char *table_name) { @@ -6318,9 +6257,7 @@ inline MY_ATTRIBUTE((warn_unused_result)) bool commit_try_rebuild( /** Apply the changes made during commit_try_rebuild(), to the data dictionary cache and the file system. @param ctx In-place ALTER TABLE context */ -inline void commit_cache_rebuild( - /*=================*/ - ha_innobase_inplace_ctx *ctx) { +inline void commit_cache_rebuild(ha_innobase_inplace_ctx *ctx) { dberr_t error; DBUG_ENTER("commit_cache_rebuild"); @@ -6452,7 +6389,6 @@ after a successful commit_try_norebuild() call. (will be started and committed) @return whether all replacements were found for dropped indexes */ inline MY_ATTRIBUTE((warn_unused_result)) bool commit_cache_norebuild( - /*===================*/ ha_innobase_inplace_ctx *ctx, const TABLE *table, trx_t *trx) { DBUG_ENTER("commit_cache_norebuild"); @@ -6548,10 +6484,10 @@ and rename statistics for renamed indexes. @param table_name Table name in MySQL @param thd MySQL connection */ -static void alter_stats_norebuild( - /*==================*/ - Alter_inplace_info *ha_alter_info, ha_innobase_inplace_ctx *ctx, - TABLE *altered_table, const char *table_name, THD *thd) { +static void alter_stats_norebuild(Alter_inplace_info *ha_alter_info, + ha_innobase_inplace_ctx *ctx, + TABLE *altered_table, const char *table_name, + THD *thd) { ulint i; DBUG_ENTER("alter_stats_norebuild"); @@ -6631,9 +6567,8 @@ and rename statistics for renamed indexes. @param table_name Table name in MySQL @param thd MySQL connection */ -static void alter_stats_rebuild( - /*================*/ - dict_table_t *table, const char *table_name, THD *thd) { +static void alter_stats_rebuild(dict_table_t *table, const char *table_name, + THD *thd) { DBUG_ENTER("alter_stats_rebuild"); DBUG_EXECUTE_IF("ib_ddl_crash_before_rename", DBUG_SUICIDE();); diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index 4936f5a53fe8..cb06dc50f6ca 100644 --- a/storage/innobase/handler/i_s.cc +++ b/storage/innobase/handler/i_s.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file handler/i_s.cc +/** @file handler/i_s.cc InnoDB INFORMATION SCHEMA tables interface to MySQL. Created July 18, 2007 Vasil Dimov @@ -228,28 +227,21 @@ time_t MYSQL_TYPE_DATETIME --------------------------------- */ -/*******************************************************************/ /** - Common function to fill any of the dynamic tables: +/** Common function to fill any of the dynamic tables: INFORMATION_SCHEMA.innodb_trx @return 0 on success */ static int trx_i_s_common_fill_table( - /*======================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ Item *); /*!< in: condition (not used) */ -/*******************************************************************/ /** - Unbind a dynamic INFORMATION_SCHEMA table. +/** Unbind a dynamic INFORMATION_SCHEMA table. @return 0 on success */ -static int i_s_common_deinit( - /*==============*/ - void *p); /*!< in/out: table schema object */ -/*******************************************************************/ /** - Auxiliary function to store time_t value in MYSQL_TYPE_DATETIME +static int i_s_common_deinit(void *p); /*!< in/out: table schema object */ +/** Auxiliary function to store time_t value in MYSQL_TYPE_DATETIME field. @return 0 on success */ static int field_store_time_t( - /*===============*/ Field *field, /*!< in/out: target field for storage */ time_t time) /*!< in: value to store */ { @@ -274,11 +266,9 @@ static int field_store_time_t( return (field->store_time(&my_time, MYSQL_TIMESTAMP_DATETIME)); } -/*******************************************************************/ /** - Auxiliary function to store char* value in MYSQL_TYPE_STRING field. +/** Auxiliary function to store char* value in MYSQL_TYPE_STRING field. @return 0 on success */ static int field_store_string( - /*===============*/ Field *field, /*!< in/out: target field for storage */ const char *str) /*!< in: NUL-terminated utf-8 string, or NULL */ @@ -297,12 +287,10 @@ static int field_store_string( return (ret); } -/*******************************************************************/ /** - Store the name of an index in a MYSQL_TYPE_VARCHAR field. +/** Store the name of an index in a MYSQL_TYPE_VARCHAR field. Handles the names of incomplete secondary indexes. @return 0 on success */ static int field_store_index_name( - /*===================*/ Field *field, /*!< in/out: target field for storage */ const char *index_name) /*!< in: NUL-terminated utf-8 @@ -497,12 +485,10 @@ static ST_FIELD_INFO innodb_trx_fields_info[] = { END_OF_ST_FIELD_INFO}; -/*******************************************************************/ /** - Read data from cache buffer and fill the INFORMATION_SCHEMA.innodb_trx +/** Read data from cache buffer and fill the INFORMATION_SCHEMA.innodb_trx table with it. @return 0 on success */ static int fill_innodb_trx_from_cache( - /*=======================*/ trx_i_s_cache_t *cache, /*!< in: cache to read from */ THD *thd, /*!< in: used to call schema_table_store_record() */ @@ -628,12 +614,9 @@ static int fill_innodb_trx_from_cache( DBUG_RETURN(0); } -/*******************************************************************/ /** - Bind the dynamic table INFORMATION_SCHEMA.innodb_trx +/** Bind the dynamic table INFORMATION_SCHEMA.innodb_trx @return 0 on success */ -static int innodb_trx_init( - /*============*/ - void *p) /*!< in/out: table schema object */ +static int innodb_trx_init(void *p) /*!< in/out: table schema object */ { ST_SCHEMA_TABLE *schema; @@ -706,12 +689,10 @@ struct st_mysql_plugin i_s_innodb_trx = { STRUCT_FLD(flags, 0UL), }; -/*******************************************************************/ /** - Common function to fill any of the dynamic tables: +/** Common function to fill any of the dynamic tables: INFORMATION_SCHEMA.innodb_trx @return 0 on success */ static int trx_i_s_common_fill_table( - /*======================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ Item *) /*!< in: condition (not used) */ @@ -832,16 +813,13 @@ static ST_FIELD_INFO i_s_cmp_fields_info[] = { END_OF_ST_FIELD_INFO}; -/*******************************************************************/ /** - Fill the dynamic table information_schema.innodb_cmp or +/** Fill the dynamic table information_schema.innodb_cmp or innodb_cmp_reset. @return 0 on success, 1 on failure */ -static int i_s_cmp_fill_low( - /*=============*/ - THD *thd, /*!< in: thread */ - TABLE_LIST *tables, /*!< in/out: tables to fill */ - Item *, /*!< in: condition (ignored) */ - ibool reset) /*!< in: TRUE=reset cumulated counts */ +static int i_s_cmp_fill_low(THD *thd, /*!< in: thread */ + TABLE_LIST *tables, /*!< in/out: tables to fill */ + Item *, /*!< in: condition (ignored) */ + ibool reset) /*!< in: TRUE=reset cumulated counts */ { TABLE *table = (TABLE *)tables->table; int status = 0; @@ -883,36 +861,27 @@ static int i_s_cmp_fill_low( DBUG_RETURN(status); } -/*******************************************************************/ /** - Fill the dynamic table information_schema.innodb_cmp. +/** Fill the dynamic table information_schema.innodb_cmp. @return 0 on success, 1 on failure */ -static int i_s_cmp_fill( - /*=========*/ - THD *thd, /*!< in: thread */ - TABLE_LIST *tables, /*!< in/out: tables to fill */ - Item *cond) /*!< in: condition (ignored) */ +static int i_s_cmp_fill(THD *thd, /*!< in: thread */ + TABLE_LIST *tables, /*!< in/out: tables to fill */ + Item *cond) /*!< in: condition (ignored) */ { return (i_s_cmp_fill_low(thd, tables, cond, FALSE)); } -/*******************************************************************/ /** - Fill the dynamic table information_schema.innodb_cmp_reset. +/** Fill the dynamic table information_schema.innodb_cmp_reset. @return 0 on success, 1 on failure */ -static int i_s_cmp_reset_fill( - /*===============*/ - THD *thd, /*!< in: thread */ - TABLE_LIST *tables, /*!< in/out: tables to fill */ - Item *cond) /*!< in: condition (ignored) */ +static int i_s_cmp_reset_fill(THD *thd, /*!< in: thread */ + TABLE_LIST *tables, /*!< in/out: tables to fill */ + Item *cond) /*!< in: condition (ignored) */ { return (i_s_cmp_fill_low(thd, tables, cond, TRUE)); } -/*******************************************************************/ /** - Bind the dynamic table information_schema.innodb_cmp. +/** Bind the dynamic table information_schema.innodb_cmp. @return 0 on success */ -static int i_s_cmp_init( - /*=========*/ - void *p) /*!< in/out: table schema object */ +static int i_s_cmp_init(void *p) /*!< in/out: table schema object */ { DBUG_ENTER("i_s_cmp_init"); ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p; @@ -923,12 +892,9 @@ static int i_s_cmp_init( DBUG_RETURN(0); } -/*******************************************************************/ /** - Bind the dynamic table information_schema.innodb_cmp_reset. +/** Bind the dynamic table information_schema.innodb_cmp_reset. @return 0 on success */ -static int i_s_cmp_reset_init( - /*===============*/ - void *p) /*!< in/out: table schema object */ +static int i_s_cmp_reset_init(void *p) /*!< in/out: table schema object */ { DBUG_ENTER("i_s_cmp_reset_init"); ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p; @@ -1112,13 +1078,11 @@ static ST_FIELD_INFO i_s_cmp_per_index_fields_info[] = { END_OF_ST_FIELD_INFO}; -/*******************************************************************/ /** - Fill the dynamic table +/** Fill the dynamic table information_schema.innodb_cmp_per_index or information_schema.innodb_cmp_per_index_reset. @return 0 on success, 1 on failure */ static int i_s_cmp_per_index_fill_low( - /*=======================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ Item *, /*!< in: condition (ignored) */ @@ -1214,11 +1178,9 @@ static int i_s_cmp_per_index_fill_low( DBUG_RETURN(status); } -/*******************************************************************/ /** - Fill the dynamic table information_schema.innodb_cmp_per_index. +/** Fill the dynamic table information_schema.innodb_cmp_per_index. @return 0 on success, 1 on failure */ static int i_s_cmp_per_index_fill( - /*===================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ Item *cond) /*!< in: condition (ignored) */ @@ -1226,11 +1188,9 @@ static int i_s_cmp_per_index_fill( return (i_s_cmp_per_index_fill_low(thd, tables, cond, FALSE)); } -/*******************************************************************/ /** - Fill the dynamic table information_schema.innodb_cmp_per_index_reset. +/** Fill the dynamic table information_schema.innodb_cmp_per_index_reset. @return 0 on success, 1 on failure */ static int i_s_cmp_per_index_reset_fill( - /*=========================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ Item *cond) /*!< in: condition (ignored) */ @@ -1238,12 +1198,9 @@ static int i_s_cmp_per_index_reset_fill( return (i_s_cmp_per_index_fill_low(thd, tables, cond, TRUE)); } -/*******************************************************************/ /** - Bind the dynamic table information_schema.innodb_cmp_per_index. +/** Bind the dynamic table information_schema.innodb_cmp_per_index. @return 0 on success */ -static int i_s_cmp_per_index_init( - /*===================*/ - void *p) /*!< in/out: table schema object */ +static int i_s_cmp_per_index_init(void *p) /*!< in/out: table schema object */ { DBUG_ENTER("i_s_cmp_init"); ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p; @@ -1254,11 +1211,9 @@ static int i_s_cmp_per_index_init( DBUG_RETURN(0); } -/*******************************************************************/ /** - Bind the dynamic table information_schema.innodb_cmp_per_index_reset. +/** Bind the dynamic table information_schema.innodb_cmp_per_index_reset. @return 0 on success */ static int i_s_cmp_per_index_reset_init( - /*=========================*/ void *p) /*!< in/out: table schema object */ { DBUG_ENTER("i_s_cmp_reset_init"); @@ -1500,23 +1455,18 @@ static int i_s_cmpmem_fill_low(THD *thd, TABLE_LIST *tables, Item *item, DBUG_RETURN(status); } -/*******************************************************************/ /** - Fill the dynamic table information_schema.innodb_cmpmem. +/** Fill the dynamic table information_schema.innodb_cmpmem. @return 0 on success, 1 on failure */ -static int i_s_cmpmem_fill( - /*============*/ - THD *thd, /*!< in: thread */ - TABLE_LIST *tables, /*!< in/out: tables to fill */ - Item *cond) /*!< in: condition (ignored) */ +static int i_s_cmpmem_fill(THD *thd, /*!< in: thread */ + TABLE_LIST *tables, /*!< in/out: tables to fill */ + Item *cond) /*!< in: condition (ignored) */ { return (i_s_cmpmem_fill_low(thd, tables, cond, FALSE)); } -/*******************************************************************/ /** - Fill the dynamic table information_schema.innodb_cmpmem_reset. +/** Fill the dynamic table information_schema.innodb_cmpmem_reset. @return 0 on success, 1 on failure */ static int i_s_cmpmem_reset_fill( - /*==================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ Item *cond) /*!< in: condition (ignored) */ @@ -1524,12 +1474,9 @@ static int i_s_cmpmem_reset_fill( return (i_s_cmpmem_fill_low(thd, tables, cond, TRUE)); } -/*******************************************************************/ /** - Bind the dynamic table information_schema.innodb_cmpmem. +/** Bind the dynamic table information_schema.innodb_cmpmem. @return 0 on success */ -static int i_s_cmpmem_init( - /*============*/ - void *p) /*!< in/out: table schema object */ +static int i_s_cmpmem_init(void *p) /*!< in/out: table schema object */ { DBUG_ENTER("i_s_cmpmem_init"); ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p; @@ -1540,12 +1487,9 @@ static int i_s_cmpmem_init( DBUG_RETURN(0); } -/*******************************************************************/ /** - Bind the dynamic table information_schema.innodb_cmpmem_reset. +/** Bind the dynamic table information_schema.innodb_cmpmem_reset. @return 0 on success */ -static int i_s_cmpmem_reset_init( - /*==================*/ - void *p) /*!< in/out: table schema object */ +static int i_s_cmpmem_reset_init(void *p) /*!< in/out: table schema object */ { DBUG_ENTER("i_s_cmpmem_reset_init"); ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p; @@ -1786,11 +1730,9 @@ static ST_FIELD_INFO innodb_metrics_fields_info[] = { END_OF_ST_FIELD_INFO}; -/**********************************************************************/ /** - Fill the information schema metrics table. +/** Fill the information schema metrics table. @return 0 on success */ static int i_s_metrics_fill( - /*=============*/ THD *thd, /*!< in: thread */ TABLE *table_to_fill) /*!< in/out: fill this table */ { @@ -2026,11 +1968,9 @@ static int i_s_metrics_fill( DBUG_RETURN(0); } -/*******************************************************************/ /** - Function to fill information schema metrics tables. +/** Function to fill information schema metrics tables. @return 0 on success */ static int i_s_metrics_fill_table( - /*===================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ Item *) /*!< in: condition (not used) */ @@ -2046,12 +1986,9 @@ static int i_s_metrics_fill_table( DBUG_RETURN(0); } -/*******************************************************************/ /** - Bind the dynamic table INFORMATION_SCHEMA.innodb_metrics +/** Bind the dynamic table INFORMATION_SCHEMA.innodb_metrics @return 0 on success */ -static int innodb_metrics_init( - /*================*/ - void *p) /*!< in/out: table schema object */ +static int innodb_metrics_init(void *p) /*!< in/out: table schema object */ { ST_SCHEMA_TABLE *schema; @@ -2131,14 +2068,11 @@ static ST_FIELD_INFO i_s_stopword_fields_info[] = { END_OF_ST_FIELD_INFO}; -/*******************************************************************/ /** - Fill the dynamic table information_schema.innodb_ft_default_stopword. +/** Fill the dynamic table information_schema.innodb_ft_default_stopword. @return 0 on success, 1 on failure */ -static int i_s_stopword_fill( - /*==============*/ - THD *thd, /*!< in: thread */ - TABLE_LIST *tables, /*!< in/out: tables to fill */ - Item *) /*!< in: condition (not used) */ +static int i_s_stopword_fill(THD *thd, /*!< in: thread */ + TABLE_LIST *tables, /*!< in/out: tables to fill */ + Item *) /*!< in: condition (not used) */ { Field **fields; ulint i = 0; @@ -2160,12 +2094,9 @@ static int i_s_stopword_fill( DBUG_RETURN(0); } -/*******************************************************************/ /** - Bind the dynamic table information_schema.innodb_ft_default_stopword. +/** Bind the dynamic table information_schema.innodb_ft_default_stopword. @return 0 on success */ -static int i_s_stopword_init( - /*==============*/ - void *p) /*!< in/out: table schema object */ +static int i_s_stopword_init(void *p) /*!< in/out: table schema object */ { DBUG_ENTER("i_s_stopword_init"); ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p; @@ -2244,12 +2175,10 @@ static ST_FIELD_INFO i_s_fts_doc_fields_info[] = { END_OF_ST_FIELD_INFO}; -/*******************************************************************/ /** - Fill the dynamic table INFORMATION_SCHEMA.INNODB_FT_DELETED or +/** Fill the dynamic table INFORMATION_SCHEMA.INNODB_FT_DELETED or INFORMATION_SCHEMA.INNODB_FT_BEING_DELETED @return 0 on success, 1 on failure */ static int i_s_fts_deleted_generic_fill( - /*=========================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ ibool being_deleted) /*!< in: BEING_DELTED table */ @@ -2330,11 +2259,9 @@ static int i_s_fts_deleted_generic_fill( DBUG_RETURN(0); } -/*******************************************************************/ /** - Fill the dynamic table INFORMATION_SCHEMA.INNODB_FT_DELETED +/** Fill the dynamic table INFORMATION_SCHEMA.INNODB_FT_DELETED @return 0 on success, 1 on failure */ static int i_s_fts_deleted_fill( - /*=================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ Item *) /*!< in: condition (ignored) */ @@ -2344,12 +2271,9 @@ static int i_s_fts_deleted_fill( DBUG_RETURN(i_s_fts_deleted_generic_fill(thd, tables, FALSE)); } -/*******************************************************************/ /** - Bind the dynamic table INFORMATION_SCHEMA.INNODB_FT_DELETED +/** Bind the dynamic table INFORMATION_SCHEMA.INNODB_FT_DELETED @return 0 on success */ -static int i_s_fts_deleted_init( - /*=================*/ - void *p) /*!< in/out: table schema object */ +static int i_s_fts_deleted_init(void *p) /*!< in/out: table schema object */ { DBUG_ENTER("i_s_fts_deleted_init"); ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p; @@ -2416,11 +2340,9 @@ struct st_mysql_plugin i_s_innodb_ft_deleted = { STRUCT_FLD(flags, 0UL), }; -/*******************************************************************/ /** - Fill the dynamic table INFORMATION_SCHEMA.INNODB_FT_BEING_DELETED +/** Fill the dynamic table INFORMATION_SCHEMA.INNODB_FT_BEING_DELETED @return 0 on success, 1 on failure */ static int i_s_fts_being_deleted_fill( - /*=======================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ Item *) /*!< in: condition (ignored) */ @@ -2430,11 +2352,9 @@ static int i_s_fts_being_deleted_fill( DBUG_RETURN(i_s_fts_deleted_generic_fill(thd, tables, TRUE)); } -/*******************************************************************/ /** - Bind the dynamic table INFORMATION_SCHEMA.INNODB_FT_BEING_DELETED +/** Bind the dynamic table INFORMATION_SCHEMA.INNODB_FT_BEING_DELETED @return 0 on success */ static int i_s_fts_being_deleted_init( - /*=======================*/ void *p) /*!< in/out: table schema object */ { DBUG_ENTER("i_s_fts_deleted_init"); @@ -2549,12 +2469,10 @@ static ST_FIELD_INFO i_s_fts_index_fields_info[] = { END_OF_ST_FIELD_INFO}; -/*******************************************************************/ /** - Go through the Doc Node and its ilist, fill the dynamic table +/** Go through the Doc Node and its ilist, fill the dynamic table INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHED for one FTS index on the table. @return 0 on success, 1 on failure */ static int i_s_fts_index_cache_fill_one_index( - /*===============================*/ fts_index_cache_t *index_cache, /*!< in: FTS index cache */ THD *thd, /*!< in: thread */ TABLE_LIST *tables) /*!< in/out: tables to fill */ @@ -2643,11 +2561,9 @@ static int i_s_fts_index_cache_fill_one_index( DBUG_RETURN(0); } -/*******************************************************************/ /** - Fill the dynamic table INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHED +/** Fill the dynamic table INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHED @return 0 on success, 1 on failure */ static int i_s_fts_index_cache_fill( - /*=====================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ Item *) /*!< in: condition (ignored) */ @@ -2701,12 +2617,9 @@ static int i_s_fts_index_cache_fill( DBUG_RETURN(0); } -/*******************************************************************/ /** - Bind the dynamic table INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE +/** Bind the dynamic table INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE @return 0 on success */ -static int i_s_fts_index_cache_init( - /*=====================*/ - void *p) /*!< in/out: table schema object */ +static int i_s_fts_index_cache_init(void *p) /*!< in/out: table schema object */ { DBUG_ENTER("i_s_fts_index_cache_init"); ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p; @@ -2773,12 +2686,10 @@ struct st_mysql_plugin i_s_innodb_ft_index_cache = { STRUCT_FLD(flags, 0UL), }; -/*******************************************************************/ /** - Go through a FTS index auxiliary table, fetch its rows and fill +/** Go through a FTS index auxiliary table, fetch its rows and fill FTS word cache structure. @return DB_SUCCESS on success, otherwise error code */ static dberr_t i_s_fts_index_table_fill_selected( - /*==============================*/ dict_index_t *index, /*!< in: FTS index */ ib_vector_t *words, /*!< in/out: vector to hold fetched words */ @@ -2866,10 +2777,8 @@ static dberr_t i_s_fts_index_table_fill_selected( return (error); } -/*******************************************************************/ /** - Free words. */ +/** Free words. */ static void i_s_fts_index_table_free_one_fetch( - /*===============================*/ ib_vector_t *words) /*!< in: words fetched */ { for (ulint i = 0; i < ib_vector_size(words); i++) { @@ -2890,11 +2799,9 @@ static void i_s_fts_index_table_free_one_fetch( ib_vector_reset(words); } -/*******************************************************************/ /** - Go through words, fill INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE. +/** Go through words, fill INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE. @return 0 on success, 1 on failure */ static int i_s_fts_index_table_fill_one_fetch( - /*===============================*/ CHARSET_INFO *index_charset, /*!< in: FTS index charset */ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ @@ -2989,12 +2896,10 @@ static int i_s_fts_index_table_fill_one_fetch( DBUG_RETURN(ret); } -/*******************************************************************/ /** - Go through a FTS index and its auxiliary tables, fetch rows in each table +/** Go through a FTS index and its auxiliary tables, fetch rows in each table and fill INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE. @return 0 on success, 1 on failure */ static int i_s_fts_index_table_fill_one_index( - /*===============================*/ dict_index_t *index, /*!< in: FTS index */ THD *thd, /*!< in: thread */ TABLE_LIST *tables) /*!< in/out: tables to fill */ @@ -3069,11 +2974,9 @@ static int i_s_fts_index_table_fill_one_index( DBUG_RETURN(ret); } -/*******************************************************************/ /** - Fill the dynamic table INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE +/** Fill the dynamic table INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE @return 0 on success, 1 on failure */ static int i_s_fts_index_table_fill( - /*=====================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ Item *) /*!< in: condition (ignored) */ @@ -3122,12 +3025,9 @@ static int i_s_fts_index_table_fill( DBUG_RETURN(0); } -/*******************************************************************/ /** - Bind the dynamic table INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE +/** Bind the dynamic table INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE @return 0 on success */ -static int i_s_fts_index_table_init( - /*=====================*/ - void *p) /*!< in/out: table schema object */ +static int i_s_fts_index_table_init(void *p) /*!< in/out: table schema object */ { DBUG_ENTER("i_s_fts_index_table_init"); ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p; @@ -3214,11 +3114,9 @@ static const char *fts_config_key[] = { FTS_OPTIMIZE_LIMIT_IN_SECS, FTS_SYNCED_DOC_ID, FTS_STOPWORD_TABLE_NAME, FTS_USE_STOPWORD, NULL}; -/*******************************************************************/ /** - Fill the dynamic table INFORMATION_SCHEMA.INNODB_FT_CONFIG +/** Fill the dynamic table INFORMATION_SCHEMA.INNODB_FT_CONFIG @return 0 on success, 1 on failure */ static int i_s_fts_config_fill( - /*================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ Item *) /*!< in: condition (ignored) */ @@ -3326,12 +3224,9 @@ static int i_s_fts_config_fill( DBUG_RETURN(0); } -/*******************************************************************/ /** - Bind the dynamic table INFORMATION_SCHEMA.INNODB_FT_CONFIG +/** Bind the dynamic table INFORMATION_SCHEMA.INNODB_FT_CONFIG @return 0 on success */ -static int i_s_fts_config_init( - /*=================*/ - void *p) /*!< in/out: table schema object */ +static int i_s_fts_config_init(void *p) /*!< in/out: table schema object */ { DBUG_ENTER("i_s_fts_config_init"); ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p; @@ -3438,12 +3333,10 @@ struct temp_table_info_t { typedef std::vector> temp_table_info_cache_t; -/*******************************************************************/ /** - Fill Information Schema table INNODB_TEMP_TABLE_INFO for a particular +/** Fill Information Schema table INNODB_TEMP_TABLE_INFO for a particular temp-table @return 0 on success, 1 on failure */ static int i_s_innodb_temp_table_info_fill( - /*=============================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ @@ -3489,12 +3382,10 @@ static void innodb_temp_table_populate_cache(const dict_table_t *table, cache->m_space_id = table->space; } -/*******************************************************************/ /** - This function will iterate over all available table and will fill +/** This function will iterate over all available table and will fill stats for temp-tables to INNODB_TEMP_TABLE_INFO. @return 0 on success, 1 on failure */ static int i_s_innodb_temp_table_info_fill_table( - /*===================================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ Item *) /*!< in: condition (ignored) */ @@ -3545,11 +3436,9 @@ static int i_s_innodb_temp_table_info_fill_table( DBUG_RETURN(status); } -/*******************************************************************/ /** - Bind the dynamic table INFORMATION_SCHEMA.INNODB_TEMP_TABLE_INFO. +/** Bind the dynamic table INFORMATION_SCHEMA.INNODB_TEMP_TABLE_INFO. @return 0 on success, 1 on failure */ static int i_s_innodb_temp_table_info_init( - /*=============================*/ void *p) /*!< in/out: table schema object */ { ST_SCHEMA_TABLE *schema; @@ -3848,12 +3737,10 @@ static ST_FIELD_INFO i_s_innodb_buffer_stats_fields_info[] = { END_OF_ST_FIELD_INFO}; -/*******************************************************************/ /** - Fill Information Schema table INNODB_BUFFER_POOL_STATS for a particular +/** Fill Information Schema table INNODB_BUFFER_POOL_STATS for a particular buffer pool @return 0 on success, 1 on failure */ static int i_s_innodb_stats_fill( - /*==================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ const buf_pool_info_t *info) /*!< in: buffer pool @@ -3948,12 +3835,10 @@ static int i_s_innodb_stats_fill( DBUG_RETURN(schema_table_store_record(thd, table)); } -/*******************************************************************/ /** - This is the function that loops through each buffer pool and fetch buffer +/** This is the function that loops through each buffer pool and fetch buffer pool stats to information schema table: I_S_INNODB_BUFFER_POOL_STATS @return 0 on success, 1 on failure */ static int i_s_innodb_buffer_stats_fill_table( - /*===============================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ Item *) /*!< in: condition (ignored) */ @@ -3993,11 +3878,9 @@ static int i_s_innodb_buffer_stats_fill_table( DBUG_RETURN(status); } -/*******************************************************************/ /** - Bind the dynamic table INFORMATION_SCHEMA.INNODB_BUFFER_POOL_STATS. +/** Bind the dynamic table INFORMATION_SCHEMA.INNODB_BUFFER_POOL_STATS. @return 0 on success, 1 on failure */ static int i_s_innodb_buffer_pool_stats_init( - /*==============================*/ void *p) /*!< in/out: table schema object */ { ST_SCHEMA_TABLE *schema; @@ -4205,12 +4088,10 @@ static ST_FIELD_INFO i_s_innodb_buffer_page_fields_info[] = { END_OF_ST_FIELD_INFO}; -/*******************************************************************/ /** - Fill Information Schema table INNODB_BUFFER_PAGE with information +/** Fill Information Schema table INNODB_BUFFER_PAGE with information cached in the buf_page_info_t array @return 0 on success, 1 on failure */ static int i_s_innodb_buffer_page_fill( - /*========================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ const buf_page_info_t *info_array, /*!< in: array cached page @@ -4373,10 +4254,8 @@ static int i_s_innodb_buffer_page_fill( DBUG_RETURN(0); } -/*******************************************************************/ /** - Set appropriate page type to a buf_page_info_t structure */ +/** Set appropriate page type to a buf_page_info_t structure */ static void i_s_innodb_set_page_type( - /*=====================*/ buf_page_info_t *page_info, /*!< in/out: structure to fill with scanned info */ ulint page_type, /*!< in: page type */ @@ -4438,12 +4317,10 @@ static void i_s_innodb_set_page_type( mach_read_from_4(frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); } } -/*******************************************************************/ /** - Scans pages in the buffer cache, and collect their general information +/** Scans pages in the buffer cache, and collect their general information into the buf_page_info_t array which is zero-filled. So any fields that are not initialized in the function will default to 0 */ static void i_s_innodb_buffer_page_get_info( - /*============================*/ const buf_page_t *bpage, /*!< in: buffer pool page to scan */ ulint pool_id, /*!< in: buffer pool id */ ulint pos, /*!< in: buffer block position in @@ -4529,12 +4406,10 @@ static void i_s_innodb_buffer_page_get_info( mutex_exit(mutex); } -/*******************************************************************/ /** - This is the function that goes through each block of the buffer pool +/** This is the function that goes through each block of the buffer pool and fetch information to information schema tables: INNODB_BUFFER_PAGE. @return 0 on success, 1 on failure */ static int i_s_innodb_fill_buffer_pool( - /*========================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ buf_pool_t *buf_pool, /*!< in: buffer pool to scan */ @@ -4604,12 +4479,10 @@ static int i_s_innodb_fill_buffer_pool( DBUG_RETURN(status); } -/*******************************************************************/ /** - Fill page information for pages in InnoDB buffer pool to the +/** Fill page information for pages in InnoDB buffer pool to the dynamic table INFORMATION_SCHEMA.INNODB_BUFFER_PAGE @return 0 on success, 1 on failure */ static int i_s_innodb_buffer_page_fill_table( - /*==============================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ Item *) /*!< in: condition (ignored) */ @@ -4642,11 +4515,9 @@ static int i_s_innodb_buffer_page_fill_table( DBUG_RETURN(status); } -/*******************************************************************/ /** - Bind the dynamic table INFORMATION_SCHEMA.INNODB_BUFFER_PAGE. +/** Bind the dynamic table INFORMATION_SCHEMA.INNODB_BUFFER_PAGE. @return 0 on success, 1 on failure */ static int i_s_innodb_buffer_page_init( - /*========================*/ void *p) /*!< in/out: table schema object */ { ST_SCHEMA_TABLE *schema; @@ -4853,12 +4724,10 @@ static ST_FIELD_INFO i_s_innodb_buf_page_lru_fields_info[] = { END_OF_ST_FIELD_INFO}; -/*******************************************************************/ /** - Fill Information Schema table INNODB_BUFFER_PAGE_LRU with information +/** Fill Information Schema table INNODB_BUFFER_PAGE_LRU with information cached in the buf_page_info_t array @return 0 on success, 1 on failure */ static int i_s_innodb_buf_page_lru_fill( - /*=========================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ const buf_page_info_t *info_array, /*!< in: array cached page @@ -5075,12 +4944,10 @@ static int i_s_innodb_fill_buffer_lru(THD *thd, TABLE_LIST *tables, DBUG_RETURN(status); } -/*******************************************************************/ /** - Fill page information for pages in InnoDB buffer pool to the +/** Fill page information for pages in InnoDB buffer pool to the dynamic table INFORMATION_SCHEMA.INNODB_BUFFER_PAGE_LRU @return 0 on success, 1 on failure */ static int i_s_innodb_buf_page_lru_fill_table( - /*===============================*/ THD *thd, /*!< in: thread */ TABLE_LIST *tables, /*!< in/out: tables to fill */ Item *) /*!< in: condition (ignored) */ @@ -5113,11 +4980,9 @@ static int i_s_innodb_buf_page_lru_fill_table( DBUG_RETURN(status); } -/*******************************************************************/ /** - Bind the dynamic table INFORMATION_SCHEMA.INNODB_BUFFER_PAGE_LRU. +/** Bind the dynamic table INFORMATION_SCHEMA.INNODB_BUFFER_PAGE_LRU. @return 0 on success, 1 on failure */ static int i_s_innodb_buffer_page_lru_init( - /*============================*/ void *p) /*!< in/out: table schema object */ { ST_SCHEMA_TABLE *schema; @@ -5188,12 +5053,9 @@ struct st_mysql_plugin i_s_innodb_buffer_page_lru = { STRUCT_FLD(flags, 0UL), }; -/*******************************************************************/ /** - Unbind a dynamic INFORMATION_SCHEMA table. +/** Unbind a dynamic INFORMATION_SCHEMA table. @return 0 on success */ -static int i_s_common_deinit( - /*==============*/ - void *p) /*!< in/out: table schema object */ +static int i_s_common_deinit(void *p) /*!< in/out: table schema object */ { DBUG_ENTER("i_s_common_deinit"); diff --git a/storage/innobase/handler/i_s.h b/storage/innobase/handler/i_s.h index 84c94ba72e44..5133c257b61d 100644 --- a/storage/innobase/handler/i_s.h +++ b/storage/innobase/handler/i_s.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file handler/i_s.h +/** @file handler/i_s.h InnoDB INFORMATION SCHEMA tables interface to MySQL. Created July 18, 2007 Vasil Dimov diff --git a/storage/innobase/handler/p_s.cc b/storage/innobase/handler/p_s.cc index 0ba9d4fd2af7..d107825c469b 100644 --- a/storage/innobase/handler/p_s.cc +++ b/storage/innobase/handler/p_s.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2016, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2016, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file handler/p_s.cc +/** @file handler/p_s.cc InnoDB performance_schema tables interface to MySQL. *******************************************************/ diff --git a/storage/innobase/handler/p_s.h b/storage/innobase/handler/p_s.h index 49d16eada917..256246cf7074 100644 --- a/storage/innobase/handler/p_s.h +++ b/storage/innobase/handler/p_s.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file handler/p_s.h +/** @file handler/p_s.h InnoDB performance_schema tables interface to MySQL. *******************************************************/ diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index 27db849ecaea..4b65781c7879 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file ibuf/ibuf0ibuf.cc +/** @file ibuf/ibuf0ibuf.cc Insert buffer Created 7/19/1997 Heikki Tuuri @@ -332,36 +331,28 @@ because ibuf merge is done to a page when it is read in, and it is still physically like the index page even if the index would have been dropped! So, there seems to be no problem. */ -/******************************************************************/ /** - Sets the flag in the current mini-transaction record indicating we're +/** Sets the flag in the current mini-transaction record indicating we're inside an insert buffer routine. */ UNIV_INLINE -void ibuf_enter( - /*=======*/ - mtr_t *mtr) /*!< in/out: mini-transaction */ +void ibuf_enter(mtr_t *mtr) /*!< in/out: mini-transaction */ { ut_ad(!mtr->is_inside_ibuf()); mtr->enter_ibuf(); } -/******************************************************************/ /** - Sets the flag in the current mini-transaction record indicating we're +/** Sets the flag in the current mini-transaction record indicating we're exiting an insert buffer routine. */ UNIV_INLINE -void ibuf_exit( - /*======*/ - mtr_t *mtr) /*!< in/out: mini-transaction */ +void ibuf_exit(mtr_t *mtr) /*!< in/out: mini-transaction */ { ut_ad(mtr->is_inside_ibuf()); mtr->exit_ibuf(); } -/**************************************************************/ /** - Commits an insert buffer mini-transaction and sets the persistent +/** Commits an insert buffer mini-transaction and sets the persistent cursor latch mode to BTR_NO_LATCHES, that is, detaches the cursor. */ UNIV_INLINE void ibuf_btr_pcur_commit_specify_mtr( - /*=============================*/ btr_pcur_t *pcur, /*!< in/out: persistent cursor */ mtr_t *mtr) /*!< in/out: mini-transaction */ { @@ -369,12 +360,9 @@ void ibuf_btr_pcur_commit_specify_mtr( btr_pcur_commit_specify_mtr(pcur, mtr); } -/******************************************************************/ /** - Gets the ibuf header page and x-latches it. +/** Gets the ibuf header page and x-latches it. @return insert buffer header page */ -static page_t *ibuf_header_page_get( - /*=================*/ - mtr_t *mtr) /*!< in/out: mini-transaction */ +static page_t *ibuf_header_page_get(mtr_t *mtr) /*!< in/out: mini-transaction */ { buf_block_t *block; @@ -388,12 +376,9 @@ static page_t *ibuf_header_page_get( return (buf_block_get_frame(block)); } -/******************************************************************/ /** - Gets the root page and sx-latches it. +/** Gets the root page and sx-latches it. @return insert buffer tree root page */ -static page_t *ibuf_tree_root_get( - /*===============*/ - mtr_t *mtr) /*!< in: mtr */ +static page_t *ibuf_tree_root_get(mtr_t *mtr) /*!< in: mtr */ { buf_block_t *block; page_t *root; @@ -441,11 +426,8 @@ static void ibuf_count_set(const page_id_t &page_id, ulint val) { } #endif -/******************************************************************/ /** - Closes insert buffer and frees the data structures. */ -void ibuf_close(void) -/*============*/ -{ +/** Closes insert buffer and frees the data structures. */ +void ibuf_close(void) { if (ibuf == NULL) { return; } @@ -465,12 +447,9 @@ void ibuf_close(void) ibuf = NULL; } -/******************************************************************/ /** - Updates the size information of the ibuf, assuming the segment size has not +/** Updates the size information of the ibuf, assuming the segment size has not changed. */ -static void ibuf_size_update( - /*=============*/ - const page_t *root) /*!< in: ibuf tree root */ +static void ibuf_size_update(const page_t *root) /*!< in: ibuf tree root */ { ut_ad(mutex_own(&ibuf_mutex)); @@ -483,12 +462,9 @@ static void ibuf_size_update( ibuf->size = ibuf->seg_size - (1 + ibuf->free_list_len); } -/******************************************************************/ /** - Creates the insert buffer data structure at a database startup and initializes - the data structures for the insert buffer. */ -void ibuf_init_at_db_start(void) -/*=======================*/ -{ +/** Creates the insert buffer data structure at a database startup and + initializes the data structures for the insert buffer. */ +void ibuf_init_at_db_start(void) { page_t *root; mtr_t mtr; ulint n_used; @@ -559,12 +535,9 @@ void ibuf_init_at_db_start(void) ut_d(ibuf->index->cached = TRUE); } -/*********************************************************************/ /** - Updates the max_size value for ibuf. */ -void ibuf_max_size_update( - /*=================*/ - ulint new_val) /*!< in: new value in terms of - percentage of the buffer pool size */ +/** Updates the max_size value for ibuf. */ +void ibuf_max_size_update(ulint new_val) /*!< in: new value in terms of + percentage of the buffer pool size */ { ulint new_size = ((buf_pool_get_curr_size() / UNIV_PAGE_SIZE) * new_val) / 100; @@ -574,12 +547,9 @@ void ibuf_max_size_update( } #endif /* !UNIV_HOTBACKUP */ -/*********************************************************************/ /** - Initializes an ibuf bitmap page. */ -void ibuf_bitmap_page_init( - /*==================*/ - buf_block_t *block, /*!< in: bitmap page */ - mtr_t *mtr) /*!< in: mtr */ +/** Initializes an ibuf bitmap page. */ +void ibuf_bitmap_page_init(buf_block_t *block, /*!< in: bitmap page */ + mtr_t *mtr) /*!< in: mtr */ { page_t *page; ulint byte_offset; @@ -601,15 +571,13 @@ void ibuf_bitmap_page_init( #endif /* !UNIV_HOTBACKUP */ } -/*********************************************************************/ /** - Parses a redo log record of an ibuf bitmap page init. +/** Parses a redo log record of an ibuf bitmap page init. @return end of log record or NULL */ -byte *ibuf_parse_bitmap_init( - /*===================*/ - byte *ptr, /*!< in: buffer */ - byte *end_ptr MY_ATTRIBUTE((unused)), /*!< in: buffer end */ - buf_block_t *block, /*!< in: block or NULL */ - mtr_t *mtr) /*!< in: mtr or NULL */ +byte *ibuf_parse_bitmap_init(byte *ptr, /*!< in: buffer */ + byte *end_ptr + MY_ATTRIBUTE((unused)), /*!< in: buffer end */ + buf_block_t *block, /*!< in: block or NULL */ + mtr_t *mtr) /*!< in: mtr or NULL */ { ut_ad(ptr != NULL); ut_ad(end_ptr != NULL); @@ -794,14 +762,12 @@ is x-latched */ #define ibuf_bitmap_get_map_page(page_id, page_size, mtr) \ ibuf_bitmap_get_map_page_func(page_id, page_size, __FILE__, __LINE__, mtr) -/************************************************************************/ /** - Sets the free bits of the page in the ibuf bitmap. This is done in a separate - mini-transaction, hence this operation does not restrict further work to only - ibuf bitmap operations, which would result if the latch to the bitmap page - were kept. */ +/** Sets the free bits of the page in the ibuf bitmap. This is done in a + separate mini-transaction, hence this operation does not restrict further work + to only ibuf bitmap operations, which would result if the latch to the bitmap + page were kept. */ UNIV_INLINE void ibuf_set_free_bits_low( - /*===================*/ const buf_block_t *block, /*!< in: index page; free bits are set if the index is non-clustered and page level is 0 */ @@ -824,13 +790,11 @@ void ibuf_set_free_bits_low( IBUF_BITMAP_FREE, val, mtr); } -/************************************************************************/ /** - Sets the free bit of the page in the ibuf bitmap. This is done in a separate +/** Sets the free bit of the page in the ibuf bitmap. This is done in a separate mini-transaction, hence this operation does not restrict further work to only ibuf bitmap operations, which would result if the latch to the bitmap page were kept. */ void ibuf_set_free_bits_func( - /*====================*/ buf_block_t *block, /*!< in: index page of a non-clustered index; free bit is reset if page level is 0 */ #ifdef UNIV_IBUF_DEBUG @@ -900,8 +864,7 @@ void ibuf_set_free_bits_func( mtr_commit(&mtr); } -/************************************************************************/ /** - Resets the free bits of the page in the ibuf bitmap. This is done in a +/** Resets the free bits of the page in the ibuf bitmap. This is done in a separate mini-transaction, hence this operation does not restrict further work to only ibuf bitmap operations, which would result if the latch to the bitmap page were kept. NOTE: The free bits in the insert @@ -910,7 +873,6 @@ void ibuf_set_free_bits_func( that is committed before the mini-transaction that affects the free space. */ void ibuf_reset_free_bits( - /*=================*/ buf_block_t *block) /*!< in: index page; free bits are set to 0 if the index is a non-clustered non-unique, and page level is 0 */ @@ -918,23 +880,20 @@ void ibuf_reset_free_bits( ibuf_set_free_bits(block, 0, ULINT_UNDEFINED); } -/**********************************************************************/ /** - Updates the free bits for an uncompressed page to reflect the present +/** Updates the free bits for an uncompressed page to reflect the present state. Does this in the mtr given, which means that the latching order rules virtually prevent any further operations for this OS thread until mtr is committed. NOTE: The free bits in the insert buffer bitmap must never exceed the free space on a page. It is safe to set the free bits in the same mini-transaction that updated the page. */ -void ibuf_update_free_bits_low( - /*======================*/ - const buf_block_t *block, /*!< in: index page */ - ulint max_ins_size, /*!< in: value of - maximum insert size - with reorganize before - the latest operation - performed to the page */ - mtr_t *mtr) /*!< in/out: mtr */ +void ibuf_update_free_bits_low(const buf_block_t *block, /*!< in: index page */ + ulint max_ins_size, /*!< in: value of + maximum insert size + with reorganize before + the latest operation + performed to the page */ + mtr_t *mtr) /*!< in/out: mtr */ { ulint before; ulint after; @@ -955,18 +914,15 @@ void ibuf_update_free_bits_low( } } -/**********************************************************************/ /** - Updates the free bits for a compressed page to reflect the present +/** Updates the free bits for a compressed page to reflect the present state. Does this in the mtr given, which means that the latching order rules virtually prevent any further operations for this OS thread until mtr is committed. NOTE: The free bits in the insert buffer bitmap must never exceed the free space on a page. It is safe to set the free bits in the same mini-transaction that updated the page. */ -void ibuf_update_free_bits_zip( - /*======================*/ - buf_block_t *block, /*!< in/out: index page */ - mtr_t *mtr) /*!< in/out: mtr */ +void ibuf_update_free_bits_zip(buf_block_t *block, /*!< in/out: index page */ + mtr_t *mtr) /*!< in/out: mtr */ { page_t *bitmap_page; ulint after; @@ -991,15 +947,13 @@ void ibuf_update_free_bits_zip( IBUF_BITMAP_FREE, after, mtr); } -/**********************************************************************/ /** - Updates the free bits for the two pages to reflect the present state. +/** Updates the free bits for the two pages to reflect the present state. Does this in the mtr given, which means that the latching order rules virtually prevent any further operations until mtr is committed. NOTE: The free bits in the insert buffer bitmap must never exceed the free space on a page. It is safe to set the free bits in the same mini-transaction that updated the pages. */ void ibuf_update_free_bits_for_two_pages_low( - /*====================================*/ buf_block_t *block1, /*!< in: index page */ buf_block_t *block2, /*!< in: index page */ mtr_t *mtr) /*!< in: mtr */ @@ -1121,11 +1075,9 @@ ibool ibuf_page_low(const page_id_t &page_id, const page_size_t &page_size, #define ibuf_rec_get_page_no(mtr, rec) ibuf_rec_get_page_no_func(rec) #endif /* UNIV_DEBUG */ -/********************************************************************/ /** - Returns the page number field of an ibuf record. +/** Returns the page number field of an ibuf record. @return page number */ static page_no_t ibuf_rec_get_page_no_func( -/*======================*/ #ifdef UNIV_DEBUG mtr_t *mtr, /*!< in: mini-transaction owning rec */ #endif /* UNIV_DEBUG */ @@ -1156,12 +1108,10 @@ static page_no_t ibuf_rec_get_page_no_func( #define ibuf_rec_get_space(mtr, rec) ibuf_rec_get_space_func(rec) #endif /* UNIV_DEBUG */ -/********************************************************************/ /** - Returns the space id field of an ibuf record. For < 4.1.x format records +/** Returns the space id field of an ibuf record. For < 4.1.x format records returns 0. @return space id */ static space_id_t ibuf_rec_get_space_func( -/*====================*/ #ifdef UNIV_DEBUG mtr_t *mtr, /*!< in: mini-transaction owning rec */ #endif /* UNIV_DEBUG */ @@ -1193,10 +1143,8 @@ static space_id_t ibuf_rec_get_space_func( #define ibuf_rec_get_info(mtr, rec, op, comp, info_len, counter) \ ibuf_rec_get_info_func(rec, op, comp, info_len, counter) #endif -/****************************************************************/ /** - Get various information about an ibuf record in >= 4.1.x format. */ +/** Get various information about an ibuf record in >= 4.1.x format. */ static void ibuf_rec_get_info_func( -/*===================*/ #ifdef UNIV_DEBUG mtr_t *mtr, /*!< in: mini-transaction owning rec */ #endif /* UNIV_DEBUG */ @@ -1274,11 +1222,9 @@ static void ibuf_rec_get_info_func( #define ibuf_rec_get_op_type(mtr, rec) ibuf_rec_get_op_type_func(rec) #endif -/****************************************************************/ /** - Returns the operation type field of an ibuf record. +/** Returns the operation type field of an ibuf record. @return operation type */ static ibuf_op_t ibuf_rec_get_op_type_func( -/*======================*/ #ifdef UNIV_DEBUG mtr_t *mtr, /*!< in: mini-transaction owning rec */ #endif /* UNIV_DEBUG */ @@ -1306,14 +1252,11 @@ static ibuf_op_t ibuf_rec_get_op_type_func( } } -/****************************************************************/ /** - Read the first two bytes from a record's fourth field (counter field in new +/** Read the first two bytes from a record's fourth field (counter field in new records; something else in older records). @return "counter" field, or ULINT_UNDEFINED if for some reason it can't be read */ -ulint ibuf_rec_get_counter( - /*=================*/ - const rec_t *rec) /*!< in: ibuf record */ +ulint ibuf_rec_get_counter(const rec_t *rec) /*!< in: ibuf record */ { const byte *ptr; ulint len; @@ -1331,13 +1274,10 @@ ulint ibuf_rec_get_counter( } } -/****************************************************************/ /** - Add accumulated operation counts to a permanent array. Both arrays must be +/** Add accumulated operation counts to a permanent array. Both arrays must be of size IBUF_OP_COUNT. */ -static void ibuf_add_ops( - /*=========*/ - ulint *arr, /*!< in/out: array to modify */ - const ulint *ops) /*!< in: operation counts */ +static void ibuf_add_ops(ulint *arr, /*!< in/out: array to modify */ + const ulint *ops) /*!< in: operation counts */ { ulint i; @@ -1347,12 +1287,9 @@ static void ibuf_add_ops( } } -/****************************************************************/ /** - Print operation counts. The array must be of size IBUF_OP_COUNT. */ -static void ibuf_print_ops( - /*===========*/ - const ulint *ops, /*!< in: operation counts */ - FILE *file) /*!< in: file where to print */ +/** Print operation counts. The array must be of size IBUF_OP_COUNT. */ +static void ibuf_print_ops(const ulint *ops, /*!< in: operation counts */ + FILE *file) /*!< in: file where to print */ { static const char *op_names[] = {"insert", "delete mark", "delete"}; ulint i; @@ -1367,11 +1304,9 @@ static void ibuf_print_ops( putc('\n', file); } -/********************************************************************/ /** - Creates a dummy index for inserting a record to a non-clustered index. +/** Creates a dummy index for inserting a record to a non-clustered index. @return dummy index */ static dict_index_t *ibuf_dummy_index_create( - /*====================*/ ulint n, /*!< in: number of fields */ ibool comp) /*!< in: TRUE=use compact record format */ { @@ -1391,10 +1326,8 @@ static dict_index_t *ibuf_dummy_index_create( return (index); } -/********************************************************************/ /** - Add a column to the dummy index */ +/** Add a column to the dummy index */ static void ibuf_dummy_index_add_col( - /*=====================*/ dict_index_t *index, /*!< in: dummy index */ const dtype_t *type, /*!< in: the data type of the column */ ulint len) /*!< in: length of the column */ @@ -1404,10 +1337,9 @@ static void ibuf_dummy_index_add_col( dtype_get_prtype(type), dtype_get_len(type)); dict_index_add_col(index, index->table, index->table->get_col(i), len, true); } -/********************************************************************/ /** - Deallocates a dummy index for inserting a record to a non-clustered index. */ +/** Deallocates a dummy index for inserting a record to a non-clustered index. + */ static void ibuf_dummy_index_free( - /*==================*/ dict_index_t *index) /*!< in, own: dummy index */ { dict_table_t *table = index->table; @@ -1424,8 +1356,7 @@ static void ibuf_dummy_index_free( ibuf_build_entry_from_ibuf_rec_func(ibuf_rec, heap, pindex) #endif -/*********************************************************************/ /** - Builds the entry used to +/** Builds the entry used to 1) IBUF_OP_INSERT: insert into a non-clustered index @@ -1441,7 +1372,6 @@ static void ibuf_dummy_index_free( @return own: entry to insert to a non-clustered index */ static dtuple_t *ibuf_build_entry_from_ibuf_rec_func( -/*================================*/ #ifdef UNIV_DEBUG mtr_t *mtr, /*!< in: mini-transaction owning rec */ #endif /* UNIV_DEBUG */ @@ -1511,17 +1441,14 @@ static dtuple_t *ibuf_build_entry_from_ibuf_rec_func( return (tuple); } -/******************************************************************/ /** - Get the data size. +/** Get the data size. @return size of fields */ UNIV_INLINE -ulint ibuf_rec_get_size( - /*==============*/ - const rec_t *rec, /*!< in: ibuf record */ - const byte *types, /*!< in: fields */ - ulint n_fields, /*!< in: number of fields */ - ulint comp) /*!< in: 0=ROW_FORMAT=REDUNDANT, - nonzero=ROW_FORMAT=COMPACT */ +ulint ibuf_rec_get_size(const rec_t *rec, /*!< in: ibuf record */ + const byte *types, /*!< in: fields */ + ulint n_fields, /*!< in: number of fields */ + ulint comp) /*!< in: 0=ROW_FORMAT=REDUNDANT, + nonzero=ROW_FORMAT=COMPACT */ { ulint i; ulint field_offset; @@ -1557,13 +1484,11 @@ ulint ibuf_rec_get_size( #define ibuf_rec_get_volume(mtr, rec) ibuf_rec_get_volume_func(rec) #endif -/********************************************************************/ /** - Returns the space taken by a stored non-clustered index entry if converted to - an index record. +/** Returns the space taken by a stored non-clustered index entry if converted + to an index record. @return size of index record in bytes + an upper limit of the space taken in the page directory */ static ulint ibuf_rec_get_volume_func( -/*=====================*/ #ifdef UNIV_DEBUG mtr_t *mtr, /*!< in: mini-transaction owning rec */ #endif /* UNIV_DEBUG */ @@ -1624,8 +1549,7 @@ static ulint ibuf_rec_get_volume_func( page_dir_calc_reserved_space(1)); } -/*********************************************************************/ /** - Builds the tuple to insert to an ibuf tree when we have an entry for a +/** Builds the tuple to insert to an ibuf tree when we have an entry for a non-clustered index. NOTE that the original entry must be kept because we copy pointers to @@ -1633,7 +1557,6 @@ static ulint ibuf_rec_get_volume_func( @return own: entry to insert into an ibuf index tree */ static dtuple_t *ibuf_entry_build( - /*=============*/ ibuf_op_t op, /*!< in: operation type */ dict_index_t *index, /*!< in: non-clustered index */ const dtuple_t *entry, /*!< in: entry for a non-clustered index */ @@ -1784,12 +1707,10 @@ static dtuple_t *ibuf_entry_build( return (tuple); } -/*********************************************************************/ /** - Builds a search tuple used to search buffered inserts for an index page. +/** Builds a search tuple used to search buffered inserts for an index page. This is for >= 4.1.x format records. @return own: search tuple */ static dtuple_t *ibuf_search_tuple_build( - /*====================*/ space_id_t space, /*!< in: space id */ page_no_t page_no, /*!< in: index page number */ mem_heap_t *heap) /*!< in: heap into which to build */ @@ -1835,14 +1756,11 @@ static dtuple_t *ibuf_search_tuple_build( return (tuple); } -/*********************************************************************/ /** - Checks if there are enough pages in the free list of the ibuf tree that we +/** Checks if there are enough pages in the free list of the ibuf tree that we dare to start a pessimistic insert to the insert buffer. @return true if enough free pages in list */ UNIV_INLINE -ibool ibuf_data_enough_free_for_insert(void) -/*==================================*/ -{ +ibool ibuf_data_enough_free_for_insert(void) { ut_ad(mutex_own(&ibuf_mutex)); /* We want a big margin of free pages, because a B-tree can sometimes @@ -1854,26 +1772,20 @@ ibool ibuf_data_enough_free_for_insert(void) return (ibuf->free_list_len >= (ibuf->size / 2) + 3 * ibuf->height); } -/*********************************************************************/ /** - Checks if there are enough pages in the free list of the ibuf tree that we +/** Checks if there are enough pages in the free list of the ibuf tree that we should remove them and free to the file space management. @return true if enough free pages in list */ UNIV_INLINE -ibool ibuf_data_too_much_free(void) -/*=========================*/ -{ +ibool ibuf_data_too_much_free(void) { ut_ad(mutex_own(&ibuf_mutex)); return (ibuf->free_list_len >= 3 + (ibuf->size / 2) + 3 * ibuf->height); } -/*********************************************************************/ /** - Allocates a new page from the ibuf file segment and adds it to the free +/** Allocates a new page from the ibuf file segment and adds it to the free list. @return true on success, false if no space left */ -static ibool ibuf_add_free_page(void) -/*====================*/ -{ +static ibool ibuf_add_free_page(void) { mtr_t mtr; page_t *header_page; buf_block_t *block; @@ -1946,11 +1858,8 @@ static ibool ibuf_add_free_page(void) return (TRUE); } -/*********************************************************************/ /** - Removes a page from the free list and frees it to the fsp system. */ -static void ibuf_remove_free_page(void) -/*=======================*/ -{ +/** Removes a page from the free list and frees it to the fsp system. */ +static void ibuf_remove_free_page(void) { mtr_t mtr; mtr_t mtr2; page_t *header_page; @@ -2058,13 +1967,10 @@ static void ibuf_remove_free_page(void) ibuf_mtr_commit(&mtr); } -/***********************************************************************/ /** - Frees excess pages from the ibuf free list. This function is called when an OS - thread calls fsp services to allocate a new file segment, or a new page to a +/** Frees excess pages from the ibuf free list. This function is called when an + OS thread calls fsp services to allocate a new file segment, or a new page to a file segment, and the thread did not own the fsp latch before this call. */ -void ibuf_free_excess_pages(void) -/*========================*/ -{ +void ibuf_free_excess_pages(void) { ut_ad(rw_lock_own(fil_space_get_latch(IBUF_SPACE_ID), RW_LOCK_X)); ut_ad(rw_lock_get_x_lock_count(fil_space_get_latch(IBUF_SPACE_ID)) == 1); @@ -2106,12 +2012,10 @@ void ibuf_free_excess_pages(void) ibuf_get_merge_page_nos_func(contract, rec, ids, pages, n_stored) #endif /* UNIV_DEBUG */ -/*********************************************************************/ /** - Reads page numbers from a leaf in an ibuf tree. +/** Reads page numbers from a leaf in an ibuf tree. @return a lower limit for the combined volume of records which will be merged */ static ulint ibuf_get_merge_page_nos_func( - /*=========================*/ ibool contract, /*!< in: TRUE if this function is called to contract the tree, FALSE if this is called when a single page becomes full and we look @@ -2279,11 +2183,9 @@ static ulint ibuf_get_merge_page_nos_func( return (sum_volumes); } -/*******************************************************************/ /** - Get the matching records for space id. +/** Get the matching records for space id. @return current rec or NULL */ static MY_ATTRIBUTE((warn_unused_result)) const rec_t *ibuf_get_user_rec( - /*===============*/ btr_pcur_t *pcur, /*!< in: the current cursor */ mtr_t *mtr) /*!< in: mini transaction */ { @@ -2298,19 +2200,17 @@ static MY_ATTRIBUTE((warn_unused_result)) const rec_t *ibuf_get_user_rec( return (NULL); } -/*********************************************************************/ /** - Reads page numbers for a space id from an ibuf tree. +/** Reads page numbers for a space id from an ibuf tree. @return a lower limit for the combined volume of records which will be merged */ -static MY_ATTRIBUTE((warn_unused_result)) ulint ibuf_get_merge_pages( - /*=================*/ - btr_pcur_t *pcur, /*!< in/out: cursor */ - space_id_t space, /*!< in: space for which to merge */ - ulint limit, /*!< in: max page numbers to read */ - page_no_t *pages, /*!< out: pages read */ - space_id_t *spaces, /*!< out: spaces read */ - ulint *n_pages, /*!< out: number of pages read */ - mtr_t *mtr) /*!< in: mini transaction */ +static MY_ATTRIBUTE((warn_unused_result)) ulint + ibuf_get_merge_pages(btr_pcur_t *pcur, /*!< in/out: cursor */ + space_id_t space, /*!< in: space for which to merge */ + ulint limit, /*!< in: max page numbers to read */ + page_no_t *pages, /*!< out: pages read */ + space_id_t *spaces, /*!< out: spaces read */ + ulint *n_pages, /*!< out: number of pages read */ + mtr_t *mtr) /*!< in: mini transaction */ { const rec_t *rec; ulint volume = 0; @@ -2337,13 +2237,11 @@ static MY_ATTRIBUTE((warn_unused_result)) ulint ibuf_get_merge_pages( return (volume); } -/*********************************************************************/ /** - Contracts insert buffer trees by reading pages to the buffer pool. +/** Contracts insert buffer trees by reading pages to the buffer pool. @return a lower limit for the combined size in bytes of entries which will be merged from ibuf trees to the pages read, 0 if ibuf is empty */ static ulint ibuf_merge_pages( - /*=============*/ ulint *n_pages, /*!< out: number of pages to which merged */ bool sync) /*!< in: true if the caller wants to wait for the issued read with the highest tablespace @@ -2399,13 +2297,10 @@ static ulint ibuf_merge_pages( return (sum_sizes + 1); } -/*********************************************************************/ /** - Contracts insert buffer trees by reading pages referring to space_id +/** Contracts insert buffer trees by reading pages referring to space_id to the buffer pool. @returns number of pages merged.*/ -ulint ibuf_merge_space( - /*=============*/ - space_id_t space) /*!< in: tablespace id to merge */ +ulint ibuf_merge_space(space_id_t space) /*!< in: tablespace id to merge */ { mtr_t mtr; btr_pcur_t pcur; @@ -2556,11 +2451,9 @@ ulint ibuf_merge_in_background(bool full) { return (sum_bytes); } -/*********************************************************************/ /** - Contract insert buffer trees after insert if they are too big. */ +/** Contract insert buffer trees after insert if they are too big. */ UNIV_INLINE void ibuf_contract_after_insert( - /*=======================*/ ulint entry_size) /*!< in: size of a record which was inserted into an ibuf tree */ { @@ -2595,11 +2488,9 @@ void ibuf_contract_after_insert( } while (size > 0 && sum_sizes < entry_size); } -/*********************************************************************/ /** - Determine if an insert buffer record has been encountered already. +/** Determine if an insert buffer record has been encountered already. @return true if a new record, false if possible duplicate */ static ibool ibuf_get_volume_buffered_hash( - /*==========================*/ const rec_t *rec, /*!< in: ibuf record in post-4.1 format */ const byte *types, /*!< in: fields */ const byte *data, /*!< in: start of user record data */ @@ -2637,13 +2528,11 @@ static ibool ibuf_get_volume_buffered_hash( ibuf_get_volume_buffered_count_func(rec, hash, size, n_recs) #endif /* UNIV_DEBUG */ -/*********************************************************************/ /** - Update the estimate of the number of records on a page, and +/** Update the estimate of the number of records on a page, and get the space taken by merging the buffered record to the index page. @return size of index record in bytes + an upper limit of the space taken in the page directory */ static ulint ibuf_get_volume_buffered_count_func( -/*================================*/ #ifdef UNIV_DEBUG mtr_t *mtr, /*!< in: mini-transaction owning rec */ #endif /* UNIV_DEBUG */ @@ -2761,14 +2650,12 @@ get_volume_comp : { } } -/*********************************************************************/ /** - Gets an upper limit for the combined size of entries buffered in the insert +/** Gets an upper limit for the combined size of entries buffered in the insert buffer for a given page. @return upper limit for the volume of buffered inserts for the index page, in bytes; UNIV_PAGE_SIZE, if the entries for the index page span several pages in the insert buffer */ static ulint ibuf_get_volume_buffered( - /*=====================*/ const btr_pcur_t *pcur, /*!< in: pcur positioned at a place in an insert buffer tree where we would insert an entry for the index page whose number is @@ -2933,12 +2820,9 @@ static ulint ibuf_get_volume_buffered( } } -/*********************************************************************/ /** - Reads the biggest tablespace id from the high end of the insert buffer +/** Reads the biggest tablespace id from the high end of the insert buffer tree and updates the counter in fil_system. */ -void ibuf_update_max_tablespace_id(void) -/*===============================*/ -{ +void ibuf_update_max_tablespace_id(void) { space_id_t max_space_id; const rec_t *rec; const byte *field; @@ -2985,15 +2869,13 @@ void ibuf_update_max_tablespace_id(void) #define ibuf_get_entry_counter_low(mtr, rec, space, page_no) \ ibuf_get_entry_counter_low_func(rec, space, page_no) #endif -/****************************************************************/ /** - Helper function for ibuf_get_entry_counter_func. Checks if rec is for +/** Helper function for ibuf_get_entry_counter_func. Checks if rec is for (space, page_no), and if so, reads counter value from it and returns that + 1. @retval ULINT_UNDEFINED if the record does not contain any counter @retval 0 if the record is not for (space, page_no) @retval 1 + previous counter value, otherwise */ static ulint ibuf_get_entry_counter_low_func( -/*============================*/ #ifdef UNIV_DEBUG mtr_t *mtr, /*!< in: mini-transaction of rec */ #endif /* UNIV_DEBUG */ @@ -3056,13 +2938,11 @@ static ulint ibuf_get_entry_counter_low_func( ibuf_get_entry_counter_func(space, page_no, rec, exact_leaf) #endif /* UNIV_DEBUG */ -/****************************************************************/ /** - Calculate the counter field for an entry based on the current +/** Calculate the counter field for an entry based on the current last record in ibuf for (space, page_no). @return the counter field, or ULINT_UNDEFINED if we should abort this insertion to ibuf */ static ulint ibuf_get_entry_counter_func( - /*========================*/ space_id_t space, /*!< in: space id of entry */ page_no_t page_no, /*!< in: page number of entry */ const rec_t *rec, /*!< in: the record preceding the @@ -3550,12 +3430,10 @@ ibool ibuf_insert(ibuf_op_t op, const dtuple_t *entry, dict_index_t *index, } } -/********************************************************************/ /** - During merge, inserts to an index page a secondary index entry extracted +/** During merge, inserts to an index page a secondary index entry extracted from the insert buffer. @return newly inserted record */ static rec_t *ibuf_insert_to_index_page_low( - /*==========================*/ const dtuple_t *entry, /*!< in: buffered entry to insert */ buf_block_t *block, /*!< in/out: index page where the buffered entry should be placed */ @@ -3625,7 +3503,6 @@ static rec_t *ibuf_insert_to_index_page_low( During merge, inserts to an index page a secondary index entry extracted from the insert buffer. */ static void ibuf_insert_to_index_page( - /*======================*/ const dtuple_t *entry, /*!< in: buffered entry to insert */ buf_block_t *block, /*!< in/out: index page where the buffered entry should be placed */ @@ -3790,11 +3667,9 @@ static void ibuf_insert_to_index_page( DBUG_VOID_RETURN; } -/****************************************************************/ /** - During merge, sets the delete mark on a record for a secondary index +/** During merge, sets the delete mark on a record for a secondary index entry. */ static void ibuf_set_del_mark( - /*==============*/ const dtuple_t *entry, /*!< in: entry */ buf_block_t *block, /*!< in/out: block */ const dict_index_t *index, /*!< in: record descriptor */ @@ -3846,15 +3721,12 @@ static void ibuf_set_del_mark( } } -/****************************************************************/ /** - During merge, delete a record for a secondary index entry. */ -static void ibuf_delete( - /*========*/ - const dtuple_t *entry, /*!< in: entry */ - buf_block_t *block, /*!< in/out: block */ - dict_index_t *index, /*!< in: record descriptor */ - mtr_t *mtr) /*!< in/out: mtr; must be committed - before latching any further pages */ +/** During merge, delete a record for a secondary index entry. */ +static void ibuf_delete(const dtuple_t *entry, /*!< in: entry */ + buf_block_t *block, /*!< in/out: block */ + dict_index_t *index, /*!< in: record descriptor */ + mtr_t *mtr) /*!< in/out: mtr; must be committed + before latching any further pages */ { page_cur_t page_cur; ulint low_match; @@ -3934,11 +3806,9 @@ static void ibuf_delete( } } -/*********************************************************************/ /** - Restores insert buffer tree cursor position +/** Restores insert buffer tree cursor position @return true if the position was restored; false if not */ static ibool ibuf_restore_pos( - /*=============*/ space_id_t space, /*!< in: space id */ page_no_t page_no, /*!< in: index page number where the record should belong */ @@ -3980,13 +3850,11 @@ static ibool ibuf_restore_pos( return (FALSE); } -/*********************************************************************/ /** - Deletes from ibuf the record on which pcur is positioned. If we have to +/** Deletes from ibuf the record on which pcur is positioned. If we have to resort to a pessimistic delete, this function commits mtr and closes the cursor. @return true if mtr was committed and pcur closed in this operation */ static MY_ATTRIBUTE((warn_unused_result)) ibool ibuf_delete_rec( - /*============*/ space_id_t space, /*!< in: space id */ page_no_t page_no, /*!< in: index page number that the record should belong to */ @@ -4431,14 +4299,11 @@ void ibuf_merge_or_delete_for_page(buf_block_t *block, const page_id_t &page_id, #endif } -/*********************************************************************/ /** - Deletes all entries in the insert buffer for a given space id. This is used +/** Deletes all entries in the insert buffer for a given space id. This is used in DISCARD TABLESPACE and IMPORT TABLESPACE. NOTE: this does not update the page free bitmaps in the space. The space will become CORRUPT when you call this function! */ -void ibuf_delete_for_discarded_space( - /*============================*/ - space_id_t space) /*!< in: space id */ +void ibuf_delete_for_discarded_space(space_id_t space) /*!< in: space id */ { mem_heap_t *heap; btr_pcur_t pcur; @@ -4512,12 +4377,9 @@ void ibuf_delete_for_discarded_space( mem_heap_free(heap); } -/******************************************************************/ /** - Looks if the insert buffer is empty. +/** Looks if the insert buffer is empty. @return true if empty */ -bool ibuf_is_empty(void) -/*===============*/ -{ +bool ibuf_is_empty(void) { bool is_empty; const page_t *root; mtr_t mtr; @@ -4535,11 +4397,8 @@ bool ibuf_is_empty(void) return (is_empty); } -/******************************************************************/ /** - Prints info of ibuf. */ -void ibuf_print( - /*=======*/ - FILE *file) /*!< in: file where to print */ +/** Prints info of ibuf. */ +void ibuf_print(FILE *file) /*!< in: file where to print */ { #ifdef UNIV_IBUF_COUNT_DEBUG space_id_t i; @@ -4578,11 +4437,9 @@ void ibuf_print( mutex_exit(&ibuf_mutex); } -/******************************************************************/ /** - Checks the insert buffer bitmaps on IMPORT TABLESPACE. +/** Checks the insert buffer bitmaps on IMPORT TABLESPACE. @return DB_SUCCESS or error code */ dberr_t ibuf_check_bitmap_on_import( - /*========================*/ const trx_t *trx, /*!< in: transaction */ space_id_t space_id) /*!< in: tablespace identifier */ { diff --git a/storage/innobase/include/api0api.h b/storage/innobase/include/api0api.h index a90f9203d2dc..936fb829f4b5 100644 --- a/storage/innobase/include/api0api.h +++ b/storage/innobase/include/api0api.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2012, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2012, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/api0api.h +/** @file include/api0api.h InnoDB Native API 2008-08-01 Created by Sunny Bains. @@ -424,8 +423,7 @@ typedef struct trx_t *ib_trx_t; /** InnoDB cursor handle */ typedef struct ib_cursor_t *ib_crsr_t; -/*************************************************************/ /** - This function is used to compare two data fields for which the data type +/** This function is used to compare two data fields for which the data type is such that we must use the client code to compare them. @param col_meta column meta data @@ -443,8 +441,7 @@ typedef int (*ib_client_cmp_t)(const ib_col_meta_t *col_meta, /** Represents SQL_NULL length */ #define IB_SQL_NULL 0xFFFFFFFF -/*****************************************************************/ /** - Start a transaction that's been rolled back. This special function +/** Start a transaction that's been rolled back. This special function exists for the case when InnoDB's deadlock detector has rolledack a transaction. While the transaction has been rolled back the handle is still valid and can be reused by calling this function. If you @@ -452,7 +449,6 @@ typedef int (*ib_client_cmp_t)(const ib_col_meta_t *col_meta, by calling ib_trx_release(). @return innobase txn handle */ ib_err_t ib_trx_start( - /*=========*/ ib_trx_t ib_trx, /*!< in: transaction to restart */ ib_trx_level_t ib_trx_level, /*!< in: trx isolation level */ ib_bool_t read_write, /*!< in: true if read write @@ -471,117 +467,80 @@ put the transaction in the active state. ib_trx_t ib_trx_begin(ib_trx_level_t ib_trx_level, ib_bool_t read_write, ib_bool_t auto_commit, void *thd); -/*****************************************************************/ /** - Check if the transaction is read_only */ -ib_u32_t ib_trx_read_only( - /*=============*/ - ib_trx_t ib_trx); /*!< in: trx handle */ +/** Check if the transaction is read_only */ +ib_u32_t ib_trx_read_only(ib_trx_t ib_trx); /*!< in: trx handle */ -/*****************************************************************/ /** - Release the resources of the transaction. If the transaction was +/** Release the resources of the transaction. If the transaction was selected as a victim by InnoDB and rolled back then use this function to free the transaction handle. @return DB_SUCCESS or err code */ -ib_err_t ib_trx_release( - /*===========*/ - ib_trx_t ib_trx); /*!< in: trx handle */ +ib_err_t ib_trx_release(ib_trx_t ib_trx); /*!< in: trx handle */ -/*****************************************************************/ /** - Commit a transaction. This function will release the schema latches too. +/** Commit a transaction. This function will release the schema latches too. It will also free the transaction handle. @return DB_SUCCESS or err code */ -ib_err_t ib_trx_commit( - /*==========*/ - ib_trx_t ib_trx); /*!< in: trx handle */ +ib_err_t ib_trx_commit(ib_trx_t ib_trx); /*!< in: trx handle */ -/*****************************************************************/ /** - Rollback a transaction. This function will release the schema latches too. +/** Rollback a transaction. This function will release the schema latches too. It will also free the transaction handle. @return DB_SUCCESS or err code */ -ib_err_t ib_trx_rollback( - /*============*/ - ib_trx_t ib_trx); /*!< in: trx handle */ +ib_err_t ib_trx_rollback(ib_trx_t ib_trx); /*!< in: trx handle */ -/*****************************************************************/ /** - Open an InnoDB secondary index cursor and return a cursor handle to it. +/** Open an InnoDB secondary index cursor and return a cursor handle to it. @return DB_SUCCESS or err code */ ib_err_t ib_cursor_open_index_using_name( - /*============================*/ ib_crsr_t ib_open_crsr, /*!< in: open/active cursor */ const char *index_name, /*!< in: secondary index name */ ib_crsr_t *ib_crsr, /*!< out,own: InnoDB index cursor */ int *idx_type, /*!< out: index is cluster index */ ib_id_u64_t *idx_id); /*!< out: index id */ -/*****************************************************************/ /** - Open an InnoDB table by name and return a cursor handle to it. +/** Open an InnoDB table by name and return a cursor handle to it. @return DB_SUCCESS or err code */ ib_err_t ib_cursor_open_table( - /*=================*/ const char *name, /*!< in: table name */ ib_trx_t ib_trx, /*!< in: Current transaction handle can be NULL */ ib_crsr_t *ib_crsr); /*!< out,own: InnoDB cursor */ -/*****************************************************************/ /** - Reset the cursor. +/** Reset the cursor. @return DB_SUCCESS or err code */ -ib_err_t ib_cursor_reset( - /*============*/ - ib_crsr_t ib_crsr); /*!< in/out: InnoDB cursor */ +ib_err_t ib_cursor_reset(ib_crsr_t ib_crsr); /*!< in/out: InnoDB cursor */ -/*****************************************************************/ /** - Close an InnoDB table and free the cursor. +/** Close an InnoDB table and free the cursor. @return DB_SUCCESS or err code */ -ib_err_t ib_cursor_close( - /*============*/ - ib_crsr_t ib_crsr); /*!< in/out: InnoDB cursor */ +ib_err_t ib_cursor_close(ib_crsr_t ib_crsr); /*!< in/out: InnoDB cursor */ -/*****************************************************************/ /** - update the cursor with new transactions and also reset the cursor +/** update the cursor with new transactions and also reset the cursor @return DB_SUCCESS or err code */ -ib_err_t ib_cursor_new_trx( - /*==============*/ - ib_crsr_t ib_crsr, /*!< in/out: InnoDB cursor */ - ib_trx_t ib_trx); /*!< in: transaction */ +ib_err_t ib_cursor_new_trx(ib_crsr_t ib_crsr, /*!< in/out: InnoDB cursor */ + ib_trx_t ib_trx); /*!< in: transaction */ -/*****************************************************************/ /** - Commit the transaction in a cursor +/** Commit the transaction in a cursor @return DB_SUCCESS or err code */ -ib_err_t ib_cursor_commit_trx( - /*=================*/ - ib_crsr_t ib_crsr, /*!< in/out: InnoDB cursor */ - ib_trx_t ib_trx); /*!< in: transaction */ +ib_err_t ib_cursor_commit_trx(ib_crsr_t ib_crsr, /*!< in/out: InnoDB cursor */ + ib_trx_t ib_trx); /*!< in: transaction */ -/*****************************************************************/ /** - Insert a row to a table. +/** Insert a row to a table. @return DB_SUCCESS or err code */ ib_err_t ib_cursor_insert_row( - /*=================*/ ib_crsr_t ib_crsr, /*!< in/out: InnoDB cursor instance */ const ib_tpl_t ib_tpl); /*!< in: tuple to insert */ -/*****************************************************************/ /** - Update a row in a table. +/** Update a row in a table. @return DB_SUCCESS or err code */ ib_err_t ib_cursor_update_row( - /*=================*/ ib_crsr_t ib_crsr, /*!< in: InnoDB cursor instance */ const ib_tpl_t ib_old_tpl, /*!< in: Old tuple in table */ const ib_tpl_t ib_new_tpl); /*!< in: New tuple to update */ -/*****************************************************************/ /** - Delete a row in a table. +/** Delete a row in a table. @return DB_SUCCESS or err code */ -ib_err_t ib_cursor_delete_row( - /*=================*/ - ib_crsr_t ib_crsr); /*!< in: cursor instance */ +ib_err_t ib_cursor_delete_row(ib_crsr_t ib_crsr); /*!< in: cursor instance */ -/*****************************************************************/ /** - Read current row. +/** Read current row. @return DB_SUCCESS or err code */ ib_err_t ib_cursor_read_row( - /*===============*/ ib_crsr_t ib_crsr, /*!< in: InnoDB cursor instance */ ib_tpl_t ib_tpl, /*!< out: read cols into this tuple */ ib_tpl_t cmp_tpl, /*!< in: tuple to compare and stop @@ -592,356 +551,243 @@ ib_err_t ib_cursor_read_row( ib_ulint_t *row_len, /*!< in/out: row buffer len */ ib_ulint_t *used_len); /*!< in/out: row buffer len used */ -/*****************************************************************/ /** - Move cursor to the first record in the table. +/** Move cursor to the first record in the table. @return DB_SUCCESS or err code */ -ib_err_t ib_cursor_first( - /*============*/ - ib_crsr_t ib_crsr); /*!< in: InnoDB cursor instance */ +ib_err_t ib_cursor_first(ib_crsr_t ib_crsr); /*!< in: InnoDB cursor instance */ -/*****************************************************************/ /** - Move cursor to the next record in the table. +/** Move cursor to the next record in the table. @return DB_SUCCESS or err code */ -ib_err_t ib_cursor_next( - /*===========*/ - ib_crsr_t ib_crsr); /*!< in: InnoDB cursor instance */ +ib_err_t ib_cursor_next(ib_crsr_t ib_crsr); /*!< in: InnoDB cursor instance */ -/*****************************************************************/ /** - Search for key. +/** Search for key. @return DB_SUCCESS or err code */ -ib_err_t ib_cursor_moveto( - /*=============*/ - ib_crsr_t ib_crsr, /*!< in: InnoDB cursor instance */ - ib_tpl_t ib_tpl, /*!< in: Key to search for */ - ib_srch_mode_t ib_srch_mode, /*!< in: search mode */ - ib_ulint_t direction); /*!< in: search direction */ - -/*****************************************************************/ /** - Set the match mode for ib_cursor_move(). */ +ib_err_t ib_cursor_moveto(ib_crsr_t ib_crsr, /*!< in: InnoDB cursor instance */ + ib_tpl_t ib_tpl, /*!< in: Key to search for */ + ib_srch_mode_t ib_srch_mode, /*!< in: search mode */ + ib_ulint_t direction); /*!< in: search direction */ + +/** Set the match mode for ib_cursor_move(). */ void ib_cursor_set_match_mode( - /*=====================*/ ib_crsr_t ib_crsr, /*!< in: Cursor instance */ ib_match_mode_t match_mode); /*!< in: ib_cursor_moveto match mode */ -/*****************************************************************/ /** - Set a column of the tuple. Make a copy using the tuple's heap. +/** Set a column of the tuple. Make a copy using the tuple's heap. @return DB_SUCCESS or error code */ -ib_err_t ib_col_set_value( - /*=============*/ - ib_tpl_t ib_tpl, /*!< in: tuple instance */ - ib_ulint_t col_no, /*!< in: column index in tuple */ - const void *src, /*!< in: data value */ - ib_ulint_t len, /*!< in: data value len */ - ib_bool_t need_cpy); /*!< in: if need memcpy */ - -/*****************************************************************/ /** - Get the size of the data available in the column the tuple. +ib_err_t ib_col_set_value(ib_tpl_t ib_tpl, /*!< in: tuple instance */ + ib_ulint_t col_no, /*!< in: column index in tuple */ + const void *src, /*!< in: data value */ + ib_ulint_t len, /*!< in: data value len */ + ib_bool_t need_cpy); /*!< in: if need memcpy */ + +/** Get the size of the data available in the column the tuple. @return bytes avail or IB_SQL_NULL */ -ib_ulint_t ib_col_get_len( - /*===========*/ - ib_tpl_t ib_tpl, /*!< in: tuple instance */ - ib_ulint_t i); /*!< in: column index in tuple */ +ib_ulint_t ib_col_get_len(ib_tpl_t ib_tpl, /*!< in: tuple instance */ + ib_ulint_t i); /*!< in: column index in tuple */ -/*****************************************************************/ /** - Copy a column value from the tuple. +/** Copy a column value from the tuple. @return bytes copied or IB_SQL_NULL */ ib_ulint_t ib_col_copy_value( - /*==============*/ ib_tpl_t ib_tpl, /*!< in: tuple instance */ ib_ulint_t i, /*!< in: column index in tuple */ void *dst, /*!< out: copied data value */ ib_ulint_t len); /*!< in: max data value len to copy */ -/*************************************************************/ /** - Read a signed int 8 bit column from an InnoDB tuple. +/** Read a signed int 8 bit column from an InnoDB tuple. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_read_i8( - /*=============*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t i, /*!< in: column number */ - ib_i8_t *ival); /*!< out: integer value */ - -/*************************************************************/ /** - Read an unsigned int 8 bit column from an InnoDB tuple. +ib_err_t ib_tuple_read_i8(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t i, /*!< in: column number */ + ib_i8_t *ival); /*!< out: integer value */ + +/** Read an unsigned int 8 bit column from an InnoDB tuple. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_read_u8( - /*=============*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t i, /*!< in: column number */ - ib_u8_t *ival); /*!< out: integer value */ - -/*************************************************************/ /** - Read a signed int 16 bit column from an InnoDB tuple. +ib_err_t ib_tuple_read_u8(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t i, /*!< in: column number */ + ib_u8_t *ival); /*!< out: integer value */ + +/** Read a signed int 16 bit column from an InnoDB tuple. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_read_i16( - /*==============*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t i, /*!< in: column number */ - ib_i16_t *ival); /*!< out: integer value */ - -/*************************************************************/ /** - Read an unsigned int 16 bit column from an InnoDB tuple. +ib_err_t ib_tuple_read_i16(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t i, /*!< in: column number */ + ib_i16_t *ival); /*!< out: integer value */ + +/** Read an unsigned int 16 bit column from an InnoDB tuple. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_read_u16( - /*==============*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t i, /*!< in: column number */ - ib_u16_t *ival); /*!< out: integer value */ - -/*************************************************************/ /** - Read a signed int 32 bit column from an InnoDB tuple. +ib_err_t ib_tuple_read_u16(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t i, /*!< in: column number */ + ib_u16_t *ival); /*!< out: integer value */ + +/** Read a signed int 32 bit column from an InnoDB tuple. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_read_i32( - /*==============*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t i, /*!< in: column number */ - ib_i32_t *ival); /*!< out: integer value */ - -/*************************************************************/ /** - Read an unsigned int 32 bit column from an InnoDB tuple. +ib_err_t ib_tuple_read_i32(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t i, /*!< in: column number */ + ib_i32_t *ival); /*!< out: integer value */ + +/** Read an unsigned int 32 bit column from an InnoDB tuple. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_read_u32( - /*==============*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t i, /*!< in: column number */ - ib_u32_t *ival); /*!< out: integer value */ - -/*************************************************************/ /** - Read a signed int 64 bit column from an InnoDB tuple. +ib_err_t ib_tuple_read_u32(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t i, /*!< in: column number */ + ib_u32_t *ival); /*!< out: integer value */ + +/** Read a signed int 64 bit column from an InnoDB tuple. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_read_i64( - /*==============*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t i, /*!< in: column number */ - ib_i64_t *ival); /*!< out: integer value */ - -/*************************************************************/ /** - Read an unsigned int 64 bit column from an InnoDB tuple. +ib_err_t ib_tuple_read_i64(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t i, /*!< in: column number */ + ib_i64_t *ival); /*!< out: integer value */ + +/** Read an unsigned int 64 bit column from an InnoDB tuple. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_read_u64( - /*==============*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t i, /*!< in: column number */ - ib_u64_t *ival); /*!< out: integer value */ - -/*****************************************************************/ /** - Get a column value pointer from the tuple. +ib_err_t ib_tuple_read_u64(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t i, /*!< in: column number */ + ib_u64_t *ival); /*!< out: integer value */ + +/** Get a column value pointer from the tuple. @return NULL or pointer to buffer */ -const void *ib_col_get_value( - /*=============*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t i); /*!< in: column number */ +const void *ib_col_get_value(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t i); /*!< in: column number */ -/*****************************************************************/ /** - Get a column type, length and attributes from the tuple. +/** Get a column type, length and attributes from the tuple. @return len of column data */ ib_ulint_t ib_col_get_meta( - /*============*/ ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ ib_ulint_t i, /*!< in: column number */ ib_col_meta_t *ib_col_meta); /*!< out: column meta data */ -/*****************************************************************/ /** - "Clear" or reset an InnoDB tuple. We free the heap and recreate the tuple. +/** "Clear" or reset an InnoDB tuple. We free the heap and recreate the tuple. @return new tuple, or NULL */ -ib_tpl_t ib_tuple_clear( - /*============*/ - ib_tpl_t ib_tpl); /*!< in: InnoDB tuple */ +ib_tpl_t ib_tuple_clear(ib_tpl_t ib_tpl); /*!< in: InnoDB tuple */ -/*****************************************************************/ /** - Create a new cluster key search tuple and copy the contents of the +/** Create a new cluster key search tuple and copy the contents of the secondary index key tuple columns that refer to the cluster index record to the cluster key. It does a deep copy of the column data. @return DB_SUCCESS or error code */ ib_err_t ib_tuple_get_cluster_key( - /*=====================*/ ib_crsr_t ib_crsr, /*!< in: secondary index cursor */ ib_tpl_t *ib_dst_tpl, /*!< out,own: destination tuple */ const ib_tpl_t ib_src_tpl); /*!< in: source tuple */ -/*****************************************************************/ /** - Create an InnoDB tuple used for index/table search. +/** Create an InnoDB tuple used for index/table search. @return tuple for current index */ ib_tpl_t ib_sec_search_tuple_create( - /*=======================*/ ib_crsr_t ib_crsr); /*!< in: Cursor instance */ -/*****************************************************************/ /** - Create an InnoDB tuple used for index/table search. +/** Create an InnoDB tuple used for index/table search. @return tuple for current index */ ib_tpl_t ib_sec_read_tuple_create( - /*=====================*/ ib_crsr_t ib_crsr); /*!< in: Cursor instance */ -/*****************************************************************/ /** - Create an InnoDB tuple used for table key operations. +/** Create an InnoDB tuple used for table key operations. @return tuple for current table */ ib_tpl_t ib_clust_search_tuple_create( - /*=========================*/ ib_crsr_t ib_crsr); /*!< in: Cursor instance */ -/*****************************************************************/ /** - Create an InnoDB tuple for table row operations. +/** Create an InnoDB tuple for table row operations. @return tuple for current table */ ib_tpl_t ib_clust_read_tuple_create( - /*=======================*/ ib_crsr_t ib_crsr); /*!< in: Cursor instance */ -/*****************************************************************/ /** - Return the number of user columns in the tuple definition. +/** Return the number of user columns in the tuple definition. @return number of user columns */ ib_ulint_t ib_tuple_get_n_user_cols( - /*=====================*/ const ib_tpl_t ib_tpl); /*!< in: Tuple for current table */ -/*****************************************************************/ /** - Return the number of columns in the tuple definition. +/** Return the number of columns in the tuple definition. @return number of columns */ ib_ulint_t ib_tuple_get_n_cols( - /*================*/ const ib_tpl_t ib_tpl); /*!< in: Tuple for current table */ -/*****************************************************************/ /** - Destroy an InnoDB tuple. */ -void ib_tuple_delete( - /*============*/ - ib_tpl_t ib_tpl); /*!< in,own: Tuple instance to delete */ +/** Destroy an InnoDB tuple. */ +void ib_tuple_delete(ib_tpl_t ib_tpl); /*!< in,own: Tuple instance to delete */ -/*****************************************************************/ /** - Get a table id. +/** Get a table id. @return DB_SUCCESS if found */ -ib_err_t ib_table_get_id( - /*============*/ - const char *table_name, /*!< in: table to find */ - ib_id_u64_t *table_id); /*!< out: table id if found */ +ib_err_t ib_table_get_id(const char *table_name, /*!< in: table to find */ + ib_id_u64_t *table_id); /*!< out: table id if found */ -/*****************************************************************/ /** - Check if cursor is positioned. +/** Check if cursor is positioned. @return IB_true if positioned */ ib_bool_t ib_cursor_is_positioned( - /*====================*/ const ib_crsr_t ib_crsr); /*!< in: InnoDB cursor instance */ -/*****************************************************************/ /** - Checks if the data dictionary is latched in exclusive mode by a +/** Checks if the data dictionary is latched in exclusive mode by a user transaction. @return true if exclusive latch */ ib_bool_t ib_schema_lock_is_exclusive( - /*========================*/ const ib_trx_t ib_trx); /*!< in: transaction */ -/*****************************************************************/ /** - Lock an InnoDB cursor/table. +/** Lock an InnoDB cursor/table. @return DB_SUCCESS or error code */ -ib_err_t ib_cursor_lock( - /*===========*/ - ib_crsr_t ib_crsr, /*!< in/out: InnoDB cursor */ - ib_lck_mode_t ib_lck_mode); /*!< in: InnoDB lock mode */ +ib_err_t ib_cursor_lock(ib_crsr_t ib_crsr, /*!< in/out: InnoDB cursor */ + ib_lck_mode_t ib_lck_mode); /*!< in: InnoDB lock mode */ -/*****************************************************************/ /** - Set the Lock mode of the cursor. +/** Set the Lock mode of the cursor. @return DB_SUCCESS or error code */ ib_err_t ib_cursor_set_lock_mode( - /*====================*/ ib_crsr_t ib_crsr, /*!< in/out: InnoDB cursor */ ib_lck_mode_t ib_lck_mode); /*!< in: InnoDB lock mode */ -/*****************************************************************/ /** - Set need to access clustered index record flag. */ +/** Set need to access clustered index record flag. */ void ib_cursor_set_cluster_access( - /*=========================*/ ib_crsr_t ib_crsr); /*!< in/out: InnoDB cursor */ -/*****************************************************************/ /** - Inform the cursor that it's the start of an SQL statement. */ -void ib_cursor_stmt_begin( - /*=================*/ - ib_crsr_t ib_crsr); /*!< in: cursor */ +/** Inform the cursor that it's the start of an SQL statement. */ +void ib_cursor_stmt_begin(ib_crsr_t ib_crsr); /*!< in: cursor */ -/*****************************************************************/ /** - Write a double value to a column. +/** Write a double value to a column. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_write_double( - /*==================*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - int col_no, /*!< in: column number */ - double val); /*!< in: value to write */ - -/*************************************************************/ /** - Read a double column value from an InnoDB tuple. +ib_err_t ib_tuple_write_double(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + int col_no, /*!< in: column number */ + double val); /*!< in: value to write */ + +/** Read a double column value from an InnoDB tuple. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_read_double( - /*=================*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t col_no, /*!< in: column number */ - double *dval); /*!< out: double value */ - -/*****************************************************************/ /** - Write a float value to a column. +ib_err_t ib_tuple_read_double(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t col_no, /*!< in: column number */ + double *dval); /*!< out: double value */ + +/** Write a float value to a column. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_write_float( - /*=================*/ - ib_tpl_t ib_tpl, /*!< in/out: tuple to write to */ - int col_no, /*!< in: column number */ - float val); /*!< in: value to write */ - -/*************************************************************/ /** - Read a float value from an InnoDB tuple. +ib_err_t ib_tuple_write_float(ib_tpl_t ib_tpl, /*!< in/out: tuple to write to */ + int col_no, /*!< in: column number */ + float val); /*!< in: value to write */ + +/** Read a float value from an InnoDB tuple. @return DB_SUCCESS or error */ -ib_err_t ib_tuple_read_float( - /*================*/ - ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ - ib_ulint_t col_no, /*!< in: column number */ - float *fval); /*!< out: float value */ - -/*****************************************************************/ /** - Get a column type, length and attributes from the tuple. +ib_err_t ib_tuple_read_float(ib_tpl_t ib_tpl, /*!< in: InnoDB tuple */ + ib_ulint_t col_no, /*!< in: column number */ + float *fval); /*!< out: float value */ + +/** Get a column type, length and attributes from the tuple. @return len of column data */ const char *ib_col_get_name( - /*============*/ ib_crsr_t ib_crsr, /*!< in: InnoDB cursor instance */ ib_ulint_t i); /*!< in: column index in tuple */ -/*****************************************************************/ /** - Get an index field name from the cursor. +/** Get an index field name from the cursor. @return name of the field */ const char *ib_get_idx_field_name( - /*==================*/ ib_crsr_t ib_crsr, /*!< in: InnoDB cursor instance */ ib_ulint_t i); /*!< in: column index in tuple */ -/*****************************************************************/ /** - Get generic configure status +/** Get generic configure status @return configure status*/ int ib_cfg_get_cfg(); -/*============*/ -/*****************************************************************/ /** - Return isolation configuration set by "innodb_api_trx_level" +/** Return isolation configuration set by "innodb_api_trx_level" @return trx isolation level*/ ib_trx_level_t ib_cfg_trx_level(); -/*==============*/ -/*****************************************************************/ /** - Return configure value for background commit interval (in seconds) +/** Return configure value for background commit interval (in seconds) @return background commit interval (in seconds) */ ib_ulint_t ib_cfg_bk_commit_interval(); -/*=======================*/ -/*****************************************************************/ /** - Get a trx start time. +/** Get a trx start time. @return trx start_time */ -ib_u64_t ib_trx_get_start_time( - /*==================*/ - ib_trx_t ib_trx); /*!< in: transaction */ +ib_u64_t ib_trx_get_start_time(ib_trx_t ib_trx); /*!< in: transaction */ -/*****************************************************************/ /** - Wrapper of ut_strerr() which converts an InnoDB error number to a +/** Wrapper of ut_strerr() which converts an InnoDB error number to a human readable text message. @return string, describing the error */ -const char *ib_ut_strerr( - /*=========*/ - ib_err_t num); /*!< in: error number */ +const char *ib_ut_strerr(ib_err_t num); /*!< in: error number */ /** Get the SDI keys in a tablespace into vector. @param[in] tablespace_id tablespace id diff --git a/storage/innobase/include/api0misc.h b/storage/innobase/include/api0misc.h index f3e4b3175286..8982666154a8 100644 --- a/storage/innobase/include/api0misc.h +++ b/storage/innobase/include/api0misc.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2008, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2008, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/api0misc.h +/** @file include/api0misc.h InnoDB Native API 3/20/2011 Jimmy Yang extracted from Embedded InnoDB @@ -82,7 +81,6 @@ ibool ib_handle_errors(dberr_t *new_err, trx_t *trx, que_thr_t *thr, Sets a lock on a table. @return error code or DB_SUCCESS */ dberr_t ib_trx_lock_table_with_retry( - /*=========================*/ trx_t *trx, /*!< in/out: transaction */ dict_table_t *table, /*!< in: table to lock */ enum lock_mode mode); /*!< in: lock mode */ diff --git a/storage/innobase/include/arch0arch.h b/storage/innobase/include/arch0arch.h index aec9c11546ba..57f15c11559e 100644 --- a/storage/innobase/include/arch0arch.h +++ b/storage/innobase/include/arch0arch.h @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/arch0arch.h +/** @file include/arch0arch.h Common interface for redo log and dirty page archiver system *******************************************************/ diff --git a/storage/innobase/include/arch0log.h b/storage/innobase/include/arch0log.h index fad47c689b69..db46eb9a30ec 100644 --- a/storage/innobase/include/arch0log.h +++ b/storage/innobase/include/arch0log.h @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/arch0log.h +/** @file include/arch0log.h Innodb interface for log archive *******************************************************/ diff --git a/storage/innobase/include/arch0page.h b/storage/innobase/include/arch0page.h index 735e1ae5ca57..289a47536aee 100644 --- a/storage/innobase/include/arch0page.h +++ b/storage/innobase/include/arch0page.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/arch0page.h +/** @file include/arch0page.h Innodb interface for modified page archive *******************************************************/ diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h index c2129fccb91d..7786cbbd3779 100644 --- a/storage/innobase/include/btr0btr.h +++ b/storage/innobase/include/btr0btr.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -27,8 +27,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "my_compiler.h" -/**************************************************/ /** - @file include/btr0btr.h +/** @file include/btr0btr.h The B-tree Created 6/2/1994 Heikki Tuuri @@ -141,12 +140,9 @@ record is in spatial index */ ((latch_mode) & \ ~(BTR_LATCH_FOR_INSERT | BTR_LATCH_FOR_DELETE | BTR_MODIFY_EXTERNAL)) -/**************************************************************/ /** - Report that an index page is corrupted. */ -void btr_corruption_report( - /*==================*/ - const buf_block_t *block, /*!< in: corrupted block */ - const dict_index_t *index) /*!< in: index tree */ +/** Report that an index page is corrupted. */ +void btr_corruption_report(const buf_block_t *block, /*!< in: corrupted block */ + const dict_index_t *index) /*!< in: index tree */ UNIV_COLD; /** Assert that a B-tree page is not corrupted. @@ -159,31 +155,23 @@ void btr_corruption_report( ut_error; \ } -/**************************************************************/ /** - Gets the root node of a tree and sx-latches it for segment access. +/** Gets the root node of a tree and sx-latches it for segment access. @return root page, sx-latched */ -page_t *btr_root_get( - /*=========*/ - const dict_index_t *index, /*!< in: index tree */ - mtr_t *mtr); /*!< in: mtr */ +page_t *btr_root_get(const dict_index_t *index, /*!< in: index tree */ + mtr_t *mtr); /*!< in: mtr */ -/**************************************************************/ /** - Checks and adjusts the root node of a tree during IMPORT TABLESPACE. +/** Checks and adjusts the root node of a tree during IMPORT TABLESPACE. @return error code, or DB_SUCCESS */ dberr_t btr_root_adjust_on_import( - /*======================*/ const dict_index_t *index) /*!< in: index tree */ MY_ATTRIBUTE((warn_unused_result)); -/**************************************************************/ /** - Gets the height of the B-tree (the level of the root, when the leaf +/** Gets the height of the B-tree (the level of the root, when the leaf level is assumed to be 0). The caller must hold an S or X latch on the index. @return tree height (level of the root) */ -ulint btr_height_get( - /*===========*/ - dict_index_t *index, /*!< in: index tree */ - mtr_t *mtr) /*!< in/out: mini-transaction */ +ulint btr_height_get(dict_index_t *index, /*!< in: index tree */ + mtr_t *mtr) /*!< in/out: mini-transaction */ MY_ATTRIBUTE((warn_unused_result)); /** Gets a buffer page and declares its latching order level. @@ -235,40 +223,28 @@ buf_block_t *btr_block_get_func(const page_id_t &page_id, @return the uncompressed page frame */ #define btr_page_get(page_id, page_size, mode, index, mtr) \ buf_block_get_frame(btr_block_get(page_id, page_size, mode, index, mtr)) -/**************************************************************/ /** - Gets the index id field of a page. +/** Gets the index id field of a page. @return index id */ UNIV_INLINE -space_index_t btr_page_get_index_id( - /*==================*/ - const page_t *page) /*!< in: index page */ +space_index_t btr_page_get_index_id(const page_t *page) /*!< in: index page */ MY_ATTRIBUTE((warn_unused_result)); -/********************************************************/ /** - Gets the node level field in an index page. +/** Gets the node level field in an index page. @return level, leaf level == 0 */ UNIV_INLINE -ulint btr_page_get_level_low( - /*===================*/ - const page_t *page) /*!< in: index page */ +ulint btr_page_get_level_low(const page_t *page) /*!< in: index page */ MY_ATTRIBUTE((warn_unused_result)); #define btr_page_get_level(page, mtr) btr_page_get_level_low(page) -/********************************************************/ /** - Gets the next index page number. +/** Gets the next index page number. @return next page number */ UNIV_INLINE -page_no_t btr_page_get_next( - /*==============*/ - const page_t *page, /*!< in: index page */ - mtr_t *mtr) /*!< in: mini-transaction handle */ +page_no_t btr_page_get_next(const page_t *page, /*!< in: index page */ + mtr_t *mtr) /*!< in: mini-transaction handle */ MY_ATTRIBUTE((warn_unused_result)); -/********************************************************/ /** - Gets the previous index page number. +/** Gets the previous index page number. @return prev page number */ UNIV_INLINE -page_no_t btr_page_get_prev( - /*==============*/ - const page_t *page, /*!< in: index page */ - mtr_t *mtr) /*!< in: mini-transaction handle */ +page_no_t btr_page_get_prev(const page_t *page, /*!< in: index page */ + mtr_t *mtr) /*!< in: mini-transaction handle */ MY_ATTRIBUTE((warn_unused_result)); /** Releases the latch on a leaf page and bufferunfixes it. @@ -278,8 +254,7 @@ page_no_t btr_page_get_prev( UNIV_INLINE void btr_leaf_page_release(buf_block_t *block, ulint latch_mode, mtr_t *mtr); -/**************************************************************/ /** - Gets the child node file address in a node pointer. +/** Gets the child node file address in a node pointer. NOTE: the offsets array must contain all offsets for the record since we read the last field according to offsets and assume that it contains the child page number. In other words offsets must have been retrieved @@ -287,7 +262,6 @@ void btr_leaf_page_release(buf_block_t *block, ulint latch_mode, mtr_t *mtr); @return child node address */ UNIV_INLINE page_no_t btr_node_ptr_get_child_page_no( - /*===========================*/ const rec_t *rec, /*!< in: node pointer record */ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ MY_ATTRIBUTE((warn_unused_result)); @@ -329,15 +303,13 @@ crash during btr_truncate, if so, do recover it, if not, do nothing. @param[in] index clustered index */ void btr_truncate_recover(const dict_index_t *index); -/*************************************************************/ /** - Makes tree one level higher by splitting the root, and inserts +/** Makes tree one level higher by splitting the root, and inserts the tuple. It is assumed that mtr contains an x-latch on the tree. NOTE that the operation of this function must always succeed, we cannot reverse it: therefore enough free disk space must be guaranteed to be available before this function is called. @return inserted record */ rec_t *btr_root_raise_and_insert( - /*======================*/ ulint flags, /*!< in: undo logging and locking flags */ btr_cur_t *cursor, /*!< in: cursor at which to insert: must be on the root page; when the function returns, @@ -350,8 +322,7 @@ rec_t *btr_root_raise_and_insert( ulint n_ext, /*!< in: number of externally stored columns */ mtr_t *mtr) /*!< in: mtr */ MY_ATTRIBUTE((warn_unused_result)); -/*************************************************************/ /** - Reorganizes an index page. +/** Reorganizes an index page. IMPORTANT: On success, the caller will have to update IBUF_BITMAP_FREE if this is a compressed leaf page in a secondary index. This has to @@ -362,7 +333,6 @@ rec_t *btr_root_raise_and_insert( @retval true if the operation was successful @retval false if it is a compressed page, and recompression failed */ bool btr_page_reorganize_low( - /*====================*/ bool recovery, /*!< in: true if called in recovery: locks should not be updated, i.e., there cannot exist locks on the @@ -374,8 +344,7 @@ bool btr_page_reorganize_low( dict_index_t *index, /*!< in: the index tree of the page */ mtr_t *mtr) /*!< in/out: mini-transaction */ MY_ATTRIBUTE((warn_unused_result)); -/*************************************************************/ /** - Reorganizes an index page. +/** Reorganizes an index page. IMPORTANT: On success, the caller will have to update IBUF_BITMAP_FREE if this is a compressed leaf page in a secondary index. This has to @@ -386,35 +355,29 @@ bool btr_page_reorganize_low( @retval true if the operation was successful @retval false if it is a compressed page, and recompression failed */ bool btr_page_reorganize( - /*================*/ page_cur_t *cursor, /*!< in/out: page cursor */ dict_index_t *index, /*!< in: the index tree of the page */ mtr_t *mtr); /*!< in/out: mini-transaction */ -/*************************************************************/ /** - Decides if the page should be split at the convergence point of +/** Decides if the page should be split at the convergence point of inserts converging to left. @return true if split recommended */ ibool btr_page_get_split_rec_to_left( - /*===========================*/ btr_cur_t *cursor, /*!< in: cursor at which to insert */ rec_t **split_rec) /*!< out: if split recommended, the first record on upper half page, or NULL if tuple should be first */ MY_ATTRIBUTE((warn_unused_result)); -/*************************************************************/ /** - Decides if the page should be split at the convergence point of +/** Decides if the page should be split at the convergence point of inserts converging to right. @return true if split recommended */ ibool btr_page_get_split_rec_to_right( - /*============================*/ btr_cur_t *cursor, /*!< in: cursor at which to insert */ rec_t **split_rec) /*!< out: if split recommended, the first record on upper half page, or NULL if tuple should be first */ MY_ATTRIBUTE((warn_unused_result)); -/*************************************************************/ /** - Splits an index page to halves and inserts the tuple. It is assumed +/** Splits an index page to halves and inserts the tuple. It is assumed that mtr holds an x-latch to the index tree. NOTE: the tree x-latch is released within this function! NOTE that the operation of this function must always succeed, we cannot reverse it: therefore enough @@ -423,7 +386,6 @@ ibool btr_page_get_split_rec_to_right( @return inserted record */ rec_t *btr_page_split_and_insert( - /*======================*/ ulint flags, /*!< in: undo logging and locking flags */ btr_cur_t *cursor, /*!< in: cursor at which to insert; when the function returns, the cursor is positioned @@ -435,11 +397,9 @@ rec_t *btr_page_split_and_insert( ulint n_ext, /*!< in: number of externally stored columns */ mtr_t *mtr) /*!< in: mtr */ MY_ATTRIBUTE((warn_unused_result)); -/*******************************************************/ /** - Inserts a data tuple to a tree on a non-leaf level. It is assumed +/** Inserts a data tuple to a tree on a non-leaf level. It is assumed that mtr holds an x-latch on the tree. */ void btr_insert_on_non_leaf_level_func( - /*==============================*/ ulint flags, /*!< in: undo logging and locking flags */ dict_index_t *index, /*!< in: index */ ulint level, /*!< in: level, must be > 0 */ @@ -449,32 +409,23 @@ void btr_insert_on_non_leaf_level_func( mtr_t *mtr); /*!< in: mtr */ #define btr_insert_on_non_leaf_level(f, i, l, t, m) \ btr_insert_on_non_leaf_level_func(f, i, l, t, __FILE__, __LINE__, m) -/****************************************************************/ /** - Sets a record as the predefined minimum record. */ -void btr_set_min_rec_mark( - /*=================*/ - rec_t *rec, /*!< in/out: record */ - mtr_t *mtr); /*!< in: mtr */ -/*************************************************************/ /** - Deletes on the upper level the node pointer to a page. */ +/** Sets a record as the predefined minimum record. */ +void btr_set_min_rec_mark(rec_t *rec, /*!< in/out: record */ + mtr_t *mtr); /*!< in: mtr */ +/** Deletes on the upper level the node pointer to a page. */ void btr_node_ptr_delete( - /*================*/ dict_index_t *index, /*!< in: index tree */ buf_block_t *block, /*!< in: page whose node pointer is deleted */ mtr_t *mtr); /*!< in: mtr */ #ifdef UNIV_DEBUG -/************************************************************/ /** - Checks that the node pointer to a page is appropriate. +/** Checks that the node pointer to a page is appropriate. @return true */ -ibool btr_check_node_ptr( - /*===============*/ - dict_index_t *index, /*!< in: index tree */ - buf_block_t *block, /*!< in: index page */ - mtr_t *mtr) /*!< in: mtr */ +ibool btr_check_node_ptr(dict_index_t *index, /*!< in: index tree */ + buf_block_t *block, /*!< in: index page */ + mtr_t *mtr) /*!< in: mtr */ MY_ATTRIBUTE((warn_unused_result)); -#endif /* UNIV_DEBUG */ -/*************************************************************/ /** - Tries to merge the page first to the left immediate brother if such a +#endif /* UNIV_DEBUG */ +/** Tries to merge the page first to the left immediate brother if such a brother exists, and the node pointers to the current page and to the brother reside on the same page. If the left brother does not satisfy these conditions, looks at the right brother. If the page is the only one on that @@ -484,7 +435,6 @@ ibool btr_check_node_ptr( the brothers, if they exist. @return true on success */ ibool btr_compress( - /*=========*/ btr_cur_t *cursor, /*!< in/out: cursor on the page to merge or lift; the page must not be empty: when deleting records, use btr_discard_page() @@ -492,32 +442,26 @@ ibool btr_compress( ibool adjust, /*!< in: TRUE if should adjust the cursor position even if compression occurs */ mtr_t *mtr); /*!< in/out: mini-transaction */ -/*************************************************************/ /** - Discards a page from a B-tree. This is used to remove the last record from +/** Discards a page from a B-tree. This is used to remove the last record from a B-tree page: the whole page must be removed at the same time. This cannot be used for the root page, which is allowed to be empty. */ void btr_discard_page( - /*=============*/ btr_cur_t *cursor, /*!< in: cursor on the page to discard: not on the root page */ mtr_t *mtr); /*!< in: mtr */ -/****************************************************************/ /** - Parses the redo log record for setting an index record as the predefined +/** Parses the redo log record for setting an index record as the predefined minimum record. @return end of log record or NULL */ byte *btr_parse_set_min_rec_mark( - /*=======================*/ byte *ptr, /*!< in: buffer */ byte *end_ptr, /*!< in: buffer end */ ulint comp, /*!< in: nonzero=compact page format */ page_t *page, /*!< in: page or NULL */ mtr_t *mtr) /*!< in: mtr or NULL */ MY_ATTRIBUTE((warn_unused_result)); -/***********************************************************/ /** - Parses a redo log record of reorganizing a page. +/** Parses a redo log record of reorganizing a page. @return end of log record or NULL */ byte *btr_parse_page_reorganize( - /*======================*/ byte *ptr, /*!< in: buffer */ byte *end_ptr, /*!< in: buffer end */ dict_index_t *index, /*!< in: record descriptor */ @@ -525,25 +469,20 @@ byte *btr_parse_page_reorganize( buf_block_t *block, /*!< in: page to be reorganized, or NULL */ mtr_t *mtr) /*!< in: mtr or NULL */ MY_ATTRIBUTE((warn_unused_result)); -/**************************************************************/ /** - Gets the number of pages in a B-tree. +/** Gets the number of pages in a B-tree. @return number of pages, or ULINT_UNDEFINED if the index is unavailable */ -ulint btr_get_size( - /*=========*/ - dict_index_t *index, /*!< in: index */ - ulint flag, /*!< in: BTR_N_LEAF_PAGES or BTR_TOTAL_SIZE */ - mtr_t *mtr) /*!< in/out: mini-transaction where index - is s-latched */ +ulint btr_get_size(dict_index_t *index, /*!< in: index */ + ulint flag, /*!< in: BTR_N_LEAF_PAGES or BTR_TOTAL_SIZE */ + mtr_t *mtr) /*!< in/out: mini-transaction where index + is s-latched */ MY_ATTRIBUTE((warn_unused_result)); -/**************************************************************/ /** - Allocates a new file page to be used in an index tree. NOTE: we assume +/** Allocates a new file page to be used in an index tree. NOTE: we assume that the caller has made the reservation for free extents! @retval NULL if no page could be allocated @retval block, rw_lock_x_lock_count(&block->lock) == 1 if allocation succeeded (init_mtr == mtr, or the page was not previously freed in mtr) @retval block (not allocated or initialized) otherwise */ buf_block_t *btr_page_alloc( - /*===========*/ dict_index_t *index, /*!< in: index tree */ page_no_t hint_page_no, /*!< in: hint of a good page */ byte file_direction, /*!< in: direction where a possible @@ -556,74 +495,55 @@ buf_block_t *btr_page_alloc( for x-latching and initializing the page */ MY_ATTRIBUTE((warn_unused_result)); -/**************************************************************/ /** - Frees a file page used in an index tree. NOTE: cannot free field external +/** Frees a file page used in an index tree. NOTE: cannot free field external storage pages because the page must contain info on its level. */ -void btr_page_free( - /*==========*/ - dict_index_t *index, /*!< in: index tree */ - buf_block_t *block, /*!< in: block to be freed, x-latched */ - mtr_t *mtr); /*!< in: mtr */ -/**************************************************************/ /** - Creates a new index page (not the root, and also not +void btr_page_free(dict_index_t *index, /*!< in: index tree */ + buf_block_t *block, /*!< in: block to be freed, x-latched */ + mtr_t *mtr); /*!< in: mtr */ +/** Creates a new index page (not the root, and also not used in page reorganization). @see btr_page_empty(). */ void btr_page_create( - /*============*/ buf_block_t *block, /*!< in/out: page to be created */ page_zip_des_t *page_zip, /*!< in/out: compressed page, or NULL */ dict_index_t *index, /*!< in: index */ ulint level, /*!< in: the B-tree level of the page */ mtr_t *mtr); /*!< in: mtr */ -/**************************************************************/ /** - Frees a file page used in an index tree. Can be used also to BLOB +/** Frees a file page used in an index tree. Can be used also to BLOB external storage pages. */ void btr_page_free_low( - /*==============*/ dict_index_t *index, /*!< in: index tree */ buf_block_t *block, /*!< in: block to be freed, x-latched */ ulint level, /*!< in: page level (ULINT_UNDEFINED=BLOB) */ mtr_t *mtr); /*!< in: mtr */ -/**************************************************************/ /** - Gets the root node of a tree and x- or s-latches it. +/** Gets the root node of a tree and x- or s-latches it. @return root page, x- or s-latched */ buf_block_t *btr_root_block_get( - /*===============*/ const dict_index_t *index, /*!< in: index tree */ ulint mode, /*!< in: either RW_S_LATCH or RW_X_LATCH */ mtr_t *mtr); /*!< in: mtr */ #ifdef UNIV_BTR_PRINT -/*************************************************************/ /** - Prints size info of a B-tree. */ -void btr_print_size( - /*===========*/ - dict_index_t *index); /*!< in: index tree */ -/**************************************************************/ /** - Prints directories and other info of all nodes in the index. */ -void btr_print_index( - /*============*/ - dict_index_t *index, /*!< in: index */ - ulint width); /*!< in: print this many entries from start - and end */ -#endif /* UNIV_BTR_PRINT */ -/************************************************************/ /** - Checks the size and number of fields in a record based on the definition of +/** Prints size info of a B-tree. */ +void btr_print_size(dict_index_t *index); /*!< in: index tree */ +/** Prints directories and other info of all nodes in the index. */ +void btr_print_index(dict_index_t *index, /*!< in: index */ + ulint width); /*!< in: print this many entries from start + and end */ +#endif /* UNIV_BTR_PRINT */ +/** Checks the size and number of fields in a record based on the definition of the index. @return true if ok */ ibool btr_index_rec_validate( - /*===================*/ const rec_t *rec, /*!< in: index record */ const dict_index_t *index, /*!< in: index */ ibool dump_on_error) /*!< in: TRUE if the function should print hex dump of record and page on error */ MY_ATTRIBUTE((warn_unused_result)); -/**************************************************************/ /** - Checks the consistency of an index tree. +/** Checks the consistency of an index tree. @return true if ok */ bool btr_validate_index( - /*===============*/ dict_index_t *index, /*!< in: index */ const trx_t *trx, /*!< in: transaction or 0 */ bool lockout) /*!< in: true if X-latch index is intended */ diff --git a/storage/innobase/include/btr0btr.ic b/storage/innobase/include/btr0btr.ic index ec510e3daef4..1268f31de094 100644 --- a/storage/innobase/include/btr0btr.ic +++ b/storage/innobase/include/btr0btr.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/btr0btr.ic +/** @file include/btr0btr.ic The B-tree Created 6/2/1994 Heikki Tuuri @@ -77,11 +76,9 @@ buf_block_t *btr_block_get_func(const page_id_t &page_id, return (block); } -/**************************************************************/ /** - Sets the index id field of a page. */ +/** Sets the index id field of a page. */ UNIV_INLINE void btr_page_set_index_id( - /*==================*/ page_t *page, /*!< in: page to be created */ page_zip_des_t *page_zip, /*!< in: compressed page whose uncompressed part will be updated, or NULL */ @@ -98,24 +95,18 @@ void btr_page_set_index_id( } #endif /* !UNIV_HOTBACKUP */ -/**************************************************************/ /** - Gets the index id field of a page. +/** Gets the index id field of a page. @return index id */ UNIV_INLINE -space_index_t btr_page_get_index_id( - /*==================*/ - const page_t *page) /*!< in: index page */ +space_index_t btr_page_get_index_id(const page_t *page) /*!< in: index page */ { return (mach_read_from_8(page + PAGE_HEADER + PAGE_INDEX_ID)); } -/********************************************************/ /** - Gets the node level field in an index page. +/** Gets the node level field in an index page. @return level, leaf level == 0 */ UNIV_INLINE -ulint btr_page_get_level_low( - /*===================*/ - const page_t *page) /*!< in: index page */ +ulint btr_page_get_level_low(const page_t *page) /*!< in: index page */ { ulint level; @@ -128,11 +119,9 @@ ulint btr_page_get_level_low( return (level); } -/********************************************************/ /** - Sets the node level field in an index page. */ +/** Sets the node level field in an index page. */ UNIV_INLINE void btr_page_set_level( - /*===============*/ page_t *page, /*!< in: index page */ page_zip_des_t *page_zip, /*!< in: compressed page whose uncompressed part will be updated, or NULL */ @@ -152,14 +141,11 @@ void btr_page_set_level( } } -/********************************************************/ /** - Gets the next index page number. +/** Gets the next index page number. @return next page number */ UNIV_INLINE -page_no_t btr_page_get_next( - /*==============*/ - const page_t *page, /*!< in: index page */ - mtr_t *mtr MY_ATTRIBUTE((unused))) +page_no_t btr_page_get_next(const page_t *page, /*!< in: index page */ + mtr_t *mtr MY_ATTRIBUTE((unused))) /*!< in: mini-transaction handle */ { ut_ad(page != NULL); @@ -168,11 +154,9 @@ page_no_t btr_page_get_next( return (mach_read_from_4(page + FIL_PAGE_NEXT)); } -/********************************************************/ /** - Sets the next index page field. */ +/** Sets the next index page field. */ UNIV_INLINE void btr_page_set_next( - /*==============*/ page_t *page, /*!< in: index page */ page_zip_des_t *page_zip, /*!< in: compressed page whose uncompressed part will be updated, or NULL */ @@ -190,12 +174,10 @@ void btr_page_set_next( } } -/********************************************************/ /** - Gets the previous index page number. +/** Gets the previous index page number. @return prev page number */ UNIV_INLINE page_no_t btr_page_get_prev( - /*==============*/ const page_t *page, /*!< in: index page */ mtr_t *mtr MY_ATTRIBUTE((unused))) /*!< in: mini-transaction handle */ { @@ -205,11 +187,9 @@ page_no_t btr_page_get_prev( return (mach_read_from_4(page + FIL_PAGE_PREV)); } -/********************************************************/ /** - Sets the previous index page field. */ +/** Sets the previous index page field. */ UNIV_INLINE void btr_page_set_prev( - /*==============*/ page_t *page, /*!< in: index page */ page_zip_des_t *page_zip, /*!< in: compressed page whose uncompressed part will be updated, or NULL */ @@ -227,8 +207,7 @@ void btr_page_set_prev( } } -/**************************************************************/ /** - Gets the child node file address in a node pointer. +/** Gets the child node file address in a node pointer. NOTE: the offsets array must contain all offsets for the record since we read the last field according to offsets and assume that it contains the child page number. In other words offsets must have been retrieved @@ -236,7 +215,6 @@ void btr_page_set_prev( @return child node address */ UNIV_INLINE page_no_t btr_node_ptr_get_child_page_no( - /*===========================*/ const rec_t *rec, /*!< in: node pointer record */ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ { @@ -258,15 +236,12 @@ page_no_t btr_node_ptr_get_child_page_no( } #ifndef UNIV_HOTBACKUP -/**************************************************************/ /** - Releases the latches on a leaf page and bufferunfixes it. */ +/** Releases the latches on a leaf page and bufferunfixes it. */ UNIV_INLINE -void btr_leaf_page_release( - /*==================*/ - buf_block_t *block, /*!< in: buffer block */ - ulint latch_mode, /*!< in: BTR_SEARCH_LEAF or - BTR_MODIFY_LEAF */ - mtr_t *mtr) /*!< in: mtr */ +void btr_leaf_page_release(buf_block_t *block, /*!< in: buffer block */ + ulint latch_mode, /*!< in: BTR_SEARCH_LEAF or + BTR_MODIFY_LEAF */ + mtr_t *mtr) /*!< in: mtr */ { ut_ad(latch_mode == BTR_SEARCH_LEAF || latch_mode == BTR_MODIFY_LEAF || latch_mode == BTR_NO_LATCHES); diff --git a/storage/innobase/include/btr0bulk.h b/storage/innobase/include/btr0bulk.h index 35a030c15d99..c68e7c399c22 100644 --- a/storage/innobase/include/btr0bulk.h +++ b/storage/innobase/include/btr0bulk.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2014, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2014, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file include/btr0bulk.h +/** @file include/btr0bulk.h The B-tree bulk load Created 03/11/2014 Shaohua Wang diff --git a/storage/innobase/include/btr0cur.h b/storage/innobase/include/btr0cur.h index 6ccde06d8407..baa638ee14fb 100644 --- a/storage/innobase/include/btr0cur.h +++ b/storage/innobase/include/btr0cur.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -29,8 +29,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "my_compiler.h" -/**************************************************/ /** - @file include/btr0cur.h +/** @file include/btr0cur.h The index tree cursor Created 10/16/1994 Heikki Tuuri @@ -83,48 +82,33 @@ struct btr_latch_leaves_t { #define BTR_CUR_HASH_ADAPT #ifdef UNIV_DEBUG -/*********************************************************/ /** - Returns the page cursor component of a tree cursor. +/** Returns the page cursor component of a tree cursor. @return pointer to page cursor component */ UNIV_INLINE page_cur_t *btr_cur_get_page_cur( - /*=================*/ const btr_cur_t *cursor); /*!< in: tree cursor */ -/*********************************************************/ /** - Returns the buffer block on which the tree cursor is positioned. +/** Returns the buffer block on which the tree cursor is positioned. @return pointer to buffer block */ UNIV_INLINE -buf_block_t *btr_cur_get_block( - /*==============*/ - const btr_cur_t *cursor); /*!< in: tree cursor */ -/*********************************************************/ /** - Returns the record pointer of a tree cursor. +buf_block_t *btr_cur_get_block(const btr_cur_t *cursor); /*!< in: tree cursor */ +/** Returns the record pointer of a tree cursor. @return pointer to record */ UNIV_INLINE -rec_t *btr_cur_get_rec( - /*============*/ - const btr_cur_t *cursor); /*!< in: tree cursor */ -#else /* UNIV_DEBUG */ +rec_t *btr_cur_get_rec(const btr_cur_t *cursor); /*!< in: tree cursor */ +#else /* UNIV_DEBUG */ #define btr_cur_get_page_cur(cursor) (&(cursor)->page_cur) #define btr_cur_get_block(cursor) ((cursor)->page_cur.block) #define btr_cur_get_rec(cursor) ((cursor)->page_cur.rec) -#endif /* UNIV_DEBUG */ -/*********************************************************/ /** - Returns the compressed page on which the tree cursor is positioned. +#endif /* UNIV_DEBUG */ +/** Returns the compressed page on which the tree cursor is positioned. @return pointer to compressed page, or NULL if the page is not compressed */ UNIV_INLINE -page_zip_des_t *btr_cur_get_page_zip( - /*=================*/ - btr_cur_t *cursor); /*!< in: tree cursor */ -/*********************************************************/ /** - Returns the page of a tree cursor. +page_zip_des_t *btr_cur_get_page_zip(btr_cur_t *cursor); /*!< in: tree cursor */ +/** Returns the page of a tree cursor. @return pointer to page */ UNIV_INLINE -page_t *btr_cur_get_page( - /*=============*/ - btr_cur_t *cursor); /*!< in: tree cursor */ -/*********************************************************/ /** - Returns the index of a cursor. +page_t *btr_cur_get_page(btr_cur_t *cursor); /*!< in: tree cursor */ +/** Returns the index of a cursor. @param cursor b-tree cursor @return index */ #define btr_cur_get_index(cursor) ((cursor)->index) @@ -152,15 +136,13 @@ bool btr_cur_optimistic_latch_leaves(buf_block_t *block, ulint *latch_mode, btr_cur_t *cursor, const char *file, ulint line, mtr_t *mtr); -/********************************************************************/ /** - Searches an index tree and positions a tree cursor on a given level. +/** Searches an index tree and positions a tree cursor on a given level. NOTE: n_fields_cmp in tuple must be set so that it cannot be compared to node pointer page number fields on the upper levels of the tree! Note that if mode is PAGE_CUR_LE, which is used in inserts, then cursor->up_match and cursor->low_match both will have sensible values. If mode is PAGE_CUR_GE, then up_match will a have a sensible value. */ void btr_cur_search_to_nth_level( - /*========================*/ dict_index_t *index, /*!< in: index */ ulint level, /*!< in: the tree level of search */ const dtuple_t *tuple, /*!< in: data tuple; NOTE: n_fields_cmp in @@ -216,10 +198,8 @@ void btr_cur_search_to_nth_level_with_no_latch( page_cur_mode_t mode, btr_cur_t *cursor, const char *file, ulint line, mtr_t *mtr, bool mark_dirty = true); -/*****************************************************************/ /** - Opens a cursor at either end of an index. */ +/** Opens a cursor at either end of an index. */ void btr_cur_open_at_index_side_func( - /*============================*/ bool from_left, /*!< in: true if open to the low end, false if to the high end */ dict_index_t *index, /*!< in: index */ @@ -252,12 +232,10 @@ void btr_cur_open_at_index_side_with_no_latch_func( btr_cur_open_at_index_side_with_no_latch_func(f, i, c, lv, __FILE__, \ __LINE__, m) -/**********************************************************************/ /** - Positions a cursor at a randomly chosen position within a B-tree. +/** Positions a cursor at a randomly chosen position within a B-tree. @return true if the index is available and we have put the cursor, false if the index is unavailable */ bool btr_cur_open_at_rnd_pos_func( - /*=========================*/ dict_index_t *index, /*!< in: index */ ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ... */ btr_cur_t *cursor, /*!< in/out: B-tree cursor */ @@ -266,15 +244,13 @@ bool btr_cur_open_at_rnd_pos_func( mtr_t *mtr); /*!< in: mtr */ #define btr_cur_open_at_rnd_pos(i, l, c, m) \ btr_cur_open_at_rnd_pos_func(i, l, c, __FILE__, __LINE__, m) -/*************************************************************/ /** - Tries to perform an insert to a page in an index tree, next to cursor. +/** Tries to perform an insert to a page in an index tree, next to cursor. It is assumed that mtr holds an x-latch on the page. The operation does not succeed if there is too little space on the page. If there is just one record on the page, the insert will always succeed; this is to prevent trying to split a page with just one record. @return DB_SUCCESS, DB_WAIT_LOCK, DB_FAIL, or error number */ dberr_t btr_cur_optimistic_insert( - /*======================*/ ulint flags, /*!< in: undo logging and locking flags: if not zero, the parameters index and thr should be specified */ @@ -297,14 +273,12 @@ dberr_t btr_cur_optimistic_insert( mtr_commit(mtr) before latching any further pages */ MY_ATTRIBUTE((warn_unused_result)); -/*************************************************************/ /** - Performs an insert on a page of an index tree. It is assumed that mtr +/** Performs an insert on a page of an index tree. It is assumed that mtr holds an x-latch on the tree and on the cursor page. If the insert is made on the leaf level, to avoid deadlocks, mtr must also own x-latches to brothers of page, if those brothers exist. @return DB_SUCCESS or error number */ dberr_t btr_cur_pessimistic_insert( - /*=======================*/ ulint flags, /*!< in: undo logging and locking flags: if not zero, the parameter thr should be specified; if no undo logging is specified, @@ -326,8 +300,7 @@ dberr_t btr_cur_pessimistic_insert( que_thr_t *thr, /*!< in: query thread or NULL */ mtr_t *mtr) /*!< in/out: mini-transaction */ MY_ATTRIBUTE((warn_unused_result)); -/*************************************************************/ /** - See if there is enough place in the page modification log to log +/** See if there is enough place in the page modification log to log an update-in-place. @retval false if out of space; IBUF_BITMAP_FREE will be reset @@ -339,7 +312,6 @@ dberr_t btr_cur_pessimistic_insert( same mini-transaction, or by invoking ibuf_reset_free_bits() before mtr_commit(mtr). */ bool btr_cur_update_alloc_zip_func( - /*==========================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ page_cur_t *cursor, /*!< in/out: B-tree page cursor */ dict_index_t *index, /*!< in: the index corresponding to cursor */ @@ -359,15 +331,13 @@ bool btr_cur_update_alloc_zip_func( #define btr_cur_update_alloc_zip(page_zip, cursor, index, offsets, len, cr, \ mtr) \ btr_cur_update_alloc_zip_func(page_zip, cursor, index, len, cr, mtr) -#endif /* UNIV_DEBUG */ -/*************************************************************/ /** - Updates a record when the update causes no size changes in its fields. +#endif /* UNIV_DEBUG */ +/** Updates a record when the update causes no size changes in its fields. @return locking or undo log related error code, or @retval DB_SUCCESS on success @retval DB_ZIP_OVERFLOW if there is not enough space left on the compressed page (IBUF_BITMAP_FREE was reset outside mtr) */ dberr_t btr_cur_update_in_place( - /*====================*/ ulint flags, /*!< in: undo logging and locking flags */ btr_cur_t *cursor, /*!< in: cursor on the record to update; cursor stays valid and positioned on the @@ -387,10 +357,8 @@ dberr_t btr_cur_update_in_place( mtr_commit(mtr) before latching any further pages */ MY_ATTRIBUTE((warn_unused_result)); -/***********************************************************/ /** - Writes a redo log record of updating a record in-place. */ +/** Writes a redo log record of updating a record in-place. */ void btr_cur_update_in_place_log( - /*========================*/ ulint flags, /*!< in: flags */ const rec_t *rec, /*!< in: record */ dict_index_t *index, /*!< in: index of the record */ @@ -398,8 +366,7 @@ void btr_cur_update_in_place_log( trx_id_t trx_id, /*!< in: transaction id */ roll_ptr_t roll_ptr, /*!< in: roll ptr */ mtr_t *mtr); /*!< in: mtr */ -/*************************************************************/ /** - Tries to update a record on a page in an index tree. It is assumed that mtr +/** Tries to update a record on a page in an index tree. It is assumed that mtr holds an x-latch on the page. The operation does not succeed if there is too little space on the page or if the update would result in too empty a page, so that tree compression is recommended. @@ -410,7 +377,6 @@ void btr_cur_update_in_place_log( @retval DB_ZIP_OVERFLOW if there is not enough space left on the compressed page */ dberr_t btr_cur_optimistic_update( - /*======================*/ ulint flags, /*!< in: undo logging and locking flags */ btr_cur_t *cursor, /*!< in: cursor on the record to update; cursor stays valid and positioned on the @@ -432,14 +398,12 @@ dberr_t btr_cur_optimistic_update( mtr_commit(mtr) before latching any further pages */ MY_ATTRIBUTE((warn_unused_result)); -/*************************************************************/ /** - Performs an update of a record on a page of a tree. It is assumed +/** Performs an update of a record on a page of a tree. It is assumed that mtr holds an x-latch on the tree and on the cursor page. If the update is made on the leaf level, to avoid deadlocks, mtr must also own x-latches to brothers of page, if those brothers exist. @return DB_SUCCESS or error code */ dberr_t btr_cur_pessimistic_update( - /*=======================*/ ulint flags, /*!< in: undo logging, locking, and rollback flags */ btr_cur_t *cursor, /*!< in/out: cursor on the record to update; @@ -473,14 +437,12 @@ dberr_t btr_cur_pessimistic_update( mtr_t *mtr) /*!< in/out: mini-transaction; must be committed before latching any further pages */ MY_ATTRIBUTE((warn_unused_result)); -/***********************************************************/ /** - Marks a clustered index record deleted. Writes an undo log record to +/** Marks a clustered index record deleted. Writes an undo log record to undo log on this delete marking. Writes in the trx id field the id of the deleting transaction, and in the roll ptr field pointer to the undo log record created. @return DB_SUCCESS, DB_LOCK_WAIT, or error number */ dberr_t btr_cur_del_mark_set_clust_rec( - /*===========================*/ ulint flags, /*!< in: undo logging and locking flags */ buf_block_t *block, /*!< in/out: buffer block of the record */ rec_t *rec, /*!< in/out: record */ @@ -490,39 +452,33 @@ dberr_t btr_cur_del_mark_set_clust_rec( const dtuple_t *entry, /*!< in: dtuple for the deleting record */ mtr_t *mtr) /*!< in/out: mini-transaction */ MY_ATTRIBUTE((warn_unused_result)); -/***********************************************************/ /** - Sets a secondary index record delete mark to TRUE or FALSE. +/** Sets a secondary index record delete mark to TRUE or FALSE. @return DB_SUCCESS, DB_LOCK_WAIT, or error number */ dberr_t btr_cur_del_mark_set_sec_rec( - /*=========================*/ ulint flags, /*!< in: locking flag */ btr_cur_t *cursor, /*!< in: cursor */ ibool val, /*!< in: value to set */ que_thr_t *thr, /*!< in: query thread */ mtr_t *mtr) /*!< in/out: mini-transaction */ MY_ATTRIBUTE((warn_unused_result)); -/*************************************************************/ /** - Tries to compress a page of the tree if it seems useful. It is assumed +/** Tries to compress a page of the tree if it seems useful. It is assumed that mtr holds an x-latch on the tree and on the cursor page. To avoid deadlocks, mtr must also own x-latches to brothers of page, if those brothers exist. NOTE: it is assumed that the caller has reserved enough free extents so that the compression will always succeed if done! @return true if compression occurred */ ibool btr_cur_compress_if_useful( - /*=======================*/ btr_cur_t *cursor, /*!< in/out: cursor on the page to compress; cursor does not stay valid if compression occurs */ ibool adjust, /*!< in: TRUE if should adjust the cursor position even if compression occurs */ mtr_t *mtr); /*!< in/out: mini-transaction */ -/*******************************************************/ /** - Removes the record on which the tree cursor is positioned. It is assumed +/** Removes the record on which the tree cursor is positioned. It is assumed that the mtr has an x-latch on the page where the cursor is positioned, but no latch on the whole tree. @return true if success, i.e., the page did not become too empty */ ibool btr_cur_optimistic_delete_func( - /*===========================*/ btr_cur_t *cursor, /*!< in: cursor on the record to delete; cursor stays valid: if deletion succeeds, on function exit it points to the successor @@ -541,9 +497,8 @@ ibool btr_cur_optimistic_delete_func( #else /* UNIV_DEBUG */ #define btr_cur_optimistic_delete(cursor, flags, mtr) \ btr_cur_optimistic_delete_func(cursor, mtr) -#endif /* UNIV_DEBUG */ -/*************************************************************/ /** - Removes the record on which the tree cursor is positioned. Tries +#endif /* UNIV_DEBUG */ +/** Removes the record on which the tree cursor is positioned. Tries to compress the page if its fillfactor drops below a threshold or if it is the only page on the level. It is assumed that mtr holds an x-latch on the tree and on the cursor page. To avoid deadlocks, @@ -551,7 +506,6 @@ ibool btr_cur_optimistic_delete_func( exist. @return true if compression occurred */ ibool btr_cur_pessimistic_delete( - /*=======================*/ dberr_t *err, /*!< out: DB_SUCCESS or DB_OUT_OF_FILE_SPACE; the latter may occur because we may have to update node pointers on upper levels, @@ -574,34 +528,28 @@ ibool btr_cur_pessimistic_delete( partially updated LOB.*/ ulint rec_type, /*!< in: undo record type. */ - mtr_t *mtr); /*!< in: mtr */ -/***********************************************************/ /** - Parses a redo log record of updating a record in-place. + mtr_t *mtr); /*!< in: mtr */ +/** Parses a redo log record of updating a record in-place. @return end of log record or NULL */ byte *btr_cur_parse_update_in_place( - /*==========================*/ byte *ptr, /*!< in: buffer */ byte *end_ptr, /*!< in: buffer end */ page_t *page, /*!< in/out: page or NULL */ page_zip_des_t *page_zip, /*!< in/out: compressed page, or NULL */ dict_index_t *index); /*!< in: index corresponding to page */ -/****************************************************************/ /** - Parses the redo log record for delete marking or unmarking of a clustered +/** Parses the redo log record for delete marking or unmarking of a clustered index record. @return end of log record or NULL */ byte *btr_cur_parse_del_mark_set_clust_rec( - /*=================================*/ byte *ptr, /*!< in: buffer */ byte *end_ptr, /*!< in: buffer end */ page_t *page, /*!< in/out: page or NULL */ page_zip_des_t *page_zip, /*!< in/out: compressed page, or NULL */ dict_index_t *index); /*!< in: index corresponding to page */ -/****************************************************************/ /** - Parses the redo log record for delete marking or unmarking of a secondary +/** Parses the redo log record for delete marking or unmarking of a secondary index record. @return end of log record or NULL */ byte *btr_cur_parse_del_mark_set_sec_rec( - /*===============================*/ byte *ptr, /*!< in: buffer */ byte *end_ptr, /*!< in: buffer end */ page_t *page, /*!< in/out: page or NULL */ @@ -621,8 +569,7 @@ int64_t btr_estimate_n_rows_in_range(dict_index_t *index, const dtuple_t *tuple2, page_cur_mode_t mode2); -/*******************************************************************/ /** - Estimates the number of different key values in a given index, for +/** Estimates the number of different key values in a given index, for each n-column prefix of the index where 1 <= n <= dict_index_get_n_unique(index). The estimates are stored in the array index->stat_n_diff_key_vals[] (indexed 0..n_uniq-1) and the number of pages @@ -633,7 +580,6 @@ int64_t btr_estimate_n_rows_in_range(dict_index_t *index, @return true if the index is available and we get the estimated numbers, false if the index is unavailable. */ bool btr_estimate_number_of_different_key_vals( - /*======================================*/ dict_index_t *index); /*!< in: index */ /** Copies an externally stored field of a record to mem heap. @@ -658,11 +604,9 @@ byte *btr_rec_copy_externally_stored_field_func(trx_t *trx, dict_index_t *index, #endif /* UNIV_DEBUG */ mem_heap_t *heap); -/***********************************************************/ /** - Sets a secondary index record's delete mark to the given value. This +/** Sets a secondary index record's delete mark to the given value. This function is only used by the insert buffer merge mechanism. */ void btr_cur_set_deleted_flag_for_ibuf( - /*==============================*/ rec_t *rec, /*!< in/out: record */ page_zip_des_t *page_zip, /*!< in/out: compressed page corresponding to rec, or NULL diff --git a/storage/innobase/include/btr0cur.ic b/storage/innobase/include/btr0cur.ic index e999ab6d5622..145c31f87611 100644 --- a/storage/innobase/include/btr0cur.ic +++ b/storage/innobase/include/btr0cur.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/btr0cur.ic +/** @file include/btr0cur.ic The index tree cursor Created 10/16/1994 Heikki Tuuri @@ -46,71 +45,54 @@ this program; if not, write to the Free Software Foundation, Inc., #endif /* UNIV_DEBUG */ #ifdef UNIV_DEBUG -/*********************************************************/ /** - Returns the page cursor component of a tree cursor. +/** Returns the page cursor component of a tree cursor. @return pointer to page cursor component */ UNIV_INLINE page_cur_t *btr_cur_get_page_cur( - /*=================*/ const btr_cur_t *cursor) /*!< in: tree cursor */ { return (&((btr_cur_t *)cursor)->page_cur); } -/*********************************************************/ /** - Returns the buffer block on which the tree cursor is positioned. +/** Returns the buffer block on which the tree cursor is positioned. @return pointer to buffer block */ UNIV_INLINE -buf_block_t *btr_cur_get_block( - /*==============*/ - const btr_cur_t *cursor) /*!< in: tree cursor */ +buf_block_t *btr_cur_get_block(const btr_cur_t *cursor) /*!< in: tree cursor */ { return (page_cur_get_block(btr_cur_get_page_cur(cursor))); } -/*********************************************************/ /** - Returns the record pointer of a tree cursor. +/** Returns the record pointer of a tree cursor. @return pointer to record */ UNIV_INLINE -rec_t *btr_cur_get_rec( - /*============*/ - const btr_cur_t *cursor) /*!< in: tree cursor */ +rec_t *btr_cur_get_rec(const btr_cur_t *cursor) /*!< in: tree cursor */ { return (page_cur_get_rec(btr_cur_get_page_cur(cursor))); } #endif /* UNIV_DEBUG */ -/*********************************************************/ /** - Returns the compressed page on which the tree cursor is positioned. +/** Returns the compressed page on which the tree cursor is positioned. @return pointer to compressed page, or NULL if the page is not compressed */ UNIV_INLINE -page_zip_des_t *btr_cur_get_page_zip( - /*=================*/ - btr_cur_t *cursor) /*!< in: tree cursor */ +page_zip_des_t *btr_cur_get_page_zip(btr_cur_t *cursor) /*!< in: tree cursor */ { return (buf_block_get_page_zip(btr_cur_get_block(cursor))); } -/*********************************************************/ /** - Returns the page of a tree cursor. +/** Returns the page of a tree cursor. @return pointer to page */ UNIV_INLINE -page_t *btr_cur_get_page( - /*=============*/ - btr_cur_t *cursor) /*!< in: tree cursor */ +page_t *btr_cur_get_page(btr_cur_t *cursor) /*!< in: tree cursor */ { return (page_align(page_cur_get_rec(&(cursor->page_cur)))); } -/*********************************************************/ /** - Positions a tree cursor at a given record. */ +/** Positions a tree cursor at a given record. */ UNIV_INLINE -void btr_cur_position( - /*=============*/ - dict_index_t *index, /*!< in: index */ - rec_t *rec, /*!< in: record in tree */ - buf_block_t *block, /*!< in: buffer block of rec */ - btr_cur_t *cursor) /*!< out: cursor */ +void btr_cur_position(dict_index_t *index, /*!< in: index */ + rec_t *rec, /*!< in: record in tree */ + buf_block_t *block, /*!< in: buffer block of rec */ + btr_cur_t *cursor) /*!< out: cursor */ { ut_ad(page_align(rec) == block->frame); @@ -119,15 +101,12 @@ void btr_cur_position( cursor->index = index; } -/*********************************************************************/ /** - Checks if compressing an index page where a btr cursor is placed makes +/** Checks if compressing an index page where a btr cursor is placed makes sense. @return true if compression is recommended */ UNIV_INLINE -ibool btr_cur_compress_recommendation( - /*============================*/ - btr_cur_t *cursor, /*!< in: btr cursor */ - mtr_t *mtr) /*!< in: mtr */ +ibool btr_cur_compress_recommendation(btr_cur_t *cursor, /*!< in: btr cursor */ + mtr_t *mtr) /*!< in: mtr */ { const page_t *page; @@ -152,13 +131,11 @@ ibool btr_cur_compress_recommendation( return (FALSE); } -/*********************************************************************/ /** - Checks if the record on which the cursor is placed can be deleted without +/** Checks if the record on which the cursor is placed can be deleted without making tree compression necessary (or, recommended). @return true if can be deleted without recommended compression */ UNIV_INLINE ibool btr_cur_can_delete_without_compress( - /*================================*/ btr_cur_t *cursor, /*!< in: btr cursor */ ulint rec_size, /*!< in: rec_get_size(btr_cur_get_rec(cursor))*/ mtr_t *mtr) /*!< in: mtr */ diff --git a/storage/innobase/include/btr0pcur.h b/storage/innobase/include/btr0pcur.h index 6d674a827669..38b84077a0ac 100644 --- a/storage/innobase/include/btr0pcur.h +++ b/storage/innobase/include/btr0pcur.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/btr0pcur.h +/** @file include/btr0pcur.h The index tree persistent cursor Created 2/23/1996 Heikki Tuuri @@ -60,50 +59,36 @@ enum btr_pcur_pos_t { BTR_PCUR_AFTER_LAST_IN_TREE = 5 /* in an empty tree */ }; -/**************************************************************/ /** - Allocates memory for a persistent cursor object and initializes the cursor. +/** Allocates memory for a persistent cursor object and initializes the cursor. @return own: persistent cursor */ btr_pcur_t *btr_pcur_create_for_mysql(void); -/*============================*/ -/**************************************************************/ /** - Resets a persistent cursor object, freeing "::old_rec_buf" if it is +/** Resets a persistent cursor object, freeing "::old_rec_buf" if it is allocated and resetting the other members to their initial values. */ -void btr_pcur_reset( - /*===========*/ - btr_pcur_t *cursor); /*!< in, out: persistent cursor */ +void btr_pcur_reset(btr_pcur_t *cursor); /*!< in, out: persistent cursor */ -/**************************************************************/ /** - Frees the memory for a persistent cursor object. */ +/** Frees the memory for a persistent cursor object. */ void btr_pcur_free_for_mysql( - /*====================*/ btr_pcur_t *cursor); /*!< in, own: persistent cursor */ -/**************************************************************/ /** - Copies the stored position of a pcur to another pcur. */ +/** Copies the stored position of a pcur to another pcur. */ void btr_pcur_copy_stored_position( - /*==========================*/ btr_pcur_t *pcur_receive, /*!< in: pcur which will receive the position info */ btr_pcur_t *pcur_donate); /*!< in: pcur from which the info is copied */ -/**************************************************************/ /** - Sets the old_rec_buf field to NULL. */ +/** Sets the old_rec_buf field to NULL. */ UNIV_INLINE -void btr_pcur_init( - /*==========*/ - btr_pcur_t *pcur); /*!< in: persistent cursor */ +void btr_pcur_init(btr_pcur_t *pcur); /*!< in: persistent cursor */ /** Free old_rec_buf. @param[in] pcur Persistent cursor holding old_rec to be freed. */ UNIV_INLINE void btr_pcur_free(btr_pcur_t *pcur); -/**************************************************************/ /** - Initializes and opens a persistent cursor to an index tree. It should be +/** Initializes and opens a persistent cursor to an index tree. It should be closed with btr_pcur_close. */ UNIV_INLINE void btr_pcur_open_low( - /*==============*/ dict_index_t *index, /*!< in: index */ ulint level, /*!< in: level in the btree */ const dtuple_t *tuple, /*!< in: tuple on which search done */ @@ -121,12 +106,10 @@ void btr_pcur_open_low( ; #define btr_pcur_open(i, t, md, l, c, m) \ btr_pcur_open_low(i, 0, t, md, l, c, __FILE__, __LINE__, m) -/**************************************************************/ /** - Opens an persistent cursor to an index tree without initializing the +/** Opens an persistent cursor to an index tree without initializing the cursor. */ UNIV_INLINE void btr_pcur_open_with_no_init_func( - /*============================*/ dict_index_t *index, /*!< in: index */ const dtuple_t *tuple, /*!< in: tuple on which search done */ page_cur_mode_t mode, /*!< in: PAGE_CUR_L, ...; @@ -152,11 +135,9 @@ void btr_pcur_open_with_no_init_func( #define btr_pcur_open_with_no_init(ix, t, md, l, cur, has, m) \ btr_pcur_open_with_no_init_func(ix, t, md, l, cur, has, __FILE__, __LINE__, m) -/*****************************************************************/ /** - Opens a persistent cursor at either end of an index. */ +/** Opens a persistent cursor at either end of an index. */ UNIV_INLINE void btr_pcur_open_at_index_side( - /*========================*/ bool from_left, /*!< in: true if open to the low end, false if to the high end */ dict_index_t *index, /*!< in: index */ @@ -167,31 +148,25 @@ void btr_pcur_open_at_index_side( (0=leaf) */ mtr_t *mtr) /*!< in/out: mini-transaction */ ; -/**************************************************************/ /** - Gets the up_match value for a pcur after a search. +/** Gets the up_match value for a pcur after a search. @return number of matched fields at the cursor or to the right if search mode was PAGE_CUR_GE, otherwise undefined */ UNIV_INLINE ulint btr_pcur_get_up_match( - /*==================*/ const btr_pcur_t *cursor); /*!< in: persistent cursor */ -/**************************************************************/ /** - Gets the low_match value for a pcur after a search. +/** Gets the low_match value for a pcur after a search. @return number of matched fields at the cursor or to the right if search mode was PAGE_CUR_LE, otherwise undefined */ UNIV_INLINE ulint btr_pcur_get_low_match( - /*===================*/ const btr_pcur_t *cursor); /*!< in: persistent cursor */ -/**************************************************************/ /** - If mode is PAGE_CUR_G or PAGE_CUR_GE, opens a persistent cursor on the first +/** If mode is PAGE_CUR_G or PAGE_CUR_GE, opens a persistent cursor on the first user record satisfying the search condition, in the case PAGE_CUR_L or PAGE_CUR_LE, on the last user record. If no such user record exists, then in the first case sets the cursor after last in tree, and in the latter case before first in tree. The latching mode must be BTR_SEARCH_LEAF or BTR_MODIFY_LEAF. */ void btr_pcur_open_on_user_rec_func( - /*===========================*/ dict_index_t *index, /*!< in: index */ const dtuple_t *tuple, /*!< in: tuple on which search done */ page_cur_mode_t mode, /*!< in: PAGE_CUR_L, ... */ @@ -204,13 +179,11 @@ void btr_pcur_open_on_user_rec_func( mtr_t *mtr); /*!< in: mtr */ #define btr_pcur_open_on_user_rec(i, t, md, l, c, m) \ btr_pcur_open_on_user_rec_func(i, t, md, l, c, __FILE__, __LINE__, m) -/**********************************************************************/ /** - Positions a cursor at a randomly chosen position within a B-tree. +/** Positions a cursor at a randomly chosen position within a B-tree. @return true if the index is available and we have put the cursor, false if the index is unavailable */ UNIV_INLINE bool btr_pcur_open_at_rnd_pos_func( - /*==========================*/ dict_index_t *index, /*!< in: index */ ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ... */ btr_pcur_t *cursor, /*!< in/out: B-tree pcur */ @@ -220,8 +193,7 @@ bool btr_pcur_open_at_rnd_pos_func( ; #define btr_pcur_open_at_rnd_pos(i, l, c, m) \ btr_pcur_open_at_rnd_pos_func(i, l, c, __FILE__, __LINE__, m) -/**************************************************************/ /** - Frees the possible memory heap of a persistent cursor and sets the latch +/** Frees the possible memory heap of a persistent cursor and sets the latch mode of the persistent cursor to BTR_NO_LATCHES. WARNING: this function does not release the latch on the page where the cursor is currently positioned. The latch is acquired by the @@ -233,23 +205,17 @@ bool btr_pcur_open_at_rnd_pos_func( A subsequent attempt to crawl the same page in the same mtr would cause an assertion failure. */ UNIV_INLINE -void btr_pcur_close( - /*===========*/ - btr_pcur_t *cursor); /*!< in: persistent cursor */ -/**************************************************************/ /** - The position of the cursor is stored by taking an initial segment of the +void btr_pcur_close(btr_pcur_t *cursor); /*!< in: persistent cursor */ +/** The position of the cursor is stored by taking an initial segment of the record the cursor is positioned on, before, or after, and copying it to the cursor data structure, or just setting a flag if the cursor id before the first in an EMPTY tree, or after the last in an EMPTY tree. NOTE that the page where the cursor is positioned must not be empty if the index tree is not totally empty! */ -void btr_pcur_store_position( - /*====================*/ - btr_pcur_t *cursor, /*!< in: persistent cursor */ - mtr_t *mtr); /*!< in: mtr */ -/**************************************************************/ /** - Restores the stored position of a persistent cursor bufferfixing the page and - obtaining the specified latches. If the cursor position was saved when the +void btr_pcur_store_position(btr_pcur_t *cursor, /*!< in: persistent cursor */ + mtr_t *mtr); /*!< in: mtr */ +/** Restores the stored position of a persistent cursor bufferfixing the page + and obtaining the specified latches. If the cursor position was saved when the (1) cursor was positioned on a user record: this function restores the position to the last record LESS OR EQUAL to the stored record; (2) cursor was positioned on a page infimum record: restores the position to @@ -263,7 +229,6 @@ void btr_pcur_store_position( record and it can be restored on a user record whose ordering fields are identical to the ones of the original user record */ ibool btr_pcur_restore_position_func( - /*===========================*/ ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ... */ btr_pcur_t *cursor, /*!< in: detached persistent cursor */ const char *file, /*!< in: file name */ @@ -271,171 +236,129 @@ ibool btr_pcur_restore_position_func( mtr_t *mtr); /*!< in: mtr */ #define btr_pcur_restore_position(l, cur, mtr) \ btr_pcur_restore_position_func(l, cur, __FILE__, __LINE__, mtr) -/*********************************************************/ /** - Gets the rel_pos field for a cursor whose position has been stored. +/** Gets the rel_pos field for a cursor whose position has been stored. @return BTR_PCUR_ON, ... */ UNIV_INLINE ulint btr_pcur_get_rel_pos( - /*=================*/ const btr_pcur_t *cursor); /*!< in: persistent cursor */ -/**************************************************************/ /** - Commits the mtr and sets the pcur latch mode to BTR_NO_LATCHES, +/** Commits the mtr and sets the pcur latch mode to BTR_NO_LATCHES, that is, the cursor becomes detached. Function btr_pcur_store_position should be used before calling this, if restoration of cursor is wanted later. */ UNIV_INLINE -void btr_pcur_commit_specify_mtr( - /*========================*/ - btr_pcur_t *pcur, /*!< in: persistent cursor */ - mtr_t *mtr) /*!< in: mtr to commit */ +void btr_pcur_commit_specify_mtr(btr_pcur_t *pcur, /*!< in: persistent cursor */ + mtr_t *mtr) /*!< in: mtr to commit */ ; -/*********************************************************/ /** - Moves the persistent cursor to the next record in the tree. If no records are - left, the cursor stays 'after last in tree'. +/** Moves the persistent cursor to the next record in the tree. If no records + are left, the cursor stays 'after last in tree'. @return true if the cursor was not after last in tree */ UNIV_INLINE ibool btr_pcur_move_to_next( - /*==================*/ btr_pcur_t *cursor, /*!< in: persistent cursor; NOTE that the function may release the page latch */ mtr_t *mtr) /*!< in: mtr */ ; -/*********************************************************/ /** - Moves the persistent cursor to the previous record in the tree. If no records - are left, the cursor stays 'before first in tree'. +/** Moves the persistent cursor to the previous record in the tree. If no + records are left, the cursor stays 'before first in tree'. @return true if the cursor was not before first in tree */ ibool btr_pcur_move_to_prev( - /*==================*/ btr_pcur_t *cursor, /*!< in: persistent cursor; NOTE that the function may release the page latch */ mtr_t *mtr); /*!< in: mtr */ -/*********************************************************/ /** - Moves the persistent cursor to the last record on the same page. */ +/** Moves the persistent cursor to the last record on the same page. */ UNIV_INLINE void btr_pcur_move_to_last_on_page( - /*==========================*/ btr_pcur_t *cursor, /*!< in: persistent cursor */ mtr_t *mtr) /*!< in: mtr */ ; -/*********************************************************/ /** - Moves the persistent cursor to the next user record in the tree. If no user +/** Moves the persistent cursor to the next user record in the tree. If no user records are left, the cursor ends up 'after last in tree'. @return true if the cursor moved forward, ending on a user record */ UNIV_INLINE ibool btr_pcur_move_to_next_user_rec( - /*===========================*/ btr_pcur_t *cursor, /*!< in: persistent cursor; NOTE that the function may release the page latch */ mtr_t *mtr) /*!< in: mtr */ ; -/*********************************************************/ /** - Moves the persistent cursor to the first record on the next page. +/** Moves the persistent cursor to the first record on the next page. Releases the latch on the current page, and bufferunfixes it. Note that there must not be modifications on the current page, as then the x-latch can be released only in mtr_commit. */ void btr_pcur_move_to_next_page( - /*=======================*/ btr_pcur_t *cursor, /*!< in: persistent cursor; must be on the last record of the current page */ mtr_t *mtr); /*!< in: mtr */ #ifdef UNIV_DEBUG -/*********************************************************/ /** - Returns the btr cursor component of a persistent cursor. +/** Returns the btr cursor component of a persistent cursor. @return pointer to btr cursor component */ UNIV_INLINE btr_cur_t *btr_pcur_get_btr_cur( - /*=================*/ const btr_pcur_t *cursor); /*!< in: persistent cursor */ -/*********************************************************/ /** - Returns the page cursor component of a persistent cursor. +/** Returns the page cursor component of a persistent cursor. @return pointer to page cursor component */ UNIV_INLINE page_cur_t *btr_pcur_get_page_cur( - /*==================*/ const btr_pcur_t *cursor); /*!< in: persistent cursor */ -/*********************************************************/ /** - Returns the page of a persistent cursor. +/** Returns the page of a persistent cursor. @return pointer to the page */ UNIV_INLINE page_t *btr_pcur_get_page( - /*==============*/ const btr_pcur_t *cursor); /*!< in: persistent cursor */ -/*********************************************************/ /** - Returns the buffer block of a persistent cursor. +/** Returns the buffer block of a persistent cursor. @return pointer to the block */ UNIV_INLINE buf_block_t *btr_pcur_get_block( - /*===============*/ const btr_pcur_t *cursor); /*!< in: persistent cursor */ -/*********************************************************/ /** - Returns the record of a persistent cursor. +/** Returns the record of a persistent cursor. @return pointer to the record */ UNIV_INLINE -rec_t *btr_pcur_get_rec( - /*=============*/ - const btr_pcur_t *cursor); /*!< in: persistent cursor */ -#else /* UNIV_DEBUG */ +rec_t *btr_pcur_get_rec(const btr_pcur_t *cursor); /*!< in: persistent cursor */ +#else /* UNIV_DEBUG */ #define btr_pcur_get_btr_cur(cursor) (&(cursor)->btr_cur) #define btr_pcur_get_page_cur(cursor) (&(cursor)->btr_cur.page_cur) #define btr_pcur_get_page(cursor) ((cursor)->btr_cur.page_cur.block->frame) #define btr_pcur_get_block(cursor) ((cursor)->btr_cur.page_cur.block) #define btr_pcur_get_rec(cursor) ((cursor)->btr_cur.page_cur.rec) -#endif /* UNIV_DEBUG */ -/*********************************************************/ /** - Checks if the persistent cursor is on a user record. */ +#endif /* UNIV_DEBUG */ +/** Checks if the persistent cursor is on a user record. */ UNIV_INLINE ibool btr_pcur_is_on_user_rec( - /*====================*/ const btr_pcur_t *cursor); /*!< in: persistent cursor */ -/*********************************************************/ /** - Checks if the persistent cursor is after the last user record on +/** Checks if the persistent cursor is after the last user record on a page. */ UNIV_INLINE ibool btr_pcur_is_after_last_on_page( - /*===========================*/ const btr_pcur_t *cursor); /*!< in: persistent cursor */ -/*********************************************************/ /** - Checks if the persistent cursor is before the first user record on +/** Checks if the persistent cursor is before the first user record on a page. */ UNIV_INLINE ibool btr_pcur_is_before_first_on_page( - /*=============================*/ const btr_pcur_t *cursor); /*!< in: persistent cursor */ -/*********************************************************/ /** - Checks if the persistent cursor is before the first user record in +/** Checks if the persistent cursor is before the first user record in the index tree. */ UNIV_INLINE ibool btr_pcur_is_before_first_in_tree( - /*=============================*/ btr_pcur_t *cursor, /*!< in: persistent cursor */ mtr_t *mtr) /*!< in: mtr */ ; -/*********************************************************/ /** - Checks if the persistent cursor is after the last user record in +/** Checks if the persistent cursor is after the last user record in the index tree. */ UNIV_INLINE ibool btr_pcur_is_after_last_in_tree( - /*===========================*/ btr_pcur_t *cursor, /*!< in: persistent cursor */ mtr_t *mtr) /*!< in: mtr */ ; -/*********************************************************/ /** - Moves the persistent cursor to the next record on the same page. */ +/** Moves the persistent cursor to the next record on the same page. */ UNIV_INLINE void btr_pcur_move_to_next_on_page( - /*==========================*/ btr_pcur_t *cursor); /*!< in/out: persistent cursor */ -/*********************************************************/ /** - Moves the persistent cursor to the previous record on the same page. */ +/** Moves the persistent cursor to the previous record on the same page. */ UNIV_INLINE void btr_pcur_move_to_prev_on_page( - /*==========================*/ btr_pcur_t *cursor); /*!< in/out: persistent cursor */ -/*********************************************************/ /** - Moves the persistent cursor to the infimum record on the same page. */ +/** Moves the persistent cursor to the infimum record on the same page. */ UNIV_INLINE void btr_pcur_move_before_first_on_page( - /*===============================*/ btr_pcur_t *cursor); /*!< in/out: persistent cursor */ /** Position state of persistent B-tree cursor. */ diff --git a/storage/innobase/include/btr0pcur.ic b/storage/innobase/include/btr0pcur.ic index 2e575c862e22..88b9b13b0389 100644 --- a/storage/innobase/include/btr0pcur.ic +++ b/storage/innobase/include/btr0pcur.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,20 +24,17 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/btr0pcur.ic +/** @file include/btr0pcur.ic The index tree persistent cursor Created 2/23/1996 Heikki Tuuri *******************************************************/ #ifndef UNIV_HOTBACKUP -/*********************************************************/ /** - Gets the rel_pos field for a cursor whose position has been stored. +/** Gets the rel_pos field for a cursor whose position has been stored. @return BTR_PCUR_ON, ... */ UNIV_INLINE ulint btr_pcur_get_rel_pos( - /*=================*/ const btr_pcur_t *cursor) /*!< in: persistent cursor */ { ut_ad(cursor); @@ -51,35 +48,29 @@ ulint btr_pcur_get_rel_pos( #endif /* !UNIV_HOTBACKUP */ #ifdef UNIV_DEBUG -/*********************************************************/ /** - Returns the btr cursor component of a persistent cursor. +/** Returns the btr cursor component of a persistent cursor. @return pointer to btr cursor component */ UNIV_INLINE btr_cur_t *btr_pcur_get_btr_cur( - /*=================*/ const btr_pcur_t *cursor) /*!< in: persistent cursor */ { const btr_cur_t *btr_cur = &cursor->btr_cur; return ((btr_cur_t *)btr_cur); } -/*********************************************************/ /** - Returns the page cursor component of a persistent cursor. +/** Returns the page cursor component of a persistent cursor. @return pointer to page cursor component */ UNIV_INLINE page_cur_t *btr_pcur_get_page_cur( - /*==================*/ const btr_pcur_t *cursor) /*!< in: persistent cursor */ { return (btr_cur_get_page_cur(btr_pcur_get_btr_cur(cursor))); } -/*********************************************************/ /** - Returns the page of a persistent cursor. +/** Returns the page of a persistent cursor. @return pointer to the page */ UNIV_INLINE page_t *btr_pcur_get_page( - /*==============*/ const btr_pcur_t *cursor) /*!< in: persistent cursor */ { ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); @@ -87,12 +78,10 @@ page_t *btr_pcur_get_page( return (btr_cur_get_page(btr_pcur_get_btr_cur(cursor))); } -/*********************************************************/ /** - Returns the buffer block of a persistent cursor. +/** Returns the buffer block of a persistent cursor. @return pointer to the block */ UNIV_INLINE buf_block_t *btr_pcur_get_block( - /*===============*/ const btr_pcur_t *cursor) /*!< in: persistent cursor */ { ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); @@ -100,13 +89,10 @@ buf_block_t *btr_pcur_get_block( return (btr_cur_get_block(btr_pcur_get_btr_cur(cursor))); } -/*********************************************************/ /** - Returns the record of a persistent cursor. +/** Returns the record of a persistent cursor. @return pointer to the record */ UNIV_INLINE -rec_t *btr_pcur_get_rec( - /*=============*/ - const btr_pcur_t *cursor) /*!< in: persistent cursor */ +rec_t *btr_pcur_get_rec(const btr_pcur_t *cursor) /*!< in: persistent cursor */ { ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); ut_ad(cursor->latch_mode != BTR_NO_LATCHES); @@ -116,13 +102,11 @@ rec_t *btr_pcur_get_rec( #endif /* UNIV_DEBUG */ #ifndef UNIV_HOTBACKUP -/**************************************************************/ /** - Gets the up_match value for a pcur after a search. +/** Gets the up_match value for a pcur after a search. @return number of matched fields at the cursor or to the right if search mode was PAGE_CUR_GE, otherwise undefined */ UNIV_INLINE ulint btr_pcur_get_up_match( - /*==================*/ const btr_pcur_t *cursor) /*!< in: persistent cursor */ { const btr_cur_t *btr_cursor; @@ -137,13 +121,11 @@ ulint btr_pcur_get_up_match( return (btr_cursor->up_match); } -/**************************************************************/ /** - Gets the low_match value for a pcur after a search. +/** Gets the low_match value for a pcur after a search. @return number of matched fields at the cursor or to the right if search mode was PAGE_CUR_LE, otherwise undefined */ UNIV_INLINE ulint btr_pcur_get_low_match( - /*===================*/ const btr_pcur_t *cursor) /*!< in: persistent cursor */ { const btr_cur_t *btr_cursor; @@ -157,12 +139,10 @@ ulint btr_pcur_get_low_match( return (btr_cursor->low_match); } -/*********************************************************/ /** - Checks if the persistent cursor is after the last user record on +/** Checks if the persistent cursor is after the last user record on a page. */ UNIV_INLINE ibool btr_pcur_is_after_last_on_page( - /*===========================*/ const btr_pcur_t *cursor) /*!< in: persistent cursor */ { ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); @@ -171,12 +151,10 @@ ibool btr_pcur_is_after_last_on_page( return (page_cur_is_after_last(btr_pcur_get_page_cur(cursor))); } -/*********************************************************/ /** - Checks if the persistent cursor is before the first user record on +/** Checks if the persistent cursor is before the first user record on a page. */ UNIV_INLINE ibool btr_pcur_is_before_first_on_page( - /*=============================*/ const btr_pcur_t *cursor) /*!< in: persistent cursor */ { ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); @@ -185,11 +163,9 @@ ibool btr_pcur_is_before_first_on_page( return (page_cur_is_before_first(btr_pcur_get_page_cur(cursor))); } -/*********************************************************/ /** - Checks if the persistent cursor is on a user record. */ +/** Checks if the persistent cursor is on a user record. */ UNIV_INLINE ibool btr_pcur_is_on_user_rec( - /*====================*/ const btr_pcur_t *cursor) /*!< in: persistent cursor */ { ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); @@ -203,12 +179,10 @@ ibool btr_pcur_is_on_user_rec( return (TRUE); } -/*********************************************************/ /** - Checks if the persistent cursor is before the first user record in +/** Checks if the persistent cursor is before the first user record in the index tree. */ UNIV_INLINE ibool btr_pcur_is_before_first_in_tree( - /*=============================*/ btr_pcur_t *cursor, /*!< in: persistent cursor */ mtr_t *mtr) /*!< in: mtr */ { @@ -222,12 +196,10 @@ ibool btr_pcur_is_before_first_in_tree( return (page_cur_is_before_first(btr_pcur_get_page_cur(cursor))); } -/*********************************************************/ /** - Checks if the persistent cursor is after the last user record in +/** Checks if the persistent cursor is after the last user record in the index tree. */ UNIV_INLINE ibool btr_pcur_is_after_last_in_tree( - /*===========================*/ btr_pcur_t *cursor, /*!< in: persistent cursor */ mtr_t *mtr) /*!< in: mtr */ { @@ -241,11 +213,9 @@ ibool btr_pcur_is_after_last_in_tree( return (page_cur_is_after_last(btr_pcur_get_page_cur(cursor))); } -/*********************************************************/ /** - Moves the persistent cursor to the next record on the same page. */ +/** Moves the persistent cursor to the next record on the same page. */ UNIV_INLINE void btr_pcur_move_to_next_on_page( - /*==========================*/ btr_pcur_t *cursor) /*!< in/out: persistent cursor */ { ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); @@ -256,11 +226,9 @@ void btr_pcur_move_to_next_on_page( cursor->old_stored = false; } -/*********************************************************/ /** - Moves the persistent cursor to the previous record on the same page. */ +/** Moves the persistent cursor to the previous record on the same page. */ UNIV_INLINE void btr_pcur_move_to_prev_on_page( - /*==========================*/ btr_pcur_t *cursor) /*!< in/out: persistent cursor */ { ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); @@ -271,11 +239,9 @@ void btr_pcur_move_to_prev_on_page( cursor->old_stored = false; } -/*********************************************************/ /** - Moves the persistent cursor to the last record on the same page. */ +/** Moves the persistent cursor to the last record on the same page. */ UNIV_INLINE void btr_pcur_move_to_last_on_page( - /*==========================*/ btr_pcur_t *cursor, /*!< in: persistent cursor */ mtr_t *mtr) /*!< in: mtr */ { @@ -288,13 +254,11 @@ void btr_pcur_move_to_last_on_page( cursor->old_stored = false; } -/*********************************************************/ /** - Moves the persistent cursor to the next user record in the tree. If no user +/** Moves the persistent cursor to the next user record in the tree. If no user records are left, the cursor ends up 'after last in tree'. @return true if the cursor moved forward, ending on a user record */ UNIV_INLINE ibool btr_pcur_move_to_next_user_rec( - /*===========================*/ btr_pcur_t *cursor, /*!< in: persistent cursor; NOTE that the function may release the page latch */ mtr_t *mtr) /*!< in: mtr */ @@ -320,13 +284,11 @@ loop: goto loop; } -/*********************************************************/ /** - Moves the persistent cursor to the next record in the tree. If no records are - left, the cursor stays 'after last in tree'. +/** Moves the persistent cursor to the next record in the tree. If no records + are left, the cursor stays 'after last in tree'. @return true if the cursor was not after last in tree */ UNIV_INLINE ibool btr_pcur_move_to_next( - /*==================*/ btr_pcur_t *cursor, /*!< in: persistent cursor; NOTE that the function may release the page latch */ mtr_t *mtr) /*!< in: mtr */ @@ -351,16 +313,13 @@ ibool btr_pcur_move_to_next( return (TRUE); } -/**************************************************************/ /** - Commits the mtr and sets the pcur latch mode to BTR_NO_LATCHES, +/** Commits the mtr and sets the pcur latch mode to BTR_NO_LATCHES, that is, the cursor becomes detached. Function btr_pcur_store_position should be used before calling this, if restoration of cursor is wanted later. */ UNIV_INLINE -void btr_pcur_commit_specify_mtr( - /*========================*/ - btr_pcur_t *pcur, /*!< in: persistent cursor */ - mtr_t *mtr) /*!< in: mtr to commit */ +void btr_pcur_commit_specify_mtr(btr_pcur_t *pcur, /*!< in: persistent cursor */ + mtr_t *mtr) /*!< in: mtr to commit */ { ut_ad(pcur->pos_state == BTR_PCUR_IS_POSITIONED); @@ -371,12 +330,9 @@ void btr_pcur_commit_specify_mtr( pcur->pos_state = BTR_PCUR_WAS_POSITIONED; } -/**************************************************************/ /** - Sets the old_rec_buf field to NULL. */ +/** Sets the old_rec_buf field to NULL. */ UNIV_INLINE -void btr_pcur_init( - /*==========*/ - btr_pcur_t *pcur) /*!< in: persistent cursor */ +void btr_pcur_init(btr_pcur_t *pcur) /*!< in: persistent cursor */ { pcur->old_stored = false; pcur->old_rec_buf = NULL; @@ -390,12 +346,10 @@ void btr_pcur_init( UNIV_INLINE void btr_pcur_free(btr_pcur_t *pcur) { ut_free(pcur->old_rec_buf); } -/**************************************************************/ /** - Initializes and opens a persistent cursor to an index tree. It should be +/** Initializes and opens a persistent cursor to an index tree. It should be closed with btr_pcur_close. */ UNIV_INLINE void btr_pcur_open_low( - /*==============*/ dict_index_t *index, /*!< in: index */ ulint level, /*!< in: level in the btree */ const dtuple_t *tuple, /*!< in: tuple on which search done */ @@ -444,12 +398,10 @@ void btr_pcur_open_low( cursor->trx_if_known = NULL; } -/**************************************************************/ /** - Opens an persistent cursor to an index tree without initializing the +/** Opens an persistent cursor to an index tree without initializing the cursor. */ UNIV_INLINE void btr_pcur_open_with_no_init_func( - /*============================*/ dict_index_t *index, /*!< in: index */ const dtuple_t *tuple, /*!< in: tuple on which search done */ page_cur_mode_t mode, /*!< in: PAGE_CUR_L, ...; @@ -498,11 +450,9 @@ void btr_pcur_open_with_no_init_func( cursor->trx_if_known = NULL; } -/*****************************************************************/ /** - Opens a persistent cursor at either end of an index. */ +/** Opens a persistent cursor at either end of an index. */ UNIV_INLINE void btr_pcur_open_at_index_side( - /*========================*/ bool from_left, /*!< in: true if open to the low end, false if to the high end */ dict_index_t *index, /*!< in: index */ @@ -535,13 +485,11 @@ void btr_pcur_open_at_index_side( pcur->trx_if_known = NULL; } -/**********************************************************************/ /** - Positions a cursor at a randomly chosen position within a B-tree. +/** Positions a cursor at a randomly chosen position within a B-tree. @return true if the index is available and we have put the cursor, false if the index is unavailable */ UNIV_INLINE bool btr_pcur_open_at_rnd_pos_func( - /*==========================*/ dict_index_t *index, /*!< in: index */ ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ... */ btr_pcur_t *cursor, /*!< in/out: B-tree pcur */ @@ -568,8 +516,7 @@ bool btr_pcur_open_at_rnd_pos_func( return (available); } -/**************************************************************/ /** - Frees the possible memory heap of a persistent cursor and sets the latch +/** Frees the possible memory heap of a persistent cursor and sets the latch mode of the persistent cursor to BTR_NO_LATCHES. WARNING: this function does not release the latch on the page where the cursor is currently positioned. The latch is acquired by the @@ -581,9 +528,7 @@ bool btr_pcur_open_at_rnd_pos_func( A subsequent attempt to crawl the same page in the same mtr would cause an assertion failure. */ UNIV_INLINE -void btr_pcur_close( - /*===========*/ - btr_pcur_t *cursor) /*!< in: persistent cursor */ +void btr_pcur_close(btr_pcur_t *cursor) /*!< in: persistent cursor */ { ut_free(cursor->old_rec_buf); @@ -606,11 +551,9 @@ void btr_pcur_close( cursor->trx_if_known = NULL; } -/*********************************************************/ /** - Moves the persistent cursor to the infimum record on the same page. */ +/** Moves the persistent cursor to the infimum record on the same page. */ UNIV_INLINE void btr_pcur_move_before_first_on_page( - /*===============================*/ btr_pcur_t *cursor) /*!< in/out: persistent cursor */ { ut_ad(cursor->latch_mode != BTR_NO_LATCHES); diff --git a/storage/innobase/include/btr0sea.h b/storage/innobase/include/btr0sea.h index cb02b6831dc9..943d67bef7c6 100644 --- a/storage/innobase/include/btr0sea.h +++ b/storage/innobase/include/btr0sea.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file include/btr0sea.h +/** @file include/btr0sea.h The index tree adaptive search Created 2/17/1996 Heikki Tuuri @@ -59,13 +58,10 @@ void btr_search_disable(bool need_mutex); /** Enable the adaptive hash search system. */ void btr_search_enable(); -/********************************************************************/ /** - Returns search info for an index. +/** Returns search info for an index. @return search info; search mutex reserved */ UNIV_INLINE -btr_search_t *btr_search_get_info( - /*================*/ - dict_index_t *index); /*!< in: index */ +btr_search_t *btr_search_get_info(dict_index_t *index); /*!< in: index */ /** Creates and initializes a search info struct. @param[in] heap heap where created. diff --git a/storage/innobase/include/btr0sea.ic b/storage/innobase/include/btr0sea.ic index 290ab11e0df8..4fafa743f9e5 100644 --- a/storage/innobase/include/btr0sea.ic +++ b/storage/innobase/include/btr0sea.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file include/btr0sea.ic +/** @file include/btr0sea.ic The index tree adaptive search Created 2/17/1996 Heikki Tuuri @@ -35,40 +34,31 @@ this program; if not, write to the Free Software Foundation, Inc., #include "buf0buf.h" #include "dict0mem.h" -/*********************************************************************/ /** - Updates the search info. */ +/** Updates the search info. */ void btr_search_info_update_slow( - /*========================*/ btr_search_t *info, /*!< in/out: search info */ btr_cur_t *cursor); /*!< in: cursor which was just positioned */ -/********************************************************************/ /** - Returns search info for an index. +/** Returns search info for an index. @return search info; search mutex reserved */ UNIV_INLINE const btr_search_t *btr_search_get_info( - /*================*/ const dict_index_t *index) /*!< in: index */ { return (index->search_info); } -/********************************************************************/ /** - Returns search info for an index. +/** Returns search info for an index. @return search info; search mutex reserved */ UNIV_INLINE -btr_search_t *btr_search_get_info( - /*================*/ - dict_index_t *index) /*!< in: index */ +btr_search_t *btr_search_get_info(dict_index_t *index) /*!< in: index */ { return (index->search_info); } -/*********************************************************************/ /** - Updates the search info. */ +/** Updates the search info. */ UNIV_INLINE void btr_search_info_update( - /*===================*/ dict_index_t *index, /*!< in: index of the cursor */ btr_cur_t *cursor) /*!< in: cursor which was just positioned */ { diff --git a/storage/innobase/include/btr0types.h b/storage/innobase/include/btr0types.h index c1ecf498a5ee..d1abed66edc2 100644 --- a/storage/innobase/include/btr0types.h +++ b/storage/innobase/include/btr0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file include/btr0types.h +/** @file include/btr0types.h The index tree general types Created 2/17/1996 Heikki Tuuri diff --git a/storage/innobase/include/buf0buddy.h b/storage/innobase/include/buf0buddy.h index 5ec2e222377e..0647e7ef427a 100644 --- a/storage/innobase/include/buf0buddy.h +++ b/storage/innobase/include/buf0buddy.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -26,8 +26,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "my_compiler.h" -/**************************************************/ /** - @file include/buf0buddy.h +/** @file include/buf0buddy.h Binary buddy allocator for compressed pages Created December 2006 by Marko Makela diff --git a/storage/innobase/include/buf0buddy.ic b/storage/innobase/include/buf0buddy.ic index 374dff5aa57b..8411a0777844 100644 --- a/storage/innobase/include/buf0buddy.ic +++ b/storage/innobase/include/buf0buddy.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/buf0buddy.ic +/** @file include/buf0buddy.ic Binary buddy allocator for compressed pages Created December 2006 by Marko Makela @@ -56,13 +55,10 @@ void *buf_buddy_alloc_low(buf_pool_t *buf_pool, ulint i) MY_ATTRIBUTE((malloc)); void buf_buddy_free_low(buf_pool_t *buf_pool, void *buf, ulint i, bool has_zip_free); -/**********************************************************************/ /** - Get the index of buf_pool->zip_free[] for a given block size. +/** Get the index of buf_pool->zip_free[] for a given block size. @return index of buf_pool->zip_free[], or BUF_BUDDY_SIZES */ UNIV_INLINE -ulint buf_buddy_get_slot( - /*===============*/ - ulint size) /*!< in: block size */ +ulint buf_buddy_get_slot(ulint size) /*!< in: block size */ { ulint i; ulint s; diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 1415ebea12ae..731a58372b8e 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/buf0buf.h +/** @file include/buf0buf.h The database buffer pool high-level routines Created 11/5/1995 Heikki Tuuri @@ -222,19 +221,13 @@ struct buf_pools_list_size_t { }; #ifndef UNIV_HOTBACKUP -/********************************************************************/ /** - Creates the buffer pool. +/** Creates the buffer pool. @return DB_SUCCESS if success, DB_ERROR if not enough memory or error */ -dberr_t buf_pool_init( - /*=========*/ - ulint size, /*!< in: Size of the total pool in bytes */ - ulint n_instances); /*!< in: Number of instances */ -/********************************************************************/ /** - Frees the buffer pool at shutdown. This must not be invoked before +dberr_t buf_pool_init(ulint size, /*!< in: Size of the total pool in bytes */ + ulint n_instances); /*!< in: Number of instances */ +/** Frees the buffer pool at shutdown. This must not be invoked before freeing all mutexes. */ -void buf_pool_free( - /*==========*/ - ulint n_instances); /*!< in: numbere of instances to free */ +void buf_pool_free(ulint n_instances); /*!< in: numbere of instances to free */ /** Determines if a block is intended to be withdrawn. @param[in] buf_pool buffer pool instance @@ -252,61 +245,43 @@ bool buf_frame_will_withdrawn(buf_pool_t *buf_pool, const byte *ptr); when waked up either performs a resizing and sleeps again. */ void buf_resize_thread(); -/********************************************************************/ /** - Clears the adaptive hash index on all pages in the buffer pool. */ +/** Clears the adaptive hash index on all pages in the buffer pool. */ void buf_pool_clear_hash_index(void); -/*===========================*/ -/*********************************************************************/ /** - Gets the current size of buffer buf_pool in bytes. +/** Gets the current size of buffer buf_pool in bytes. @return size in bytes */ UNIV_INLINE ulint buf_pool_get_curr_size(void); -/*========================*/ -/*********************************************************************/ /** - Gets the current size of buffer buf_pool in frames. +/** Gets the current size of buffer buf_pool in frames. @return size in pages */ UNIV_INLINE ulint buf_pool_get_n_pages(void); -/*=======================*/ #endif /* !UNIV_HOTBACKUP */ -/********************************************************************/ /** - Gets the smallest oldest_modification lsn for any page in the pool. Returns +/** Gets the smallest oldest_modification lsn for any page in the pool. Returns zero if all modified pages have been flushed to disk. @return oldest modification in pool, zero if none */ lsn_t buf_pool_get_oldest_modification(void); #ifndef UNIV_HOTBACKUP -/*==================================*/ -/********************************************************************/ /** - Allocates a buf_page_t descriptor. This function must succeed. In case +/** Allocates a buf_page_t descriptor. This function must succeed. In case of failure we assert in this function. */ UNIV_INLINE -buf_page_t *buf_page_alloc_descriptor(void) - /*===========================*/ - MY_ATTRIBUTE((malloc)); -/********************************************************************/ /** - Free a buf_page_t descriptor. */ +buf_page_t *buf_page_alloc_descriptor(void) MY_ATTRIBUTE((malloc)); +/** Free a buf_page_t descriptor. */ UNIV_INLINE void buf_page_free_descriptor( - /*=====================*/ buf_page_t *bpage); /*!< in: bpage descriptor to free. */ -/********************************************************************/ /** - Allocates a buffer block. +/** Allocates a buffer block. @return own: the allocated block, in state BUF_BLOCK_MEMORY */ buf_block_t *buf_block_alloc( - /*============*/ buf_pool_t *buf_pool); /*!< in: buffer pool instance, or NULL for round-robin selection of the buffer pool */ -/********************************************************************/ /** - Frees a buffer block which does not contain a file page. */ +/** Frees a buffer block which does not contain a file page. */ UNIV_INLINE -void buf_block_free( - /*===========*/ - buf_block_t *block); /*!< in, own: block to be freed */ -#endif /* !UNIV_HOTBACKUP */ +void buf_block_free(buf_block_t *block); /*!< in, own: block to be freed */ +#endif /* !UNIV_HOTBACKUP */ /** Copies contents of a buffer frame to a given buffer. @param[in] buf buffer to copy to @@ -316,14 +291,12 @@ UNIV_INLINE byte *buf_frame_copy(byte *buf, const buf_frame_t *frame); #ifndef UNIV_HOTBACKUP -/**************************************************************/ /** - NOTE! The following macros should be used instead of buf_page_get_gen, +/** NOTE! The following macros should be used instead of buf_page_get_gen, to improve debugging. Only values RW_S_LATCH and RW_X_LATCH are allowed in LA! */ #define buf_page_get(ID, SIZE, LA, MTR) \ buf_page_get_gen(ID, SIZE, LA, NULL, BUF_GET, __FILE__, __LINE__, MTR) -/**************************************************************/ /** - Use these macros to bufferfix a page with no latching. Remember not to +/** Use these macros to bufferfix a page with no latching. Remember not to read the contents of the page unless you know it is safe. Do not modify the contents of the page! We have separated this case, because it is error-prone programming not to set a latch, and it should be used @@ -331,24 +304,20 @@ byte *buf_frame_copy(byte *buf, const buf_frame_t *frame); #define buf_page_get_with_no_latch(ID, SIZE, MTR) \ buf_page_get_gen(ID, SIZE, RW_NO_LATCH, NULL, BUF_GET_NO_LATCH, __FILE__, \ __LINE__, MTR) -/********************************************************************/ /** - This is the general function used to get optimistic access to a database +/** This is the general function used to get optimistic access to a database page. @return true if success */ ibool buf_page_optimistic_get( - /*====================*/ ulint rw_latch, /*!< in: RW_S_LATCH, RW_X_LATCH */ buf_block_t *block, /*!< in: guessed block */ ib_uint64_t modify_clock, /*!< in: modify clock value */ const char *file, /*!< in: file name */ ulint line, /*!< in: line where called */ mtr_t *mtr); /*!< in: mini-transaction */ -/********************************************************************/ /** - This is used to get access to a known database page, when no waiting can be +/** This is used to get access to a known database page, when no waiting can be done. @return true if success */ ibool buf_page_get_known_nowait( - /*======================*/ ulint rw_latch, /*!< in: RW_S_LATCH, RW_X_LATCH */ buf_block_t *block, /*!< in: the known page */ ulint mode, /*!< in: BUF_MAKE_YOUNG or BUF_KEEP_OLD */ @@ -432,12 +401,9 @@ void meb_page_init(const page_id_t &page_id, const page_size_t &page_size, #endif /* !UNIV_HOTBACKUP */ #ifndef UNIV_HOTBACKUP -/********************************************************************/ /** - Releases a compressed-only page acquired with buf_page_get_zip(). */ +/** Releases a compressed-only page acquired with buf_page_get_zip(). */ UNIV_INLINE -void buf_page_release_zip( - /*=================*/ - buf_page_t *bpage); /*!< in: buffer block */ +void buf_page_release_zip(buf_page_t *bpage); /*!< in: buffer block */ /** Releases a latch, if specified. @param[in] block buffer block @@ -478,21 +444,15 @@ reallocated. buf_page_t *buf_page_reset_file_page_was_freed(const page_id_t &page_id); #endif /* UNIV_DEBUG */ -/********************************************************************/ /** - Reads the freed_page_clock of a buffer block. +/** Reads the freed_page_clock of a buffer block. @return freed_page_clock */ UNIV_INLINE -ulint buf_page_get_freed_page_clock( - /*==========================*/ - const buf_page_t *bpage) /*!< in: block */ +ulint buf_page_get_freed_page_clock(const buf_page_t *bpage) /*!< in: block */ MY_ATTRIBUTE((warn_unused_result)); -/********************************************************************/ /** - Reads the freed_page_clock of a buffer block. +/** Reads the freed_page_clock of a buffer block. @return freed_page_clock */ UNIV_INLINE -ulint buf_block_get_freed_page_clock( - /*===========================*/ - const buf_block_t *block) /*!< in: block */ +ulint buf_block_get_freed_page_clock(const buf_block_t *block) /*!< in: block */ MY_ATTRIBUTE((warn_unused_result)); /** Tells, for heuristics, if a block is still close enough to the MRU end of @@ -512,13 +472,11 @@ NOTE: does not reserve the LRU list mutex. UNIV_INLINE ibool buf_page_peek_if_too_old(const buf_page_t *bpage); -/********************************************************************/ /** - Gets the youngest modification log sequence number for a frame. +/** Gets the youngest modification log sequence number for a frame. Returns zero if not file page or no modification occurred yet. @return newest modification to page */ UNIV_INLINE lsn_t buf_page_get_newest_modification( - /*=============================*/ const buf_page_t *bpage); /*!< in: block containing the page frame */ @@ -605,14 +563,11 @@ pointing to a buffer frame containing a file page. UNIV_INLINE void buf_ptr_get_fsp_addr(const void *ptr, space_id_t *space, fil_addr_t *addr); -/**********************************************************************/ /** - Gets the hash value of a block. This can be used in searches in the +/** Gets the hash value of a block. This can be used in searches in the lock hash table. @return lock hash value */ UNIV_INLINE -ulint buf_block_get_lock_hash_val( - /*========================*/ - const buf_block_t *block) /*!< in: block */ +ulint buf_block_get_lock_hash_val(const buf_block_t *block) /*!< in: block */ MY_ATTRIBUTE((warn_unused_result)); #ifdef UNIV_DEBUG /** Finds a block in the buffer pool that points to a @@ -628,22 +583,17 @@ buf_block_t *buf_pool_contains_zip(buf_pool_t *buf_pool, const void *data); FIXME_FTS: Gets the frame the pointer is pointing to. */ UNIV_INLINE buf_frame_t *buf_frame_align( - /*============*/ /* out: pointer to frame */ byte *ptr); /* in: pointer to a frame */ #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG -/*********************************************************************/ /** - Validates the buffer pool data structure. +/** Validates the buffer pool data structure. @return true */ ibool buf_validate(void); -/*==============*/ #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ #if defined UNIV_DEBUG_PRINT || defined UNIV_DEBUG || defined UNIV_BUF_DEBUG -/*********************************************************************/ /** - Prints info of the buffer pool data structure. */ +/** Prints info of the buffer pool data structure. */ void buf_print(void); -/*============*/ #endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */ #endif /* !UNIV_HOTBACKUP */ enum buf_page_print_flags { @@ -661,37 +611,25 @@ BUF_PAGE_PRINT_NO_FULL */ void buf_page_print(const byte *read_buf, const page_size_t &page_size, ulint flags); -/********************************************************************/ /** - Decompress a block. +/** Decompress a block. @return true if successful */ -ibool buf_zip_decompress( - /*===============*/ - buf_block_t *block, /*!< in/out: block */ - ibool check); /*!< in: TRUE=verify the page checksum */ +ibool buf_zip_decompress(buf_block_t *block, /*!< in/out: block */ + ibool check); /*!< in: TRUE=verify the page checksum */ #ifndef UNIV_HOTBACKUP #ifdef UNIV_DEBUG -/*********************************************************************/ /** - Returns the number of latched pages in the buffer pool. +/** Returns the number of latched pages in the buffer pool. @return number of latched pages */ ulint buf_get_latched_pages_number(void); -/*==============================*/ #endif /* UNIV_DEBUG */ -/*********************************************************************/ /** - Returns the number of pending buf pool read ios. +/** Returns the number of pending buf pool read ios. @return number of pending read I/O operations */ ulint buf_get_n_pending_read_ios(void); -/*============================*/ -/*********************************************************************/ /** - Prints info of the buffer i/o. */ -void buf_print_io( - /*=========*/ - FILE *file); /*!< in: file where to print */ -/*******************************************************************/ /** - Collect buffer pool stats information for a buffer pool. Also +/** Prints info of the buffer i/o. */ +void buf_print_io(FILE *file); /*!< in: file where to print */ +/** Collect buffer pool stats information for a buffer pool. Also record aggregated stats if there are more than one buffer pool in the server */ void buf_stats_get_pool_info( - /*====================*/ buf_pool_t *buf_pool, /*!< in: buffer pool */ ulint pool_id, /*!< in: buffer pool ID */ buf_pool_info_t *all_pool_info); /*!< in/out: buffer pool info @@ -700,7 +638,6 @@ void buf_stats_get_pool_info( database pages in the buffer pool. @return modified page percentage ratio */ double buf_get_modified_ratio_pct(void); -/*============================*/ /** Refresh the statistics used to print per-second averages. */ void buf_refresh_io_stats_all(); /** Assert that all file pages in the buffer are in a replaceable state. @@ -712,12 +649,10 @@ pool. @return number of pending i/o */ ulint buf_pool_check_no_pending_io(void); -/*********************************************************************/ /** - Invalidates the file pages in the buffer pool when an archive recovery is +/** Invalidates the file pages in the buffer pool when an archive recovery is completed. All the file pages buffered must be in a replaceable state when this function is called: not latched and not modified. */ void buf_pool_invalidate(void); -/*=====================*/ #endif /* !UNIV_HOTBACKUP */ /*======================================================================== @@ -736,19 +671,15 @@ void buf_block_dbg_add_level(buf_block_t *block, latch_level_t level); #define buf_block_dbg_add_level(block, level) /* nothing */ #endif /* UNIV_DEBUG */ -/*********************************************************************/ /** - Gets the state of a block. +/** Gets the state of a block. @return state */ UNIV_INLINE enum buf_page_state buf_page_get_state( - /*===============*/ const buf_page_t *bpage); /*!< in: pointer to the control block */ -/*********************************************************************/ /** - Gets the state of a block. +/** Gets the state of a block. @return state */ UNIV_INLINE enum buf_page_state buf_block_get_state( - /*================*/ const buf_block_t *block) /*!< in: pointer to the control block */ MY_ATTRIBUTE((warn_unused_result)); @@ -764,39 +695,31 @@ void buf_page_set_state(buf_page_t *bpage, enum buf_page_state state); UNIV_INLINE void buf_block_set_state(buf_block_t *block, enum buf_page_state state); -/*********************************************************************/ /** - Determines if a block is mapped to a tablespace. +/** Determines if a block is mapped to a tablespace. @return true if mapped */ UNIV_INLINE ibool buf_page_in_file( - /*=============*/ const buf_page_t *bpage) /*!< in: pointer to control block */ MY_ATTRIBUTE((warn_unused_result)); #ifndef UNIV_HOTBACKUP -/*********************************************************************/ /** - Determines if a block should be on unzip_LRU list. +/** Determines if a block should be on unzip_LRU list. @return true if block belongs to unzip_LRU */ UNIV_INLINE ibool buf_page_belongs_to_unzip_LRU( - /*==========================*/ const buf_page_t *bpage) /*!< in: pointer to control block */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Gets the mutex of a block. +/** Gets the mutex of a block. @return pointer to mutex protecting bpage */ UNIV_INLINE BPageMutex *buf_page_get_mutex( - /*===============*/ const buf_page_t *bpage) /*!< in: pointer to control block */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Get the flush type of a page. +/** Get the flush type of a page. @return flush type */ UNIV_INLINE buf_flush_t buf_page_get_flush_type( - /*====================*/ const buf_page_t *bpage) /*!< in: buffer page */ MY_ATTRIBUTE((warn_unused_result)); @@ -812,20 +735,16 @@ void buf_page_set_flush_type(buf_page_t *bpage, buf_flush_t flush_type); UNIV_INLINE void buf_block_set_file_page(buf_block_t *block, const page_id_t &page_id); -/*********************************************************************/ /** - Gets the io_fix state of a block. +/** Gets the io_fix state of a block. @return io_fix state */ UNIV_INLINE enum buf_io_fix buf_page_get_io_fix( - /*================*/ const buf_page_t *bpage) /*!< in: pointer to the control block */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Gets the io_fix state of a block. +/** Gets the io_fix state of a block. @return io_fix state */ UNIV_INLINE enum buf_io_fix buf_block_get_io_fix( - /*================*/ const buf_block_t *block) /*!< in: pointer to the control block */ MY_ATTRIBUTE((warn_unused_result)); @@ -853,18 +772,13 @@ Note that: UNIV_INLINE void buf_page_set_sticky(buf_page_t *bpage); -/*********************************************************************/ /** - Removes stickiness of a block. */ +/** Removes stickiness of a block. */ UNIV_INLINE -void buf_page_unset_sticky( - /*==================*/ - buf_page_t *bpage); /*!< in/out: control block */ -/********************************************************************/ /** - Determine if a buffer block can be relocated in memory. The block +void buf_page_unset_sticky(buf_page_t *bpage); /*!< in/out: control block */ +/** Determine if a buffer block can be relocated in memory. The block can be dirty, but it must not be I/O-fixed or bufferfixed. */ UNIV_INLINE ibool buf_page_can_relocate( - /*==================*/ const buf_page_t *bpage) /*!< control block being relocated */ MY_ATTRIBUTE((warn_unused_result)); @@ -881,20 +795,14 @@ ibool buf_page_is_old(const buf_page_t *bpage) UNIV_INLINE void buf_page_set_old(buf_page_t *bpage, ibool old); -/*********************************************************************/ /** - Determine the time of first access of a block in the buffer pool. +/** Determine the time of first access of a block in the buffer pool. @return ut_time_ms() at the time of first access, 0 if not accessed */ UNIV_INLINE -unsigned buf_page_is_accessed( - /*=================*/ - const buf_page_t *bpage) /*!< in: control block */ +unsigned buf_page_is_accessed(const buf_page_t *bpage) /*!< in: control block */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Flag a block accessed. */ +/** Flag a block accessed. */ UNIV_INLINE -void buf_page_set_accessed( - /*==================*/ - buf_page_t *bpage); /*!< in/out: control block */ +void buf_page_set_accessed(buf_page_t *bpage); /*!< in/out: control block */ /** Gets the buf_block_t handle of a buffered file block if an uncompressed page frame exists, or NULL. page frame exists, or NULL. The caller must hold @@ -907,12 +815,10 @@ UNIV_INLINE buf_block_t *buf_page_get_block(buf_page_t *bpage) MY_ATTRIBUTE((warn_unused_result)); #ifdef UNIV_DEBUG -/*********************************************************************/ /** - Gets a pointer to the memory frame of a block. +/** Gets a pointer to the memory frame of a block. @return pointer to the frame */ UNIV_INLINE buf_frame_t *buf_block_get_frame( - /*================*/ const buf_block_t *block) /*!< in: pointer to the control block */ MY_ATTRIBUTE((warn_unused_result)); #else /* UNIV_DEBUG */ @@ -921,8 +827,7 @@ buf_frame_t *buf_block_get_frame( #else /* !UNIV_HOTBACKUP */ #define buf_block_get_frame(block) (block)->frame #endif /* !UNIV_HOTBACKUP */ -/*********************************************************************/ /** - Gets the compressed page descriptor corresponding to an uncompressed page +/** Gets the compressed page descriptor corresponding to an uncompressed page if applicable. */ #define buf_block_get_page_zip(block) \ ((block)->page.zip.data ? &(block)->page.zip : NULL) @@ -934,14 +839,11 @@ This function does not return if the block is not identified. buf_block_t *buf_block_from_ahi(const byte *ptr); #ifndef UNIV_HOTBACKUP -/********************************************************************/ /** - Find out if a pointer belongs to a buf_block_t. It can be a pointer to +/** Find out if a pointer belongs to a buf_block_t. It can be a pointer to the buf_block_t itself or a member of it @return true if ptr belongs to a buf_block_t struct */ -ibool buf_pointer_is_block_field( - /*=======================*/ - const void *ptr); /*!< in: pointer not - dereferenced */ +ibool buf_pointer_is_block_field(const void *ptr); /*!< in: pointer not + dereferenced */ /** Find out if a pointer corresponds to a buf_block_t::mutex. @param m in: mutex candidate @return true if m is a buf_block_t::mutex */ @@ -976,28 +878,20 @@ the buffer pool. @return true if successful */ bool buf_page_io_complete(buf_page_t *bpage, bool evict = false); -/********************************************************************/ /** - Calculates the index of a buffer pool to the buf_pool[] array. +/** Calculates the index of a buffer pool to the buf_pool[] array. @return the position of the buffer pool in buf_pool[] */ UNIV_INLINE -ulint buf_pool_index( - /*===========*/ - const buf_pool_t *buf_pool) /*!< in: buffer pool */ +ulint buf_pool_index(const buf_pool_t *buf_pool) /*!< in: buffer pool */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************************/ /** - Returns the buffer pool instance given a page instance +/** Returns the buffer pool instance given a page instance @return buf_pool */ UNIV_INLINE buf_pool_t *buf_pool_from_bpage( - /*================*/ const buf_page_t *bpage); /*!< in: buffer pool page */ -/******************************************************************/ /** - Returns the buffer pool instance given a block instance +/** Returns the buffer pool instance given a block instance @return buf_pool */ UNIV_INLINE -buf_pool_t *buf_pool_from_block( - /*================*/ - const buf_block_t *block); /*!< in: block */ +buf_pool_t *buf_pool_from_block(const buf_block_t *block); /*!< in: block */ /** Returns the buffer pool instance given a page id. @param[in] page_id page id @@ -1005,14 +899,11 @@ buf_pool_t *buf_pool_from_block( UNIV_INLINE buf_pool_t *buf_pool_get(const page_id_t &page_id); -/******************************************************************/ /** - Returns the buffer pool instance given its array index +/** Returns the buffer pool instance given its array index @return buffer pool */ UNIV_INLINE -buf_pool_t *buf_pool_from_array( - /*================*/ - ulint index); /*!< in: array index to get - buffer pool instance from */ +buf_pool_t *buf_pool_from_array(ulint index); /*!< in: array index to get + buffer pool instance from */ /** Returns the control block of a file page, NULL if not found. @param[in] buf_pool buffer pool instance @@ -1085,17 +976,13 @@ buf_page_hash_get_low() function. #define buf_block_hash_get(b, page_id) \ buf_block_hash_get_locked(b, page_id, NULL, 0) -/*********************************************************************/ /** - Gets the current length of the free list of buffer blocks. +/** Gets the current length of the free list of buffer blocks. @return length of the free list */ ulint buf_get_free_list_len(void); -/*=======================*/ -/********************************************************************/ /** - Determine if a block is a sentinel for a buffer pool watch. +/** Determine if a block is a sentinel for a buffer pool watch. @return true if a sentinel for a buffer pool watch, false if not */ ibool buf_pool_watch_is_sentinel( - /*=======================*/ const buf_pool_t *buf_pool, /*!< buffer pool instance */ const buf_page_t *bpage) /*!< in: block */ MY_ATTRIBUTE((warn_unused_result)); @@ -1113,23 +1000,17 @@ has returned NULL and before invoking buf_pool_watch_unset(space,offset). ibool buf_pool_watch_occurred(const page_id_t &page_id) MY_ATTRIBUTE((warn_unused_result)); -/********************************************************************/ /** - Get total buffer pool statistics. */ +/** Get total buffer pool statistics. */ void buf_get_total_list_len( - /*===================*/ ulint *LRU_len, /*!< out: length of all LRU lists */ ulint *free_len, /*!< out: length of all free lists */ ulint *flush_list_len); /*!< out: length of all flush lists */ -/********************************************************************/ /** - Get total list size in bytes from all buffer pools. */ +/** Get total list size in bytes from all buffer pools. */ void buf_get_total_list_size_in_bytes( - /*=============================*/ buf_pools_list_size_t *buf_pools_list_size); /*!< out: list sizes in all buffer pools */ -/********************************************************************/ /** - Get total buffer pool statistics. */ +/** Get total buffer pool statistics. */ void buf_get_total_stat( - /*===============*/ buf_pool_stat_t *tot_stat); /*!< out: buffer pool stats */ /** Get the nth chunk's buffer block in the specified buffer pool. @@ -1546,8 +1427,7 @@ struct buf_block_t { (buf_block_get_state(block) >= BUF_BLOCK_NOT_USED && \ (buf_block_get_state(block) <= BUF_BLOCK_REMOVE_HASH)) -/**********************************************************************/ /** - Compute the hash fold value for blocks in buf_pool->zip_hash. */ +/** Compute the hash fold value for blocks in buf_pool->zip_hash. */ /* @{ */ #define BUF_POOL_ZIP_FOLD_PTR(ptr) ((ulint)(ptr) / UNIV_PAGE_SIZE) #define BUF_POOL_ZIP_FOLD(b) BUF_POOL_ZIP_FOLD_PTR((b)->frame) diff --git a/storage/innobase/include/buf0buf.ic b/storage/innobase/include/buf0buf.ic index c7107936c114..c3f8aca835a9 100644 --- a/storage/innobase/include/buf0buf.ic +++ b/storage/innobase/include/buf0buf.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -31,8 +31,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/buf0buf.ic +/** @file include/buf0buf.ic The database buffer buf_pool Created 11/5/1995 Heikki Tuuri @@ -63,24 +62,16 @@ struct buf_chunk_t { size_t mem_size() const { return (mem_pfx.m_size); } }; -/*********************************************************************/ /** - Gets the current size of buffer buf_pool in bytes. +/** Gets the current size of buffer buf_pool in bytes. @return size in bytes */ UNIV_INLINE -ulint buf_pool_get_curr_size(void) -/*========================*/ -{ - return (srv_buf_pool_curr_size); -} +ulint buf_pool_get_curr_size(void) { return (srv_buf_pool_curr_size); } #ifndef UNIV_HOTBACKUP -/********************************************************************/ /** - Calculates the index of a buffer pool to the buf_pool[] array. +/** Calculates the index of a buffer pool to the buf_pool[] array. @return the position of the buffer pool in buf_pool[] */ UNIV_INLINE -ulint buf_pool_index( - /*===========*/ - const buf_pool_t *buf_pool) /*!< in: buffer pool */ +ulint buf_pool_index(const buf_pool_t *buf_pool) /*!< in: buffer pool */ { ulint i = buf_pool - buf_pool_ptr; ut_ad(i < MAX_BUFFER_POOLS); @@ -88,12 +79,10 @@ ulint buf_pool_index( return (i); } -/******************************************************************/ /** - Returns the buffer pool instance given a page instance +/** Returns the buffer pool instance given a page instance @return buf_pool */ UNIV_INLINE buf_pool_t *buf_pool_from_bpage( - /*================*/ const buf_page_t *bpage) /*!< in: buffer pool page */ { ulint i; @@ -102,46 +91,34 @@ buf_pool_t *buf_pool_from_bpage( return (&buf_pool_ptr[i]); } -/******************************************************************/ /** - Returns the buffer pool instance given a block instance +/** Returns the buffer pool instance given a block instance @return buf_pool */ UNIV_INLINE -buf_pool_t *buf_pool_from_block( - /*================*/ - const buf_block_t *block) /*!< in: block */ +buf_pool_t *buf_pool_from_block(const buf_block_t *block) /*!< in: block */ { return (buf_pool_from_bpage(&block->page)); } -/*********************************************************************/ /** - Gets the current size of buffer buf_pool in pages. +/** Gets the current size of buffer buf_pool in pages. @return size in pages*/ UNIV_INLINE -ulint buf_pool_get_n_pages(void) -/*======================*/ -{ +ulint buf_pool_get_n_pages(void) { return (buf_pool_get_curr_size() / UNIV_PAGE_SIZE); } -/********************************************************************/ /** - Reads the freed_page_clock of a buffer block. +/** Reads the freed_page_clock of a buffer block. @return freed_page_clock */ UNIV_INLINE -ulint buf_page_get_freed_page_clock( - /*==========================*/ - const buf_page_t *bpage) /*!< in: block */ +ulint buf_page_get_freed_page_clock(const buf_page_t *bpage) /*!< in: block */ { /* This is sometimes read without holding any buffer pool mutex. */ return (bpage->freed_page_clock); } -/********************************************************************/ /** - Reads the freed_page_clock of a buffer block. +/** Reads the freed_page_clock of a buffer block. @return freed_page_clock */ UNIV_INLINE -ulint buf_block_get_freed_page_clock( - /*===========================*/ - const buf_block_t *block) /*!< in: block */ +ulint buf_block_get_freed_page_clock(const buf_block_t *block) /*!< in: block */ { return (buf_page_get_freed_page_clock(&block->page)); } @@ -203,12 +180,10 @@ ibool buf_page_peek_if_too_old(const buf_page_t *bpage) { } #endif /* !UNIV_HOTBACKUP */ -/*********************************************************************/ /** - Gets the state of a block. +/** Gets the state of a block. @return state */ UNIV_INLINE enum buf_page_state buf_page_get_state( - /*===============*/ const buf_page_t *bpage) /*!< in: pointer to the control block */ { enum buf_page_state state = bpage->state; @@ -231,12 +206,10 @@ enum buf_page_state buf_page_get_state( return (state); } -/*********************************************************************/ /** - Gets the state of a block. +/** Gets the state of a block. @return state */ UNIV_INLINE enum buf_page_state buf_block_get_state( - /*================*/ const buf_block_t *block) /*!< in: pointer to the control block */ { return (buf_page_get_state(&block->page)); @@ -334,23 +307,19 @@ void buf_page_set_state(buf_page_t *bpage, enum buf_page_state state) { ut_ad(buf_page_get_state(bpage) == state); } -/*********************************************************************/ /** - Sets the state of a block. */ +/** Sets the state of a block. */ UNIV_INLINE void buf_block_set_state( - /*================*/ buf_block_t *block, /*!< in/out: pointer to control block */ enum buf_page_state state) /*!< in: state */ { buf_page_set_state(&block->page, state); } -/*********************************************************************/ /** - Determines if a block is mapped to a tablespace. +/** Determines if a block is mapped to a tablespace. @return true if mapped */ UNIV_INLINE ibool buf_page_in_file( - /*=============*/ const buf_page_t *bpage) /*!< in: pointer to control block */ { switch (buf_page_get_state(bpage)) { @@ -372,12 +341,10 @@ ibool buf_page_in_file( } #ifndef UNIV_HOTBACKUP -/*********************************************************************/ /** - Determines if a block should be on unzip_LRU list. +/** Determines if a block should be on unzip_LRU list. @return true if block belongs to unzip_LRU */ UNIV_INLINE ibool buf_page_belongs_to_unzip_LRU( - /*==========================*/ const buf_page_t *bpage) /*!< in: pointer to control block */ { ut_ad(buf_page_in_file(bpage)); @@ -385,12 +352,10 @@ ibool buf_page_belongs_to_unzip_LRU( return (bpage->zip.data && buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE); } -/*********************************************************************/ /** - Gets the mutex of a block. +/** Gets the mutex of a block. @return pointer to mutex protecting bpage */ UNIV_INLINE BPageMutex *buf_page_get_mutex( - /*===============*/ const buf_page_t *bpage) /*!< in: pointer to control block */ { buf_pool_t *buf_pool = buf_pool_from_bpage(bpage); @@ -407,12 +372,10 @@ BPageMutex *buf_page_get_mutex( } } -/*********************************************************************/ /** - Get the flush type of a page. +/** Get the flush type of a page. @return flush type */ UNIV_INLINE buf_flush_t buf_page_get_flush_type( - /*====================*/ const buf_page_t *bpage) /*!< in: buffer page */ { buf_flush_t flush_type = (buf_flush_t)bpage->flush_type; @@ -430,13 +393,10 @@ buf_flush_t buf_page_get_flush_type( #endif /* UNIV_DEBUG */ return (flush_type); } -/*********************************************************************/ /** - Set the flush type of a page. */ +/** Set the flush type of a page. */ UNIV_INLINE -void buf_page_set_flush_type( - /*====================*/ - buf_page_t *bpage, /*!< in: buffer page */ - buf_flush_t flush_type) /*!< in: flush type */ +void buf_page_set_flush_type(buf_page_t *bpage, /*!< in: buffer page */ + buf_flush_t flush_type) /*!< in: flush type */ { bpage->flush_type = flush_type; ut_ad(buf_page_get_flush_type(bpage) == flush_type); @@ -451,12 +411,10 @@ void buf_block_set_file_page(buf_block_t *block, const page_id_t &page_id) { block->page.id.copy_from(page_id); } -/*********************************************************************/ /** - Gets the io_fix state of a block. +/** Gets the io_fix state of a block. @return io_fix state */ UNIV_INLINE enum buf_io_fix buf_page_get_io_fix( - /*================*/ const buf_page_t *bpage) /*!< in: pointer to the control block */ { ut_ad(mutex_own(buf_page_get_mutex(bpage))); @@ -487,12 +445,10 @@ enum buf_io_fix buf_page_get_io_fix_unlocked(const buf_page_t *bpage) { return (io_fix); } -/*********************************************************************/ /** - Gets the io_fix state of a block. +/** Gets the io_fix state of a block. @return io_fix state */ UNIV_INLINE enum buf_io_fix buf_block_get_io_fix( - /*=================*/ const buf_block_t *block) /*!< in: pointer to the control block */ { return (buf_page_get_io_fix(&block->page)); @@ -508,13 +464,10 @@ enum buf_io_fix buf_block_get_io_fix_unlocked(const buf_block_t *block) { return (buf_page_get_io_fix_unlocked(&block->page)); } -/*********************************************************************/ /** - Sets the io_fix state of a block. */ +/** Sets the io_fix state of a block. */ UNIV_INLINE -void buf_page_set_io_fix( - /*================*/ - buf_page_t *bpage, /*!< in/out: control block */ - enum buf_io_fix io_fix) /*!< in: io_fix state */ +void buf_page_set_io_fix(buf_page_t *bpage, /*!< in/out: control block */ + enum buf_io_fix io_fix) /*!< in: io_fix state */ { ut_ad(mutex_own(buf_page_get_mutex(bpage))); @@ -522,13 +475,10 @@ void buf_page_set_io_fix( ut_ad(buf_page_get_io_fix(bpage) == io_fix); } -/*********************************************************************/ /** - Sets the io_fix state of a block. */ +/** Sets the io_fix state of a block. */ UNIV_INLINE -void buf_block_set_io_fix( - /*=================*/ - buf_block_t *block, /*!< in/out: control block */ - enum buf_io_fix io_fix) /*!< in: io_fix state */ +void buf_block_set_io_fix(buf_block_t *block, /*!< in/out: control block */ + enum buf_io_fix io_fix) /*!< in: io_fix state */ { buf_page_set_io_fix(&block->page, io_fix); } @@ -556,12 +506,9 @@ void buf_page_set_sticky(buf_page_t *bpage) { bpage->io_fix = BUF_IO_PIN; } -/*********************************************************************/ /** - Removes stickiness of a block. */ +/** Removes stickiness of a block. */ UNIV_INLINE -void buf_page_unset_sticky( - /*==================*/ - buf_page_t *bpage) /*!< in/out: control block */ +void buf_page_unset_sticky(buf_page_t *bpage) /*!< in/out: control block */ { ut_ad(mutex_own(buf_page_get_mutex(bpage))); ut_ad(buf_page_get_io_fix(bpage) == BUF_IO_PIN); @@ -569,12 +516,10 @@ void buf_page_unset_sticky( bpage->io_fix = BUF_IO_NONE; } -/********************************************************************/ /** - Determine if a buffer block can be relocated in memory. The block +/** Determine if a buffer block can be relocated in memory. The block can be dirty, but it must not be I/O-fixed or bufferfixed. */ UNIV_INLINE ibool buf_page_can_relocate( - /*==================*/ const buf_page_t *bpage) /*!< control block being relocated */ { ut_ad(mutex_own(buf_page_get_mutex(bpage))); @@ -635,25 +580,19 @@ void buf_page_set_old(buf_page_t *bpage, ibool old) { bpage->old = old; } -/*********************************************************************/ /** - Determine the time of first access of a block in the buffer pool. +/** Determine the time of first access of a block in the buffer pool. @return ut_time_ms() at the time of first access, 0 if not accessed */ UNIV_INLINE -unsigned buf_page_is_accessed( - /*=================*/ - const buf_page_t *bpage) /*!< in: control block */ +unsigned buf_page_is_accessed(const buf_page_t *bpage) /*!< in: control block */ { ut_ad(buf_page_in_file(bpage)); return (bpage->access_time); } -/*********************************************************************/ /** - Flag a block accessed. */ +/** Flag a block accessed. */ UNIV_INLINE -void buf_page_set_accessed( - /*==================*/ - buf_page_t *bpage) /*!< in/out: control block */ +void buf_page_set_accessed(buf_page_t *bpage) /*!< in/out: control block */ { ut_ad(mutex_own(buf_page_get_mutex(bpage))); @@ -695,12 +634,10 @@ buf_block_t *buf_page_get_block(buf_page_t *bpage) { #ifndef UNIV_HOTBACKUP #ifdef UNIV_DEBUG -/*********************************************************************/ /** - Gets a pointer to the memory frame of a block. +/** Gets a pointer to the memory frame of a block. @return pointer to the frame */ UNIV_INLINE buf_frame_t *buf_block_get_frame( - /*================*/ const buf_block_t *block) /*!< in: pointer to the control block */ { ut_ad(block); @@ -731,7 +668,6 @@ ok: FIXME_FTS Gets the frame the pointer is pointing to. */ UNIV_INLINE buf_frame_t *buf_frame_align( - /*============*/ /* out: pointer to frame */ byte *ptr) /* in: pointer to a frame */ { @@ -744,12 +680,10 @@ buf_frame_t *buf_frame_align( return (frame); } -/**********************************************************************/ /** - Gets the space id, page offset, and byte offset within page of a +/** Gets the space id, page offset, and byte offset within page of a pointer pointing to a buffer frame containing a file page. */ UNIV_INLINE void buf_ptr_get_fsp_addr( - /*=================*/ const void *ptr, /*!< in: pointer to a buffer frame */ space_id_t *space, /*!< out: space id */ fil_addr_t *addr) /*!< out: page offset and byte offset */ @@ -762,14 +696,11 @@ void buf_ptr_get_fsp_addr( } #ifndef UNIV_HOTBACKUP -/**********************************************************************/ /** - Gets the hash value of the page the pointer is pointing to. This can be used +/** Gets the hash value of the page the pointer is pointing to. This can be used in searches in the lock hash table. @return lock hash value */ UNIV_INLINE -ulint buf_block_get_lock_hash_val( - /*========================*/ - const buf_block_t *block) /*!< in: block */ +ulint buf_block_get_lock_hash_val(const buf_block_t *block) /*!< in: block */ { ut_ad(block); ut_ad(buf_page_in_file(&block->page)); @@ -779,14 +710,11 @@ ulint buf_block_get_lock_hash_val( return (block->lock_hash_val); } -/********************************************************************/ /** - Allocates a buf_page_t descriptor. This function must succeed. In case +/** Allocates a buf_page_t descriptor. This function must succeed. In case of failure we assert in this function. @return: the allocated descriptor. */ UNIV_INLINE -buf_page_t *buf_page_alloc_descriptor(void) -/*===========================*/ -{ +buf_page_t *buf_page_alloc_descriptor(void) { buf_page_t *bpage; bpage = (buf_page_t *)ut_zalloc_nokey(sizeof *bpage); @@ -796,22 +724,17 @@ buf_page_t *buf_page_alloc_descriptor(void) return (bpage); } -/********************************************************************/ /** - Free a buf_page_t descriptor. */ +/** Free a buf_page_t descriptor. */ UNIV_INLINE void buf_page_free_descriptor( - /*=====================*/ buf_page_t *bpage) /*!< in: bpage descriptor to free. */ { ut_free(bpage); } -/********************************************************************/ /** - Frees a buffer block which does not contain a file page. */ +/** Frees a buffer block which does not contain a file page. */ UNIV_INLINE -void buf_block_free( - /*===========*/ - buf_block_t *block) /*!< in, own: block to be freed */ +void buf_block_free(buf_block_t *block) /*!< in, own: block to be freed */ { ut_a(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE); @@ -819,14 +742,11 @@ void buf_block_free( } #endif /* !UNIV_HOTBACKUP */ -/*********************************************************************/ /** - Copies contents of a buffer frame to a given buffer. +/** Copies contents of a buffer frame to a given buffer. @return buf */ UNIV_INLINE -byte *buf_frame_copy( - /*===========*/ - byte *buf, /*!< in: buffer to copy to */ - const buf_frame_t *frame) /*!< in: buffer frame */ +byte *buf_frame_copy(byte *buf, /*!< in: buffer to copy to */ + const buf_frame_t *frame) /*!< in: buffer frame */ { ut_ad(buf && frame); @@ -836,13 +756,11 @@ byte *buf_frame_copy( } #ifndef UNIV_HOTBACKUP -/********************************************************************/ /** - Gets the youngest modification log sequence number for a frame. +/** Gets the youngest modification log sequence number for a frame. Returns zero if not file page or no modification occurred yet. @return newest modification to page */ UNIV_INLINE lsn_t buf_page_get_newest_modification( - /*=============================*/ const buf_page_t *bpage) /*!< in: block containing the page frame */ { @@ -916,11 +834,9 @@ ulint buf_block_fix(buf_block_t *block) { return (buf_block_fix(&block->page)); } -/*******************************************************************/ /** - Increments the bufferfix count. */ +/** Increments the bufferfix count. */ UNIV_INLINE void buf_block_buf_fix_inc_func( -/*=======================*/ #ifdef UNIV_DEBUG const char *file, /*!< in: file name */ ulint line, /*!< in: line */ @@ -960,11 +876,9 @@ ulint buf_block_unfix(buf_block_t *block) { return (buf_block_unfix(&block->page)); } -/*******************************************************************/ /** - Decrements the bufferfix count. */ +/** Decrements the bufferfix count. */ UNIV_INLINE void buf_block_buf_fix_dec( - /*==================*/ buf_block_t *block) /*!< in/out: block to bufferunfix */ { buf_block_unfix(block); @@ -994,14 +908,11 @@ buf_pool_t *buf_pool_get(const page_id_t &page_id) { return (&buf_pool_ptr[i]); } -/******************************************************************/ /** - Returns the buffer pool instance given its array index +/** Returns the buffer pool instance given its array index @return buffer pool */ UNIV_INLINE -buf_pool_t *buf_pool_from_array( - /*================*/ - ulint index) /*!< in: array index to get - buffer pool instance from */ +buf_pool_t *buf_pool_from_array(ulint index) /*!< in: array index to get + buffer pool instance from */ { ut_ad(index < MAX_BUFFER_POOLS); ut_ad(index < srv_buf_pool_instances); @@ -1178,12 +1089,9 @@ ibool buf_page_peek(const page_id_t &page_id) { return (buf_page_hash_get(buf_pool, page_id) != NULL); } -/********************************************************************/ /** - Releases a compressed-only page acquired with buf_page_get_zip(). */ +/** Releases a compressed-only page acquired with buf_page_get_zip(). */ UNIV_INLINE -void buf_page_release_zip( - /*=================*/ - buf_page_t *bpage) /*!< in: buffer block */ +void buf_page_release_zip(buf_page_t *bpage) /*!< in: buffer block */ { ut_ad(bpage); ut_a(bpage->buf_fix_count > 0); @@ -1219,14 +1127,11 @@ void buf_page_release_zip( ut_error; } -/********************************************************************/ /** - Releases a latch, if specified. */ +/** Releases a latch, if specified. */ UNIV_INLINE -void buf_page_release_latch( - /*===================*/ - buf_block_t *block, /*!< in: buffer block */ - ulint rw_latch) /*!< in: RW_S_LATCH, RW_X_LATCH, - RW_NO_LATCH */ +void buf_page_release_latch(buf_block_t *block, /*!< in: buffer block */ + ulint rw_latch) /*!< in: RW_S_LATCH, RW_X_LATCH, + RW_NO_LATCH */ { #ifdef UNIV_DEBUG /* No debug latch is acquired if block belongs to system @@ -1247,13 +1152,11 @@ void buf_page_release_latch( } #ifdef UNIV_DEBUG -/*********************************************************************/ /** - Adds latch level info for the rw-lock protecting the buffer frame. This +/** Adds latch level info for the rw-lock protecting the buffer frame. This should be called in the debug version after a successful latching of a page if we know the latching order level of the acquired latch. */ UNIV_INLINE void buf_block_dbg_add_level( - /*====================*/ buf_block_t *block, /*!< in: buffer page where we have acquired latch */ latch_level_t level) /*!< in: latching order level */ @@ -1262,12 +1165,10 @@ void buf_block_dbg_add_level( } #endif /* UNIV_DEBUG */ -/*********************************************************************/ /** - Get the nth chunk's buffer block in the specified buffer pool. +/** Get the nth chunk's buffer block in the specified buffer pool. @return the nth chunk's buffer block. */ UNIV_INLINE buf_block_t *buf_get_nth_chunk_block( - /*====================*/ const buf_pool_t *buf_pool, /*!< in: buffer pool instance */ ulint n, /*!< in: nth chunk in the buffer pool */ ulint *chunk_size) /*!< in: chunk size */ diff --git a/storage/innobase/include/buf0checksum.h b/storage/innobase/include/buf0checksum.h index a2a94dec61d1..3e76619ec940 100644 --- a/storage/innobase/include/buf0checksum.h +++ b/storage/innobase/include/buf0checksum.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/buf0checksum.h +/** @file include/buf0checksum.h Buffer pool checksum functions, also linked from /extra/innochecksum.cc Created Aug 11, 2011 Vasil Dimov @@ -50,32 +49,24 @@ byteorder when converting byte strings to integers uint32_t buf_calc_page_crc32(const byte *page, bool use_legacy_big_endian = false); -/********************************************************************/ /** - Calculates a page checksum which is stored to the page when it is written +/** Calculates a page checksum which is stored to the page when it is written to a file. Note that we must be careful to calculate the same value on 32-bit and 64-bit architectures. @return checksum */ -ulint buf_calc_page_new_checksum( - /*=======================*/ - const byte *page); /*!< in: buffer page */ +ulint buf_calc_page_new_checksum(const byte *page); /*!< in: buffer page */ -/********************************************************************/ /** - In versions < 4.0.14 and < 4.1.1 there was a bug that the checksum only +/** In versions < 4.0.14 and < 4.1.1 there was a bug that the checksum only looked at the first few bytes of the page. This calculates that old checksum. NOTE: we must first store the new formula checksum to FIL_PAGE_SPACE_OR_CHKSUM before calculating and storing this old checksum because this takes that field as an input! @return checksum */ -ulint buf_calc_page_old_checksum( - /*=======================*/ - const byte *page); /*!< in: buffer page */ +ulint buf_calc_page_old_checksum(const byte *page); /*!< in: buffer page */ -/********************************************************************/ /** - Return a printable string describing the checksum algorithm. +/** Return a printable string describing the checksum algorithm. @return algorithm name */ const char *buf_checksum_algorithm_name( - /*========================*/ srv_checksum_algorithm_t algo); /*!< in: algorithm */ extern ulong srv_checksum_algorithm; diff --git a/storage/innobase/include/buf0dblwr.h b/storage/innobase/include/buf0dblwr.h index 7910af03ce51..689edcfc38b0 100644 --- a/storage/innobase/include/buf0dblwr.h +++ b/storage/innobase/include/buf0dblwr.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/buf0dblwr.h +/** @file include/buf0dblwr.h Doublewrite buffer module Created 2011/12/19 Inaam Rana @@ -45,16 +44,13 @@ extern buf_dblwr_t *buf_dblwr; /** Set to TRUE when the doublewrite buffer is being created */ extern ibool buf_dblwr_being_created; -/****************************************************************/ /** - Creates the doublewrite buffer to a new InnoDB installation. The header of the - doublewrite buffer is placed on the trx system header page. +/** Creates the doublewrite buffer to a new InnoDB installation. The header of + the doublewrite buffer is placed on the trx system header page. @return true if successful, false if not. */ MY_ATTRIBUTE((warn_unused_result)) bool buf_dblwr_create(void); -/*==================*/ -/****************************************************************/ /** - At a database startup initializes the doublewrite buffer memory structure if +/** At a database startup initializes the doublewrite buffer memory structure if we already have a doublewrite buffer created in the data files. If we are upgrading to an InnoDB version which supports multiple tablespaces, then this function performs the necessary update operations. If we are in a crash @@ -65,23 +61,16 @@ dberr_t buf_dblwr_init_or_load_pages(pfs_os_file_t file, const char *path); /** Process and remove the double write buffer pages for all tablespaces. */ void buf_dblwr_process(void); -/****************************************************************/ /** - frees doublewrite buffer. */ +/** frees doublewrite buffer. */ void buf_dblwr_free(void); -/*================*/ -/********************************************************************/ /** - Updates the doublewrite buffer when an IO request is completed. */ +/** Updates the doublewrite buffer when an IO request is completed. */ void buf_dblwr_update( - /*=============*/ const buf_page_t *bpage, /*!< in: buffer block descriptor */ buf_flush_t flush_type); /*!< in: flush type */ -/****************************************************************/ /** - Determines if a page number is located inside the doublewrite buffer. +/** Determines if a page number is located inside the doublewrite buffer. @return true if the location is inside the two blocks of the doublewrite buffer */ -ibool buf_dblwr_page_inside( - /*==================*/ - page_no_t page_no); /*!< in: page number */ +ibool buf_dblwr_page_inside(page_no_t page_no); /*!< in: page number */ /** Posts a buffer page for writing. If the doublewrite memory buffer is full, calls buf_dblwr_flush_buffered_writes and waits for for free @@ -89,21 +78,17 @@ space to appear. @param[in] bpage buffer block to write */ void buf_dblwr_add_to_batch(buf_page_t *bpage); -/********************************************************************/ /** - Flush a batch of writes to the datafiles that have already been +/** Flush a batch of writes to the datafiles that have already been written to the dblwr buffer on disk. */ void buf_dblwr_sync_datafiles(); -/********************************************************************/ /** - Flushes possible buffered writes from the doublewrite memory buffer to disk, +/** Flushes possible buffered writes from the doublewrite memory buffer to disk, and also wakes up the aio thread if simulated aio is used. It is very important to call this function after a batch of writes has been posted, and also when we may have to wait for a page latch! Otherwise a deadlock of threads can occur. */ void buf_dblwr_flush_buffered_writes(void); -/*=================================*/ -/********************************************************************/ /** - Writes a page to the doublewrite buffer on disk, sync it, then write +/** Writes a page to the doublewrite buffer on disk, sync it, then write the page to the datafile and sync the datafile. This function is used for single page flushes. If all the buffers allocated for single page flushes in the doublewrite buffer are in use we wait here for one to @@ -111,7 +96,6 @@ void buf_dblwr_flush_buffered_writes(void); thread that is using a slot must also release the slot before leaving this function. */ void buf_dblwr_write_single_page( - /*========================*/ buf_page_t *bpage, /*!< in: buffer block to write */ bool sync); /*!< in: true if sync IO requested */ diff --git a/storage/innobase/include/buf0dump.h b/storage/innobase/include/buf0dump.h index 071276e1f748..06cfba1b92e3 100644 --- a/storage/innobase/include/buf0dump.h +++ b/storage/innobase/include/buf0dump.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/buf0dump.h +/** @file include/buf0dump.h Implements a buffer pool dump/load. Created April 08, 2011 Vasil Dimov @@ -36,28 +35,22 @@ this program; if not, write to the Free Software Foundation, Inc., #include "univ.i" -/*****************************************************************/ /** - Wakes up the buffer pool dump/load thread and instructs it to start +/** Wakes up the buffer pool dump/load thread and instructs it to start a dump. This function is called by MySQL code via buffer_pool_dump_now() and it should return immediately because the whole MySQL is frozen during its execution. */ void buf_dump_start(); -/*============*/ -/*****************************************************************/ /** - Wakes up the buffer pool dump/load thread and instructs it to start +/** Wakes up the buffer pool dump/load thread and instructs it to start a load. This function is called by MySQL code via buffer_pool_load_now() and it should return immediately because the whole MySQL is frozen during its execution. */ void buf_load_start(); -/*============*/ -/*****************************************************************/ /** - Aborts a currently running buffer pool load. This function is called by +/** Aborts a currently running buffer pool load. This function is called by MySQL code via buffer_pool_load_abort() and it should return immediately because the whole MySQL is frozen during its execution. */ void buf_load_abort(); -/*============*/ /** This is the main thread for buffer pool dump/load. It waits for an event and when waked up either performs a dump or load and sleeps diff --git a/storage/innobase/include/buf0flu.h b/storage/innobase/include/buf0flu.h index c767b4edbd83..5267913d600c 100644 --- a/storage/innobase/include/buf0flu.h +++ b/storage/innobase/include/buf0flu.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/buf0flu.h +/** @file include/buf0flu.h The database buffer pool flush algorithm Created 11/5/1995 Heikki Tuuri @@ -59,12 +58,10 @@ class ut_stage_alter_t; @param[in] bpage pointer to the block in question */ void buf_flush_remove(buf_page_t *bpage); -/*******************************************************************/ /** - Relocates a buffer control block on the flush_list. +/** Relocates a buffer control block on the flush_list. Note that it is assumed that the contents of bpage has already been copied to dpage. */ void buf_flush_relocate_on_flush_list( - /*=============================*/ buf_page_t *bpage, /*!< in/out: control block being moved */ buf_page_t *dpage); /*!< in/out: destination block */ @@ -136,10 +133,8 @@ is not fast enough to keep pace with the workload. @return true if success. */ bool buf_flush_single_page_from_LRU(buf_pool_t *buf_pool); -/******************************************************************/ /** - Waits until a flush batch of the given type ends */ +/** Waits until a flush batch of the given type ends */ void buf_flush_wait_batch_end( - /*=====================*/ buf_pool_t *buf_pool, /*!< in: buffer pool instance */ buf_flush_t type); /*!< in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */ @@ -205,25 +200,18 @@ void buf_flush_page_cleaner_init(size_t n_page_cleaners); void buf_flush_wait_LRU_batch_end(); #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG -/******************************************************************/ /** - Validates the flush list. +/** Validates the flush list. @return true if ok */ -ibool buf_flush_validate( - /*===============*/ - buf_pool_t *buf_pool); +ibool buf_flush_validate(buf_pool_t *buf_pool); #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ -/********************************************************************/ /** - Initialize the red-black tree to speed up insertions into the flush_list +/** Initialize the red-black tree to speed up insertions into the flush_list during recovery process. Should be called at the start of recovery process before any page has been read/written. */ void buf_flush_init_flush_rbt(void); -/*==========================*/ -/********************************************************************/ /** - Frees up the red-black tree. */ +/** Frees up the red-black tree. */ void buf_flush_free_flush_rbt(void); -/*==========================*/ /** Writes a flushable page asynchronously from the buffer pool to a file. NOTE: 1. in simulated aio we must call os_aio_simulated_wake_handler_threads @@ -246,22 +234,18 @@ ibool buf_flush_page(buf_pool_t *buf_pool, buf_page_t *bpage, bool buf_flush_ready_for_flush(buf_page_t *bpage, buf_flush_t flush_type) MY_ATTRIBUTE((warn_unused_result)); -/******************************************************************/ /** - Check if there are any dirty pages that belong to a space id in the flush +/** Check if there are any dirty pages that belong to a space id in the flush list in a particular buffer pool. @return number of dirty pages present in a single buffer pool */ ulint buf_pool_get_dirty_pages_count( - /*===========================*/ buf_pool_t *buf_pool, /*!< in: buffer pool */ space_id_t id, /*!< in: space id to check */ FlushObserver *observer); /*!< in: flush observer to check */ -/*******************************************************************/ /** - Synchronously flush dirty blocks from the end of the flush list of all buffer - pool instances. - NOTE: The calling thread is not allowed to own any latches on pages! */ +/** Synchronously flush dirty blocks from the end of the flush list of all + buffer pool instances. NOTE: The calling thread is not allowed to own any + latches on pages! */ void buf_flush_sync_all_buf_pools(void); -/*==============================*/ /** Request IO burst and wake page_cleaner up. @param[in] lsn_limit upper limit of LSN to be flushed */ diff --git a/storage/innobase/include/buf0flu.ic b/storage/innobase/include/buf0flu.ic index ed28f581e215..f8bb92bfc055 100644 --- a/storage/innobase/include/buf0flu.ic +++ b/storage/innobase/include/buf0flu.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/buf0flu.ic +/** @file include/buf0flu.ic The database buffer pool flush algorithm Created 11/5/1995 Heikki Tuuri @@ -37,31 +36,25 @@ this program; if not, write to the Free Software Foundation, Inc., #include "srv0srv.h" #ifndef UNIV_HOTBACKUP -/********************************************************************/ /** - Inserts a modified block into the flush list. */ +/** Inserts a modified block into the flush list. */ void buf_flush_insert_into_flush_list( - /*=============================*/ buf_pool_t *buf_pool, /*!< buffer pool instance */ buf_block_t *block, /*!< in/out: block which is modified */ lsn_t lsn); /*!< in: oldest modification */ -/********************************************************************/ /** - Inserts a modified block into the flush list in the right sorted position. +/** Inserts a modified block into the flush list in the right sorted position. This function is used by recovery, because there the modifications do not necessarily come in the order of lsn's. */ void buf_flush_insert_sorted_into_flush_list( - /*====================================*/ buf_pool_t *buf_pool, /*!< buffer pool instance */ buf_block_t *block, /*!< in/out: block which is modified */ lsn_t lsn); /*!< in: oldest modification */ -/********************************************************************/ /** - This function should be called at a mini-transaction commit, if a page was +/** This function should be called at a mini-transaction commit, if a page was modified in it. Puts the block to the list of modified blocks, if it is not already in it. */ UNIV_INLINE void buf_flush_note_modification( - /*========================*/ buf_block_t *block, /*!< in: block which is modified */ lsn_t start_lsn, /*!< in: start lsn of the mtr that modified this block */ @@ -108,11 +101,9 @@ void buf_flush_note_modification( srv_stats.buf_pool_write_requests.inc(); } -/********************************************************************/ /** - This function should be called when recovery has modified a buffer page. */ +/** This function should be called when recovery has modified a buffer page. */ UNIV_INLINE void buf_flush_recv_note_modification( - /*=============================*/ buf_block_t *block, /*!< in: block which is modified */ lsn_t start_lsn, /*!< in: start lsn of the first mtr in a set of mtr's */ diff --git a/storage/innobase/include/buf0lru.h b/storage/innobase/include/buf0lru.h index 468990445d68..30ee59fde697 100644 --- a/storage/innobase/include/buf0lru.h +++ b/storage/innobase/include/buf0lru.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -28,8 +28,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "my_compiler.h" -/**************************************************/ /** - @file include/buf0lru.h +/** @file include/buf0lru.h The database buffer pool LRU replacement algorithm Created 11/5/1995 Heikki Tuuri @@ -46,13 +45,11 @@ this program; if not, write to the Free Software Foundation, Inc., // Forward declaration struct trx_t; -/******************************************************************/ /** - Returns TRUE if less than 25 % of the buffer pool is available. This can be +/** Returns TRUE if less than 25 % of the buffer pool is available. This can be used in heuristics to prevent huge transactions eating up the whole buffer pool for their locks. @return true if less than 25 % of buffer pool left */ ibool buf_LRU_buf_pool_running_out(void); -/*==============================*/ /*####################################################################### These are low-level functions @@ -62,13 +59,11 @@ These are low-level functions #define BUF_LRU_OLD_MIN_LEN 512 /* 8 megabytes of 16k pages */ #endif /* !UNIV_HOTBACKUP */ -/******************************************************************/ /** - Flushes all dirty pages or removes all pages belonging +/** Flushes all dirty pages or removes all pages belonging to a given tablespace. A PROBLEM: if readahead is being started, what guarantees that it will not try to read in pages after this operation has completed? */ void buf_LRU_flush_or_remove_pages( - /*==========================*/ space_id_t id, /*!< in: space id */ buf_remove_t buf_remove, /*!< in: remove or flush strategy */ const trx_t *trx); /*!< to check if the operation must @@ -146,12 +141,10 @@ ibool buf_LRU_evict_from_unzip_LRU(buf_pool_t *buf_pool); @param[in] block block must not contain a file page */ void buf_LRU_block_free_non_file_page(buf_block_t *block); -/******************************************************************/ /** - Adds a block to the LRU list. Please make sure that the page_size is +/** Adds a block to the LRU list. Please make sure that the page_size is already set when invoking the function, so that we can get correct page_size from the buffer page when adding a block into LRU */ void buf_LRU_add_block( - /*==============*/ buf_page_t *bpage, /*!< in: control block */ ibool old); /*!< in: TRUE if should be put to the old blocks in the LRU list, else put to the @@ -168,21 +161,17 @@ void buf_unzip_LRU_add_block(buf_block_t *block, ibool old); @param[in] bpage control block */ void buf_LRU_make_block_young(buf_page_t *bpage); -/**********************************************************************/ /** - Updates buf_pool->LRU_old_ratio. +/** Updates buf_pool->LRU_old_ratio. @return updated old_pct */ uint buf_LRU_old_ratio_update( - /*=====================*/ uint old_pct, /*!< in: Reserve this percentage of the buffer pool for "old" blocks. */ ibool adjust); /*!< in: TRUE=adjust the LRU list; FALSE=just assign buf_pool->LRU_old_ratio during the initialization of InnoDB */ -/********************************************************************/ /** - Update the historical stats that we are collecting for LRU eviction +/** Update the historical stats that we are collecting for LRU eviction policy at the end of each interval. */ void buf_LRU_stat_update(void); -/*=====================*/ /** Remove one page from LRU list and put it to free list. The caller must hold the LRU list and block mutexes and have page hash latched in X. The latch and @@ -196,25 +185,18 @@ the block mutexes will be released. could be not initialized */ void buf_LRU_free_one_page(buf_page_t *bpage, bool zip, bool ignore_content); -/******************************************************************/ /** - Adjust LRU hazard pointers if needed. */ -void buf_LRU_adjust_hp( - /*==============*/ - buf_pool_t *buf_pool, /*!< in: buffer pool instance */ - const buf_page_t *bpage); /*!< in: control block */ +/** Adjust LRU hazard pointers if needed. */ +void buf_LRU_adjust_hp(buf_pool_t *buf_pool, /*!< in: buffer pool instance */ + const buf_page_t *bpage); /*!< in: control block */ #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG -/**********************************************************************/ /** - Validates the LRU list. +/** Validates the LRU list. @return true */ ibool buf_LRU_validate(void); -/*==================*/ #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ #if defined UNIV_DEBUG_PRINT || defined UNIV_DEBUG || defined UNIV_BUF_DEBUG -/**********************************************************************/ /** - Prints the LRU list. */ +/** Prints the LRU list. */ void buf_LRU_print(void); -/*===============*/ #endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */ /** @name Heuristics for detecting index scan @{ */ @@ -261,11 +243,9 @@ extern buf_LRU_stat_t buf_LRU_stat_cur; Updated by buf_LRU_stat_update(). Accesses protected by memory barriers. */ extern buf_LRU_stat_t buf_LRU_stat_sum; -/********************************************************************/ /** - Increments the I/O counter in buf_LRU_stat_cur. */ +/** Increments the I/O counter in buf_LRU_stat_cur. */ #define buf_LRU_stat_inc_io() buf_LRU_stat_cur.io++ -/********************************************************************/ /** - Increments the page_zip_decompress() counter in buf_LRU_stat_cur. */ +/** Increments the page_zip_decompress() counter in buf_LRU_stat_cur. */ #define buf_LRU_stat_inc_unzip() buf_LRU_stat_cur.unzip++ #include "buf0lru.ic" diff --git a/storage/innobase/include/buf0lru.ic b/storage/innobase/include/buf0lru.ic index 6cd66163a5f8..c1ae646a94ef 100644 --- a/storage/innobase/include/buf0lru.ic +++ b/storage/innobase/include/buf0lru.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/buf0lru.ic +/** @file include/buf0lru.ic The database buffer replacement algorithm Created 11/5/1995 Heikki Tuuri diff --git a/storage/innobase/include/buf0rea.h b/storage/innobase/include/buf0rea.h index 86b859f2dcfa..e52caa018050 100644 --- a/storage/innobase/include/buf0rea.h +++ b/storage/innobase/include/buf0rea.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/buf0rea.h +/** @file include/buf0rea.h The database buffer read Created 11/5/1995 Heikki Tuuri @@ -106,12 +105,10 @@ which could result in a deadlock if the OS does not support asynchronous io. ulint buf_read_ahead_linear(const page_id_t &page_id, const page_size_t &page_size, ibool inside_ibuf); -/********************************************************************/ /** - Issues read requests for pages which the ibuf module wants to read in, in +/** Issues read requests for pages which the ibuf module wants to read in, in order to contract the insert buffer tree. Technically, this function is like a read-ahead function. */ void buf_read_ibuf_merge_pages( - /*======================*/ bool sync, /*!< in: true if the caller wants this function to wait for the highest address page diff --git a/storage/innobase/include/buf0stats.h b/storage/innobase/include/buf0stats.h index a1fc632646bf..8a80108d0c59 100644 --- a/storage/innobase/include/buf0stats.h +++ b/storage/innobase/include/buf0stats.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2015, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2015, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/buf0stats.h +/** @file include/buf0stats.h Buffer pool stats Created May 22, 2015 Vasil Dimov diff --git a/storage/innobase/include/buf0types.h b/storage/innobase/include/buf0types.h index fb579c745274..134f42f036b5 100644 --- a/storage/innobase/include/buf0types.h +++ b/storage/innobase/include/buf0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/buf0types.h +/** @file include/buf0types.h The database buffer pool global types for the directory Created 11/17/1995 Heikki Tuuri diff --git a/storage/innobase/include/clone0api.h b/storage/innobase/include/clone0api.h index 017f90b2b951..5f9f48a23fe0 100644 --- a/storage/innobase/include/clone0api.h +++ b/storage/innobase/include/clone0api.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/clone0api.h +/** @file include/clone0api.h Innodb Clone Interface *******************************************************/ diff --git a/storage/innobase/include/clone0clone.h b/storage/innobase/include/clone0clone.h index 66bd896942ac..d10bb54f190e 100644 --- a/storage/innobase/include/clone0clone.h +++ b/storage/innobase/include/clone0clone.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/clone0clone.h +/** @file include/clone0clone.h Innodb Clone System *******************************************************/ diff --git a/storage/innobase/include/clone0desc.h b/storage/innobase/include/clone0desc.h index 5796778df4b7..9776dad3b156 100644 --- a/storage/innobase/include/clone0desc.h +++ b/storage/innobase/include/clone0desc.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/clone0desc.h +/** @file include/clone0desc.h Innodb clone descriptors *******************************************************/ diff --git a/storage/innobase/include/clone0monitor.h b/storage/innobase/include/clone0monitor.h index a93ee16ceec4..1ea805e9c08b 100644 --- a/storage/innobase/include/clone0monitor.h +++ b/storage/innobase/include/clone0monitor.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/*************************************************************************/ /** - @file include/clone0monitor.h +/** @file include/clone0monitor.h Performance Schema stage instrumentation to monitor clone progress. ****************************************************************************/ diff --git a/storage/innobase/include/clone0snapshot.h b/storage/innobase/include/clone0snapshot.h index 25e6c27e58d0..f6033afbac2c 100644 --- a/storage/innobase/include/clone0snapshot.h +++ b/storage/innobase/include/clone0snapshot.h @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/clone0snapshot.h +/** @file include/clone0snapshot.h Database Physical Snapshot *******************************************************/ diff --git a/storage/innobase/include/data0data.h b/storage/innobase/include/data0data.h index 6ba6c4bc3232..20c584f9efa5 100644 --- a/storage/innobase/include/data0data.h +++ b/storage/innobase/include/data0data.h @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file include/data0data.h +/** @file include/data0data.h SQL data field and tuple Created 5/30/1994 Heikki Tuuri @@ -50,21 +49,15 @@ struct big_rec_t; struct upd_t; #ifdef UNIV_DEBUG -/*********************************************************************/ /** - Gets pointer to the type struct of SQL data field. +/** Gets pointer to the type struct of SQL data field. @return pointer to the type struct */ UNIV_INLINE -dtype_t *dfield_get_type( - /*============*/ - const dfield_t *field) /*!< in: SQL data field */ +dtype_t *dfield_get_type(const dfield_t *field) /*!< in: SQL data field */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Gets pointer to the data in a field. +/** Gets pointer to the data in a field. @return pointer to data */ UNIV_INLINE -void *dfield_get_data( - /*============*/ - const dfield_t *field) /*!< in: field */ +void *dfield_get_data(const dfield_t *field) /*!< in: field */ MY_ATTRIBUTE((warn_unused_result)); #else /* UNIV_DEBUG */ #define dfield_get_type(field) (&(field)->type) @@ -77,13 +70,10 @@ void *dfield_get_data( UNIV_INLINE void dfield_set_type(dfield_t *field, const dtype_t *type); -/*********************************************************************/ /** - Gets length of field data. +/** Gets length of field data. @return length of data; UNIV_SQL_NULL if SQL null data */ UNIV_INLINE -ulint dfield_get_len( - /*===========*/ - const dfield_t *field) /*!< in: field */ +ulint dfield_get_len(const dfield_t *field) /*!< in: field */ MY_ATTRIBUTE((warn_unused_result)); /** Sets length in a field. @@ -92,28 +82,19 @@ ulint dfield_get_len( UNIV_INLINE void dfield_set_len(dfield_t *field, ulint len); -/*********************************************************************/ /** - Determines if a field is SQL NULL +/** Determines if a field is SQL NULL @return nonzero if SQL null data */ UNIV_INLINE -ulint dfield_is_null( - /*===========*/ - const dfield_t *field) /*!< in: field */ +ulint dfield_is_null(const dfield_t *field) /*!< in: field */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Determines if a field is externally stored +/** Determines if a field is externally stored @return nonzero if externally stored */ UNIV_INLINE -ulint dfield_is_ext( - /*==========*/ - const dfield_t *field) /*!< in: field */ +ulint dfield_is_ext(const dfield_t *field) /*!< in: field */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Sets the "external storage" flag */ +/** Sets the "external storage" flag */ UNIV_INLINE -void dfield_set_ext( - /*===========*/ - dfield_t *field); /*!< in/out: field */ +void dfield_set_ext(dfield_t *field); /*!< in/out: field */ /** Gets spatial status for "external storage" @param[in,out] field field */ @@ -140,12 +121,9 @@ void dfield_set_data(dfield_t *field, const void *data, ulint len); UNIV_INLINE void dfield_write_mbr(dfield_t *field, const double *mbr); -/*********************************************************************/ /** - Sets a data field to SQL NULL. */ +/** Sets a data field to SQL NULL. */ UNIV_INLINE -void dfield_set_null( - /*============*/ - dfield_t *field); /*!< in/out: field */ +void dfield_set_null(dfield_t *field); /*!< in/out: field */ /** Writes an SQL null field full of zeros. @param[in] data pointer to a buffer of size len @@ -171,36 +149,29 @@ void dfield_copy(dfield_t *field1, const dfield_t *field2); UNIV_INLINE void dfield_dup(dfield_t *field, mem_heap_t *heap); -/*********************************************************************/ /** - Tests if two data fields are equal. +/** Tests if two data fields are equal. If len==0, tests the data length and content for equality. If len>0, tests the first len bytes of the content for equality. @return true if both fields are NULL or if they are equal */ UNIV_INLINE ibool dfield_datas_are_binary_equal( - /*==========================*/ const dfield_t *field1, /*!< in: field */ const dfield_t *field2, /*!< in: field */ ulint len) /*!< in: maximum prefix to compare, or 0 to compare the whole field length */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Tests if dfield data length and content is equal to the given. +/** Tests if dfield data length and content is equal to the given. @return true if equal */ UNIV_INLINE ibool dfield_data_is_binary_equal( - /*========================*/ const dfield_t *field, /*!< in: field */ ulint len, /*!< in: data length or UNIV_SQL_NULL */ const byte *data) /*!< in: data */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Gets number of fields in a data tuple. +/** Gets number of fields in a data tuple. @return number of fields */ UNIV_INLINE -ulint dtuple_get_n_fields( - /*================*/ - const dtuple_t *tuple) /*!< in: tuple */ +ulint dtuple_get_n_fields(const dtuple_t *tuple) /*!< in: tuple */ MY_ATTRIBUTE((warn_unused_result)); /** Gets number of virtual fields in a data tuple. @@ -229,13 +200,10 @@ dfield_t *dtuple_get_nth_v_field(const dtuple_t *tuple, ulint n); #define dtuple_get_nth_v_field(tuple, n) \ ((tuple)->fields + (tuple)->n_fields + (n)) #endif /* UNIV_DEBUG */ -/*********************************************************************/ /** - Gets info bits in a data tuple. +/** Gets info bits in a data tuple. @return info bits */ UNIV_INLINE -ulint dtuple_get_info_bits( - /*=================*/ - const dtuple_t *tuple) /*!< in: tuple */ +ulint dtuple_get_info_bits(const dtuple_t *tuple) /*!< in: tuple */ MY_ATTRIBUTE((warn_unused_result)); /** Sets info bits in a data tuple. @@ -244,13 +212,10 @@ ulint dtuple_get_info_bits( UNIV_INLINE void dtuple_set_info_bits(dtuple_t *tuple, ulint info_bits); -/*********************************************************************/ /** - Gets number of fields used in record comparisons. +/** Gets number of fields used in record comparisons. @return number of fields used in comparisons in rem0cmp.* */ UNIV_INLINE -ulint dtuple_get_n_fields_cmp( - /*====================*/ - const dtuple_t *tuple) /*!< in: tuple */ +ulint dtuple_get_n_fields_cmp(const dtuple_t *tuple) /*!< in: tuple */ MY_ATTRIBUTE((warn_unused_result)); /** Gets number of fields used in record comparisons. @@ -265,8 +230,7 @@ creating a new dtuple_t object */ #define DTUPLE_EST_ALLOC(n_fields) \ (sizeof(dtuple_t) + (n_fields) * sizeof(dfield_t)) -/**********************************************************/ /** - Creates a data tuple from an already allocated chunk of memory. +/** Creates a data tuple from an already allocated chunk of memory. The size of the chunk must be at least DTUPLE_EST_ALLOC(n_fields). The default value for number of fields used in record comparisons for this tuple is n_fields. @@ -276,17 +240,14 @@ creating a new dtuple_t object */ @param[in] n_v_fields number of fields on virtual columns @return created tuple (inside buf) */ UNIV_INLINE -dtuple_t *dtuple_create_from_mem( - /*===================*/ - void *buf, ulint buf_size, ulint n_fields, ulint n_v_fields) +dtuple_t *dtuple_create_from_mem(void *buf, ulint buf_size, ulint n_fields, + ulint n_v_fields) MY_ATTRIBUTE((warn_unused_result)); -/**********************************************************/ /** - Creates a data tuple to a memory heap. The default value for number +/** Creates a data tuple to a memory heap. The default value for number of fields used in record comparisons for this tuple is n_fields. @return own: created tuple */ UNIV_INLINE dtuple_t *dtuple_create( - /*==========*/ mem_heap_t *heap, /*!< in: memory heap where the tuple is created, DTUPLE_EST_ALLOC(n_fields) bytes will be allocated from this heap */ @@ -312,28 +273,22 @@ void dtuple_dup_v_fld(const dtuple_t *vrow, mem_heap_t *heap); UNIV_INLINE dtuple_t *dtuple_create_with_vcol(mem_heap_t *heap, ulint n_fields, ulint n_v_fields); -/*********************************************************************/ /** - Sets number of fields used in a tuple. Normally this is set in +/** Sets number of fields used in a tuple. Normally this is set in dtuple_create, but if you want later to set it smaller, you can use this. */ -void dtuple_set_n_fields( - /*================*/ - dtuple_t *tuple, /*!< in: tuple */ - ulint n_fields); /*!< in: number of fields */ +void dtuple_set_n_fields(dtuple_t *tuple, /*!< in: tuple */ + ulint n_fields); /*!< in: number of fields */ /** Copies a data tuple's virtaul fields to another. This is a shallow copy; @param[in,out] d_tuple destination tuple @param[in] s_tuple source tuple */ UNIV_INLINE void dtuple_copy_v_fields(dtuple_t *d_tuple, const dtuple_t *s_tuple); -/*********************************************************************/ /** - Copies a data tuple to another. This is a shallow copy; if a deep copy +/** Copies a data tuple to another. This is a shallow copy; if a deep copy is desired, dfield_dup() will have to be invoked on each field. @return own: copy of tuple */ UNIV_INLINE -dtuple_t *dtuple_copy( - /*========*/ - const dtuple_t *tuple, /*!< in: tuple to copy from */ - mem_heap_t *heap) /*!< in: memory heap - where the tuple is created */ +dtuple_t *dtuple_copy(const dtuple_t *tuple, /*!< in: tuple to copy from */ + mem_heap_t *heap) /*!< in: memory heap + where the tuple is created */ MY_ATTRIBUTE((malloc)); /** The following function returns the sum of data lengths of a tuple. The space @@ -343,13 +298,10 @@ occupied by the field structs or the tuple struct is not counted. @return sum of data lens */ UNIV_INLINE ulint dtuple_get_data_size(const dtuple_t *tuple, ulint comp); -/*********************************************************************/ /** - Computes the number of externally stored fields in a data tuple. +/** Computes the number of externally stored fields in a data tuple. @return number of fields */ UNIV_INLINE -ulint dtuple_get_n_ext( - /*=============*/ - const dtuple_t *tuple); /*!< in: tuple */ +ulint dtuple_get_n_ext(const dtuple_t *tuple); /*!< in: tuple */ /** Compare two data tuples. @param[in] tuple1 first data tuple @param[in] tuple2 second data tuple @@ -373,50 +325,32 @@ ulint dtuple_fold(const dtuple_t *tuple, ulint n_fields, ulint n_bytes, UNIV_INLINE void dtuple_set_types_binary(dtuple_t *tuple, ulint n); -/**********************************************************************/ /** - Checks if a dtuple contains an SQL null value. +/** Checks if a dtuple contains an SQL null value. @return true if some field is SQL null */ UNIV_INLINE -ibool dtuple_contains_null( - /*=================*/ - const dtuple_t *tuple) /*!< in: dtuple */ +ibool dtuple_contains_null(const dtuple_t *tuple) /*!< in: dtuple */ MY_ATTRIBUTE((warn_unused_result)); -/**********************************************************/ /** - Checks that a data field is typed. Asserts an error if not. +/** Checks that a data field is typed. Asserts an error if not. @return true if ok */ -ibool dfield_check_typed( - /*===============*/ - const dfield_t *field) /*!< in: data field */ +ibool dfield_check_typed(const dfield_t *field) /*!< in: data field */ MY_ATTRIBUTE((warn_unused_result)); -/**********************************************************/ /** - Checks that a data tuple is typed. Asserts an error if not. +/** Checks that a data tuple is typed. Asserts an error if not. @return true if ok */ -ibool dtuple_check_typed( - /*===============*/ - const dtuple_t *tuple) /*!< in: tuple */ +ibool dtuple_check_typed(const dtuple_t *tuple) /*!< in: tuple */ MY_ATTRIBUTE((warn_unused_result)); #ifdef UNIV_DEBUG -/**********************************************************/ /** - Validates the consistency of a tuple which must be complete, i.e, +/** Validates the consistency of a tuple which must be complete, i.e, all fields must have been set. @return true if ok */ -ibool dtuple_validate( - /*============*/ - const dtuple_t *tuple) /*!< in: tuple */ +ibool dtuple_validate(const dtuple_t *tuple) /*!< in: tuple */ MY_ATTRIBUTE((warn_unused_result)); -#endif /* UNIV_DEBUG */ -/*************************************************************/ /** - Pretty prints a dfield value according to its data type. Also the hex string +#endif /* UNIV_DEBUG */ +/** Pretty prints a dfield value according to its data type. Also the hex string is printed if a string contains non-printable characters. */ -void dfield_print_also_hex( - /*==================*/ - const dfield_t *dfield); /*!< in: dfield */ -/**********************************************************/ /** - The following function prints the contents of a tuple. */ -void dtuple_print( - /*=========*/ - FILE *f, /*!< in: output stream */ - const dtuple_t *tuple); /*!< in: tuple */ +void dfield_print_also_hex(const dfield_t *dfield); /*!< in: dfield */ +/** The following function prints the contents of a tuple. */ +void dtuple_print(FILE *f, /*!< in: output stream */ + const dtuple_t *tuple); /*!< in: tuple */ /** Print the contents of a tuple. @param[out] o output stream @@ -437,39 +371,31 @@ inline std::ostream &operator<<(std::ostream &o, const dtuple_t &tuple) { return (o); } -/**************************************************************/ /** - Moves parts of long fields in entry to the big record vector so that +/** Moves parts of long fields in entry to the big record vector so that the size of tuple drops below the maximum record size allowed in the database. Moves data only from those fields which are not necessary to determine uniquely the insertion place of the tuple in the index. @return own: created big record vector, NULL if we are not able to shorten the entry enough, i.e., if there are too many fixed-length or short fields in entry or the index is clustered */ -big_rec_t *dtuple_convert_big_rec( - /*===================*/ - dict_index_t *index, /*!< in: index */ - upd_t *upd, /*!< in/out: update vector */ - dtuple_t *entry, /*!< in/out: index entry */ - ulint *n_ext) /*!< in/out: number of - externally stored columns */ +big_rec_t *dtuple_convert_big_rec(dict_index_t *index, /*!< in: index */ + upd_t *upd, /*!< in/out: update vector */ + dtuple_t *entry, /*!< in/out: index entry */ + ulint *n_ext) /*!< in/out: number of + externally stored columns */ MY_ATTRIBUTE((malloc, warn_unused_result)); -/**************************************************************/ /** - Puts back to entry the data stored in vector. Note that to ensure the +/** Puts back to entry the data stored in vector. Note that to ensure the fields in entry can accommodate the data, vector must have been created from entry with dtuple_convert_big_rec. */ void dtuple_convert_back_big_rec( - /*========================*/ dict_index_t *index, /*!< in: index */ dtuple_t *entry, /*!< in: entry whose data was put to vector */ big_rec_t *vector); /*!< in, own: big rec vector; it is freed in this function */ -/**************************************************************/ /** - Frees the memory in a big rec vector. */ +/** Frees the memory in a big rec vector. */ UNIV_INLINE -void dtuple_big_rec_free( - /*================*/ - big_rec_t *vector); /*!< in, own: big rec vector; it is - freed in this function */ +void dtuple_big_rec_free(big_rec_t *vector); /*!< in, own: big rec vector; it is + freed in this function */ /*######################################################################*/ diff --git a/storage/innobase/include/data0data.ic b/storage/innobase/include/data0data.ic index f0d68627f78d..505fd8b39102 100644 --- a/storage/innobase/include/data0data.ic +++ b/storage/innobase/include/data0data.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file include/data0data.ic +/** @file include/data0data.ic SQL data field and tuple Created 5/30/1994 Heikki Tuuri @@ -40,13 +39,10 @@ debug version, dtuple_create() will make all fields of dtuple_t point to data_error. */ extern byte data_error; -/*********************************************************************/ /** - Gets pointer to the type struct of SQL data field. +/** Gets pointer to the type struct of SQL data field. @return pointer to the type struct */ UNIV_INLINE -dtype_t *dfield_get_type( - /*============*/ - const dfield_t *field) /*!< in: SQL data field */ +dtype_t *dfield_get_type(const dfield_t *field) /*!< in: SQL data field */ { ut_ad(field); @@ -54,11 +50,9 @@ dtype_t *dfield_get_type( } #endif /* UNIV_DEBUG */ -/*********************************************************************/ /** - Sets the type struct of SQL data field. */ +/** Sets the type struct of SQL data field. */ UNIV_INLINE void dfield_set_type( - /*============*/ dfield_t *field, /*!< in: SQL data field */ const dtype_t *type) /*!< in: pointer to data type struct */ { @@ -69,13 +63,10 @@ void dfield_set_type( } #ifdef UNIV_DEBUG -/*********************************************************************/ /** - Gets pointer to the data in a field. +/** Gets pointer to the data in a field. @return pointer to data */ UNIV_INLINE -void *dfield_get_data( - /*============*/ - const dfield_t *field) /*!< in: field */ +void *dfield_get_data(const dfield_t *field) /*!< in: field */ { ut_ad(field); ut_ad((field->len == UNIV_SQL_NULL) || (field->data != &data_error)); @@ -84,13 +75,10 @@ void *dfield_get_data( } #endif /* UNIV_DEBUG */ -/*********************************************************************/ /** - Gets length of field data. +/** Gets length of field data. @return length of data; UNIV_SQL_NULL if SQL null data */ UNIV_INLINE -ulint dfield_get_len( - /*===========*/ - const dfield_t *field) /*!< in: field */ +ulint dfield_get_len(const dfield_t *field) /*!< in: field */ { ut_ad(field); ut_ad((field->len == UNIV_SQL_NULL) || (field->data != &data_error)); @@ -98,13 +86,10 @@ ulint dfield_get_len( return (field->len); } -/*********************************************************************/ /** - Sets length in a field. */ +/** Sets length in a field. */ UNIV_INLINE -void dfield_set_len( - /*===========*/ - dfield_t *field, /*!< in: field */ - ulint len) /*!< in: length or UNIV_SQL_NULL */ +void dfield_set_len(dfield_t *field, /*!< in: field */ + ulint len) /*!< in: length or UNIV_SQL_NULL */ { ut_ad(field); #ifdef UNIV_VALGRIND_DEBUG @@ -115,26 +100,20 @@ void dfield_set_len( field->len = static_cast(len); } -/*********************************************************************/ /** - Determines if a field is SQL NULL +/** Determines if a field is SQL NULL @return nonzero if SQL null data */ UNIV_INLINE -ulint dfield_is_null( - /*===========*/ - const dfield_t *field) /*!< in: field */ +ulint dfield_is_null(const dfield_t *field) /*!< in: field */ { ut_ad(field); return (field->len == UNIV_SQL_NULL); } -/*********************************************************************/ /** - Determines if a field is externally stored +/** Determines if a field is externally stored @return nonzero if externally stored */ UNIV_INLINE -ulint dfield_is_ext( - /*==========*/ - const dfield_t *field) /*!< in: field */ +ulint dfield_is_ext(const dfield_t *field) /*!< in: field */ { ut_ad(field); ut_ad(!field->ext || field->len >= BTR_EXTERN_FIELD_REF_SIZE); @@ -142,12 +121,9 @@ ulint dfield_is_ext( return (field->ext); } -/*********************************************************************/ /** - Sets the "external storage" flag */ +/** Sets the "external storage" flag */ UNIV_INLINE -void dfield_set_ext( - /*===========*/ - dfield_t *field) /*!< in/out: field */ +void dfield_set_ext(dfield_t *field) /*!< in/out: field */ { ut_ad(field); @@ -176,14 +152,11 @@ void dfield_set_spatial_status(dfield_t *field, field->spatial_status = spatial_status; } -/*********************************************************************/ /** - Sets pointer to the data and length in a field. */ +/** Sets pointer to the data and length in a field. */ UNIV_INLINE -void dfield_set_data( - /*============*/ - dfield_t *field, /*!< in: field */ - const void *data, /*!< in: data */ - ulint len) /*!< in: length or UNIV_SQL_NULL */ +void dfield_set_data(dfield_t *field, /*!< in: field */ + const void *data, /*!< in: data */ + ulint len) /*!< in: length or UNIV_SQL_NULL */ { ut_ad(field); @@ -195,13 +168,10 @@ void dfield_set_data( field->len = static_cast(len); } -/*********************************************************************/ /** - Sets pointer to the data and length in a field. */ +/** Sets pointer to the data and length in a field. */ UNIV_INLINE -void dfield_write_mbr( - /*=============*/ - dfield_t *field, /*!< in: field */ - const double *mbr) /*!< in: data */ +void dfield_write_mbr(dfield_t *field, /*!< in: field */ + const double *mbr) /*!< in: data */ { ut_ad(field); @@ -218,23 +188,17 @@ void dfield_write_mbr( field->len = DATA_MBR_LEN; } -/*********************************************************************/ /** - Sets a data field to SQL NULL. */ +/** Sets a data field to SQL NULL. */ UNIV_INLINE -void dfield_set_null( - /*============*/ - dfield_t *field) /*!< in/out: field */ +void dfield_set_null(dfield_t *field) /*!< in/out: field */ { dfield_set_data(field, NULL, UNIV_SQL_NULL); } -/*********************************************************************/ /** - Copies the data and len fields. */ +/** Copies the data and len fields. */ UNIV_INLINE -void dfield_copy_data( - /*=============*/ - dfield_t *field1, /*!< out: field to copy to */ - const dfield_t *field2) /*!< in: field to copy from */ +void dfield_copy_data(dfield_t *field1, /*!< out: field to copy to */ + const dfield_t *field2) /*!< in: field to copy from */ { ut_ad(field1 != NULL); ut_ad(field2 != NULL); @@ -245,24 +209,18 @@ void dfield_copy_data( field1->spatial_status = field2->spatial_status; } -/*********************************************************************/ /** - Copies a data field to another. */ +/** Copies a data field to another. */ UNIV_INLINE -void dfield_copy( - /*========*/ - dfield_t *field1, /*!< out: field to copy to */ - const dfield_t *field2) /*!< in: field to copy from */ +void dfield_copy(dfield_t *field1, /*!< out: field to copy to */ + const dfield_t *field2) /*!< in: field to copy from */ { *field1 = *field2; } -/*********************************************************************/ /** - Copies the data pointed to by a data field. */ +/** Copies the data pointed to by a data field. */ UNIV_INLINE -void dfield_dup( - /*=======*/ - dfield_t *field, /*!< in/out: data field */ - mem_heap_t *heap) /*!< in: memory heap where allocated */ +void dfield_dup(dfield_t *field, /*!< in/out: data field */ + mem_heap_t *heap) /*!< in: memory heap where allocated */ { if (!dfield_is_null(field) && field->data != NULL) { UNIV_MEM_ASSERT_RW(field->data, field->len); @@ -270,14 +228,12 @@ void dfield_dup( } } -/*********************************************************************/ /** - Tests if two data fields are equal. +/** Tests if two data fields are equal. If len==0, tests the data length and content for equality. If len>0, tests the first len bytes of the content for equality. @return true if both fields are NULL or if they are equal */ UNIV_INLINE ibool dfield_datas_are_binary_equal( - /*==========================*/ const dfield_t *field1, /*!< in: field */ const dfield_t *field2, /*!< in: field */ ulint len) /*!< in: maximum prefix to compare, @@ -297,12 +253,10 @@ ibool dfield_datas_are_binary_equal( (len == UNIV_SQL_NULL || !memcmp(field1->data, field2->data, len))); } -/*********************************************************************/ /** - Tests if dfield data length and content is equal to the given. +/** Tests if dfield data length and content is equal to the given. @return true if equal */ UNIV_INLINE ibool dfield_data_is_binary_equal( - /*========================*/ const dfield_t *field, /*!< in: field */ ulint len, /*!< in: data length or UNIV_SQL_NULL */ const byte *data) /*!< in: data */ @@ -314,50 +268,39 @@ ibool dfield_data_is_binary_equal( #ifndef UNIV_HOTBACKUP #endif /* !UNIV_HOTBACKUP */ -/*********************************************************************/ /** - Gets info bits in a data tuple. +/** Gets info bits in a data tuple. @return info bits */ UNIV_INLINE -ulint dtuple_get_info_bits( - /*=================*/ - const dtuple_t *tuple) /*!< in: tuple */ +ulint dtuple_get_info_bits(const dtuple_t *tuple) /*!< in: tuple */ { ut_ad(tuple); return (tuple->info_bits); } -/*********************************************************************/ /** - Sets info bits in a data tuple. */ +/** Sets info bits in a data tuple. */ UNIV_INLINE -void dtuple_set_info_bits( - /*=================*/ - dtuple_t *tuple, /*!< in: tuple */ - ulint info_bits) /*!< in: info bits */ +void dtuple_set_info_bits(dtuple_t *tuple, /*!< in: tuple */ + ulint info_bits) /*!< in: info bits */ { ut_ad(tuple); tuple->info_bits = info_bits; } -/*********************************************************************/ /** - Gets number of fields used in record comparisons. +/** Gets number of fields used in record comparisons. @return number of fields used in comparisons in rem0cmp.* */ UNIV_INLINE -ulint dtuple_get_n_fields_cmp( - /*====================*/ - const dtuple_t *tuple) /*!< in: tuple */ +ulint dtuple_get_n_fields_cmp(const dtuple_t *tuple) /*!< in: tuple */ { ut_ad(tuple); return (tuple->n_fields_cmp); } -/*********************************************************************/ /** - Sets number of fields used in record comparisons. */ +/** Sets number of fields used in record comparisons. */ UNIV_INLINE void dtuple_set_n_fields_cmp( - /*====================*/ dtuple_t *tuple, /*!< in: tuple */ ulint n_fields_cmp) /*!< in: number of fields used in comparisons in rem0cmp.* */ @@ -368,13 +311,10 @@ void dtuple_set_n_fields_cmp( tuple->n_fields_cmp = n_fields_cmp; } -/*********************************************************************/ /** - Gets number of fields in a data tuple. +/** Gets number of fields in a data tuple. @return number of fields */ UNIV_INLINE -ulint dtuple_get_n_fields( - /*================*/ - const dtuple_t *tuple) /*!< in: tuple */ +ulint dtuple_get_n_fields(const dtuple_t *tuple) /*!< in: tuple */ { ut_ad(tuple); @@ -494,13 +434,11 @@ void dtuple_init_v_fld(const dtuple_t *vrow) { } } -/**********************************************************/ /** - Creates a data tuple to a memory heap. The default value for number +/** Creates a data tuple to a memory heap. The default value for number of fields used in record comparisons for this tuple is n_fields. @return own: created tuple */ UNIV_INLINE dtuple_t *dtuple_create( - /*==========*/ mem_heap_t *heap, /*!< in: memory heap where the tuple is created, DTUPLE_EST_ALLOC(n_fields) bytes will be allocated from this heap */ @@ -545,16 +483,13 @@ void dtuple_copy_v_fields(dtuple_t *d_tuple, const dtuple_t *s_tuple) { } } -/*********************************************************************/ /** - Copies a data tuple to another. This is a shallow copy; if a deep copy +/** Copies a data tuple to another. This is a shallow copy; if a deep copy is desired, dfield_dup() will have to be invoked on each field. @return own: copy of tuple */ UNIV_INLINE -dtuple_t *dtuple_copy( - /*========*/ - const dtuple_t *tuple, /*!< in: tuple to copy from */ - mem_heap_t *heap) /*!< in: memory heap - where the tuple is created */ +dtuple_t *dtuple_copy(const dtuple_t *tuple, /*!< in: tuple to copy from */ + mem_heap_t *heap) /*!< in: memory heap + where the tuple is created */ { ulint n_fields = dtuple_get_n_fields(tuple); ulint n_v_fields = dtuple_get_n_v_fields(tuple); @@ -574,16 +509,13 @@ dtuple_t *dtuple_copy( return (new_tuple); } -/**********************************************************/ /** - The following function returns the sum of data lengths of a tuple. The space +/** The following function returns the sum of data lengths of a tuple. The space occupied by the field structs or the tuple struct is not counted. Neither is possible space in externally stored parts of the field. @return sum of data lengths */ UNIV_INLINE -ulint dtuple_get_data_size( - /*=================*/ - const dtuple_t *tuple, /*!< in: typed data tuple */ - ulint comp) /*!< in: nonzero=ROW_FORMAT=COMPACT */ +ulint dtuple_get_data_size(const dtuple_t *tuple, /*!< in: typed data tuple */ + ulint comp) /*!< in: nonzero=ROW_FORMAT=COMPACT */ { const dfield_t *field; ulint n_fields; @@ -611,13 +543,10 @@ ulint dtuple_get_data_size( return (sum); } -/*********************************************************************/ /** - Computes the number of externally stored fields in a data tuple. +/** Computes the number of externally stored fields in a data tuple. @return number of externally stored fields */ UNIV_INLINE -ulint dtuple_get_n_ext( - /*=============*/ - const dtuple_t *tuple) /*!< in: tuple */ +ulint dtuple_get_n_ext(const dtuple_t *tuple) /*!< in: tuple */ { ulint n_ext = 0; ulint n_fields = tuple->n_fields; @@ -634,13 +563,10 @@ ulint dtuple_get_n_ext( return (n_ext); } -/*******************************************************************/ /** - Sets types of fields binary in a tuple. */ +/** Sets types of fields binary in a tuple. */ UNIV_INLINE -void dtuple_set_types_binary( - /*====================*/ - dtuple_t *tuple, /*!< in: data tuple */ - ulint n) /*!< in: number of fields to set */ +void dtuple_set_types_binary(dtuple_t *tuple, /*!< in: data tuple */ + ulint n) /*!< in: number of fields to set */ { dtype_t *dfield_type; ulint i; @@ -698,24 +624,18 @@ ulint dtuple_fold(const dtuple_t *tuple, ulint n_fields, ulint n_bytes, return (fold); } -/**********************************************************************/ /** - Writes an SQL null field full of zeros. */ +/** Writes an SQL null field full of zeros. */ UNIV_INLINE -void data_write_sql_null( - /*================*/ - byte *data, /*!< in: pointer to a buffer of size len */ - ulint len) /*!< in: SQL null size in bytes */ +void data_write_sql_null(byte *data, /*!< in: pointer to a buffer of size len */ + ulint len) /*!< in: SQL null size in bytes */ { memset(data, 0, len); } -/**********************************************************************/ /** - Checks if a dtuple contains an SQL null value. +/** Checks if a dtuple contains an SQL null value. @return true if some field is SQL null */ UNIV_INLINE -ibool dtuple_contains_null( - /*=================*/ - const dtuple_t *tuple) /*!< in: dtuple */ +ibool dtuple_contains_null(const dtuple_t *tuple) /*!< in: dtuple */ { ulint n; ulint i; @@ -731,13 +651,10 @@ ibool dtuple_contains_null( return (FALSE); } -/**************************************************************/ /** - Frees the memory in a big rec vector. */ +/** Frees the memory in a big rec vector. */ UNIV_INLINE -void dtuple_big_rec_free( - /*================*/ - big_rec_t *vector) /*!< in, own: big rec vector; it is - freed in this function */ +void dtuple_big_rec_free(big_rec_t *vector) /*!< in, own: big rec vector; it is + freed in this function */ { mem_heap_free(vector->heap); } diff --git a/storage/innobase/include/data0type.h b/storage/innobase/include/data0type.h index a9a0a3dbc1ae..d299c992fc22 100644 --- a/storage/innobase/include/data0type.h +++ b/storage/innobase/include/data0type.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/data0type.h +/** @file include/data0type.h Data types Created 1/16/1996 Heikki Tuuri @@ -280,20 +279,15 @@ the underling datatype of GEOMETRY(not DATA_POINT) data. */ #define CHAR_COLL_MASK MAX_CHAR_COLL_NUM #ifndef UNIV_HOTBACKUP -/*********************************************************************/ /** - Gets the MySQL type code from a dtype. +/** Gets the MySQL type code from a dtype. @return MySQL type code; this is NOT an InnoDB type code! */ UNIV_INLINE -ulint dtype_get_mysql_type( - /*=================*/ - const dtype_t *type); /*!< in: type struct */ -/*********************************************************************/ /** - Determine how many bytes the first n characters of the given string occupy. +ulint dtype_get_mysql_type(const dtype_t *type); /*!< in: type struct */ +/** Determine how many bytes the first n characters of the given string occupy. If the string is shorter than n characters, returns the number of bytes the characters in the string occupy. @return length of the prefix, in bytes */ ulint dtype_get_at_most_n_mbchars( - /*========================*/ ulint prtype, /*!< in: precise type */ ulint mbminmaxlen, /*!< in: minimum and maximum length of a multi-byte character */ @@ -304,32 +298,24 @@ ulint dtype_get_at_most_n_mbchars( const char *str); /*!< in: the string whose prefix length is being determined */ #endif /* !UNIV_HOTBACKUP */ -/*********************************************************************/ /** - Checks if a data main type is a string type. Also a BLOB is considered a +/** Checks if a data main type is a string type. Also a BLOB is considered a string type. @return true if string type */ ibool dtype_is_string_type( - /*=================*/ ulint mtype); /*!< in: InnoDB main data type code: DATA_CHAR, ... */ -/*********************************************************************/ /** - Checks if a type is a binary string type. Note that for tables created with +/** Checks if a type is a binary string type. Note that for tables created with < 4.0.14, we do not know if a DATA_BLOB column is a BLOB or a TEXT column. For those DATA_BLOB columns this function currently returns FALSE. @return true if binary string type */ -ibool dtype_is_binary_string_type( - /*========================*/ - ulint mtype, /*!< in: main data type */ - ulint prtype); /*!< in: precise type */ -/*********************************************************************/ /** - Checks if a type is a non-binary string type. That is, dtype_is_string_type is - TRUE and dtype_is_binary_string_type is FALSE. Note that for tables created +ibool dtype_is_binary_string_type(ulint mtype, /*!< in: main data type */ + ulint prtype); /*!< in: precise type */ +/** Checks if a type is a non-binary string type. That is, dtype_is_string_type + is TRUE and dtype_is_binary_string_type is FALSE. Note that for tables created with < 4.0.14, we do not know if a DATA_BLOB column is a BLOB or a TEXT column. For those DATA_BLOB columns this function currently returns TRUE. @return true if non-binary string type */ -ibool dtype_is_non_binary_string_type( - /*============================*/ - ulint mtype, /*!< in: main data type */ - ulint prtype); /*!< in: precise type */ +ibool dtype_is_non_binary_string_type(ulint mtype, /*!< in: main data type */ + ulint prtype); /*!< in: precise type */ /** Sets a data type structure. @param[in] type type struct to init @@ -345,20 +331,14 @@ void dtype_set(dtype_t *type, ulint mtype, ulint prtype, ulint len); UNIV_INLINE void dtype_copy(dtype_t *type1, const dtype_t *type2); -/*********************************************************************/ /** - Gets the SQL main data type. +/** Gets the SQL main data type. @return SQL main data type */ UNIV_INLINE -ulint dtype_get_mtype( - /*============*/ - const dtype_t *type); /*!< in: data type */ -/*********************************************************************/ /** - Gets the precise data type. +ulint dtype_get_mtype(const dtype_t *type); /*!< in: data type */ +/** Gets the precise data type. @return precise data type */ UNIV_INLINE -ulint dtype_get_prtype( - /*=============*/ - const dtype_t *type); /*!< in: data type */ +ulint dtype_get_prtype(const dtype_t *type); /*!< in: data type */ /** Compute the mbminlen and mbmaxlen members of a data type structure. @param[in] mtype main type @@ -369,55 +349,38 @@ UNIV_INLINE void dtype_get_mblen(ulint mtype, ulint prtype, ulint *mbminlen, ulint *mbmaxlen); -/*********************************************************************/ /** - Gets the MySQL charset-collation code for MySQL string types. +/** Gets the MySQL charset-collation code for MySQL string types. @return MySQL charset-collation code */ UNIV_INLINE -ulint dtype_get_charset_coll( - /*===================*/ - ulint prtype); /*!< in: precise data type */ -/*********************************************************************/ /** - Forms a precise type from the < 4.1.2 format precise type plus the +ulint dtype_get_charset_coll(ulint prtype); /*!< in: precise data type */ +/** Forms a precise type from the < 4.1.2 format precise type plus the charset-collation code. @return precise type, including the charset-collation code */ ulint dtype_form_prtype( - /*==============*/ ulint old_prtype, /*!< in: the MySQL type code and the flags DATA_BINARY_TYPE etc. */ ulint charset_coll); /*!< in: MySQL charset-collation code */ -/*********************************************************************/ /** - Determines if a MySQL string type is a subset of UTF-8. This function +/** Determines if a MySQL string type is a subset of UTF-8. This function may return false negatives, in case further character-set collation codes are introduced in MySQL later. @return true if a subset of UTF-8 */ UNIV_INLINE -ibool dtype_is_utf8( - /*==========*/ - ulint prtype); /*!< in: precise data type */ -/*********************************************************************/ /** - Gets the type length. +ibool dtype_is_utf8(ulint prtype); /*!< in: precise data type */ +/** Gets the type length. @return fixed length of the type, in bytes, or 0 if variable-length */ UNIV_INLINE -ulint dtype_get_len( - /*==========*/ - const dtype_t *type); /*!< in: data type */ +ulint dtype_get_len(const dtype_t *type); /*!< in: data type */ #ifndef UNIV_HOTBACKUP -/*********************************************************************/ /** - Gets the minimum length of a character, in bytes. +/** Gets the minimum length of a character, in bytes. @return minimum length of a char, in bytes, or 0 if this is not a character type */ UNIV_INLINE -ulint dtype_get_mbminlen( - /*===============*/ - const dtype_t *type); /*!< in: type */ -/*********************************************************************/ /** - Gets the maximum length of a character, in bytes. +ulint dtype_get_mbminlen(const dtype_t *type); /*!< in: type */ +/** Gets the maximum length of a character, in bytes. @return maximum length of a char, in bytes, or 0 if this is not a character type */ UNIV_INLINE -ulint dtype_get_mbmaxlen( - /*===============*/ - const dtype_t *type); /*!< in: type */ +ulint dtype_get_mbmaxlen(const dtype_t *type); /*!< in: type */ /** Sets the minimum and maximum length of a character, in bytes. @param[in,out] type type @@ -507,12 +470,9 @@ char *dtype_sql_name(unsigned mtype, unsigned prtype, unsigned len, char *name, unsigned name_sz); #endif /* !UNIV_HOTBACKUP */ -/*********************************************************************/ /** - Validates a data type structure. +/** Validates a data type structure. @return true if ok */ -ibool dtype_validate( - /*===========*/ - const dtype_t *type); /*!< in: type struct to validate */ +ibool dtype_validate(const dtype_t *type); /*!< in: type struct to validate */ #ifdef UNIV_DEBUG /** Print a data type structure. @param[in] type data type */ diff --git a/storage/innobase/include/data0type.ic b/storage/innobase/include/data0type.ic index a03131d7071a..ab2934c7b8a8 100644 --- a/storage/innobase/include/data0type.ic +++ b/storage/innobase/include/data0type.ic @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/data0type.ic +/** @file include/data0type.ic Data types Created 1/16/1996 Heikki Tuuri @@ -34,27 +33,21 @@ this program; if not, write to the Free Software Foundation, Inc., #include "ha_prototypes.h" #include "mach0data.h" -/*********************************************************************/ /** - Gets the MySQL charset-collation code for MySQL string types. +/** Gets the MySQL charset-collation code for MySQL string types. @return MySQL charset-collation code */ UNIV_INLINE -ulint dtype_get_charset_coll( - /*===================*/ - ulint prtype) /*!< in: precise data type */ +ulint dtype_get_charset_coll(ulint prtype) /*!< in: precise data type */ { return ((prtype >> 16) & CHAR_COLL_MASK); } #ifndef UNIV_HOTBACKUP -/*********************************************************************/ /** - Determines if a MySQL string type is a subset of UTF-8. This function +/** Determines if a MySQL string type is a subset of UTF-8. This function may return false negatives, in case further character-set collation codes are introduced in MySQL later. @return true if a subset of UTF-8 */ UNIV_INLINE -ibool dtype_is_utf8( - /*==========*/ - ulint prtype) /*!< in: precise data type */ +ibool dtype_is_utf8(ulint prtype) /*!< in: precise data type */ { /* These codes have been copied from strings/ctype-extra.c and strings/ctype-utf8.c. */ @@ -70,28 +63,22 @@ ibool dtype_is_utf8( return (FALSE); } -/*********************************************************************/ /** - Gets the MySQL type code from a dtype. +/** Gets the MySQL type code from a dtype. @return MySQL type code; this is NOT an InnoDB type code! */ UNIV_INLINE -ulint dtype_get_mysql_type( - /*=================*/ - const dtype_t *type) /*!< in: type struct */ +ulint dtype_get_mysql_type(const dtype_t *type) /*!< in: type struct */ { return (type->prtype & 0xFFUL); } -/*********************************************************************/ /** - Compute the mbminlen and mbmaxlen members of a data type structure. */ +/** Compute the mbminlen and mbmaxlen members of a data type structure. */ UNIV_INLINE -void dtype_get_mblen( - /*============*/ - ulint mtype, /*!< in: main type */ - ulint prtype, /*!< in: precise type (and collation) */ - ulint *mbminlen, /*!< out: minimum length of a - multi-byte character */ - ulint *mbmaxlen) /*!< out: maximum length of a - multi-byte character */ +void dtype_get_mblen(ulint mtype, /*!< in: main type */ + ulint prtype, /*!< in: precise type (and collation) */ + ulint *mbminlen, /*!< out: minimum length of a + multi-byte character */ + ulint *mbmaxlen) /*!< out: maximum length of a + multi-byte character */ { if (dtype_is_string_type(mtype)) { innobase_get_cset_width(dtype_get_charset_coll(prtype), mbminlen, mbmaxlen); @@ -103,18 +90,15 @@ void dtype_get_mblen( } } -/*********************************************************************/ /** - Sets the minimum and maximum length of a character, in bytes. */ +/** Sets the minimum and maximum length of a character, in bytes. */ UNIV_INLINE -void dtype_set_mbminmaxlen( - /*==================*/ - dtype_t *type, /*!< in/out: type */ - ulint mbminlen, /*!< in: minimum length of a char, - in bytes, or 0 if this is not - a character type */ - ulint mbmaxlen) /*!< in: maximum length of a char, - in bytes, or 0 if this is not - a character type */ +void dtype_set_mbminmaxlen(dtype_t *type, /*!< in/out: type */ + ulint mbminlen, /*!< in: minimum length of a char, + in bytes, or 0 if this is not + a character type */ + ulint mbmaxlen) /*!< in: maximum length of a char, + in bytes, or 0 if this is not + a character type */ { ut_ad(mbminlen < DATA_MBMAX); ut_ad(mbmaxlen < DATA_MBMAX); @@ -123,12 +107,9 @@ void dtype_set_mbminmaxlen( type->mbminmaxlen = DATA_MBMINMAXLEN(mbminlen, mbmaxlen); } -/*********************************************************************/ /** - Compute the mbminlen and mbmaxlen members of a data type structure. */ +/** Compute the mbminlen and mbmaxlen members of a data type structure. */ UNIV_INLINE -void dtype_set_mblen( - /*============*/ - dtype_t *type) /*!< in/out: type */ +void dtype_set_mblen(dtype_t *type) /*!< in/out: type */ { ulint mbminlen; ulint mbmaxlen; @@ -142,15 +123,12 @@ void dtype_set_mblen( #define dtype_set_mblen(type) (void)0 #endif /* !UNIV_HOTBACKUP */ -/*********************************************************************/ /** - Sets a data type structure. */ +/** Sets a data type structure. */ UNIV_INLINE -void dtype_set( - /*======*/ - dtype_t *type, /*!< in: type struct to init */ - ulint mtype, /*!< in: main data type */ - ulint prtype, /*!< in: precise type */ - ulint len) /*!< in: precision of type */ +void dtype_set(dtype_t *type, /*!< in: type struct to init */ + ulint mtype, /*!< in: main data type */ + ulint prtype, /*!< in: precise type */ + ulint len) /*!< in: precision of type */ { ut_ad(type); ut_ad(mtype <= DATA_MTYPE_MAX); @@ -162,52 +140,40 @@ void dtype_set( dtype_set_mblen(type); } -/*********************************************************************/ /** - Copies a data type structure. */ +/** Copies a data type structure. */ UNIV_INLINE -void dtype_copy( - /*=======*/ - dtype_t *type1, /*!< in: type struct to copy to */ - const dtype_t *type2) /*!< in: type struct to copy from */ +void dtype_copy(dtype_t *type1, /*!< in: type struct to copy to */ + const dtype_t *type2) /*!< in: type struct to copy from */ { *type1 = *type2; ut_ad(dtype_validate(type1)); } -/*********************************************************************/ /** - Gets the SQL main data type. +/** Gets the SQL main data type. @return SQL main data type */ UNIV_INLINE -ulint dtype_get_mtype( - /*============*/ - const dtype_t *type) /*!< in: data type */ +ulint dtype_get_mtype(const dtype_t *type) /*!< in: data type */ { ut_ad(type); return (type->mtype); } -/*********************************************************************/ /** - Gets the precise data type. +/** Gets the precise data type. @return precise data type */ UNIV_INLINE -ulint dtype_get_prtype( - /*=============*/ - const dtype_t *type) /*!< in: data type */ +ulint dtype_get_prtype(const dtype_t *type) /*!< in: data type */ { ut_ad(type); return (type->prtype); } -/*********************************************************************/ /** - Gets the type length. +/** Gets the type length. @return fixed length of the type, in bytes, or 0 if variable-length */ UNIV_INLINE -ulint dtype_get_len( - /*==========*/ - const dtype_t *type) /*!< in: data type */ +ulint dtype_get_len(const dtype_t *type) /*!< in: data type */ { ut_ad(type); @@ -215,38 +181,30 @@ ulint dtype_get_len( } #ifndef UNIV_HOTBACKUP -/*********************************************************************/ /** - Gets the minimum length of a character, in bytes. +/** Gets the minimum length of a character, in bytes. @return minimum length of a char, in bytes, or 0 if this is not a character type */ UNIV_INLINE -ulint dtype_get_mbminlen( - /*===============*/ - const dtype_t *type) /*!< in: type */ +ulint dtype_get_mbminlen(const dtype_t *type) /*!< in: type */ { ut_ad(type); return (DATA_MBMINLEN(type->mbminmaxlen)); } -/*********************************************************************/ /** - Gets the maximum length of a character, in bytes. +/** Gets the maximum length of a character, in bytes. @return maximum length of a char, in bytes, or 0 if this is not a character type */ UNIV_INLINE -ulint dtype_get_mbmaxlen( - /*===============*/ - const dtype_t *type) /*!< in: type */ +ulint dtype_get_mbmaxlen(const dtype_t *type) /*!< in: type */ { ut_ad(type); return (DATA_MBMAXLEN(type->mbminmaxlen)); } -/**********************************************************************/ /** - Stores for a type the information which determines its alphabetical ordering +/** Stores for a type the information which determines its alphabetical ordering and the storage size of an SQL NULL value. This is the >= 4.1.x storage format. */ UNIV_INLINE void dtype_new_store_for_order_and_null_size( - /*====================================*/ byte *buf, /*!< in: buffer for DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE bytes where we store the info */ @@ -288,13 +246,11 @@ void dtype_new_store_for_order_and_null_size( } } -/**********************************************************************/ /** - Reads to a type the stored information which determines its alphabetical +/** Reads to a type the stored information which determines its alphabetical ordering and the storage size of an SQL NULL value. This is the < 4.1.x storage format. */ UNIV_INLINE void dtype_read_for_order_and_null_size( - /*===============================*/ dtype_t *type, /*!< in: type struct */ const byte *buf) /*!< in: buffer for stored type order info */ { @@ -316,13 +272,11 @@ void dtype_read_for_order_and_null_size( dtype_set_mblen(type); } -/**********************************************************************/ /** - Reads to a type the stored information which determines its alphabetical +/** Reads to a type the stored information which determines its alphabetical ordering and the storage size of an SQL NULL value. This is the >= 4.1.x storage format. */ UNIV_INLINE void dtype_new_read_for_order_and_null_size( - /*===================================*/ dtype_t *type, /*!< in: type struct */ const byte *buf) /*!< in: buffer for stored type order info */ { @@ -365,17 +319,14 @@ void dtype_new_read_for_order_and_null_size( dtype_set_mblen(type); } -/*********************************************************************/ /** - Returns the type's SQL name (e.g. BIGINT UNSIGNED) from mtype,prtype,len +/** Returns the type's SQL name (e.g. BIGINT UNSIGNED) from mtype,prtype,len @return the SQL type name */ UNIV_INLINE -char *dtype_sql_name( - /*===========*/ - unsigned mtype, /*!< in: mtype */ - unsigned prtype, /*!< in: prtype */ - unsigned len, /*!< in: len */ - char *name, /*!< out: SQL name */ - unsigned name_sz) /*!< in: size of the name buffer */ +char *dtype_sql_name(unsigned mtype, /*!< in: mtype */ + unsigned prtype, /*!< in: prtype */ + unsigned len, /*!< in: len */ + char *name, /*!< out: SQL name */ + unsigned name_sz) /*!< in: size of the name buffer */ { #define APPEND_UNSIGNED() \ do { \ @@ -458,12 +409,10 @@ char *dtype_sql_name( #endif /* !UNIV_HOTBACKUP */ -/***********************************************************************/ /** - Returns the size of a fixed size data type, 0 if not a fixed size type. +/** Returns the size of a fixed size data type, 0 if not a fixed size type. @return fixed size, or 0 */ UNIV_INLINE ulint dtype_get_fixed_size_low( - /*=====================*/ ulint mtype, /*!< in: main type */ ulint prtype, /*!< in: precise type */ ulint len, /*!< in: length */ @@ -537,12 +486,10 @@ ulint dtype_get_fixed_size_low( return (0); } -/***********************************************************************/ /** - Returns the minimum size of a data type. +/** Returns the minimum size of a data type. @return minimum size */ UNIV_INLINE ulint dtype_get_min_size_low( - /*===================*/ ulint mtype, /*!< in: main type */ ulint prtype, /*!< in: precise type */ ulint len, /*!< in: length */ @@ -613,10 +560,8 @@ be incomplete and return incorrect information. @param[in] len length @return maximum size */ UNIV_INLINE -ulint dtype_get_max_size_low( - /*===================*/ - ulint mtype, /*!< in: main type */ - ulint len) /*!< in: length */ +ulint dtype_get_max_size_low(ulint mtype, /*!< in: main type */ + ulint len) /*!< in: length */ { switch (mtype) { case DATA_SYS: @@ -643,15 +588,12 @@ ulint dtype_get_max_size_low( return (ULINT_MAX); } -/***********************************************************************/ /** - Returns the ROW_FORMAT=REDUNDANT stored SQL NULL size of a type. +/** Returns the ROW_FORMAT=REDUNDANT stored SQL NULL size of a type. For fixed length types it is the fixed length of the type, otherwise 0. @return SQL null storage size in ROW_FORMAT=REDUNDANT */ UNIV_INLINE -ulint dtype_get_sql_null_size( - /*====================*/ - const dtype_t *type, /*!< in: type */ - ulint comp) /*!< in: nonzero=ROW_FORMAT=COMPACT */ +ulint dtype_get_sql_null_size(const dtype_t *type, /*!< in: type */ + ulint comp) /*!< in: nonzero=ROW_FORMAT=COMPACT */ { #ifndef UNIV_HOTBACKUP return (dtype_get_fixed_size_low(type->mtype, type->prtype, type->len, diff --git a/storage/innobase/include/data0types.h b/storage/innobase/include/data0types.h index 7b4d66a732ca..13394b82c0cb 100644 --- a/storage/innobase/include/data0types.h +++ b/storage/innobase/include/data0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2000, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2000, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file include/data0types.h +/** @file include/data0types.h Some type definitions Created 9/21/2000 Heikki Tuuri diff --git a/storage/innobase/include/db0err.h b/storage/innobase/include/db0err.h index 6f95aec84479..5b738ee5d181 100644 --- a/storage/innobase/include/db0err.h +++ b/storage/innobase/include/db0err.h @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/db0err.h +/** @file include/db0err.h Global error codes for the database Created 5/24/1996 Heikki Tuuri diff --git a/storage/innobase/include/dict0boot.h b/storage/innobase/include/dict0boot.h index 1eb1d2b982da..5c61074f53ec 100644 --- a/storage/innobase/include/dict0boot.h +++ b/storage/innobase/include/dict0boot.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/dict0boot.h +/** @file include/dict0boot.h Data dictionary creation and booting Created 4/18/1996 Heikki Tuuri @@ -45,44 +44,31 @@ this program; if not, write to the Free Software Foundation, Inc., typedef byte dict_hdr_t; -/**********************************************************************/ /** - Gets a pointer to the dictionary header and x-latches its page. +/** Gets a pointer to the dictionary header and x-latches its page. @return pointer to the dictionary header, page x-latched */ -dict_hdr_t *dict_hdr_get( - /*=========*/ - mtr_t *mtr); /*!< in: mtr */ -/**********************************************************************/ /** - Returns a new table, index, or space id. */ -void dict_hdr_get_new_id( - /*================*/ - table_id_t *table_id, /*!< out: table id - (not assigned if NULL) */ - space_index_t *index_id, /*!< out: index id - (not assigned if NULL) */ - space_id_t *space_id, /*!< out: space id - (not assigned if NULL) */ - const dict_table_t *table, /*!< in: table */ - bool disable_redo); /*!< in: if true and table - object is NULL - then disable-redo */ -/**********************************************************************/ /** - Writes the current value of the row id counter to the dictionary header file +dict_hdr_t *dict_hdr_get(mtr_t *mtr); /*!< in: mtr */ +/** Returns a new table, index, or space id. */ +void dict_hdr_get_new_id(table_id_t *table_id, /*!< out: table id + (not assigned if NULL) */ + space_index_t *index_id, /*!< out: index id + (not assigned if NULL) */ + space_id_t *space_id, /*!< out: space id + (not assigned if NULL) */ + const dict_table_t *table, /*!< in: table */ + bool disable_redo); /*!< in: if true and table + object is NULL + then disable-redo */ +/** Writes the current value of the row id counter to the dictionary header file page. */ void dict_hdr_flush_row_id(void); -/*=======================*/ -/**********************************************************************/ /** - Returns a new row id. +/** Returns a new row id. @return the new id */ UNIV_INLINE row_id_t dict_sys_get_new_row_id(void); -/*=========================*/ -/**********************************************************************/ /** - Reads a row id from a record or other 6-byte stored form. +/** Reads a row id from a record or other 6-byte stored form. @return row id */ UNIV_INLINE -row_id_t dict_sys_read_row_id( - /*=================*/ - const byte *field); /*!< in: record field */ +row_id_t dict_sys_read_row_id(const byte *field); /*!< in: record field */ /** Writes a row id to a record or other 6-byte stored form. @param[in] field record field @@ -90,20 +76,14 @@ row_id_t dict_sys_read_row_id( UNIV_INLINE void dict_sys_write_row_id(byte *field, row_id_t row_id); -/*****************************************************************/ /** - Initializes the data dictionary memory structures when the database is +/** Initializes the data dictionary memory structures when the database is started. This function is also called when the data dictionary is created. @return DB_SUCCESS or error code. */ -dberr_t dict_boot(void) - /*===========*/ - MY_ATTRIBUTE((warn_unused_result)); +dberr_t dict_boot(void) MY_ATTRIBUTE((warn_unused_result)); -/*****************************************************************/ /** - Creates and initializes the data dictionary at the server bootstrap. +/** Creates and initializes the data dictionary at the server bootstrap. @return DB_SUCCESS or error code. */ -dberr_t dict_create(void) - /*=============*/ - MY_ATTRIBUTE((warn_unused_result)); +dberr_t dict_create(void) MY_ATTRIBUTE((warn_unused_result)); /** Check if a table id belongs to old innodb internal system table. @param[in] id table id diff --git a/storage/innobase/include/dict0boot.ic b/storage/innobase/include/dict0boot.ic index e49ba2fc1fcf..68356a160575 100644 --- a/storage/innobase/include/dict0boot.ic +++ b/storage/innobase/include/dict0boot.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,20 +24,16 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/dict0boot.ic +/** @file include/dict0boot.ic Data dictionary creation and booting Created 4/18/1996 Heikki Tuuri *******************************************************/ -/**********************************************************************/ /** - Returns a new row id. +/** Returns a new row id. @return the new id */ UNIV_INLINE -row_id_t dict_sys_get_new_row_id(void) -/*=========================*/ -{ +row_id_t dict_sys_get_new_row_id(void) { row_id_t id; mutex_enter(&dict_sys->mutex); @@ -55,13 +51,10 @@ row_id_t dict_sys_get_new_row_id(void) return (id); } -/**********************************************************************/ /** - Reads a row id from a record or other 6-byte stored form. +/** Reads a row id from a record or other 6-byte stored form. @return row id */ UNIV_INLINE -row_id_t dict_sys_read_row_id( - /*=================*/ - const byte *field) /*!< in: record field */ +row_id_t dict_sys_read_row_id(const byte *field) /*!< in: record field */ { #if DATA_ROW_ID_LEN != 6 #error "DATA_ROW_ID_LEN != 6" @@ -70,13 +63,10 @@ row_id_t dict_sys_read_row_id( return (mach_read_from_6(field)); } -/**********************************************************************/ /** - Writes a row id to a record or other 6-byte stored form. */ +/** Writes a row id to a record or other 6-byte stored form. */ UNIV_INLINE -void dict_sys_write_row_id( - /*==================*/ - byte *field, /*!< in: record field */ - row_id_t row_id) /*!< in: row id */ +void dict_sys_write_row_id(byte *field, /*!< in: record field */ + row_id_t row_id) /*!< in: row id */ { #if DATA_ROW_ID_LEN != 6 #error "DATA_ROW_ID_LEN != 6" diff --git a/storage/innobase/include/dict0crea.h b/storage/innobase/include/dict0crea.h index 3c499796d38b..9c1061f7abf2 100644 --- a/storage/innobase/include/dict0crea.h +++ b/storage/innobase/include/dict0crea.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/dict0crea.h +/** @file include/dict0crea.h Database object creation Created 1/8/1996 Heikki Tuuri @@ -65,16 +64,12 @@ dberr_t dict_build_tablespace_for_table(dict_table_t *table, trx_t *trx); @param[in,out] trx Transaction */ void dict_table_assign_new_id(dict_table_t *table, trx_t *trx); -/***************************************************************/ /** - Builds an index definition but doesn't update sys_table. */ -void dict_build_index_def( - /*=================*/ - const dict_table_t *table, /*!< in: table */ - dict_index_t *index, /*!< in/out: index */ - trx_t *trx); /*!< in/out: InnoDB transaction - handle */ -/***************************************************************/ /** - Creates an index tree for the index if it is not a member of a cluster. +/** Builds an index definition but doesn't update sys_table. */ +void dict_build_index_def(const dict_table_t *table, /*!< in: table */ + dict_index_t *index, /*!< in/out: index */ + trx_t *trx); /*!< in/out: InnoDB transaction + handle */ +/** Creates an index tree for the index if it is not a member of a cluster. @param[in,out] index InnoDB index object @param[in,out] trx transaction @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ diff --git a/storage/innobase/include/dict0crea.ic b/storage/innobase/include/dict0crea.ic index 56c4c92efde8..88da653d3562 100644 --- a/storage/innobase/include/dict0crea.ic +++ b/storage/innobase/include/dict0crea.ic @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/dict0crea.ic +/** @file include/dict0crea.ic Database object creation Created 1/8/1996 Heikki Tuuri @@ -35,24 +34,20 @@ this program; if not, write to the Free Software Foundation, Inc., #include "mem0mem.h" -/*********************************************************************/ /** - Checks if a table name contains the string "/#sql" which denotes temporary +/** Checks if a table name contains the string "/#sql" which denotes temporary tables in MySQL. @return true if temporary table */ -bool row_is_mysql_tmp_table_name( - /*========================*/ - const char *name) MY_ATTRIBUTE((warn_unused_result)); +bool row_is_mysql_tmp_table_name(const char *name) + MY_ATTRIBUTE((warn_unused_result)); /*!< in: table name in the form 'database/tablename' */ -/********************************************************************/ /** - Generate a foreign key constraint name when it was not named by the user. +/** Generate a foreign key constraint name when it was not named by the user. A generated constraint has a name of the format dbname/tablename_ibfk_NUMBER, where the numbers start from 1, and are given locally for this table, that is, the number is not global, as it used to be before MySQL 4.0.18. */ UNIV_INLINE dberr_t dict_create_add_foreign_id( - /*=======================*/ ulint *id_nr, /*!< in/out: number to use in id generation; incremented if used */ const char *name, /*!< in: table name */ diff --git a/storage/innobase/include/dict0dd.ic b/storage/innobase/include/dict0dd.ic index ea35cbe02c3a..2a7941231b84 100644 --- a/storage/innobase/include/dict0dd.ic +++ b/storage/innobase/include/dict0dd.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2016, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2016, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/dict0dd.ic +/** @file include/dict0dd.ic Data dictionary access Created 10/2016 Jimmy Yamg diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index f12320f8ceab..341f99d33aea 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -25,8 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/dict0dict.h +/** @file include/dict0dict.h Data dictionary system Created 1/8/1996 Heikki Tuuri @@ -68,22 +67,17 @@ const uint32_t SDI_VERSION = 1; /** Space id of system tablespace */ const space_id_t SYSTEM_TABLE_SPACE = TRX_SYS_SPACE; -/********************************************************************/ /** - Get the database name length in a table name. +/** Get the database name length in a table name. @return database name length */ -ulint dict_get_db_name_len( - /*=================*/ - const char *name) /*!< in: table name in the form - dbname '/' tablename */ +ulint dict_get_db_name_len(const char *name) /*!< in: table name in the form + dbname '/' tablename */ MY_ATTRIBUTE((warn_unused_result)); #ifndef UNIV_HOTBACKUP -/*********************************************************************/ /** - Open a table from its database and table name, this is currently used by +/** Open a table from its database and table name, this is currently used by foreign constraint parser to get the referenced table. @return complete table name with database and table name, allocated from heap memory passed in */ char *dict_get_referenced_table( - /*======================*/ const char *name, /*!< in: foreign key table name */ const char *database_name, /*!< in: table db name */ ulint database_name_len, /*!< in: db name length */ @@ -91,26 +85,20 @@ char *dict_get_referenced_table( ulint table_name_len, /*!< in: table name length */ dict_table_t **table, /*!< out: table object or NULL */ mem_heap_t *heap); /*!< in: heap memory */ -/*********************************************************************/ /** - Frees a foreign key struct. */ +/** Frees a foreign key struct. */ void dict_foreign_free( - /*==============*/ dict_foreign_t *foreign); /*!< in, own: foreign key struct */ -/*********************************************************************/ /** - Finds the highest [number] for foreign key constraints of the table. Looks +/** Finds the highest [number] for foreign key constraints of the table. Looks only at the >= 4.0.18-format id's, which are of the form databasename/tablename_ibfk_[number]. @return highest number, 0 if table has no new format foreign key constraints */ ulint dict_table_get_highest_foreign_id( - /*==============================*/ dict_table_t *table); /*!< in: table in the dictionary memory cache */ #endif /* !UNIV_HOTBACKUP */ -/********************************************************************/ /** - Return the end of table name where we have removed dbname and '/'. +/** Return the end of table name where we have removed dbname and '/'. @return table name */ const char *dict_remove_db_name( - /*================*/ const char *name) /*!< in: table name in the form dbname '/' tablename */ MY_ATTRIBUTE((warn_unused_result)); @@ -126,27 +114,21 @@ enum dict_table_op_t { DICT_TABLE_OP_LOAD_TABLESPACE }; -/********************************************************************/ /** - Decrements the count of open handles to a table. */ -void dict_table_close( - /*=============*/ - dict_table_t *table, /*!< in/out: table */ - ibool dict_locked, /*!< in: TRUE=data dictionary locked */ - ibool try_drop); /*!< in: TRUE=try to drop any orphan - indexes after an aborted online - index creation */ -/*********************************************************************/ /** - Closes the only open handle to a table and drops a table while assuring +/** Decrements the count of open handles to a table. */ +void dict_table_close(dict_table_t *table, /*!< in/out: table */ + ibool dict_locked, /*!< in: TRUE=data dictionary locked */ + ibool try_drop); /*!< in: TRUE=try to drop any orphan + indexes after an aborted online + index creation */ +/** Closes the only open handle to a table and drops a table while assuring that dict_sys->mutex is held the whole time. This assures that the table is not evicted after the close when the count of open handles goes to zero. Because dict_sys->mutex is held, we do not need to call dict_table_prevent_eviction(). */ void dict_table_close_and_drop( - /*======================*/ trx_t *trx, /*!< in: data dictionary transaction */ dict_table_t *table); /*!< in/out: table */ -/**********************************************************************/ /** - Inits the data dictionary module. */ +/** Inits the data dictionary module. */ void dict_init(void); /** Inits the structure for persisting dynamic metadata */ @@ -168,14 +150,12 @@ void dict_table_persist_to_dd_table_buffer(dict_table_t *table); void dict_table_read_dynamic_metadata(const byte *buffer, ulint size, PersistentTableMetadata *metadata); -/**********************************************************************/ /** - Determine bytes of column prefix to be stored in the undo log. Please +/** Determine bytes of column prefix to be stored in the undo log. Please note that if !dict_table_has_atomic_blobs(table), no prefix needs to be stored in the undo log. @return bytes of column prefix to be stored in the undo log */ UNIV_INLINE ulint dict_max_field_len_store_undo( - /*==========================*/ dict_table_t *table, /*!< in: table */ const dict_col_t *col) /*!< in: column which index prefix is based on */ @@ -190,19 +170,14 @@ UNIV_INLINE ulint dict_max_v_field_len_store_undo(dict_table_t *table, ulint col_no); #endif /* !UNIV_HOTBACKUP */ -/*********************************************************************/ /** - Gets the column number. +/** Gets the column number. @return col->ind, table column position (starting from 0) */ UNIV_INLINE -ulint dict_col_get_no( - /*============*/ - const dict_col_t *col) /*!< in: column */ +ulint dict_col_get_no(const dict_col_t *col) /*!< in: column */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Gets the column position in the clustered index. */ +/** Gets the column position in the clustered index. */ UNIV_INLINE ulint dict_col_get_clust_pos( - /*===================*/ const dict_col_t *col, /*!< in: table column */ const dict_index_t *clust_index) /*!< in: clustered index */ MY_ATTRIBUTE((warn_unused_result)); @@ -216,47 +191,31 @@ UNIV_INLINE ulint dict_col_get_index_pos(const dict_col_t *col, const dict_index_t *index) MY_ATTRIBUTE((nonnull, warn_unused_result)); -/****************************************************************/ /** - If the given column name is reserved for InnoDB system columns, return +/** If the given column name is reserved for InnoDB system columns, return TRUE. @return true if name is reserved */ -ibool dict_col_name_is_reserved( - /*======================*/ - const char *name) /*!< in: column name */ +ibool dict_col_name_is_reserved(const char *name) /*!< in: column name */ MY_ATTRIBUTE((warn_unused_result)); -/********************************************************************/ /** - Acquire the autoinc lock. */ -void dict_table_autoinc_lock( - /*====================*/ - dict_table_t *table); /*!< in/out: table */ +/** Acquire the autoinc lock. */ +void dict_table_autoinc_lock(dict_table_t *table); /*!< in/out: table */ -/********************************************************************/ /** - Unconditionally set the autoinc counter. */ +/** Unconditionally set the autoinc counter. */ void dict_table_autoinc_initialize( - /*==========================*/ dict_table_t *table, /*!< in/out: table */ ib_uint64_t value); /*!< in: next value to assign to a row */ -/********************************************************************/ /** - Reads the next autoinc value (== autoinc counter value), 0 if not yet +/** Reads the next autoinc value (== autoinc counter value), 0 if not yet initialized. @return value for a new row, or 0 */ -ib_uint64_t dict_table_autoinc_read( - /*====================*/ - const dict_table_t *table) /*!< in: table */ +ib_uint64_t dict_table_autoinc_read(const dict_table_t *table) /*!< in: table */ MY_ATTRIBUTE((warn_unused_result)); -/********************************************************************/ /** - Updates the autoinc counter if the value supplied is greater than the +/** Updates the autoinc counter if the value supplied is greater than the current value. */ void dict_table_autoinc_update_if_greater( - /*=================================*/ dict_table_t *table, /*!< in/out: table */ ib_uint64_t value); /*!< in: value which was assigned to a row */ -/********************************************************************/ /** - Release the autoinc lock. */ -void dict_table_autoinc_unlock( - /*======================*/ - dict_table_t *table); /*!< in/out: table */ +/** Release the autoinc lock. */ +void dict_table_autoinc_unlock(dict_table_t *table); /*!< in/out: table */ /** Update the persisted autoinc counter to specified one, we should hold autoinc_persisted_mutex. @@ -279,12 +238,9 @@ UNIV_INLINE bool dict_table_has_autoinc_col(const dict_table_t *table); #endif /* !UNIV_HOTBACKUP */ -/**********************************************************************/ /** - Adds system columns to a table object. */ -void dict_table_add_system_columns( - /*==========================*/ - dict_table_t *table, /*!< in/out: table */ - mem_heap_t *heap); /*!< in: temporary heap */ +/** Adds system columns to a table object. */ +void dict_table_add_system_columns(dict_table_t *table, /*!< in/out: table */ + mem_heap_t *heap); /*!< in: temporary heap */ #ifndef UNIV_HOTBACKUP /** Mark if table has big rows. @param[in,out] table table handler */ @@ -297,11 +253,8 @@ void dict_table_set_big_rows(dict_table_t *table) MY_ATTRIBUTE((nonnull)); void dict_table_add_to_cache(dict_table_t *table, ibool can_be_evicted, mem_heap_t *heap); -/**********************************************************************/ /** - Removes a table object from the dictionary cache. */ -void dict_table_remove_from_cache( - /*=========================*/ - dict_table_t *table); /*!< in, own: table */ +/** Removes a table object from the dictionary cache. */ +void dict_table_remove_from_cache(dict_table_t *table); /*!< in, own: table */ /** Try to invalidate an entry from the dict cache, for a partitioned table, if any table found. @@ -316,14 +269,11 @@ void dict_partitioned_table_remove_from_cache(const char *name); void dict_table_remove_from_cache_debug(dict_table_t *table, bool lru_evict); #endif /* UNIV_DEBUG */ -/**********************************************************************/ /** - Renames a table object. +/** Renames a table object. @return true if success */ -dberr_t dict_table_rename_in_cache( - /*=======================*/ - dict_table_t *table, /*!< in/out: table */ - const char *new_name, /*!< in: new name */ - ibool rename_also_foreigns) +dberr_t dict_table_rename_in_cache(dict_table_t *table, /*!< in/out: table */ + const char *new_name, /*!< in: new name */ + ibool rename_also_foreigns) /*!< in: in ALTER TABLE we want to preserve the original table name in constraints which reference it */ @@ -335,52 +285,41 @@ dberr_t dict_table_rename_in_cache( be accessed by the caller afterwards */ void dict_index_remove_from_cache(dict_table_t *table, dict_index_t *index); -/**********************************************************************/ /** - Change the id of a table object in the dictionary cache. This is used in +/** Change the id of a table object in the dictionary cache. This is used in DISCARD TABLESPACE. */ void dict_table_change_id_in_cache( - /*==========================*/ dict_table_t *table, /*!< in/out: table object already in cache */ table_id_t new_id); /*!< in: new id to set */ -/**********************************************************************/ /** - Removes a foreign constraint struct from the dictionary cache. */ +/** Removes a foreign constraint struct from the dictionary cache. */ void dict_foreign_remove_from_cache( - /*===========================*/ dict_foreign_t *foreign); /*!< in, own: foreign constraint */ -/**********************************************************************/ /** - Adds a foreign key constraint object to the dictionary cache. May free +/** Adds a foreign key constraint object to the dictionary cache. May free the object if there already is an object with the same identifier in. At least one of foreign table or referenced table must already be in the dictionary cache! @return DB_SUCCESS or error code */ -dberr_t dict_foreign_add_to_cache( - /*======================*/ - dict_foreign_t *foreign, - /*!< in, own: foreign key constraint */ - const char **col_names, - /*!< in: column names, or NULL to use - foreign->foreign_table->col_names */ - bool check_charsets, - /*!< in: whether to check charset - compatibility */ - bool can_free_fk, - /*!< in: whether free existing FK */ - dict_err_ignore_t ignore_err) +dberr_t dict_foreign_add_to_cache(dict_foreign_t *foreign, + /*!< in, own: foreign key constraint */ + const char **col_names, + /*!< in: column names, or NULL to use + foreign->foreign_table->col_names */ + bool check_charsets, + /*!< in: whether to check charset + compatibility */ + bool can_free_fk, + /*!< in: whether free existing FK */ + dict_err_ignore_t ignore_err) /*!< in: error to be ignored */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Checks if a table is referenced by foreign keys. +/** Checks if a table is referenced by foreign keys. @return true if table is referenced by a foreign key */ ibool dict_table_is_referenced_by_foreign_key( - /*====================================*/ const dict_table_t *table) /*!< in: InnoDB table */ MY_ATTRIBUTE((warn_unused_result)); -/**********************************************************************/ /** - Replace the index passed in with another equivalent index in the +/** Replace the index passed in with another equivalent index in the foreign key lists of the table. @return whether all replacements were found */ bool dict_foreign_replace_index( - /*=======================*/ dict_table_t *table, /*!< in/out: table */ const char **col_names, /*!< in: column names, or NULL @@ -411,12 +350,10 @@ dberr_t dict_create_foreign_constraints(trx_t *trx, const char *sql_string, size_t sql_length, const char *name, ibool reject_fks) MY_ATTRIBUTE((warn_unused_result)); -/**********************************************************************/ /** - Parses the CONSTRAINT id's to be dropped in an ALTER TABLE statement. +/** Parses the CONSTRAINT id's to be dropped in an ALTER TABLE statement. @return DB_SUCCESS or DB_CANNOT_DROP_CONSTRAINT if syntax error or the constraint id does not match */ dberr_t dict_foreign_parse_drop_constraints( - /*================================*/ mem_heap_t *heap, /*!< in: heap from which we can allocate memory */ trx_t *trx, /*!< in: transaction */ @@ -427,8 +364,7 @@ dberr_t dict_foreign_parse_drop_constraints( constraints to drop */ MY_ATTRIBUTE((warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ -/**********************************************************************/ /** - Returns a table object and increments its open handle count. +/** Returns a table object and increments its open handle count. NOTE! This is a high-level function to be used mainly from outside the 'dict' directory. Inside this directory dict_table_get_low is usually the appropriate function. @@ -443,13 +379,11 @@ dict_table_t *dict_table_open_on_name(const char *table_name, ibool dict_locked, dict_err_ignore_t ignore_err) MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Tries to find an index whose first fields are the columns in the array, +/** Tries to find an index whose first fields are the columns in the array, in the same order and is not marked for deletion and is not the same as types_idx. @return matching index, NULL if not found */ dict_index_t *dict_foreign_find_index( - /*====================*/ const dict_table_t *table, /*!< in: table */ const char **col_names, /*!< in: column names, or NULL @@ -485,10 +419,8 @@ otherwise table->n_def */ ulint dict_table_has_column(const dict_table_t *table, const char *col_name, ulint col_nr = 0); -/**********************************************************************/ /** - Outputs info on foreign keys of a table. */ +/** Outputs info on foreign keys of a table. */ void dict_print_info_on_foreign_keys( - /*============================*/ ibool create_table_format, /*!< in: if TRUE then print in a format suitable to be inserted into a CREATE TABLE, otherwise in the format @@ -496,22 +428,18 @@ void dict_print_info_on_foreign_keys( FILE *file, /*!< in: file where to print */ trx_t *trx, /*!< in: transaction */ dict_table_t *table); /*!< in: table */ -/**********************************************************************/ /** - Outputs info on a foreign key of a table in a format suitable for +/** Outputs info on a foreign key of a table in a format suitable for CREATE TABLE. */ void dict_print_info_on_foreign_key_in_create_format( - /*============================================*/ FILE *file, /*!< in: file where to print */ trx_t *trx, /*!< in: transaction */ dict_foreign_t *foreign, /*!< in: foreign key constraint */ ibool add_newline); /*!< in: whether to add a newline */ -/*********************************************************************/ /** - Tries to find an index whose first fields are the columns in the array, +/** Tries to find an index whose first fields are the columns in the array, in the same order and is not marked for deletion and is not the same as types_idx. @return matching index, NULL if not found */ bool dict_foreign_qualify_index( - /*====================*/ const dict_table_t *table, /*!< in: table */ const char **col_names, /*!< in: column names, or NULL @@ -553,34 +481,25 @@ bool dict_foreign_qualify_index( UNIV_INLINE bool dict_index_is_auto_gen_clust(const dict_index_t *index); -/********************************************************************/ /** - Check whether the index is unique. +/** Check whether the index is unique. @return nonzero for unique index, zero for other indexes */ UNIV_INLINE -ulint dict_index_is_unique( - /*=================*/ - const dict_index_t *index) /*!< in: index */ +ulint dict_index_is_unique(const dict_index_t *index) /*!< in: index */ MY_ATTRIBUTE((warn_unused_result)); -/********************************************************************/ /** - Check whether the index is a Spatial Index. +/** Check whether the index is a Spatial Index. @return nonzero for Spatial Index, zero for other indexes */ UNIV_INLINE -ulint dict_index_is_spatial( - /*==================*/ - const dict_index_t *index) /*!< in: index */ +ulint dict_index_is_spatial(const dict_index_t *index) /*!< in: index */ MY_ATTRIBUTE((warn_unused_result)); /** Check whether the index contains a virtual column. @param[in] index index @return nonzero for index on virtual column, zero for other indexes */ UNIV_INLINE ulint dict_index_has_virtual(const dict_index_t *index); -/********************************************************************/ /** - Check whether the index is the insert buffer tree. +/** Check whether the index is the insert buffer tree. @return nonzero for insert buffer, zero for other indexes */ UNIV_INLINE -ulint dict_index_is_ibuf( - /*===============*/ - const dict_index_t *index) /*!< in: index */ +ulint dict_index_is_ibuf(const dict_index_t *index) /*!< in: index */ MY_ATTRIBUTE((warn_unused_result)); /** Check whether the index consists of descending columns only. @@ -590,13 +509,10 @@ ulint dict_index_is_ibuf( UNIV_INLINE bool dict_index_has_desc(const dict_index_t *index) MY_ATTRIBUTE((warn_unused_result)); -/********************************************************************/ /** - Check whether the index is a secondary index or the insert buffer tree. +/** Check whether the index is a secondary index or the insert buffer tree. @return nonzero for insert buffer, zero for other indexes */ UNIV_INLINE -ulint dict_index_is_sec_or_ibuf( - /*======================*/ - const dict_index_t *index) /*!< in: index */ +ulint dict_index_is_sec_or_ibuf(const dict_index_t *index) /*!< in: index */ MY_ATTRIBUTE((warn_unused_result)); /** Get all the FTS indexes on a table. @@ -620,30 +536,21 @@ ulint dict_table_get_n_v_cols(const dict_table_t *table); UNIV_INLINE bool dict_table_has_indexed_v_cols(const dict_table_t *table); -/********************************************************************/ /** - Gets the approximately estimated number of rows in the table. +/** Gets the approximately estimated number of rows in the table. @return estimated number of rows */ UNIV_INLINE -ib_uint64_t dict_table_get_n_rows( - /*==================*/ - const dict_table_t *table) /*!< in: table */ +ib_uint64_t dict_table_get_n_rows(const dict_table_t *table) /*!< in: table */ MY_ATTRIBUTE((warn_unused_result)); -/********************************************************************/ /** - Increment the number of rows in the table by one. +/** Increment the number of rows in the table by one. Notice that this operation is not protected by any latch, the number is approximate. */ UNIV_INLINE -void dict_table_n_rows_inc( - /*==================*/ - dict_table_t *table); /*!< in/out: table */ -/********************************************************************/ /** - Decrement the number of rows in the table by one. +void dict_table_n_rows_inc(dict_table_t *table); /*!< in/out: table */ +/** Decrement the number of rows in the table by one. Notice that this operation is not protected by any latch, the number is approximate. */ UNIV_INLINE -void dict_table_n_rows_dec( - /*==================*/ - dict_table_t *table); /*!< in/out: table */ +void dict_table_n_rows_dec(dict_table_t *table); /*!< in/out: table */ /** Get nth virtual column @param[in] table target table @@ -664,22 +571,16 @@ dict_v_col_t *dict_table_get_nth_v_col(const dict_table_t *table, ulint pos); /* Get nth virtual columns */ #define dict_table_get_nth_v_col(table, pos) ((table)->v_cols + (pos)) #endif /* UNIV_DEBUG */ -/********************************************************************/ /** - Gets the given system column number of a table. +/** Gets the given system column number of a table. @return column number */ UNIV_INLINE -ulint dict_table_get_sys_col_no( - /*======================*/ - const dict_table_t *table, /*!< in: table */ - ulint sys) /*!< in: DATA_ROW_ID, ... */ +ulint dict_table_get_sys_col_no(const dict_table_t *table, /*!< in: table */ + ulint sys) /*!< in: DATA_ROW_ID, ... */ MY_ATTRIBUTE((warn_unused_result)); -/********************************************************************/ /** - Check whether the table uses the compact page format. +/** Check whether the table uses the compact page format. @return true if table uses the compact page format */ UNIV_INLINE -ibool dict_table_is_comp( - /*===============*/ - const dict_table_t *table) /*!< in: table */ +ibool dict_table_is_comp(const dict_table_t *table) /*!< in: table */ MY_ATTRIBUTE((warn_unused_result)); /** Determine if a table uses atomic BLOBs (no locally stored prefix). @@ -747,37 +648,26 @@ const page_size_t dict_table_page_size(const dict_table_t *table) MY_ATTRIBUTE((warn_unused_result)); #ifndef UNIV_HOTBACKUP -/*********************************************************************/ /** - Obtain exclusive locks on all index trees of the table. This is to prevent +/** Obtain exclusive locks on all index trees of the table. This is to prevent accessing index trees while InnoDB is updating internal metadata for operations such as FLUSH TABLES. */ UNIV_INLINE -void dict_table_x_lock_indexes( - /*======================*/ - dict_table_t *table); /*!< in: table */ -/*********************************************************************/ /** - Release the exclusive locks on all index tree. */ +void dict_table_x_lock_indexes(dict_table_t *table); /*!< in: table */ +/** Release the exclusive locks on all index tree. */ UNIV_INLINE -void dict_table_x_unlock_indexes( - /*========================*/ - dict_table_t *table); /*!< in: table */ -#endif /* !UNIV_HOTBACKUP */ -/********************************************************************/ /** - Checks if a column is in the ordering columns of the clustered index of a +void dict_table_x_unlock_indexes(dict_table_t *table); /*!< in: table */ +#endif /* !UNIV_HOTBACKUP */ +/** Checks if a column is in the ordering columns of the clustered index of a table. Column prefixes are treated like whole columns. @return true if the column, or its prefix, is in the clustered key */ ibool dict_table_col_in_clustered_key( - /*============================*/ const dict_table_t *table, /*!< in: table */ ulint n) /*!< in: column number */ MY_ATTRIBUTE((warn_unused_result)); -/*******************************************************************/ /** - Check if the table has an FTS index. +/** Check if the table has an FTS index. @return true if table has an FTS index */ UNIV_INLINE -ibool dict_table_has_fts_index( - /*=====================*/ - dict_table_t *table) /*!< in: table */ +ibool dict_table_has_fts_index(dict_table_t *table) /*!< in: table */ MY_ATTRIBUTE((warn_unused_result)); /** Copies types of virtual columns contained in table to tuple and sets all fields of the tuple to the SQL NULL value. This function should @@ -785,21 +675,17 @@ be called right after dtuple_create(). @param[in,out] tuple data tuple @param[in] table table */ void dict_table_copy_v_types(dtuple_t *tuple, const dict_table_t *table); -/*******************************************************************/ /** - Copies types of columns contained in table to tuple and sets all +/** Copies types of columns contained in table to tuple and sets all fields of the tuple to the SQL NULL value. This function should be called right after dtuple_create(). */ -void dict_table_copy_types( - /*==================*/ - dtuple_t *tuple, /*!< in/out: data tuple */ - const dict_table_t *table); /*!< in: table */ +void dict_table_copy_types(dtuple_t *tuple, /*!< in/out: data tuple */ + const dict_table_t *table); /*!< in: table */ #ifndef UNIV_HOTBACKUP /******************************************************************** Wait until all the background threads of the given table have exited, i.e., bg_threads == 0. Note: bg_threads_mutex must be reserved when calling this. */ void dict_table_wait_for_bg_threads_to_exit( - /*===================================*/ dict_table_t *table, /* in: table */ ulint delay); /* in: time in microseconds to wait between checks of bg_threads. */ @@ -808,13 +694,11 @@ void dict_table_wait_for_bg_threads_to_exit( @return index or NULL if not found */ const dict_index_t *dict_index_find(const index_id_t &id) MY_ATTRIBUTE((warn_unused_result)); -/**********************************************************************/ /** - Make room in the table cache by evicting an unused table. The unused table +/** Make room in the table cache by evicting an unused table. The unused table should not be part of FK relationship and currently not used in any user transaction. There is no guarantee that it will remove a table. @return number of tables evicted. */ ulint dict_make_room_in_cache( - /*====================*/ ulint max_tables, /*!< in: max tables allowed in cache */ ulint pct_check); /*!< in: max percent to check */ @@ -830,7 +714,6 @@ ulint dict_make_room_in_cache( an B-tree page @return DB_SUCCESS, DB_TOO_BIG_RECORD, or DB_CORRUPTION */ dberr_t dict_index_add_to_cache( - /*====================*/ dict_table_t *table, /*!< in: table on which the index is */ dict_index_t *index, /*!< in, own: index; NOTE! The index memory object is freed in this function! */ @@ -861,37 +744,31 @@ dberr_t dict_index_add_to_cache_w_vcol(dict_table_t *table, dict_index_t *index, page_no_t page_no, ibool strict) MY_ATTRIBUTE((warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ -/********************************************************************/ /** - Gets the number of fields in the internal representation of an index, +/** Gets the number of fields in the internal representation of an index, including fields added by the dictionary system. @return number of fields */ UNIV_INLINE ulint dict_index_get_n_fields( - /*====================*/ const dict_index_t *index) /*!< in: an internal representation of index (in the dictionary cache) */ MY_ATTRIBUTE((warn_unused_result)); -/********************************************************************/ /** - Gets the number of fields in the internal representation of an index +/** Gets the number of fields in the internal representation of an index that uniquely determine the position of an index entry in the index, if we do not take multiversioning into account: in the B-tree use the value returned by dict_index_get_n_unique_in_tree. @return number of fields */ UNIV_INLINE ulint dict_index_get_n_unique( - /*====================*/ const dict_index_t *index) /*!< in: an internal representation of index (in the dictionary cache) */ MY_ATTRIBUTE((warn_unused_result)); -/********************************************************************/ /** - Gets the number of fields in the internal representation of an index +/** Gets the number of fields in the internal representation of an index which uniquely determine the position of an index entry in the index, if we also take multiversioning into account. @return number of fields */ UNIV_INLINE ulint dict_index_get_n_unique_in_tree( - /*============================*/ const dict_index_t *index) /*!< in: an internal representation of index (in the dictionary cache) */ MY_ATTRIBUTE((warn_unused_result)); @@ -909,48 +786,39 @@ include page no field. UNIV_INLINE ulint dict_index_get_n_unique_in_tree_nonleaf(const dict_index_t *index) MY_ATTRIBUTE((warn_unused_result)); -/********************************************************************/ /** - Gets the number of user-defined ordering fields in the index. In the internal - representation we add the row id to the ordering fields to make all indexes - unique, but this function returns the number of fields the user defined +/** Gets the number of user-defined ordering fields in the index. In the + internal representation we add the row id to the ordering fields to make all + indexes unique, but this function returns the number of fields the user defined in the index as ordering fields. @return number of fields */ UNIV_INLINE ulint dict_index_get_n_ordering_defined_by_user( - /*======================================*/ const dict_index_t *index) /*!< in: an internal representation of index (in the dictionary cache) */ MY_ATTRIBUTE((warn_unused_result)); -/********************************************************************/ /** - Returns TRUE if the index contains a column or a prefix of that column. +/** Returns TRUE if the index contains a column or a prefix of that column. @return true if contains the column or its prefix */ ibool dict_index_contains_col_or_prefix( - /*==============================*/ const dict_index_t *index, /*!< in: index */ ulint n, /*!< in: column number */ bool is_virtual) /*!< in: whether it is a virtual col */ MY_ATTRIBUTE((warn_unused_result)); -/********************************************************************/ /** - Looks for a matching field in an index. The column has to be the same. The +/** Looks for a matching field in an index. The column has to be the same. The column in index must be complete, or must contain a prefix longer than the column in index2. That is, we must be able to construct the prefix in index2 from the prefix in index. @return position in internal representation of the index; ULINT_UNDEFINED if not contained */ ulint dict_index_get_nth_field_pos( - /*=========================*/ const dict_index_t *index, /*!< in: index from which to search */ const dict_index_t *index2, /*!< in: index */ ulint n) /*!< in: field number in index2 */ MY_ATTRIBUTE((warn_unused_result)); -/********************************************************************/ /** - Looks for non-virtual column n position in the clustered index. +/** Looks for non-virtual column n position in the clustered index. @return position in internal representation of the clustered index */ -ulint dict_table_get_nth_col_pos( - /*=======================*/ - const dict_table_t *table, /*!< in: table */ - ulint n) /*!< in: column number */ +ulint dict_table_get_nth_col_pos(const dict_table_t *table, /*!< in: table */ + ulint n) /*!< in: column number */ MY_ATTRIBUTE((warn_unused_result)); /** Get the innodb column position for a non-virtual column according to @@ -960,21 +828,16 @@ its original MySQL table position n @return column position in InnoDB */ ulint dict_table_mysql_pos_to_innodb(const dict_table_t *table, ulint n); -/*******************************************************************/ /** - Copies types of fields contained in index to tuple. */ -void dict_index_copy_types( - /*==================*/ - dtuple_t *tuple, /*!< in/out: data tuple */ - const dict_index_t *index, /*!< in: index */ - ulint n_fields); /*!< in: number of - field types to copy */ +/** Copies types of fields contained in index to tuple. */ +void dict_index_copy_types(dtuple_t *tuple, /*!< in/out: data tuple */ + const dict_index_t *index, /*!< in: index */ + ulint n_fields); /*!< in: number of + field types to copy */ #ifdef UNIV_DEBUG -/**********************************************************************/ /** - Checks that a tuple has n_fields_cmp value in a sensible range, so that +/** Checks that a tuple has n_fields_cmp value in a sensible range, so that no comparison can occur with the page number field in a node pointer. @return true if ok */ ibool dict_index_check_search_tuple( - /*==========================*/ const dict_index_t *index, /*!< in: index tree */ const dtuple_t *tuple) /*!< in: tuple used in a search */ MY_ATTRIBUTE((warn_unused_result)); @@ -987,10 +850,8 @@ enum check_name { /** Allow partial indexes to exist. */ CHECK_PARTIAL_OK }; -/**********************************************************************/ /** - Check for duplicate index entries in a table [using the index name] */ +/** Check for duplicate index entries in a table [using the index name] */ void dict_table_check_for_dup_indexes( - /*=============================*/ const dict_table_t *table, /*!< in: Check for dup indexes in this table */ enum check_name check); /*!< in: whether and when to allow @@ -1001,11 +862,9 @@ we should always expect false. @return true if it's a compressed temporary table, false otherwise */ inline bool dict_table_is_compressed_temporary(const dict_table_t *table); #endif /* UNIV_DEBUG */ -/**********************************************************************/ /** - Builds a node pointer out of a physical record and a page number. +/** Builds a node pointer out of a physical record and a page number. @return own: node pointer */ dtuple_t *dict_index_build_node_ptr( - /*======================*/ const dict_index_t *index, /*!< in: index */ const rec_t *rec, /*!< in: record for which to build node pointer */ @@ -1016,12 +875,10 @@ dtuple_t *dict_index_build_node_ptr( ulint level) /*!< in: level of rec in tree: 0 means leaf level */ MY_ATTRIBUTE((warn_unused_result)); -/**********************************************************************/ /** - Copies an initial segment of a physical record, long enough to specify an +/** Copies an initial segment of a physical record, long enough to specify an index entry uniquely. @return pointer to the prefix record */ rec_t *dict_index_copy_rec_order_prefix( - /*=============================*/ const dict_index_t *index, /*!< in: index */ const rec_t *rec, /*!< in: record for which to copy prefix */ @@ -1030,23 +887,18 @@ rec_t *dict_index_copy_rec_order_prefix( copied prefix, or NULL */ ulint *buf_size) /*!< in/out: buffer size */ MY_ATTRIBUTE((warn_unused_result)); -/**********************************************************************/ /** - Builds a typed data tuple out of a physical record. +/** Builds a typed data tuple out of a physical record. @return own: data tuple */ dtuple_t *dict_index_build_data_tuple( - /*========================*/ dict_index_t *index, /*!< in: index */ rec_t *rec, /*!< in: record for which to build data tuple */ ulint n_fields, /*!< in: number of data fields */ mem_heap_t *heap) /*!< in: memory heap where tuple created */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Gets the space id of the root of the index tree. +/** Gets the space id of the root of the index tree. @return space id */ UNIV_INLINE -space_id_t dict_index_get_space( - /*=================*/ - const dict_index_t *index) /*!< in: index */ +space_id_t dict_index_get_space(const dict_index_t *index) /*!< in: index */ MY_ATTRIBUTE((warn_unused_result)); /** Sets the space id of the root of the index tree. @@ -1055,38 +907,28 @@ space_id_t dict_index_get_space( UNIV_INLINE void dict_index_set_space(dict_index_t *index, space_id_t space); -/*********************************************************************/ /** - Gets the page number of the root of the index tree. +/** Gets the page number of the root of the index tree. @return page number */ UNIV_INLINE -page_no_t dict_index_get_page( - /*================*/ - const dict_index_t *tree) /*!< in: index */ +page_no_t dict_index_get_page(const dict_index_t *tree) /*!< in: index */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Gets the read-write lock of the index tree. +/** Gets the read-write lock of the index tree. @return read-write lock */ UNIV_INLINE -rw_lock_t *dict_index_get_lock( - /*================*/ - dict_index_t *index) /*!< in: index */ +rw_lock_t *dict_index_get_lock(dict_index_t *index) /*!< in: index */ MY_ATTRIBUTE((warn_unused_result)); -/********************************************************************/ /** - Returns free space reserved for future updates of records. This is +/** Returns free space reserved for future updates of records. This is relevant only in the case of many consecutive inserts, as updates which make the records bigger might fragment the index. @return number of free bytes on page, reserved for updates */ UNIV_INLINE ulint dict_index_get_space_reserve(void); -/*==============================*/ /* Online index creation @{ */ -/********************************************************************/ /** - Gets the status of online index creation. +/** Gets the status of online index creation. @return the status */ UNIV_INLINE enum online_index_status dict_index_get_online_status( - /*=========================*/ const dict_index_t *index) /*!< in: secondary index */ MY_ATTRIBUTE((warn_unused_result)); @@ -1097,8 +939,7 @@ UNIV_INLINE void dict_index_set_online_status(dict_index_t *index, enum online_index_status status); -/********************************************************************/ /** - Determines if a secondary index is being or has been created online, +/** Determines if a secondary index is being or has been created online, or if the table is being rebuilt online, allowing concurrent modifications to the table. @retval true if the index is being or has been built online, or @@ -1106,24 +947,15 @@ void dict_index_set_online_status(dict_index_t *index, @retval false if the index has been created or the table has been rebuilt completely */ UNIV_INLINE -bool dict_index_is_online_ddl( - /*=====================*/ - const dict_index_t *index) /*!< in: index */ +bool dict_index_is_online_ddl(const dict_index_t *index) /*!< in: index */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Calculates the minimum record length in an index. */ -ulint dict_index_calc_min_rec_len( - /*========================*/ - const dict_index_t *index) /*!< in: index */ +/** Calculates the minimum record length in an index. */ +ulint dict_index_calc_min_rec_len(const dict_index_t *index) /*!< in: index */ MY_ATTRIBUTE((warn_unused_result)); -/********************************************************************/ /** - Reserves the dictionary system mutex for MySQL. */ +/** Reserves the dictionary system mutex for MySQL. */ void dict_mutex_enter_for_mysql(void); -/*============================*/ -/********************************************************************/ /** - Releases the dictionary system mutex for MySQL. */ +/** Releases the dictionary system mutex for MySQL. */ void dict_mutex_exit_for_mysql(void); -/*===========================*/ #ifndef UNIV_HOTBACKUP /** Create a dict_table_t's stats latch or delay for lazy creation. @@ -1150,11 +982,9 @@ void dict_table_stats_lock(dict_table_t *table, ulint latch_mode); @param[in] latch_mode RW_S_LATCH or RW_X_LATCH */ void dict_table_stats_unlock(dict_table_t *table, ulint latch_mode); -/********************************************************************/ /** - Checks if the database name in two table names is the same. +/** Checks if the database name in two table names is the same. @return true if same db name */ ibool dict_tables_have_same_db( - /*=====================*/ const char *name1, /*!< in: table name in the form dbname '/' tablename */ const char *name2) /*!< in: table name in the form @@ -1186,19 +1016,16 @@ inline const dict_index_t *dict_table_get_index_on_name( Check whether a column exists in an FTS index. */ UNIV_INLINE ulint dict_table_is_fts_column( - /*=====================*/ /*!< out: ULINT_UNDEFINED if no match else the offset within the vector */ ib_vector_t *indexes, /*!< in: vector containing only FTS indexes */ ulint col_no, /*!< in: col number to search for */ bool is_virtual) /*!< in: whether it is a virtual column */ MY_ATTRIBUTE((warn_unused_result)); -/**********************************************************************/ /** - Prevent table eviction by moving a table to the non-LRU list from the +/** Prevent table eviction by moving a table to the non-LRU list from the LRU list if it is not already there. */ UNIV_INLINE void dict_table_prevent_eviction( - /*========================*/ dict_table_t *table); /*!< in: table to prevent eviction */ /** Allow the table to be evicted by moving a table to the LRU list from @@ -1220,21 +1047,16 @@ to non-LRU list UNIV_INLINE void dict_table_ddl_release(dict_table_t *table); -/**********************************************************************/ /** - Move a table to the non LRU end of the LRU list. */ +/** Move a table to the non LRU end of the LRU list. */ void dict_table_move_from_lru_to_non_lru( - /*================================*/ dict_table_t *table); /*!< in: table to move from LRU to non-LRU */ /** Move a table to the LRU end from the non LRU list. @param[in] table InnoDB table object */ void dict_table_move_from_non_lru_to_lru(dict_table_t *table); -/**********************************************************************/ /** - Move to the most recently used segment of the LRU list. */ -void dict_move_to_mru( - /*=============*/ - dict_table_t *table); /*!< in: table to move to MRU */ +/** Move to the most recently used segment of the LRU list. */ +void dict_move_to_mru(dict_table_t *table); /*!< in: table to move to MRU */ /** Maximum number of columns in a foreign key constraint. Please Note MySQL has a much lower limit on the number of columns allowed in a foreign key @@ -1302,7 +1124,6 @@ struct dict_sys_t { /** Permanent handle to mysql.innodb_dynamic_metadata */ dict_table_t *dynamic_metadata; - /*=============================*/ UT_LIST_BASE_NODE_T(dict_table_t) table_LRU; /*!< List of tables that can be evicted from the cache */ @@ -1456,10 +1277,8 @@ struct dict_persist_t { /** dummy index for ROW_FORMAT=REDUNDANT supremum and infimum records */ extern dict_index_t *dict_ind_redundant; -/**********************************************************************/ /** - Inits dict_ind_redundant. */ +/** Inits dict_ind_redundant. */ void dict_ind_init(void); -/*===============*/ /** Converts a database and table name from filesystem encoding (e.g. "@code d@i1b/a@q1b@1Kc @endcode", same format as used in dict_table_t::name) @@ -1477,10 +1296,8 @@ void dict_fs2utf8(const char *db_and_table, char *db_utf8, size_t db_utf8_size, /** Resize the hash tables besed on the current buffer pool size. */ void dict_resize(); -/**********************************************************************/ /** - Closes the data dictionary module. */ +/** Closes the data dictionary module. */ void dict_close(void); -/*============*/ /** Wrapper for the mysql.innodb_dynamic_metadata used to buffer the persistent dynamic metadata. @@ -1672,21 +1489,17 @@ are compatible. UNIV_INLINE bool dict_tf2_is_valid(ulint flags, ulint flags2); -/********************************************************************/ /** - Check if the tablespace for the table has been discarded. +/** Check if the tablespace for the table has been discarded. @return true if the tablespace has been discarded. */ UNIV_INLINE bool dict_table_is_discarded( - /*====================*/ const dict_table_t *table) /*!< in: table to check */ MY_ATTRIBUTE((warn_unused_result)); -/********************************************************************/ /** - Check if it is a encrypted table. +/** Check if it is a encrypted table. @return true if table encryption flag is set. */ UNIV_INLINE bool dict_table_is_encrypted( - /*====================*/ const dict_table_t *table) /*!< in: table to check */ MY_ATTRIBUTE((warn_unused_result)); @@ -1738,38 +1551,27 @@ trx_id_t dict_table_get_next_table_sess_trx_id(dict_table_t *table); UNIV_INLINE trx_id_t dict_table_get_curr_table_sess_trx_id(const dict_table_t *table); -/*********************************************************************/ /** - This function should be called whenever a page is successfully +/** This function should be called whenever a page is successfully compressed. Updates the compression padding information. */ void dict_index_zip_success( - /*===================*/ dict_index_t *index); /*!< in/out: index to be updated. */ -/*********************************************************************/ /** - This function should be called whenever a page compression attempt +/** This function should be called whenever a page compression attempt fails. Updates the compression padding information. */ void dict_index_zip_failure( - /*===================*/ dict_index_t *index); /*!< in/out: index to be updated. */ -/*********************************************************************/ /** - Return the optimal page size, for which page will likely compress. +/** Return the optimal page size, for which page will likely compress. @return page size beyond which page may not compress*/ ulint dict_index_zip_pad_optimal_page_size( - /*=================================*/ dict_index_t *index) /*!< in: index for which page size is requested */ MY_ATTRIBUTE((warn_unused_result)); -/*************************************************************/ /** - Convert table flag to row format string. +/** Convert table flag to row format string. @return row format name */ const char *dict_tf_to_row_format_string( - /*=========================*/ ulint table_flag); /*!< in: row format setting */ -/****************************************************************/ /** - Return maximum size of the node pointer record. +/** Return maximum size of the node pointer record. @return maximum size of the record in bytes */ -ulint dict_index_node_ptr_max_size( - /*=========================*/ - const dict_index_t *index) /*!< in: index */ +ulint dict_index_node_ptr_max_size(const dict_index_t *index) /*!< in: index */ MY_ATTRIBUTE((warn_unused_result)); /** Get index by first field of the index. diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic index f8d03a5d1353..9a7ab306121b 100644 --- a/storage/innobase/include/dict0dict.ic +++ b/storage/innobase/include/dict0dict.ic @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/dict0dict.ic +/** @file include/dict0dict.ic Data dictionary system Created 1/8/1996 Heikki Tuuri @@ -39,24 +38,19 @@ this program; if not, write to the Free Software Foundation, Inc., #include "srv0srv.h" #include "sync0rw.h" -/*********************************************************************/ /** - Gets the column number. +/** Gets the column number. @return col->ind, table column position (starting from 0) */ UNIV_INLINE -ulint dict_col_get_no( - /*============*/ - const dict_col_t *col) /*!< in: column */ +ulint dict_col_get_no(const dict_col_t *col) /*!< in: column */ { ut_ad(col); return (col->ind); } -/*********************************************************************/ /** - Gets the column position in the clustered index. */ +/** Gets the column position in the clustered index. */ UNIV_INLINE ulint dict_col_get_clust_pos( - /*===================*/ const dict_col_t *col, /*!< in: table column */ const dict_index_t *clust_index) /*!< in: clustered index */ { @@ -124,13 +118,10 @@ bool dict_index_is_auto_gen_clust(const dict_index_t *index) { return (index->type == DICT_CLUSTERED); } -/********************************************************************/ /** - Check whether the index is unique. +/** Check whether the index is unique. @return nonzero for unique index, zero for other indexes */ UNIV_INLINE -ulint dict_index_is_unique( - /*=================*/ - const dict_index_t *index) /*!< in: index */ +ulint dict_index_is_unique(const dict_index_t *index) /*!< in: index */ { ut_ad(index); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); @@ -138,13 +129,10 @@ ulint dict_index_is_unique( return (index->type & DICT_UNIQUE); } -/********************************************************************/ /** - Check whether the index is a Spatial Index. +/** Check whether the index is a Spatial Index. @return nonzero for Spatial Index, zero for other indexes */ UNIV_INLINE -ulint dict_index_is_spatial( - /*==================*/ - const dict_index_t *index) /*!< in: index */ +ulint dict_index_is_spatial(const dict_index_t *index) /*!< in: index */ { ut_ad(index); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); @@ -163,13 +151,10 @@ ulint dict_index_has_virtual(const dict_index_t *index) { return (index->type & DICT_VIRTUAL); } -/********************************************************************/ /** - Check whether the index is the insert buffer tree. +/** Check whether the index is the insert buffer tree. @return nonzero for insert buffer, zero for other indexes */ UNIV_INLINE -ulint dict_index_is_ibuf( - /*===============*/ - const dict_index_t *index) /*!< in: index */ +ulint dict_index_is_ibuf(const dict_index_t *index) /*!< in: index */ { ut_ad(index); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); @@ -177,13 +162,10 @@ ulint dict_index_is_ibuf( return (index->type & DICT_IBUF); } -/********************************************************************/ /** - Check whether the index is a secondary index or the insert buffer tree. +/** Check whether the index is a secondary index or the insert buffer tree. @return nonzero for insert buffer, zero for other indexes */ UNIV_INLINE -ulint dict_index_is_sec_or_ibuf( - /*======================*/ - const dict_index_t *index) /*!< in: index */ +ulint dict_index_is_sec_or_ibuf(const dict_index_t *index) /*!< in: index */ { ulint type; @@ -234,27 +216,21 @@ bool dict_table_has_indexed_v_cols(const dict_table_t *table) { } #ifndef UNIV_HOTBACKUP -/********************************************************************/ /** - Gets the approximately estimated number of rows in the table. +/** Gets the approximately estimated number of rows in the table. @return estimated number of rows */ UNIV_INLINE -ib_uint64_t dict_table_get_n_rows( - /*==================*/ - const dict_table_t *table) /*!< in: table */ +ib_uint64_t dict_table_get_n_rows(const dict_table_t *table) /*!< in: table */ { ut_ad(table->stat_initialized); return (table->stat_n_rows); } -/********************************************************************/ /** - Increment the number of rows in the table by one. +/** Increment the number of rows in the table by one. Notice that this operation is not protected by any latch, the number is approximate. */ UNIV_INLINE -void dict_table_n_rows_inc( - /*==================*/ - dict_table_t *table) /*!< in/out: table */ +void dict_table_n_rows_inc(dict_table_t *table) /*!< in/out: table */ { if (table->stat_initialized) { ib_uint64_t n_rows = table->stat_n_rows; @@ -264,14 +240,11 @@ void dict_table_n_rows_inc( } } -/********************************************************************/ /** - Decrement the number of rows in the table by one. +/** Decrement the number of rows in the table by one. Notice that this operation is not protected by any latch, the number is approximate. */ UNIV_INLINE -void dict_table_n_rows_dec( - /*==================*/ - dict_table_t *table) /*!< in/out: table */ +void dict_table_n_rows_dec(dict_table_t *table) /*!< in/out: table */ { if (table->stat_initialized) { ib_uint64_t n_rows = table->stat_n_rows; @@ -297,14 +270,11 @@ dict_v_col_t *dict_table_get_nth_v_col(const dict_table_t *table, ulint pos) { } #endif /* UNIV_DEBUG */ -/********************************************************************/ /** - Gets the given system column number of a table. +/** Gets the given system column number of a table. @return column number */ UNIV_INLINE -ulint dict_table_get_sys_col_no( - /*======================*/ - const dict_table_t *table, /*!< in: table */ - ulint sys) /*!< in: DATA_ROW_ID, ... */ +ulint dict_table_get_sys_col_no(const dict_table_t *table, /*!< in: table */ + ulint sys) /*!< in: DATA_ROW_ID, ... */ { ut_ad(table); ut_ad(sys < table->get_n_sys_cols()); @@ -313,13 +283,10 @@ ulint dict_table_get_sys_col_no( return (table->n_cols - table->get_n_sys_cols() + sys); } -/********************************************************************/ /** - Check whether the table uses the compact page format. +/** Check whether the table uses the compact page format. @return true if table uses the compact page format */ UNIV_INLINE -ibool dict_table_is_comp( - /*===============*/ - const dict_table_t *table) /*!< in: table */ +ibool dict_table_is_comp(const dict_table_t *table) /*!< in: table */ { ut_ad(table); @@ -335,7 +302,6 @@ ibool dict_table_is_comp( Check if the table has an FTS index. */ UNIV_INLINE ibool dict_table_has_fts_index( - /*=====================*/ /* out: TRUE if table has an FTS index */ dict_table_t *table) /* in: table */ { @@ -418,15 +384,12 @@ bool dict_tf2_is_valid(ulint flags, ulint flags2) { return (true); } -/********************************************************************/ /** - Validate a SYS_TABLES TYPE field and return it. +/** Validate a SYS_TABLES TYPE field and return it. @return Same as input after validating it as a SYS_TABLES TYPE field. If there is an error, return ULINT_UNDEFINED. */ UNIV_INLINE -ulint dict_sys_tables_type_validate( - /*==========================*/ - ulint type, /*!< in: SYS_TABLES.TYPE */ - ulint n_cols) /*!< in: SYS_TABLES.N_COLS */ +ulint dict_sys_tables_type_validate(ulint type, /*!< in: SYS_TABLES.TYPE */ + ulint n_cols) /*!< in: SYS_TABLES.N_COLS */ { ulint low_order_bit = DICT_TF_GET_COMPACT(type); ulint redundant = !(n_cols & DICT_N_COLS_COMPACT); @@ -490,15 +453,12 @@ ulint dict_sys_tables_type_validate( return (type); } -/********************************************************************/ /** - Determine the page format from dict_table_t::flags +/** Determine the page format from dict_table_t::flags The low order bit will be zero for REDUNDANT and 1 for COMPACT. For any other row_format, flags is nonzero and DICT_TF_COMPACT will also be set. @return file format version */ UNIV_INLINE -rec_format_t dict_tf_get_rec_format( - /*===================*/ - ulint flags) /*!< in: dict_table_t::flags */ +rec_format_t dict_tf_get_rec_format(ulint flags) /*!< in: dict_table_t::flags */ { ut_a(dict_tf_is_valid(flags)); @@ -600,8 +560,7 @@ ulint dict_tf_init(bool compact, ulint zip_ssize, bool atomic_blobs, return (flags); } -/********************************************************************/ /** - Convert a 32 bit integer from SYS_TABLES.TYPE to dict_table_t::flags +/** Convert a 32 bit integer from SYS_TABLES.TYPE to dict_table_t::flags The following chart shows the translation of the low order bit. Other bits are the same. ========================= Low order bit ========================== @@ -612,7 +571,6 @@ ulint dict_tf_init(bool compact, ulint zip_ssize, bool atomic_blobs, @return ulint containing SYS_TABLES.TYPE */ UNIV_INLINE ulint dict_sys_tables_type_to_tf( - /*=======================*/ ulint type, /*!< in: SYS_TABLES.TYPE field */ ulint n_cols) /*!< in: SYS_TABLES.N_COLS field */ { @@ -631,8 +589,7 @@ ulint dict_sys_tables_type_to_tf( return (flags); } -/********************************************************************/ /** - Convert a 32 bit integer table flags to the 32bit integer that is written +/** Convert a 32 bit integer table flags to the 32bit integer that is written to a SYS_TABLES.TYPE field. The following chart shows the translation of the low order bit. Other bits are the same. ========================= Low order bit ========================== @@ -642,9 +599,7 @@ ulint dict_sys_tables_type_to_tf( ================================================================== @return ulint containing SYS_TABLES.TYPE */ UNIV_INLINE -ulint dict_tf_to_sys_tables_type( - /*=======================*/ - ulint flags) /*!< in: dict_table_t::flags */ +ulint dict_tf_to_sys_tables_type(ulint flags) /*!< in: dict_table_t::flags */ { ulint type; @@ -692,14 +647,11 @@ const page_size_t dict_table_page_size(const dict_table_t *table) { } #ifndef UNIV_HOTBACKUP -/*********************************************************************/ /** - Obtain exclusive locks on all index trees of the table. This is to prevent +/** Obtain exclusive locks on all index trees of the table. This is to prevent accessing index trees while InnoDB is updating internal metadata for operations such as FLUSH TABLES. */ UNIV_INLINE -void dict_table_x_lock_indexes( - /*======================*/ - dict_table_t *table) /*!< in: table */ +void dict_table_x_lock_indexes(dict_table_t *table) /*!< in: table */ { dict_index_t *index; @@ -712,12 +664,9 @@ void dict_table_x_lock_indexes( } } -/*********************************************************************/ /** - Release the exclusive locks on all index tree. */ +/** Release the exclusive locks on all index tree. */ UNIV_INLINE -void dict_table_x_unlock_indexes( - /*========================*/ - dict_table_t *table) /*!< in: table */ +void dict_table_x_unlock_indexes(dict_table_t *table) /*!< in: table */ { dict_index_t *index; @@ -730,13 +679,11 @@ void dict_table_x_unlock_indexes( } #endif /* !UNIV_HOTBACKUP */ -/********************************************************************/ /** - Gets the number of fields in the internal representation of an index, +/** Gets the number of fields in the internal representation of an index, including fields added by the dictionary system. @return number of fields */ UNIV_INLINE ulint dict_index_get_n_fields( - /*====================*/ const dict_index_t *index) /*!< in: an internal representation of index (in the dictionary cache) */ @@ -747,15 +694,13 @@ ulint dict_index_get_n_fields( return (index->n_fields); } -/********************************************************************/ /** - Gets the number of fields in the internal representation of an index +/** Gets the number of fields in the internal representation of an index that uniquely determine the position of an index entry in the index, if we do not take multiversioning into account: in the B-tree use the value returned by dict_index_get_n_unique_in_tree. @return number of fields */ UNIV_INLINE ulint dict_index_get_n_unique( - /*====================*/ const dict_index_t *index) /*!< in: an internal representation of index (in the dictionary cache) */ { @@ -766,14 +711,12 @@ ulint dict_index_get_n_unique( return (index->n_uniq); } -/********************************************************************/ /** - Gets the number of fields in the internal representation of an index +/** Gets the number of fields in the internal representation of an index which uniquely determine the position of an index entry in the index, if we also take multiversioning into account. @return number of fields */ UNIV_INLINE ulint dict_index_get_n_unique_in_tree( - /*============================*/ const dict_index_t *index) /*!< in: an internal representation of index (in the dictionary cache) */ { @@ -811,15 +754,13 @@ ulint dict_index_get_n_unique_in_tree_nonleaf(const dict_index_t *index) { } } -/********************************************************************/ /** - Gets the number of user-defined ordering fields in the index. In the internal - representation of clustered indexes we add the row id to the ordering fields - to make a clustered index unique, but this function returns the number of - fields the user defined in the index as ordering fields. +/** Gets the number of user-defined ordering fields in the index. In the + internal representation of clustered indexes we add the row id to the ordering + fields to make a clustered index unique, but this function returns the number + of fields the user defined in the index as ordering fields. @return number of fields */ UNIV_INLINE ulint dict_index_get_n_ordering_defined_by_user( - /*======================================*/ const dict_index_t *index) /*!< in: an internal representation of index (in the dictionary cache) */ { @@ -842,13 +783,10 @@ inline bool dict_table_is_compressed_temporary(const dict_table_t *table) { } #endif /* UNIV_DEBUG */ -/*********************************************************************/ /** - Gets the space id of the root of the index tree. +/** Gets the space id of the root of the index tree. @return space id */ UNIV_INLINE -space_id_t dict_index_get_space( - /*=================*/ - const dict_index_t *index) /*!< in: index */ +space_id_t dict_index_get_space(const dict_index_t *index) /*!< in: index */ { ut_ad(index); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); @@ -856,13 +794,10 @@ space_id_t dict_index_get_space( return (index->space); } -/*********************************************************************/ /** - Sets the space id of the root of the index tree. */ +/** Sets the space id of the root of the index tree. */ UNIV_INLINE -void dict_index_set_space( - /*=================*/ - dict_index_t *index, /*!< in/out: index */ - space_id_t space) /*!< in: space id */ +void dict_index_set_space(dict_index_t *index, /*!< in/out: index */ + space_id_t space) /*!< in: space id */ { ut_ad(index); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); @@ -870,13 +805,10 @@ void dict_index_set_space( index->space = space; } -/*********************************************************************/ /** - Gets the page number of the root of the index tree. +/** Gets the page number of the root of the index tree. @return page number */ UNIV_INLINE -page_no_t dict_index_get_page( - /*================*/ - const dict_index_t *index) /*!< in: index */ +page_no_t dict_index_get_page(const dict_index_t *index) /*!< in: index */ { ut_ad(index); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); @@ -884,13 +816,10 @@ page_no_t dict_index_get_page( return (index->page); } -/*********************************************************************/ /** - Gets the read-write lock of the index tree. +/** Gets the read-write lock of the index tree. @return read-write lock */ UNIV_INLINE -rw_lock_t *dict_index_get_lock( - /*================*/ - dict_index_t *index) /*!< in: index */ +rw_lock_t *dict_index_get_lock(dict_index_t *index) /*!< in: index */ { ut_ad(index); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); @@ -898,24 +827,17 @@ rw_lock_t *dict_index_get_lock( return (&(index->lock)); } -/********************************************************************/ /** - Returns free space reserved for future updates of records. This is +/** Returns free space reserved for future updates of records. This is relevant only in the case of many consecutive inserts, as updates which make the records bigger might fragment the index. @return number of free bytes on page, reserved for updates */ UNIV_INLINE -ulint dict_index_get_space_reserve(void) -/*==============================*/ -{ - return (UNIV_PAGE_SIZE / 16); -} +ulint dict_index_get_space_reserve(void) { return (UNIV_PAGE_SIZE / 16); } -/********************************************************************/ /** - Gets the status of online index creation. +/** Gets the status of online index creation. @return the status */ UNIV_INLINE enum online_index_status dict_index_get_online_status( - /*=========================*/ const dict_index_t *index) /*!< in: secondary index */ { enum online_index_status status; @@ -942,11 +864,9 @@ enum online_index_status dict_index_get_online_status( return (status); } -/********************************************************************/ /** - Sets the status of online index creation. */ +/** Sets the status of online index creation. */ UNIV_INLINE void dict_index_set_online_status( - /*=========================*/ dict_index_t *index, /*!< in/out: index */ enum online_index_status status) /*!< in: status */ { @@ -970,8 +890,7 @@ void dict_index_set_online_status( ut_ad(dict_index_get_online_status(index) == status); } -/********************************************************************/ /** - Determines if a secondary index is being or has been created online, +/** Determines if a secondary index is being or has been created online, or if the table is being rebuilt online, allowing concurrent modifications to the table. @retval true if the index is being or has been built online, or @@ -979,9 +898,7 @@ void dict_index_set_online_status( @retval false if the index has been created or the table has been rebuilt completely */ UNIV_INLINE -bool dict_index_is_online_ddl( - /*=====================*/ - const dict_index_t *index) /*!< in: index */ +bool dict_index_is_online_ddl(const dict_index_t *index) /*!< in: index */ { #ifdef UNIV_DEBUG if (index->is_clustered()) { @@ -1003,12 +920,10 @@ bool dict_index_is_online_ddl( ONLINE_INDEX_COMPLETE)); } -/**********************************************************************/ /** - Check whether a column exists in an FTS index. +/** Check whether a column exists in an FTS index. @return ULINT_UNDEFINED if no match else the offset within the vector */ UNIV_INLINE ulint dict_table_is_fts_column( - /*=====================*/ ib_vector_t *indexes, /*!< in: vector containing only FTS indexes */ ulint col_no, /*!< in: col number to search for */ bool is_virtual) /*!< in: whether it is a virtual column */ @@ -1029,14 +944,12 @@ ulint dict_table_is_fts_column( return (ULINT_UNDEFINED); } -/**********************************************************************/ /** - Determine bytes of column prefix to be stored in the undo log. Please +/** Determine bytes of column prefix to be stored in the undo log. Please note that if !dict_table_has_atomic_blobs(table), no prefix needs to be stored in the undo log. @return bytes of column prefix to be stored in the undo log */ UNIV_INLINE ulint dict_max_field_len_store_undo( - /*==========================*/ dict_table_t *table, /*!< in: table */ const dict_col_t *col) /*!< in: column which index prefix is based on */ @@ -1081,12 +994,10 @@ ulint dict_max_v_field_len_store_undo(dict_table_t *table, ulint col_no) { } #ifndef UNIV_HOTBACKUP -/**********************************************************************/ /** - Prevent table eviction by moving a table to the non-LRU list from the +/** Prevent table eviction by moving a table to the non-LRU list from the LRU list if it is not already there. */ UNIV_INLINE void dict_table_prevent_eviction( - /*========================*/ dict_table_t *table) /*!< in: table to prevent eviction */ { ut_ad(mutex_own(&dict_sys->mutex)); @@ -1136,23 +1047,19 @@ void dict_table_ddl_release(dict_table_t *table) { } #endif /* !UNIV_HOTBACKUP */ -/********************************************************************/ /** - Check if the tablespace for the table has been discarded. +/** Check if the tablespace for the table has been discarded. @return true if the tablespace has been discarded. */ UNIV_INLINE bool dict_table_is_discarded( - /*====================*/ const dict_table_t *table) /*!< in: table to check */ { return (DICT_TF2_FLAG_IS_SET(table, DICT_TF2_DISCARDED)); } -/********************************************************************/ /** - Check if it is a encrypted table. +/** Check if it is a encrypted table. @return true if table encrypted flag is set. */ UNIV_INLINE bool dict_table_is_encrypted( - /*====================*/ const dict_table_t *table) /*!< in: table to check */ { return (DICT_TF2_FLAG_IS_SET(table, DICT_TF2_ENCRYPTION)); @@ -1191,11 +1098,9 @@ bool dict_table_is_locking_disabled(const dict_table_t *table) { } #endif /* !UNIV_HOTBACKUP */ -/********************************************************************/ /** - Turn-off redo-logging if temporary table. */ +/** Turn-off redo-logging if temporary table. */ UNIV_INLINE void dict_disable_redo_if_temporary( - /*===========================*/ const dict_table_t *table, /*!< in: table to check */ mtr_t *mtr) /*!< out: mini-transaction */ { @@ -1237,13 +1142,11 @@ bool dict_table_is_file_per_table( return (is_file_per_table); } -/**********************************************************************/ /** - Get index by first field of the index +/** Get index by first field of the index @return index which is having first field matches with the field present in field_index position of table */ UNIV_INLINE dict_index_t *dict_table_get_index_on_first_col( - /*==============================*/ dict_table_t *table, /*!< in: table */ ulint col_index) /*!< in: position of column in table */ diff --git a/storage/innobase/include/dict0load.h b/storage/innobase/include/dict0load.h index dd7f8ef30e22..7b9be40bf5ab 100644 --- a/storage/innobase/include/dict0load.h +++ b/storage/innobase/include/dict0load.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/dict0load.h +/** @file include/dict0load.h Loads to the memory cache database object definitions from dictionary tables @@ -76,12 +75,10 @@ enum dict_table_info_t { extern const char *SYSTEM_TABLE_NAME[]; -/********************************************************************/ /** - Finds the first table name in the given database. +/** Finds the first table name in the given database. @return own: table name, NULL if does not exist; the caller must free the memory in the string! */ char *dict_get_first_table_name_in_db( - /*============================*/ const char *name); /*!< in: database name which ends to '/' */ /** Get the first filepath from SYS_DATAFILES for a given space_id. @@ -116,23 +113,17 @@ flag in the table object we return. */ dict_table_t *dict_load_table(const char *name, bool cached, dict_err_ignore_t ignore_err); -/***********************************************************************/ /** - Loads a table object based on the table id. +/** Loads a table object based on the table id. @return table; NULL if table does not exist */ dict_table_t *dict_load_table_on_id( - /*==================*/ table_id_t table_id, /*!< in: table id */ dict_err_ignore_t ignore_err); /*!< in: errors to ignore when loading the table */ -/********************************************************************/ /** - This function is called when the database is booted. +/** This function is called when the database is booted. Loads system table index definitions except for the clustered index which is added to the dictionary cache at booting before calling this function. */ -void dict_load_sys_table( - /*================*/ - dict_table_t *table); /*!< in: system table */ -/***********************************************************************/ /** - Loads foreign key constraints where the table is either the foreign key +void dict_load_sys_table(dict_table_t *table); /*!< in: system table */ +/** Loads foreign key constraints where the table is either the foreign key holder or where the table is referenced by a foreign key. Adds these constraints to the data dictionary. @@ -142,7 +133,6 @@ void dict_load_sys_table( @return DB_SUCCESS or error code */ dberr_t dict_load_foreigns( - /*===============*/ const char *table_name, /*!< in: table name */ const char **col_names, /*!< in: column names, or NULL to use table->col_names */ @@ -158,30 +148,24 @@ dberr_t dict_load_foreigns( foreign key constraints. */ MY_ATTRIBUTE((warn_unused_result)); -/********************************************************************/ /** - This function opens a system table, and return the first record. +/** This function opens a system table, and return the first record. @return first record of the system table */ const rec_t *dict_startscan_system( - /*==================*/ btr_pcur_t *pcur, /*!< out: persistent cursor to the record */ mtr_t *mtr, /*!< in: the mini-transaction */ dict_system_id_t system_id); /*!< in: which system table to open */ -/********************************************************************/ /** - This function get the next system table record as we scan the table. +/** This function get the next system table record as we scan the table. @return the record if found, NULL if end of scan. */ const rec_t *dict_getnext_system( - /*================*/ btr_pcur_t *pcur, /*!< in/out: persistent cursor to the record */ mtr_t *mtr); /*!< in: the mini-transaction */ -/********************************************************************/ /** - This function parses a SYS_TABLESPACES record, extracts necessary +/** This function parses a SYS_TABLESPACES record, extracts necessary information from the record and returns to caller. @return error message, or NULL on success */ const char *dict_process_sys_tablespaces( - /*=========================*/ mem_heap_t *heap, /*!< in/out: heap memory */ const rec_t *rec, /*!< in: current SYS_TABLESPACES rec */ space_id_t *space, /*!< out: space id */ diff --git a/storage/innobase/include/dict0load.ic b/storage/innobase/include/dict0load.ic index 4cb152019523..d746617206da 100644 --- a/storage/innobase/include/dict0load.ic +++ b/storage/innobase/include/dict0load.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/dict0load.ic +/** @file include/dict0load.ic Loads to the memory cache database object definitions from dictionary tables diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index e7310663e1f9..e72d03721599 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -25,8 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/dict0mem.h +/** @file include/dict0mem.h Data dictionary memory object creation Created 1/8/1996 Heikki Tuuri @@ -329,15 +328,12 @@ dict_v_col_t *dict_mem_table_add_v_col(dict_table_t *table, mem_heap_t *heap, @param[in] num_base number of base columns. */ void dict_mem_table_add_s_col(dict_table_t *table, ulint num_base); -/**********************************************************************/ /** - Renames a column of a table in the data dictionary cache. */ -void dict_mem_table_col_rename( - /*======================*/ - dict_table_t *table, /*!< in/out: table */ - ulint nth_col, /*!< in: column index */ - const char *from, /*!< in: old column name */ - const char *to, /*!< in: new column name */ - bool is_virtual); +/** Renames a column of a table in the data dictionary cache. */ +void dict_mem_table_col_rename(dict_table_t *table, /*!< in/out: table */ + ulint nth_col, /*!< in: column index */ + const char *from, /*!< in: old column name */ + const char *to, /*!< in: new column name */ + bool is_virtual); /*!< in: if this is a virtual column */ /** This function poplulates a dict_index_t index memory structure with @@ -356,34 +352,25 @@ void dict_mem_fill_index_struct(dict_index_t *index, mem_heap_t *heap, const char *table_name, const char *index_name, ulint space, ulint type, ulint n_fields); -/**********************************************************************/ /** - Frees an index memory object. */ -void dict_mem_index_free( - /*================*/ - dict_index_t *index); /*!< in: index */ -/**********************************************************************/ /** - Creates and initializes a foreign constraint memory object. +/** Frees an index memory object. */ +void dict_mem_index_free(dict_index_t *index); /*!< in: index */ +/** Creates and initializes a foreign constraint memory object. @return own: foreign constraint struct */ dict_foreign_t *dict_mem_foreign_create(void); -/*=========================*/ -/**********************************************************************/ /** - Sets the foreign_table_name_lookup pointer based on the value of +/** Sets the foreign_table_name_lookup pointer based on the value of lower_case_table_names. If that is 0 or 1, foreign_table_name_lookup will point to foreign_table_name. If 2, then another string is allocated from the heap and set to lower case. */ void dict_mem_foreign_table_name_lookup_set( - /*===================================*/ dict_foreign_t *foreign, /*!< in/out: foreign struct */ ibool do_alloc); /*!< in: is an alloc needed */ -/**********************************************************************/ /** - Sets the referenced_table_name_lookup pointer based on the value of +/** Sets the referenced_table_name_lookup pointer based on the value of lower_case_table_names. If that is 0 or 1, referenced_table_name_lookup will point to referenced_table_name. If 2, then another string is allocated from the heap and set to lower case. */ void dict_mem_referenced_table_name_lookup_set( - /*======================================*/ dict_foreign_t *foreign, /*!< in/out: foreign struct */ ibool do_alloc); /*!< in: is an alloc needed */ @@ -709,8 +696,7 @@ struct dict_field_t { unsigned is_ascending : 1; /*!< 0=DESC, 1=ASC */ }; -/**********************************************************************/ /** - PADDING HEURISTIC BASED ON LINEAR INCREASE OF PADDING TO AVOID +/** PADDING HEURISTIC BASED ON LINEAR INCREASE OF PADDING TO AVOID COMPRESSION FAILURES (Note: this is relevant only for compressed indexes) GOAL: Avoid compression failures by maintaining information about the @@ -1297,10 +1283,8 @@ bool dict_foreign_set_validate(const dict_foreign_set &fk_set); @return true if foreign key sets are fine, false otherwise. */ bool dict_foreign_set_validate(const dict_table_t &table); -/*********************************************************************/ /** - Frees a foreign key struct. */ +/** Frees a foreign key struct. */ inline void dict_foreign_free( - /*==============*/ dict_foreign_t *foreign) /*!< in, own: foreign key struct */ { if (foreign->v_cols != NULL) { @@ -2352,10 +2336,8 @@ class Persisters { }; #ifndef UNIV_HOTBACKUP -/*******************************************************************/ /** - Initialise the table lock list. */ +/** Initialise the table lock list. */ void lock_table_lock_list_init( - /*======================*/ table_lock_list_t *locks); /*!< List to initialise */ /** A function object to add the foreign key constraint to the referenced set diff --git a/storage/innobase/include/dict0mem.ic b/storage/innobase/include/dict0mem.ic index 63aadf09673e..566e20e208be 100644 --- a/storage/innobase/include/dict0mem.ic +++ b/storage/innobase/include/dict0mem.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/dict0mem.ic +/** @file include/dict0mem.ic Data dictionary memory object creation Created 1/8/1996 Heikki Tuuri @@ -35,12 +34,10 @@ this program; if not, write to the Free Software Foundation, Inc., #include "dict0mem.h" #include "fil0fil.h" -/**********************************************************************/ /** - This function poplulates a dict_index_t index memory structure with +/** This function poplulates a dict_index_t index memory structure with supplied information. */ UNIV_INLINE void dict_mem_fill_index_struct( - /*=======================*/ dict_index_t *index, /*!< out: index to be filled */ mem_heap_t *heap, /*!< in: memory heap */ const char *table_name, /*!< in: table name */ diff --git a/storage/innobase/include/dict0priv.h b/storage/innobase/include/dict0priv.h index 0a2acc61dde8..65c0ff7565c5 100644 --- a/storage/innobase/include/dict0priv.h +++ b/storage/innobase/include/dict0priv.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2010, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2010, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/dict0priv.h +/** @file include/dict0priv.h Data dictionary private functions Created Fri 2 Jul 2010 13:30:38 EST - Sunny Bains @@ -36,21 +35,16 @@ this program; if not, write to the Free Software Foundation, Inc., #include "univ.i" -/**********************************************************************/ /** - Gets a table; loads it to the dictionary cache if necessary. A low-level +/** Gets a table; loads it to the dictionary cache if necessary. A low-level function. Note: Not to be called from outside dict0*c functions. @return table, NULL if not found */ UNIV_INLINE -dict_table_t *dict_table_get_low( - /*===============*/ - const char *table_name); /*!< in: table name */ +dict_table_t *dict_table_get_low(const char *table_name); /*!< in: table name */ -/**********************************************************************/ /** - Checks if a table is in the dictionary cache. +/** Checks if a table is in the dictionary cache. @return table, NULL if not found */ UNIV_INLINE dict_table_t *dict_table_check_if_in_cache_low( - /*=============================*/ const char *table_name); /*!< in: table name */ #include "dict0priv.ic" diff --git a/storage/innobase/include/dict0priv.ic b/storage/innobase/include/dict0priv.ic index 0abb7d476cb9..d52e069e238f 100644 --- a/storage/innobase/include/dict0priv.ic +++ b/storage/innobase/include/dict0priv.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2010, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2010, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/dict0priv.ic +/** @file include/dict0priv.ic Data dictionary system private include file Created Wed 13 Oct 2010 16:10:14 EST Sunny Bains @@ -35,14 +34,11 @@ this program; if not, write to the Free Software Foundation, Inc., #include "dict0load.h" #include "dict0priv.h" -/**********************************************************************/ /** - Gets a table; loads it to the dictionary cache if necessary. A low-level +/** Gets a table; loads it to the dictionary cache if necessary. A low-level function. @return table, NULL if not found */ UNIV_INLINE -dict_table_t *dict_table_get_low( - /*===============*/ - const char *table_name) /*!< in: table name */ +dict_table_t *dict_table_get_low(const char *table_name) /*!< in: table name */ { dict_table_t *table; @@ -70,12 +66,10 @@ dict_table_t *dict_table_get_low( return (table); } -/**********************************************************************/ /** - Checks if a table is in the dictionary cache. +/** Checks if a table is in the dictionary cache. @return table, NULL if not found */ UNIV_INLINE dict_table_t *dict_table_check_if_in_cache_low( - /*=============================*/ const char *table_name) /*!< in: table name */ { dict_table_t *table; diff --git a/storage/innobase/include/dict0stats.h b/storage/innobase/include/dict0stats.h index 899587ba521e..4a85916e9370 100644 --- a/storage/innobase/include/dict0stats.h +++ b/storage/innobase/include/dict0stats.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2009, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2009, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/dict0stats.h +/** @file include/dict0stats.h Code used for calculating and manipulating table statistics. Created Jan 06, 2010 Vasil Dimov @@ -71,12 +70,10 @@ the in-memory table object and is not saved on disk. It will be read from the UNIV_INLINE void dict_stats_set_persistent(dict_table_t *table, ibool ps_on, ibool ps_off); -/*********************************************************************/ /** - Check whether persistent statistics is enabled for a given table. +/** Check whether persistent statistics is enabled for a given table. @return true if enabled, false otherwise */ UNIV_INLINE ibool dict_stats_is_persistent_enabled( - /*=============================*/ const dict_table_t *table) /*!< in: table */ MY_ATTRIBUTE((warn_unused_result)); @@ -91,91 +88,69 @@ UNIV_INLINE void dict_stats_auto_recalc_set(dict_table_t *table, ibool auto_recalc_on, ibool auto_recalc_off); -/*********************************************************************/ /** - Check whether auto recalc is enabled for a given table. +/** Check whether auto recalc is enabled for a given table. @return true if enabled, false otherwise */ UNIV_INLINE ibool dict_stats_auto_recalc_is_enabled( - /*==============================*/ const dict_table_t *table); /*!< in: table */ -/*********************************************************************/ /** - Initialize table's stats for the first time when opening a table. */ +/** Initialize table's stats for the first time when opening a table. */ UNIV_INLINE -void dict_stats_init( - /*============*/ - dict_table_t *table); /*!< in/out: table */ +void dict_stats_init(dict_table_t *table); /*!< in/out: table */ -/*********************************************************************/ /** - Deinitialize table's stats after the last close of the table. This is +/** Deinitialize table's stats after the last close of the table. This is used to detect "FLUSH TABLE" and refresh the stats upon next open. */ UNIV_INLINE -void dict_stats_deinit( - /*==============*/ - dict_table_t *table); /*!< in/out: table */ +void dict_stats_deinit(dict_table_t *table); /*!< in/out: table */ -/*********************************************************************/ /** - Calculates new estimates for table and index statistics. The statistics +/** Calculates new estimates for table and index statistics. The statistics are used in query optimization. @return DB_* error code or DB_SUCCESS */ -dberr_t dict_stats_update( - /*==============*/ - dict_table_t *table, /*!< in/out: table */ - dict_stats_upd_option_t stats_upd_option); +dberr_t dict_stats_update(dict_table_t *table, /*!< in/out: table */ + dict_stats_upd_option_t stats_upd_option); /*!< in: whether to (re) calc the stats or to fetch them from the persistent storage */ -/*********************************************************************/ /** - Removes the information for a particular index's stats from the persistent +/** Removes the information for a particular index's stats from the persistent storage if it exists and if there is data stored for this index. This function creates its own trx and commits it. @return DB_SUCCESS or error code */ dberr_t dict_stats_drop_index( - /*==================*/ const char *tname, /*!< in: table name */ const char *iname, /*!< in: index name */ char *errstr, /*!< out: error message if != DB_SUCCESS is returned */ ulint errstr_sz); /*!< in: size of the errstr buffer */ -/*********************************************************************/ /** - Removes the statistics for a table and all of its indexes from the +/** Removes the statistics for a table and all of its indexes from the persistent storage if it exists and if there is data stored for the table. This function creates its own transaction and commits it. @return DB_SUCCESS or error code */ dberr_t dict_stats_drop_table( - /*==================*/ const char *table_name, /*!< in: table name */ char *errstr, /*!< out: error message if != DB_SUCCESS is returned */ ulint errstr_sz); /*!< in: size of errstr buffer */ -/*********************************************************************/ /** - Fetches or calculates new estimates for index statistics. */ -void dict_stats_update_for_index( - /*========================*/ - dict_index_t *index); /*!< in/out: index */ +/** Fetches or calculates new estimates for index statistics. */ +void dict_stats_update_for_index(dict_index_t *index); /*!< in/out: index */ -/*********************************************************************/ /** - Renames a table in InnoDB persistent stats storage. +/** Renames a table in InnoDB persistent stats storage. This function creates its own transaction and commits it. @return DB_SUCCESS or error code */ dberr_t dict_stats_rename_table( - /*====================*/ const char *old_name, /*!< in: old table name */ const char *new_name, /*!< in: new table name */ char *errstr, /*!< out: error string if != DB_SUCCESS is returned */ size_t errstr_sz); /*!< in: errstr size */ -/*********************************************************************/ /** - Renames an index in InnoDB persistent stats storage. +/** Renames an index in InnoDB persistent stats storage. This function creates its own transaction and commits it. @return DB_SUCCESS or error code. DB_STATS_DO_NOT_EXIST will be returned if the persistent stats do not exist. */ dberr_t dict_stats_rename_index( - /*====================*/ const dict_table_t *table, /*!< in: table whose index is renamed */ const char *old_index_name, /*!< in: old index name */ diff --git a/storage/innobase/include/dict0stats.ic b/storage/innobase/include/dict0stats.ic index 4004da168041..4bdc8747b0c5 100644 --- a/storage/innobase/include/dict0stats.ic +++ b/storage/innobase/include/dict0stats.ic @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/dict0stats.ic +/** @file include/dict0stats.ic Code used for calculating and manipulating table statistics. Created Jan 23, 2012 Vasil Dimov @@ -35,13 +34,11 @@ this program; if not, write to the Free Software Foundation, Inc., #include "dict0types.h" #include "srv0srv.h" -/*********************************************************************/ /** - Set the persistent statistics flag for a given table. This is set only +/** Set the persistent statistics flag for a given table. This is set only in the in-memory table object and is not saved on disk. It will be read from the .frm file upon first open from MySQL after a server restart. */ UNIV_INLINE void dict_stats_set_persistent( - /*======================*/ dict_table_t *table, /*!< in/out: table */ ibool ps_on, /*!< in: persistent stats explicitly enabled */ ibool ps_off) /*!< in: persistent stats explicitly disabled */ @@ -67,12 +64,10 @@ void dict_stats_set_persistent( table->stat_persistent = stat_persistent; } -/*********************************************************************/ /** - Check whether persistent statistics is enabled for a given table. +/** Check whether persistent statistics is enabled for a given table. @return true if enabled, false otherwise */ UNIV_INLINE ibool dict_stats_is_persistent_enabled( - /*=============================*/ const dict_table_t *table) /*!< in: table */ { /* Because of the nature of this check (non-locking) it is possible @@ -103,14 +98,12 @@ ibool dict_stats_is_persistent_enabled( } } -/*********************************************************************/ /** - Set the auto recalc flag for a given table (only honored for a persistent +/** Set the auto recalc flag for a given table (only honored for a persistent stats enabled table). The flag is set only in the in-memory table object and is not saved in InnoDB files. It will be read from the .frm file upon first open from MySQL after a server restart. */ UNIV_INLINE void dict_stats_auto_recalc_set( - /*=======================*/ dict_table_t *table, /*!< in/out: table */ ibool auto_recalc_on, /*!< in: explicitly enabled */ ibool auto_recalc_off) /*!< in: explicitly disabled */ @@ -131,12 +124,10 @@ void dict_stats_auto_recalc_set( table->stats_auto_recalc = stats_auto_recalc; } -/*********************************************************************/ /** - Check whether auto recalc is enabled for a given table. +/** Check whether auto recalc is enabled for a given table. @return true if enabled, false otherwise */ UNIV_INLINE ibool dict_stats_auto_recalc_is_enabled( - /*==============================*/ const dict_table_t *table) /*!< in: table */ { /* we rely on this read to be atomic */ @@ -152,12 +143,9 @@ ibool dict_stats_auto_recalc_is_enabled( } } -/*********************************************************************/ /** - Initialize table's stats for the first time when opening a table. */ +/** Initialize table's stats for the first time when opening a table. */ UNIV_INLINE -void dict_stats_init( - /*============*/ - dict_table_t *table) /*!< in/out: table */ +void dict_stats_init(dict_table_t *table) /*!< in/out: table */ { ut_ad(!mutex_own(&dict_sys->mutex)); @@ -176,13 +164,10 @@ void dict_stats_init( dict_stats_update(table, opt); } -/*********************************************************************/ /** - Deinitialize table's stats after the last close of the table. This is +/** Deinitialize table's stats after the last close of the table. This is used to detect "FLUSH TABLE" and refresh the stats upon next open. */ UNIV_INLINE -void dict_stats_deinit( - /*==============*/ - dict_table_t *table) /*!< in/out: table */ +void dict_stats_deinit(dict_table_t *table) /*!< in/out: table */ { /* Don't assert the table->n_ref_count is 0 here, since there could be some background threads opening the table concurrently. This is diff --git a/storage/innobase/include/dict0stats_bg.h b/storage/innobase/include/dict0stats_bg.h index 8cf8dff3d473..f40348779c6c 100644 --- a/storage/innobase/include/dict0stats_bg.h +++ b/storage/innobase/include/dict0stats_bg.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2012, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2012, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/dict0stats_bg.h +/** @file include/dict0stats_bg.h Code used for background table and index stats gathering. Created Apr 26, 2012 Vasil Dimov @@ -52,21 +51,17 @@ extern mysql_pfs_key_t dict_stats_recalc_pool_mutex_key; extern bool innodb_dict_stats_disabled_debug; #endif /* UNIV_DEBUG */ -/*****************************************************************/ /** - Add a table to the recalc pool, which is processed by the +/** Add a table to the recalc pool, which is processed by the background stats gathering thread. Only the table id is added to the list, so the table can be closed after being enqueued and it will be opened when needed. If the table does not exist later (has been DROPped), then it will be removed from the pool and skipped. */ void dict_stats_recalc_pool_add( - /*=======================*/ const dict_table_t *table); /*!< in: table to add */ -/*****************************************************************/ /** - Delete a given table from the auto recalc pool. +/** Delete a given table from the auto recalc pool. dict_stats_recalc_pool_del() */ void dict_stats_recalc_pool_del( - /*=======================*/ const dict_table_t *table); /*!< in: table to remove */ /** Yield the data dictionary latch when waiting @@ -79,18 +74,14 @@ for the background thread to stop accessing a table. row_mysql_lock_data_dictionary(trx); \ } while (0) -/*****************************************************************/ /** - Request the background collection of statistics to stop for a table. +/** Request the background collection of statistics to stop for a table. @retval true when no background process is active @retval false when it is not safe to modify the table definition */ UNIV_INLINE -bool dict_stats_stop_bg( - /*===============*/ - dict_table_t *table) /*!< in/out: table */ +bool dict_stats_stop_bg(dict_table_t *table) /*!< in/out: table */ MY_ATTRIBUTE((warn_unused_result)); -/*****************************************************************/ /** - Wait until background stats thread has stopped using the specified table. +/** Wait until background stats thread has stopped using the specified table. The caller must have locked the data dictionary using row_mysql_lock_data_dictionary() and this function may unlock it temporarily and restore the lock before it exits. @@ -99,21 +90,16 @@ bool dict_stats_stop_bg( dictionary because it sets the BG_STAT_IN_PROGRESS bit in table->stats_bg_flag under dict_sys->mutex. */ void dict_stats_wait_bg_to_stop_using_table( - /*===================================*/ dict_table_t *table, /*!< in/out: table */ trx_t *trx); /*!< in/out: transaction to use for unlocking/locking the data dict */ -/*****************************************************************/ /** - Initialize global variables needed for the operation of dict_stats_thread(). +/** Initialize global variables needed for the operation of dict_stats_thread(). Must be called before dict_stats_thread() is started. */ void dict_stats_thread_init(); -/*====================*/ -/*****************************************************************/ /** - Free resources allocated by dict_stats_thread_init(), must be called +/** Free resources allocated by dict_stats_thread_init(), must be called after dict_stats_thread() has exited. */ void dict_stats_thread_deinit(); -/*======================*/ #ifdef UNIV_DEBUG /** Disables dict stats thread. It's used by: diff --git a/storage/innobase/include/dict0stats_bg.ic b/storage/innobase/include/dict0stats_bg.ic index 120f47559fe0..7489a80179c4 100644 --- a/storage/innobase/include/dict0stats_bg.ic +++ b/storage/innobase/include/dict0stats_bg.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2012, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2012, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/dict0stats_bg.ic +/** @file include/dict0stats_bg.ic Code used for background table and index stats gathering. Created Feb 8, 2013 Marko Makela @@ -34,14 +33,11 @@ this program; if not, write to the Free Software Foundation, Inc., #include "dict0dict.h" #include "dict0mem.h" -/*****************************************************************/ /** - Request the background collection of statistics to stop for a table. +/** Request the background collection of statistics to stop for a table. @retval true when no background process is active @retval false when it is not safe to modify the table definition */ UNIV_INLINE -bool dict_stats_stop_bg( - /*===============*/ - dict_table_t *table) /*!< in/out: table */ +bool dict_stats_stop_bg(dict_table_t *table) /*!< in/out: table */ { ut_ad(!srv_read_only_mode); ut_ad(mutex_own(&dict_sys->mutex)); diff --git a/storage/innobase/include/dict0types.h b/storage/innobase/include/dict0types.h index cfe7abc3eedb..9ff319279d2a 100644 --- a/storage/innobase/include/dict0types.h +++ b/storage/innobase/include/dict0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/dict0types.h +/** @file include/dict0types.h Data dictionary global types Created 1/8/1996 Heikki Tuuri diff --git a/storage/innobase/include/dyn0buf.h b/storage/innobase/include/dyn0buf.h index c657bb037f48..571da59711dc 100644 --- a/storage/innobase/include/dyn0buf.h +++ b/storage/innobase/include/dyn0buf.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2013, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/dyn0buf.h +/** @file include/dyn0buf.h The dynamically allocated buffer implementation Created 2013-03-16 Sunny Bains diff --git a/storage/innobase/include/dyn0types.h b/storage/innobase/include/dyn0types.h index 359ba15692bd..bdc79ca89bdf 100644 --- a/storage/innobase/include/dyn0types.h +++ b/storage/innobase/include/dyn0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/dyn0types.h +/** @file include/dyn0types.h The dynamically allocated buffer types and constants Created 2013-03-16 Sunny Bains diff --git a/storage/innobase/include/eval0eval.h b/storage/innobase/include/eval0eval.h index 7fcebf70c369..ca67d1d3214c 100644 --- a/storage/innobase/include/eval0eval.h +++ b/storage/innobase/include/eval0eval.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/eval0eval.h +/** @file include/eval0eval.h SQL evaluator: evaluates simple data structures, like expressions, in a query graph @@ -40,25 +39,16 @@ this program; if not, write to the Free Software Foundation, Inc., #include "que0types.h" #include "univ.i" -/*****************************************************************/ /** - Free the buffer from global dynamic memory for a value of a que_node, +/** Free the buffer from global dynamic memory for a value of a que_node, if it has been allocated in the above function. The freeing for pushed column values is done in sel_col_prefetch_buf_free. */ -void eval_node_free_val_buf( - /*===================*/ - que_node_t *node); /*!< in: query graph node */ -/*****************************************************************/ /** - Evaluates a symbol table symbol. */ +void eval_node_free_val_buf(que_node_t *node); /*!< in: query graph node */ +/** Evaluates a symbol table symbol. */ UNIV_INLINE -void eval_sym( - /*=====*/ - sym_node_t *sym_node); /*!< in: symbol table node */ -/*****************************************************************/ /** - Evaluates an expression. */ +void eval_sym(sym_node_t *sym_node); /*!< in: symbol table node */ +/** Evaluates an expression. */ UNIV_INLINE -void eval_exp( - /*=====*/ - que_node_t *exp_node); /*!< in: expression */ +void eval_exp(que_node_t *exp_node); /*!< in: expression */ /** Sets an integer value as the value of an expression node. @param[in] node expression node @@ -66,13 +56,10 @@ void eval_exp( UNIV_INLINE void eval_node_set_int_val(que_node_t *node, lint val); -/*****************************************************************/ /** - Gets an integer value from an expression node. +/** Gets an integer value from an expression node. @return integer value */ UNIV_INLINE -lint eval_node_get_int_val( - /*==================*/ - que_node_t *node); /*!< in: expression node */ +lint eval_node_get_int_val(que_node_t *node); /*!< in: expression node */ /** Copies a binary string value as the value of a query graph node. Allocates a new buffer if necessary. @@ -88,19 +75,13 @@ void eval_node_copy_and_alloc_val(que_node_t *node, const byte *str, ulint len); UNIV_INLINE void eval_node_copy_val(que_node_t *node1, que_node_t *node2); -/*****************************************************************/ /** - Gets a iboolean value from a query node. +/** Gets a iboolean value from a query node. @return iboolean value */ UNIV_INLINE -ibool eval_node_get_ibool_val( - /*====================*/ - que_node_t *node); /*!< in: query graph node */ -/*****************************************************************/ /** - Evaluates a comparison node. +ibool eval_node_get_ibool_val(que_node_t *node); /*!< in: query graph node */ +/** Evaluates a comparison node. @return the result of the comparison */ -ibool eval_cmp( - /*=====*/ - func_node_t *cmp_node); /*!< in: comparison node */ +ibool eval_cmp(func_node_t *cmp_node); /*!< in: comparison node */ #include "eval0eval.ic" diff --git a/storage/innobase/include/eval0eval.ic b/storage/innobase/include/eval0eval.ic index 6e62715aa32d..96996e3ba30b 100644 --- a/storage/innobase/include/eval0eval.ic +++ b/storage/innobase/include/eval0eval.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/eval0eval.ic +/** @file include/eval0eval.ic SQL evaluator: evaluates simple data structures, like expressions, in a query graph @@ -36,31 +35,24 @@ this program; if not, write to the Free Software Foundation, Inc., #include "que0que.h" #include "rem0cmp.h" -/*****************************************************************/ /** - Evaluates a function node. */ -void eval_func( - /*======*/ - func_node_t *func_node); /*!< in: function node */ -/*****************************************************************/ /** - Allocate a buffer from global dynamic memory for a value of a que_node. +/** Evaluates a function node. */ +void eval_func(func_node_t *func_node); /*!< in: function node */ +/** Allocate a buffer from global dynamic memory for a value of a que_node. NOTE that this memory must be explicitly freed when the query graph is freed. If the node already has allocated buffer, that buffer is freed here. NOTE that this is the only function where dynamic memory should be allocated for a query node val field. @return pointer to allocated buffer */ byte *eval_node_alloc_val_buf( - /*====================*/ que_node_t *node, /*!< in: query graph node; sets the val field data field to point to the new buffer, and len field equal to size */ ulint size); /*!< in: buffer size */ -/*****************************************************************/ /** - Allocates a new buffer if needed. +/** Allocates a new buffer if needed. @return pointer to buffer */ UNIV_INLINE byte *eval_node_ensure_val_buf( - /*=====================*/ que_node_t *node, /*!< in: query graph node; sets the val field data field to point to the new buffer, and len field equal to size */ @@ -81,12 +73,9 @@ byte *eval_node_ensure_val_buf( return (data); } -/*****************************************************************/ /** - Evaluates a symbol table symbol. */ +/** Evaluates a symbol table symbol. */ UNIV_INLINE -void eval_sym( - /*=====*/ - sym_node_t *sym_node) /*!< in: symbol table node */ +void eval_sym(sym_node_t *sym_node) /*!< in: symbol table node */ { ut_ad(que_node_get_type(sym_node) == QUE_NODE_SYMBOL); @@ -99,12 +88,9 @@ void eval_sym( } } -/*****************************************************************/ /** - Evaluates an expression. */ +/** Evaluates an expression. */ UNIV_INLINE -void eval_exp( - /*=====*/ - que_node_t *exp_node) /*!< in: expression */ +void eval_exp(que_node_t *exp_node) /*!< in: expression */ { if (que_node_get_type(exp_node) == QUE_NODE_SYMBOL) { eval_sym((sym_node_t *)exp_node); @@ -115,13 +101,10 @@ void eval_exp( eval_func(static_cast(exp_node)); } -/*****************************************************************/ /** - Sets an integer value as the value of an expression node. */ +/** Sets an integer value as the value of an expression node. */ UNIV_INLINE -void eval_node_set_int_val( - /*==================*/ - que_node_t *node, /*!< in: expression node */ - lint val) /*!< in: value to set */ +void eval_node_set_int_val(que_node_t *node, /*!< in: expression node */ + lint val) /*!< in: value to set */ { dfield_t *dfield; byte *data; @@ -139,13 +122,10 @@ void eval_node_set_int_val( mach_write_to_4(data, (ulint)val); } -/*****************************************************************/ /** - Gets an integer non-SQL null value from an expression node. +/** Gets an integer non-SQL null value from an expression node. @return integer value */ UNIV_INLINE -lint eval_node_get_int_val( - /*==================*/ - que_node_t *node) /*!< in: expression node */ +lint eval_node_get_int_val(que_node_t *node) /*!< in: expression node */ { const byte *ptr; dfield_t *dfield; @@ -158,13 +138,10 @@ lint eval_node_get_int_val( return (mach_read_from_4(ptr)); } -/*****************************************************************/ /** - Gets a iboolean value from a query node. +/** Gets a iboolean value from a query node. @return iboolean value */ UNIV_INLINE -ibool eval_node_get_ibool_val( - /*====================*/ - que_node_t *node) /*!< in: query graph node */ +ibool eval_node_get_ibool_val(que_node_t *node) /*!< in: query graph node */ { dfield_t *dfield; byte *data; @@ -178,13 +155,10 @@ ibool eval_node_get_ibool_val( return (mach_read_from_1(data)); } -/*****************************************************************/ /** - Sets a iboolean value as the value of a function node. */ +/** Sets a iboolean value as the value of a function node. */ UNIV_INLINE -void eval_node_set_ibool_val( - /*====================*/ - func_node_t *func_node, /*!< in: function node */ - ibool val) /*!< in: value to set */ +void eval_node_set_ibool_val(func_node_t *func_node, /*!< in: function node */ + ibool val) /*!< in: value to set */ { dfield_t *dfield; byte *data; @@ -204,12 +178,10 @@ void eval_node_set_ibool_val( mach_write_to_1(data, val); } -/*****************************************************************/ /** - Copies a binary string value as the value of a query graph node. Allocates a +/** Copies a binary string value as the value of a query graph node. Allocates a new buffer if necessary. */ UNIV_INLINE void eval_node_copy_and_alloc_val( - /*=========================*/ que_node_t *node, /*!< in: query graph node */ const byte *str, /*!< in: binary string */ ulint len) /*!< in: string length or UNIV_SQL_NULL */ @@ -227,13 +199,10 @@ void eval_node_copy_and_alloc_val( ut_memcpy(data, str, len); } -/*****************************************************************/ /** - Copies a query node value to another node. */ +/** Copies a query node value to another node. */ UNIV_INLINE -void eval_node_copy_val( - /*===============*/ - que_node_t *node1, /*!< in: node to copy to */ - que_node_t *node2) /*!< in: node to copy from */ +void eval_node_copy_val(que_node_t *node1, /*!< in: node to copy to */ + que_node_t *node2) /*!< in: node to copy from */ { dfield_t *dfield2; diff --git a/storage/innobase/include/eval0proc.h b/storage/innobase/include/eval0proc.h index dcf2838cda11..184a80de2734 100644 --- a/storage/innobase/include/eval0proc.h +++ b/storage/innobase/include/eval0proc.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1998, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1998, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/eval0proc.h +/** @file include/eval0proc.h Executes SQL stored procedures and their control structures Created 1/20/1998 Heikki Tuuri @@ -39,56 +38,32 @@ this program; if not, write to the Free Software Foundation, Inc., #include "que0types.h" #include "univ.i" -/**********************************************************************/ /** - Performs an execution step of a procedure node. +/** Performs an execution step of a procedure node. @return query thread to run next or NULL */ UNIV_INLINE -que_thr_t *proc_step( - /*======*/ - que_thr_t *thr); /*!< in: query thread */ -/**********************************************************************/ /** - Performs an execution step of an if-statement node. +que_thr_t *proc_step(que_thr_t *thr); /*!< in: query thread */ +/** Performs an execution step of an if-statement node. @return query thread to run next or NULL */ -que_thr_t *if_step( - /*====*/ - que_thr_t *thr); /*!< in: query thread */ -/**********************************************************************/ /** - Performs an execution step of a while-statement node. +que_thr_t *if_step(que_thr_t *thr); /*!< in: query thread */ +/** Performs an execution step of a while-statement node. @return query thread to run next or NULL */ -que_thr_t *while_step( - /*=======*/ - que_thr_t *thr); /*!< in: query thread */ -/**********************************************************************/ /** - Performs an execution step of a for-loop node. +que_thr_t *while_step(que_thr_t *thr); /*!< in: query thread */ +/** Performs an execution step of a for-loop node. @return query thread to run next or NULL */ -que_thr_t *for_step( - /*=====*/ - que_thr_t *thr); /*!< in: query thread */ -/**********************************************************************/ /** - Performs an execution step of an assignment statement node. +que_thr_t *for_step(que_thr_t *thr); /*!< in: query thread */ +/** Performs an execution step of an assignment statement node. @return query thread to run next or NULL */ -que_thr_t *assign_step( - /*========*/ - que_thr_t *thr); /*!< in: query thread */ -/**********************************************************************/ /** - Performs an execution step of a procedure call node. +que_thr_t *assign_step(que_thr_t *thr); /*!< in: query thread */ +/** Performs an execution step of a procedure call node. @return query thread to run next or NULL */ UNIV_INLINE -que_thr_t *proc_eval_step( - /*===========*/ - que_thr_t *thr); /*!< in: query thread */ -/**********************************************************************/ /** - Performs an execution step of an exit statement node. +que_thr_t *proc_eval_step(que_thr_t *thr); /*!< in: query thread */ +/** Performs an execution step of an exit statement node. @return query thread to run next or NULL */ -que_thr_t *exit_step( - /*======*/ - que_thr_t *thr); /*!< in: query thread */ -/**********************************************************************/ /** - Performs an execution step of a return-statement node. +que_thr_t *exit_step(que_thr_t *thr); /*!< in: query thread */ +/** Performs an execution step of a return-statement node. @return query thread to run next or NULL */ -que_thr_t *return_step( - /*========*/ - que_thr_t *thr); /*!< in: query thread */ +que_thr_t *return_step(que_thr_t *thr); /*!< in: query thread */ #include "eval0proc.ic" diff --git a/storage/innobase/include/eval0proc.ic b/storage/innobase/include/eval0proc.ic index 23ebf03eed97..e2a98a8071d5 100644 --- a/storage/innobase/include/eval0proc.ic +++ b/storage/innobase/include/eval0proc.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1998, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1998, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/eval0proc.ic +/** @file include/eval0proc.ic Executes SQL stored procedures and their control structures Created 1/20/1998 Heikki Tuuri @@ -35,13 +34,10 @@ this program; if not, write to the Free Software Foundation, Inc., #include "pars0pars.h" #include "que0que.h" -/**********************************************************************/ /** - Performs an execution step of a procedure node. +/** Performs an execution step of a procedure node. @return query thread to run next or NULL */ UNIV_INLINE -que_thr_t *proc_step( - /*======*/ - que_thr_t *thr) /*!< in: query thread */ +que_thr_t *proc_step(que_thr_t *thr) /*!< in: query thread */ { proc_node_t *node; @@ -69,13 +65,10 @@ que_thr_t *proc_step( return (thr); } -/**********************************************************************/ /** - Performs an execution step of a procedure call node. +/** Performs an execution step of a procedure call node. @return query thread to run next or NULL */ UNIV_INLINE -que_thr_t *proc_eval_step( - /*===========*/ - que_thr_t *thr) /*!< in: query thread */ +que_thr_t *proc_eval_step(que_thr_t *thr) /*!< in: query thread */ { func_node_t *node; diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index c98af2f60899..9aa34972be05 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/fil0fil.h +/** @file include/fil0fil.h The low-level file system Created 10/25/1995 Heikki Tuuri diff --git a/storage/innobase/include/fil0types.h b/storage/innobase/include/fil0types.h index ca4dfa8a5b30..fa2a51b35fbf 100644 --- a/storage/innobase/include/fil0types.h +++ b/storage/innobase/include/fil0types.h @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/fil0types.h +/** @file include/fil0types.h The low-level file system page header & trailer offsets Created 10/25/1995 Heikki Tuuri diff --git a/storage/innobase/include/fsp0file.h b/storage/innobase/include/fsp0file.h index a6651635716e..112d51024205 100644 --- a/storage/innobase/include/fsp0file.h +++ b/storage/innobase/include/fsp0file.h @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/fsp0file.h +/** @file include/fsp0file.h Tablespace data file implementation. Created 2013-7-26 by Kevin Lewis diff --git a/storage/innobase/include/fsp0fsp.h b/storage/innobase/include/fsp0fsp.h index f209527635c8..c32929cb0c05 100644 --- a/storage/innobase/include/fsp0fsp.h +++ b/storage/innobase/include/fsp0fsp.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/fsp0fsp.h +/** @file include/fsp0fsp.h File space management Created 12/18/1995 Heikki Tuuri @@ -329,19 +328,15 @@ const ulint XDES_FRAG_N_USED = 2; /* @} */ -/**********************************************************************/ /** - Initializes the file space system. */ +/** Initializes the file space system. */ void fsp_init(void); -/*==========*/ -/**********************************************************************/ /** - Gets the size of the system tablespace from the tablespace header. If +/** Gets the size of the system tablespace from the tablespace header. If we do not have an auto-extending data file, this should be equal to the size of the data files. If there is an auto-extending data file, this can be smaller. @return size in pages */ page_no_t fsp_header_get_tablespace_size(void); -/*================================*/ /** Calculate the number of pages to extend a datafile. We extend single-table and general tablespaces first one extent at a time, @@ -367,11 +362,9 @@ page_no_t fsp_get_extent_size_in_pages(const page_size_t &page_size) { page_size.physical())); } -/**********************************************************************/ /** - Reads the space id from the first page of a tablespace. +/** Reads the space id from the first page of a tablespace. @return space id, ULINT UNDEFINED if error */ space_id_t fsp_header_get_space_id( - /*====================*/ const page_t *page); /*!< in: first page of a tablespace */ /** Read a tablespace header field. @@ -414,12 +407,10 @@ bool fsp_header_check_encryption_key(ulint fsp_flags, page_t *page); @return true if valid, false if invalid. */ bool fsp_check_tablespace_size(space_id_t space_id); -/**********************************************************************/ /** - Writes the space id and flags to a tablespace header. The flags contain +/** Writes the space id and flags to a tablespace header. The flags contain row type, physical/compressed page size, and logical/uncompressed page size of the tablespace. */ void fsp_header_init_fields( - /*===================*/ page_t *page, /*!< in/out: first page in the space */ space_id_t space_id, /*!< in: space id */ ulint flags); /*!< in: tablespace flags @@ -460,19 +451,14 @@ insert buffer tree root if space == 0. bool fsp_header_init(space_id_t space_id, page_no_t size, mtr_t *mtr, bool is_boot); -/**********************************************************************/ /** - Increases the space size field of a space. */ -void fsp_header_inc_size( - /*================*/ - space_id_t space_id, /*!< in: space id */ - page_no_t size_inc, /*!< in: size increment in pages */ - mtr_t *mtr); /*!< in/out: mini-transaction */ -/**********************************************************************/ /** - Creates a new segment. +/** Increases the space size field of a space. */ +void fsp_header_inc_size(space_id_t space_id, /*!< in: space id */ + page_no_t size_inc, /*!< in: size increment in pages */ + mtr_t *mtr); /*!< in/out: mini-transaction */ +/** Creates a new segment. @return the block where the segment header is placed, x-latched, NULL if could not create segment because of lack of space */ buf_block_t *fseg_create( - /*========*/ space_id_t space, /*!< in: space id */ page_no_t page, /*!< in: page where the segment header is placed: if this is != 0, the page must belong @@ -482,12 +468,10 @@ buf_block_t *fseg_create( ulint byte_offset, /*!< in: byte offset of the created segment header on the page */ mtr_t *mtr); /*!< in/out: mini-transaction */ -/**********************************************************************/ /** - Creates a new segment. +/** Creates a new segment. @return the block where the segment header is placed, x-latched, NULL if could not create segment because of lack of space */ buf_block_t *fseg_create_general( - /*================*/ space_id_t space_id, /*!< in: space id */ page_no_t page, /*!< in: page where the segment header is placed: if this is != 0, the page must belong to another @@ -501,17 +485,14 @@ buf_block_t *fseg_create_general( the inode and the other for the segment) then there is no need to do the check for this individual operation */ mtr_t *mtr); /*!< in/out: mini-transaction */ -/**********************************************************************/ /** - Calculates the number of pages reserved by a segment, and how many pages are +/** Calculates the number of pages reserved by a segment, and how many pages are currently used. @return number of reserved pages */ ulint fseg_n_reserved_pages( - /*==================*/ fseg_header_t *header, /*!< in: segment header */ ulint *used, /*!< out: number of pages used (<= reserved) */ mtr_t *mtr); /*!< in/out: mini-transaction */ -/**********************************************************************/ /** - Allocates a single free page from a segment. This function implements +/** Allocates a single free page from a segment. This function implements the intelligent allocation strategy which tries to minimize file space fragmentation. @param[in,out] seg_header segment header @@ -525,8 +506,7 @@ ulint fseg_n_reserved_pages( @return X-latched block, or NULL if no page could be allocated */ #define fseg_alloc_free_page(seg_header, hint, direction, mtr) \ fseg_alloc_free_page_general(seg_header, hint, direction, FALSE, mtr, mtr) -/**********************************************************************/ /** - Allocates a single free page from a segment. This function implements +/** Allocates a single free page from a segment. This function implements the intelligent allocation strategy which tries to minimize file space fragmentation. @retval NULL if no page could be allocated @@ -534,7 +514,6 @@ ulint fseg_n_reserved_pages( (init_mtr == mtr, or the page was not previously freed in mtr) @retval block (not allocated or initialized) otherwise */ buf_block_t *fseg_alloc_free_page_general( - /*=========================*/ fseg_header_t *seg_header, /*!< in/out: segment header */ page_no_t hint, /*!< in: hint of which page would be desirable */ @@ -611,33 +590,25 @@ been acquired by the caller who holds it for the calculation, @return available space in KiB */ uintmax_t fsp_get_available_space_in_free_extents(const fil_space_t *space); -/**********************************************************************/ /** - Frees a single page of a segment. */ -void fseg_free_page( - /*===========*/ - fseg_header_t *seg_header, /*!< in: segment header */ - space_id_t space_id, /*!< in: space id */ - page_no_t page, /*!< in: page offset */ - bool ahi, /*!< in: whether we may need to drop - the adaptive hash index */ - mtr_t *mtr); /*!< in/out: mini-transaction */ -/**********************************************************************/ /** - Checks if a single page of a segment is free. +/** Frees a single page of a segment. */ +void fseg_free_page(fseg_header_t *seg_header, /*!< in: segment header */ + space_id_t space_id, /*!< in: space id */ + page_no_t page, /*!< in: page offset */ + bool ahi, /*!< in: whether we may need to drop + the adaptive hash index */ + mtr_t *mtr); /*!< in/out: mini-transaction */ +/** Checks if a single page of a segment is free. @return true if free */ -bool fseg_page_is_free( - /*==============*/ - fseg_header_t *seg_header, /*!< in: segment header */ - space_id_t space_id, /*!< in: space id */ - page_no_t page) /*!< in: page offset */ +bool fseg_page_is_free(fseg_header_t *seg_header, /*!< in: segment header */ + space_id_t space_id, /*!< in: space id */ + page_no_t page) /*!< in: page offset */ MY_ATTRIBUTE((warn_unused_result)); -/**********************************************************************/ /** - Frees part of a segment. This function can be used to free a segment +/** Frees part of a segment. This function can be used to free a segment by repeatedly calling this function in different mini-transactions. Doing the freeing in a single mini-transaction might result in too big a mini-transaction. @return true if freeing completed */ ibool fseg_free_step( - /*===========*/ fseg_header_t *header, /*!< in, own: segment header; NOTE: if the header resides on the first page of the frag list of the segment, this pointer becomes obsolete @@ -646,12 +617,10 @@ ibool fseg_free_step( the adaptive hash index */ mtr_t *mtr) /*!< in/out: mini-transaction */ MY_ATTRIBUTE((warn_unused_result)); -/**********************************************************************/ /** - Frees part of a segment. Differs from fseg_free_step because this function +/** Frees part of a segment. Differs from fseg_free_step because this function leaves the header page unfreed. @return true if freeing completed, except the header page */ ibool fseg_free_step_not_header( - /*======================*/ fseg_header_t *header, /*!< in: segment header which must reside on the first fragment page of the segment */ bool ahi, /*!< in: whether we may need to drop @@ -666,22 +635,16 @@ ibool fseg_free_step_not_header( UNIV_INLINE ibool fsp_descr_page(const page_id_t &page_id, const page_size_t &page_size); -/***********************************************************/ /** - Parses a redo log record of a file page init. +/** Parses a redo log record of a file page init. @return end of log record or NULL */ -byte *fsp_parse_init_file_page( - /*=====================*/ - byte *ptr, /*!< in: buffer */ - byte *end_ptr, /*!< in: buffer end */ - buf_block_t *block); /*!< in: block or NULL */ +byte *fsp_parse_init_file_page(byte *ptr, /*!< in: buffer */ + byte *end_ptr, /*!< in: buffer end */ + buf_block_t *block); /*!< in: block or NULL */ #ifdef UNIV_BTR_PRINT -/*******************************************************************/ /** - Writes info of a segment. */ -void fseg_print( - /*=======*/ - fseg_header_t *header, /*!< in: segment header */ - mtr_t *mtr); /*!< in/out: mini-transaction */ -#endif /* UNIV_BTR_PRINT */ +/** Writes info of a segment. */ +void fseg_print(fseg_header_t *header, /*!< in: segment header */ + mtr_t *mtr); /*!< in/out: mini-transaction */ +#endif /* UNIV_BTR_PRINT */ /** Check whether a space id is an undo tablespace ID @param[in] space_id space id to check diff --git a/storage/innobase/include/fsp0fsp.ic b/storage/innobase/include/fsp0fsp.ic index 5ca01db12834..1cce4e274874 100644 --- a/storage/innobase/include/fsp0fsp.ic +++ b/storage/innobase/include/fsp0fsp.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/fsp0fsp.ic +/** @file include/fsp0fsp.ic File space management Created 12/18/1995 Heikki Tuuri @@ -216,16 +215,13 @@ ulint xdes_calc_descriptor_index(const page_size_t &page_size, ulint offset) { return (ut_2pow_remainder(offset, page_size.physical()) / FSP_EXTENT_SIZE); } -/**********************************************************************/ /** - Gets a descriptor bit of a page. +/** Gets a descriptor bit of a page. @return true if free */ UNIV_INLINE -ibool xdes_get_bit( - /*=========*/ - const xdes_t *descr, /*!< in: descriptor */ - ulint bit, /*!< in: XDES_FREE_BIT or XDES_CLEAN_BIT */ - page_no_t offset) /*!< in: page offset within extent: - 0 ... FSP_EXTENT_SIZE - 1 */ +ibool xdes_get_bit(const xdes_t *descr, /*!< in: descriptor */ + ulint bit, /*!< in: XDES_FREE_BIT or XDES_CLEAN_BIT */ + page_no_t offset) /*!< in: page offset within extent: + 0 ... FSP_EXTENT_SIZE - 1 */ { ut_ad(offset < FSP_EXTENT_SIZE); ut_ad(bit == XDES_FREE_BIT || bit == XDES_CLEAN_BIT); diff --git a/storage/innobase/include/fsp0space.h b/storage/innobase/include/fsp0space.h index 1484cabcf20a..67cf01d2b958 100644 --- a/storage/innobase/include/fsp0space.h +++ b/storage/innobase/include/fsp0space.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2013, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/fsp0space.h +/** @file include/fsp0space.h General shared tablespace implementation. Created 2013-7-26 by Kevin Lewis diff --git a/storage/innobase/include/fsp0sysspace.h b/storage/innobase/include/fsp0sysspace.h index c1e2acb81a42..cb379e4a40d4 100644 --- a/storage/innobase/include/fsp0sysspace.h +++ b/storage/innobase/include/fsp0sysspace.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2013, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/fsp0sysspace.h +/** @file include/fsp0sysspace.h Multi file, shared, system tablespace implementation. Created 2013-7-26 by Kevin Lewis diff --git a/storage/innobase/include/fts0ast.h b/storage/innobase/include/fts0ast.h index 4affd377f53f..c36516543cf4 100644 --- a/storage/innobase/include/fts0ast.h +++ b/storage/innobase/include/fts0ast.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/fts0ast.h +/** @file include/fts0ast.h The FTS query parser (AST) abstract syntax tree routines Created 2007/03/16/03 Sunny Bains @@ -103,110 +102,88 @@ typedef dberr_t (*fts_ast_callback)(fts_ast_oper_t, fts_ast_node_t *, void *); /******************************************************************** Parse the string using the lexer setup within state.*/ int fts_parse( - /*======*/ /* out: 0 on OK, 1 on error */ fts_ast_state_t *state); /*!< in: ast state instance.*/ /******************************************************************** Create an AST operator node */ extern fts_ast_node_t *fts_ast_create_node_oper( - /*=====================*/ void *arg, /*!< in: ast state */ fts_ast_oper_t oper); /*!< in: ast operator */ /******************************************************************** Create an AST term node, makes a copy of ptr */ extern fts_ast_node_t *fts_ast_create_node_term( - /*=====================*/ void *arg, /*!< in: ast state */ const fts_ast_string_t *ptr); /*!< in: term string */ /******************************************************************** Create an AST text node */ extern fts_ast_node_t *fts_ast_create_node_text( - /*=====================*/ void *arg, /*!< in: ast state */ const fts_ast_string_t *ptr); /*!< in: text string */ /******************************************************************** Create an AST expr list node */ extern fts_ast_node_t *fts_ast_create_node_list( - /*=====================*/ void *arg, /*!< in: ast state */ fts_ast_node_t *expr); /*!< in: ast expr */ /******************************************************************** Create a sub-expression list node. This function takes ownership of expr and is responsible for deleting it. */ extern fts_ast_node_t *fts_ast_create_node_subexp_list( - /*============================*/ /* out: new node */ void *arg, /*!< in: ast state instance */ fts_ast_node_t *expr); /*!< in: ast expr instance */ /******************************************************************** Set the wildcard attribute of a term.*/ extern void fts_ast_term_set_wildcard( - /*======================*/ fts_ast_node_t *node); /*!< in: term to change */ /******************************************************************** Set the proximity attribute of a text node. */ -void fts_ast_text_set_distance( - /*======================*/ - fts_ast_node_t *node, /*!< in/out: text node */ - ulint distance); /*!< in: the text proximity - distance */ -/********************************************************************/ /** - Free a fts_ast_node_t instance. +void fts_ast_text_set_distance(fts_ast_node_t *node, /*!< in/out: text node */ + ulint distance); /*!< in: the text proximity + distance */ +/** Free a fts_ast_node_t instance. @return next node to free */ fts_ast_node_t *fts_ast_free_node( - /*==============*/ fts_ast_node_t *node); /*!< in: node to free */ /******************************************************************** Add a sub-expression to an AST*/ extern fts_ast_node_t *fts_ast_add_node( - /*=============*/ fts_ast_node_t *list, /*!< in: list node instance */ fts_ast_node_t *node); /*!< in: (sub) expr to add */ /******************************************************************** Print the AST node recursively.*/ extern void fts_ast_node_print( - /*===============*/ fts_ast_node_t *node); /*!< in: ast node to print */ /******************************************************************** Free node and expr allocations.*/ -extern void fts_ast_state_free( - /*===============*/ - fts_ast_state_t *state); /*!< in: state instance - to free */ +extern void fts_ast_state_free(fts_ast_state_t *state); /*!< in: state instance + to free */ /** Check only union operation involved in the node @param[in] node ast node to check @return true if the node contains only union else false. */ bool fts_ast_node_check_union(fts_ast_node_t *node); -/******************************************************************/ /** - Traverse the AST - in-order traversal. +/** Traverse the AST - in-order traversal. @return DB_SUCCESS if all went well */ -dberr_t fts_ast_visit( - /*==========*/ - fts_ast_oper_t oper, /*!< in: FTS operator */ - fts_ast_node_t *node, /*!< in: instance to traverse*/ - fts_ast_callback visitor, /*!< in: callback */ - void *arg, /*!< in: callback arg */ - bool *has_ignore) /*!< out: whether we encounter - and ignored processing an - operator, currently we only - ignore FTS_IGNORE operator */ +dberr_t fts_ast_visit(fts_ast_oper_t oper, /*!< in: FTS operator */ + fts_ast_node_t *node, /*!< in: instance to traverse*/ + fts_ast_callback visitor, /*!< in: callback */ + void *arg, /*!< in: callback arg */ + bool *has_ignore) /*!< out: whether we encounter + and ignored processing an + operator, currently we only + ignore FTS_IGNORE operator */ MY_ATTRIBUTE((warn_unused_result)); /******************************************************************** Create a lex instance.*/ -fts_lexer_t *fts_lexer_create( - /*=============*/ - ibool boolean_mode, /*!< in: query type */ - const byte *query, /*!< in: query string */ - ulint query_len) /*!< in: query string len */ +fts_lexer_t *fts_lexer_create(ibool boolean_mode, /*!< in: query type */ + const byte *query, /*!< in: query string */ + ulint query_len) /*!< in: query string len */ MY_ATTRIBUTE((malloc, warn_unused_result)); /******************************************************************** Free an fts_lexer_t instance.*/ -void fts_lexer_free( - /*===========*/ - fts_lexer_t *fts_lexer); /*!< in: lexer instance to - free */ +void fts_lexer_free(fts_lexer_t *fts_lexer); /*!< in: lexer instance to + free */ /** Create an ast string object, with NUL-terminator, so the string @@ -291,8 +268,7 @@ struct fts_ast_state_t { int depth; /*!< Depth of parsing state */ }; -/******************************************************************/ /** - Create an AST term node, makes a copy of ptr for plugin parser +/** Create an AST term node, makes a copy of ptr for plugin parser @return node */ extern fts_ast_node_t *fts_ast_create_node_term_for_parser( /*==========i=====================*/ @@ -300,11 +276,9 @@ extern fts_ast_node_t *fts_ast_create_node_term_for_parser( const char *ptr, /*!< in: term string */ const ulint len); /*!< in: term string length */ -/******************************************************************/ /** - Create an AST phrase list node for plugin parser +/** Create an AST phrase list node for plugin parser @return node */ extern fts_ast_node_t *fts_ast_create_node_phrase_list( - /*============================*/ void *arg); /*!< in: ast state */ #ifdef UNIV_DEBUG diff --git a/storage/innobase/include/fts0fts.h b/storage/innobase/include/fts0fts.h index e5557652a161..f937a29e77f5 100644 --- a/storage/innobase/include/fts0fts.h +++ b/storage/innobase/include/fts0fts.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/fts0fts.h +/** @file include/fts0fts.h Full text search header file Created 2011/09/02 Sunny Bains @@ -438,17 +437,13 @@ extern char *fts_internal_tbl_name2; que_graph_free(graph); \ } while (0) -/******************************************************************/ /** - Create a FTS cache. */ +/** Create a FTS cache. */ fts_cache_t *fts_cache_create( - /*=============*/ dict_table_t *table); /*!< table owns the FTS cache */ -/******************************************************************/ /** - Create a FTS index cache. +/** Create a FTS index cache. @return Index Cache */ fts_index_cache_t *fts_cache_index_cache_create( - /*=========================*/ dict_table_t *table, /*!< in: table with FTS index */ dict_index_t *index); /*!< in: FTS index */ @@ -457,66 +452,47 @@ fts_index_cache_t *fts_cache_index_cache_create( @param[in] index FTS index */ void fts_cache_index_cache_remove(dict_table_t *table, dict_index_t *index); -/******************************************************************/ /** - Get the next available document id. This function creates a new +/** Get the next available document id. This function creates a new transaction to generate the document id. @return DB_SUCCESS if OK */ -dberr_t fts_get_next_doc_id( - /*================*/ - const dict_table_t *table, /*!< in: table */ - doc_id_t *doc_id); /*!< out: new document id */ -/*********************************************************************/ /** - Update the next and last Doc ID in the CONFIG table to be the input +dberr_t fts_get_next_doc_id(const dict_table_t *table, /*!< in: table */ + doc_id_t *doc_id); /*!< out: new document id */ +/** Update the next and last Doc ID in the CONFIG table to be the input "doc_id" value (+ 1). We would do so after each FTS index build or table truncate */ void fts_update_next_doc_id( - /*===================*/ trx_t *trx, /*!< in/out: transaction */ const dict_table_t *table, /*!< in: table */ const char *table_name, /*!< in: table name, or NULL */ doc_id_t doc_id); /*!< in: DOC ID to set */ -/******************************************************************/ /** - Create a new document id . +/** Create a new document id . @return DB_SUCCESS if all went well else error */ -dberr_t fts_create_doc_id( - /*==============*/ - dict_table_t *table, /*!< in: row is of this - table. */ - dtuple_t *row, /*!< in/out: add doc id - value to this row. This is the - current row that is being - inserted. */ - mem_heap_t *heap); /*!< in: heap */ - -/******************************************************************/ /** - Create a new fts_doc_ids_t. +dberr_t fts_create_doc_id(dict_table_t *table, /*!< in: row is of this + table. */ + dtuple_t *row, /*!< in/out: add doc id + value to this row. This is the + current row that is being + inserted. */ + mem_heap_t *heap); /*!< in: heap */ + +/** Create a new fts_doc_ids_t. @return new fts_doc_ids_t. */ fts_doc_ids_t *fts_doc_ids_create(void); -/*=====================*/ - -/******************************************************************/ /** - Free a fts_doc_ids_t. */ -void fts_doc_ids_free( - /*=============*/ - fts_doc_ids_t *doc_ids); /*!< in: doc_ids to free */ - -/******************************************************************/ /** - Notify the FTS system about an operation on an FTS-indexed table. */ -void fts_trx_add_op( - /*===========*/ - trx_t *trx, /*!< in: InnoDB transaction */ - dict_table_t *table, /*!< in: table */ - doc_id_t doc_id, /*!< in: doc id */ - fts_row_state state, /*!< in: state of the row */ - ib_vector_t *fts_indexes); /*!< in: FTS indexes affected - (NULL=all) */ - -/******************************************************************/ /** - Free an FTS trx. */ -void fts_trx_free( - /*=========*/ - fts_trx_t *fts_trx); /*!< in, own: FTS trx */ + +/** Free a fts_doc_ids_t. */ +void fts_doc_ids_free(fts_doc_ids_t *doc_ids); /*!< in: doc_ids to free */ + +/** Notify the FTS system about an operation on an FTS-indexed table. */ +void fts_trx_add_op(trx_t *trx, /*!< in: InnoDB transaction */ + dict_table_t *table, /*!< in: table */ + doc_id_t doc_id, /*!< in: doc id */ + fts_row_state state, /*!< in: state of the row */ + ib_vector_t *fts_indexes); /*!< in: FTS indexes affected + (NULL=all) */ + +/** Free an FTS trx. */ +void fts_trx_free(fts_trx_t *fts_trx); /*!< in, own: FTS trx */ /** Check if common tables already exist @param[in] table table with fts index @@ -574,10 +550,8 @@ dberr_t fts_create_index_tables_low(trx_t *trx, dict_index_t *index, const char *table_name, table_id_t table_id) MY_ATTRIBUTE((warn_unused_result)); -/******************************************************************/ /** - Add the FTS document id hidden column. */ +/** Add the FTS document id hidden column. */ void fts_add_doc_id_column( - /*==================*/ dict_table_t *table, /*!< in/out: Table with FTS index */ mem_heap_t *heap); /*!< in: temporary memory heap, or NULL */ @@ -608,13 +582,10 @@ bool fts_drop_dd_tables(const aux_name_vec_t *aux_vec, bool file_per_table); @return true on success, false on failure. */ void fts_free_aux_names(aux_name_vec_t *aux_vec); -/******************************************************************/ /** - The given transaction is about to be committed; do whatever is necessary +/** The given transaction is about to be committed; do whatever is necessary from the FTS system's POV. @return DB_SUCCESS or error code */ -dberr_t fts_commit( - /*=======*/ - trx_t *trx) /*!< in: transaction */ +dberr_t fts_commit(trx_t *trx) /*!< in: transaction */ MY_ATTRIBUTE((warn_unused_result)); /** FTS Query entry point. @@ -630,33 +601,24 @@ dberr_t fts_query(trx_t *trx, dict_index_t *index, uint flags, const byte *query_str, ulint query_len, fts_result_t **result, ulonglong limit) MY_ATTRIBUTE((warn_unused_result)); -/******************************************************************/ /** - Retrieve the FTS Relevance Ranking result for doc with doc_id +/** Retrieve the FTS Relevance Ranking result for doc with doc_id @return the relevance ranking value. */ float fts_retrieve_ranking( - /*=================*/ fts_result_t *result, /*!< in: FTS result structure */ doc_id_t doc_id); /*!< in: the interested document doc_id */ -/******************************************************************/ /** - FTS Query sort result, returned by fts_query() on fts_ranking_t::rank. */ +/** FTS Query sort result, returned by fts_query() on fts_ranking_t::rank. */ void fts_query_sort_result_on_rank( - /*==========================*/ fts_result_t *result); /*!< out: result instance to sort.*/ -/******************************************************************/ /** - FTS Query free result, returned by fts_query(). */ -void fts_query_free_result( - /*==================*/ - fts_result_t *result); /*!< in: result instance - to free.*/ +/** FTS Query free result, returned by fts_query(). */ +void fts_query_free_result(fts_result_t *result); /*!< in: result instance + to free.*/ -/******************************************************************/ /** - Extract the doc id from the FTS hidden column. */ +/** Extract the doc id from the FTS hidden column. */ doc_id_t fts_get_doc_id_from_row( - /*====================*/ dict_table_t *table, /*!< in: table */ dtuple_t *row); /*!< in: row whose FTS doc id we want to extract.*/ @@ -685,17 +647,14 @@ doc_id_t fts_get_doc_id_from_rec(dict_table_t *table, const rec_t *rec, doc_id_t fts_update_doc_id(dict_table_t *table, upd_field_t *ufield, doc_id_t *next_doc_id); -/******************************************************************/ /** - FTS initialize. */ +/** FTS initialize. */ void fts_startup(void); -/*==============*/ #if 0 // TODO: Enable this in WL#6608 /******************************************************************//** Signal FTS threads to initiate shutdown. */ void fts_start_shutdown( -/*===============*/ dict_table_t* table, /*!< in: table with FTS indexes */ fts_t* fts); /*!< in: fts instance to @@ -705,39 +664,27 @@ fts_start_shutdown( Wait for FTS threads to shutdown. */ void fts_shutdown( -/*=========*/ dict_table_t* table, /*!< in: table with FTS indexes */ fts_t* fts); /*!< in: fts instance to shutdown */ #endif -/******************************************************************/ /** - Create an instance of fts_t. +/** Create an instance of fts_t. @return instance of fts_t */ -fts_t *fts_create( - /*=======*/ - dict_table_t *table); /*!< out: table with FTS - indexes */ - -/**********************************************************************/ /** - Free the FTS resources. */ -void fts_free( - /*=====*/ - dict_table_t *table); /*!< in/out: table with - FTS indexes */ - -/*********************************************************************/ /** - Run OPTIMIZE on the given table. +fts_t *fts_create(dict_table_t *table); /*!< out: table with FTS + indexes */ + +/** Free the FTS resources. */ +void fts_free(dict_table_t *table); /*!< in/out: table with + FTS indexes */ + +/** Run OPTIMIZE on the given table. @return DB_SUCCESS if all OK */ -dberr_t fts_optimize_table( - /*===============*/ - dict_table_t *table); /*!< in: table to optimiza */ +dberr_t fts_optimize_table(dict_table_t *table); /*!< in: table to optimiza */ -/**********************************************************************/ /** - Startup the optimize thread and create the work queue. */ +/** Startup the optimize thread and create the work queue. */ void fts_optimize_init(void); -/*====================*/ /** Since we do a horizontal split on the index table, we need to drop all the split tables. @@ -754,12 +701,9 @@ dberr_t fts_drop_index_tables(trx_t *trx, dict_index_t *index, @return DB_SUCCESS or error code. */ dberr_t fts_empty_common_tables(trx_t *trx, dict_table_t *table); -/******************************************************************/ /** - Remove the table from the OPTIMIZER's list. We do wait for +/** Remove the table from the OPTIMIZER's list. We do wait for acknowledgement from the consumer of the message. */ -void fts_optimize_remove_table( - /*======================*/ - dict_table_t *table); /*!< in: table to remove */ +void fts_optimize_remove_table(dict_table_t *table); /*!< in: table to remove */ /** Shutdown fts optimize thread. */ void fts_optimize_shutdown(); @@ -768,49 +712,31 @@ void fts_optimize_shutdown(); @param[in] table table to sync */ void fts_optimize_request_sync_table(dict_table_t *table); -/**********************************************************************/ /** - Take a FTS savepoint. */ -void fts_savepoint_take( - /*===============*/ - trx_t *trx, /*!< in: transaction */ - fts_trx_t *fts_trx, /*!< in: fts transaction */ - const char *name); /*!< in: savepoint name */ - -/**********************************************************************/ /** - Refresh last statement savepoint. */ -void fts_savepoint_laststmt_refresh( - /*===========================*/ - trx_t *trx); /*!< in: transaction */ - -/**********************************************************************/ /** - Release the savepoint data identified by name. */ -void fts_savepoint_release( - /*==================*/ - trx_t *trx, /*!< in: transaction */ - const char *name); /*!< in: savepoint name */ +/** Take a FTS savepoint. */ +void fts_savepoint_take(trx_t *trx, /*!< in: transaction */ + fts_trx_t *fts_trx, /*!< in: fts transaction */ + const char *name); /*!< in: savepoint name */ + +/** Refresh last statement savepoint. */ +void fts_savepoint_laststmt_refresh(trx_t *trx); /*!< in: transaction */ + +/** Release the savepoint data identified by name. */ +void fts_savepoint_release(trx_t *trx, /*!< in: transaction */ + const char *name); /*!< in: savepoint name */ /** Clear cache. @param[in,out] cache fts cache */ void fts_cache_clear(fts_cache_t *cache); -/*********************************************************************/ /** - Initialize things in cache. */ -void fts_cache_init( - /*===========*/ - fts_cache_t *cache); /*!< in: cache */ - -/*********************************************************************/ /** - Rollback to and including savepoint indentified by name. */ -void fts_savepoint_rollback( - /*===================*/ - trx_t *trx, /*!< in: transaction */ - const char *name); /*!< in: savepoint name */ - -/*********************************************************************/ /** - Rollback to and including savepoint indentified by name. */ -void fts_savepoint_rollback_last_stmt( - /*=============================*/ - trx_t *trx); /*!< in: transaction */ +/** Initialize things in cache. */ +void fts_cache_init(fts_cache_t *cache); /*!< in: cache */ + +/** Rollback to and including savepoint indentified by name. */ +void fts_savepoint_rollback(trx_t *trx, /*!< in: transaction */ + const char *name); /*!< in: savepoint name */ + +/** Rollback to and including savepoint indentified by name. */ +void fts_savepoint_rollback_last_stmt(trx_t *trx); /*!< in: transaction */ /* Get parent table name if it's a fts aux table @param[in] aux_table_name aux table name @@ -829,31 +755,20 @@ FTS auxiliary INDEX table and clear the cache at the end. dberr_t fts_sync_table(dict_table_t *table, bool unlock_cache, bool wait, bool has_dict); -/****************************************************************/ /** - Create an FTS index cache. */ -CHARSET_INFO *fts_index_get_charset( - /*==================*/ - dict_index_t *index); /*!< in: FTS index */ +/** Create an FTS index cache. */ +CHARSET_INFO *fts_index_get_charset(dict_index_t *index); /*!< in: FTS index */ -/*********************************************************************/ /** - Get the initial Doc ID by consulting the CONFIG table +/** Get the initial Doc ID by consulting the CONFIG table @return initial Doc ID */ -doc_id_t fts_init_doc_id( - /*============*/ - const dict_table_t *table); /*!< in: table */ - -/******************************************************************/ /** - compare two character string according to their charset. */ -extern int innobase_fts_text_cmp( - /*==================*/ - const void *cs, /*!< in: Character set */ - const void *p1, /*!< in: key */ - const void *p2); /*!< in: node */ +doc_id_t fts_init_doc_id(const dict_table_t *table); /*!< in: table */ + +/** compare two character string according to their charset. */ +extern int innobase_fts_text_cmp(const void *cs, /*!< in: Character set */ + const void *p1, /*!< in: key */ + const void *p2); /*!< in: node */ -/******************************************************************/ /** - Makes all characters in a string lower case. */ +/** Makes all characters in a string lower case. */ extern size_t innobase_fts_casedn_str( - /*====================*/ CHARSET_INFO *cs, /*!< in: Character set */ char *src, /*!< in: string to put in lower case */ @@ -862,18 +777,14 @@ extern size_t innobase_fts_casedn_str( string */ size_t dst_len); /*!< in: buffer size */ -/******************************************************************/ /** - compare two character string according to their charset. */ +/** compare two character string according to their charset. */ extern int innobase_fts_text_cmp_prefix( - /*=========================*/ const void *cs, /*!< in: Character set */ const void *p1, /*!< in: key */ const void *p2); /*!< in: node */ -/*************************************************************/ /** - Get the next token from the given string and store it in *token. */ +/** Get the next token from the given string and store it in *token. */ extern ulint innobase_mysql_fts_get_token( - /*=========================*/ CHARSET_INFO *charset, /*!< in: Character set */ const byte *start, /*!< in: start of text */ const byte *end, /*!< in: one character past @@ -886,51 +797,36 @@ extern ulint innobase_mysql_fts_get_token( @return true on success, false on failure. */ bool innobase_fts_drop_dd_table(const char *name, bool file_per_table); -/*************************************************************/ /** - Get token char size by charset +/** Get token char size by charset @return the number of token char size */ -ulint fts_get_token_size( - /*===============*/ - const CHARSET_INFO *cs, /*!< in: Character set */ - const char *token, /*!< in: token */ - ulint len); /*!< in: token length */ - -/*************************************************************/ /** - FULLTEXT tokenizer internal in MYSQL_FTPARSER_SIMPLE_MODE +ulint fts_get_token_size(const CHARSET_INFO *cs, /*!< in: Character set */ + const char *token, /*!< in: token */ + ulint len); /*!< in: token length */ + +/** FULLTEXT tokenizer internal in MYSQL_FTPARSER_SIMPLE_MODE @return 0 if tokenize sucessfully */ int fts_tokenize_document_internal( - /*===========================*/ MYSQL_FTPARSER_PARAM *param, /*!< in: parser parameter */ char *doc, /*!< in: document to tokenize */ int len); /*!< in: document length */ -/*********************************************************************/ /** - Fetch COUNT(*) from specified table. +/** Fetch COUNT(*) from specified table. @return the number of rows in the table */ -ulint fts_get_rows_count( - /*===============*/ - fts_table_t *fts_table); /*!< in: fts table to read */ +ulint fts_get_rows_count(fts_table_t *fts_table); /*!< in: fts table to read */ -/*************************************************************/ /** - Get maximum Doc ID in a table if index "FTS_DOC_ID_INDEX" exists +/** Get maximum Doc ID in a table if index "FTS_DOC_ID_INDEX" exists @return max Doc ID or 0 if index "FTS_DOC_ID_INDEX" does not exist */ -doc_id_t fts_get_max_doc_id( - /*===============*/ - dict_table_t *table); /*!< in: user table */ +doc_id_t fts_get_max_doc_id(dict_table_t *table); /*!< in: user table */ -/******************************************************************/ /** - Check whether user supplied stopword table exists and is of +/** Check whether user supplied stopword table exists and is of the right format. @return the stopword column charset if qualifies */ CHARSET_INFO *fts_valid_stopword_table( - /*=====================*/ const char *stopword_table_name); /*!< in: Stopword table name */ -/****************************************************************/ /** - This function loads specified stopword into FTS cache +/** This function loads specified stopword into FTS cache @return true if success */ ibool fts_load_stopword( - /*==============*/ const dict_table_t *table, /*!< in: Table with FTS */ trx_t *trx, /*!< in: Transaction */ const char *global_stopword_table, /*!< in: Global stopword table @@ -942,32 +838,23 @@ ibool fts_load_stopword( ibool reload); /*!< in: Whether it is during reload of FTS table */ -/****************************************************************/ /** - Read the rows from the FTS index +/** Read the rows from the FTS index @return DB_SUCCESS if OK */ -dberr_t fts_table_fetch_doc_ids( - /*====================*/ - trx_t *trx, /*!< in: transaction */ - fts_table_t *fts_table, /*!< in: aux table */ - fts_doc_ids_t *doc_ids); /*!< in: For collecting - doc ids */ -/****************************************************************/ /** - This function brings FTS index in sync when FTS index is first +dberr_t fts_table_fetch_doc_ids(trx_t *trx, /*!< in: transaction */ + fts_table_t *fts_table, /*!< in: aux table */ + fts_doc_ids_t *doc_ids); /*!< in: For collecting + doc ids */ +/** This function brings FTS index in sync when FTS index is first used. There are documents that have not yet sync-ed to auxiliary tables from last server abnormally shutdown, we will need to bring such document into FTS cache before any further operations @return true if all OK */ -ibool fts_init_index( - /*===========*/ - dict_table_t *table, /*!< in: Table with FTS */ - ibool has_cache_lock); /*!< in: Whether we already - have cache lock */ -/*******************************************************************/ /** - Add a newly create index in FTS cache */ -void fts_add_index( - /*==========*/ - dict_index_t *index, /*!< FTS index to be added */ - dict_table_t *table); /*!< table */ +ibool fts_init_index(dict_table_t *table, /*!< in: Table with FTS */ + ibool has_cache_lock); /*!< in: Whether we already + have cache lock */ +/** Add a newly create index in FTS cache */ +void fts_add_index(dict_index_t *index, /*!< FTS index to be added */ + dict_table_t *table); /*!< table */ /** Drop auxiliary tables related to an FTS index @param[in] table Table where indexes are dropped @@ -978,21 +865,16 @@ void fts_add_index( dberr_t fts_drop_index(dict_table_t *table, dict_index_t *index, trx_t *trx, aux_name_vec_t *aux_vec); -/****************************************************************/ /** - Rename auxiliary tables for all fts index for a table +/** Rename auxiliary tables for all fts index for a table @return DB_SUCCESS or error code */ -dberr_t fts_rename_aux_tables( - /*==================*/ - dict_table_t *table, /*!< in: user Table */ - const char *new_name, /*!< in: new table name */ - trx_t *trx); /*!< in: transaction */ - -/*******************************************************************/ /** - Check indexes in the fts->indexes is also present in index cache and +dberr_t fts_rename_aux_tables(dict_table_t *table, /*!< in: user Table */ + const char *new_name, /*!< in: new table name */ + trx_t *trx); /*!< in: transaction */ + +/** Check indexes in the fts->indexes is also present in index cache and table->indexes list @return true if all indexes match */ ibool fts_check_cached_index( - /*===================*/ dict_table_t *table); /*!< in: Table where indexes are dropped */ /** Fetch the document from tuple, tokenize the text data and diff --git a/storage/innobase/include/fts0opt.h b/storage/innobase/include/fts0opt.h index db2f7f18a7ec..aa2ce890e733 100644 --- a/storage/innobase/include/fts0opt.h +++ b/storage/innobase/include/fts0opt.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2001, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2001, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/fts0opt.h +/** @file include/fts0opt.h Full Text Search optimize thread Created 2011-02-15 Jimmy Yang @@ -36,7 +35,6 @@ this program; if not, write to the Free Software Foundation, Inc., /******************************************************************** Callback function to fetch the rows in an FTS INDEX record. */ ibool fts_optimize_index_fetch_node( - /*==========================*/ /* out: always returns non-NULL */ void *row, /* in: sel_node_t* */ void *user_arg); /* in: pointer to ib_vector_t */ diff --git a/storage/innobase/include/fts0plugin.h b/storage/innobase/include/fts0plugin.h index c863c0fa3bbe..def875149de6 100644 --- a/storage/innobase/include/fts0plugin.h +++ b/storage/innobase/include/fts0plugin.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/fts0plugin.h +/** @file include/fts0plugin.h Full text search plugin header file Created 2013/06/04 Shaohua Wang @@ -49,15 +48,12 @@ struct fts_ast_state_t; parser->deinit(arg); \ } -/******************************************************************/ /** - fts parse query by plugin parser. +/** fts parse query by plugin parser. @return 0 if parse successfully, or return non-zero. */ -int fts_parse_by_parser( - /*================*/ - ibool mode, /*!< in: query boolean mode */ - uchar *query, /*!< in: query string */ - ulint len, /*!< in: query string length */ - st_mysql_ftparser *parse, /*!< in: fts plugin parser */ - fts_ast_state_t *state); /*!< in: query parser state */ +int fts_parse_by_parser(ibool mode, /*!< in: query boolean mode */ + uchar *query, /*!< in: query string */ + ulint len, /*!< in: query string length */ + st_mysql_ftparser *parse, /*!< in: fts plugin parser */ + fts_ast_state_t *state); /*!< in: query parser state */ #endif /* INNOBASE_FTS0PLUGIN_H */ diff --git a/storage/innobase/include/fts0priv.h b/storage/innobase/include/fts0priv.h index e0817b8866fb..c6fc9d2e2a78 100644 --- a/storage/innobase/include/fts0priv.h +++ b/storage/innobase/include/fts0priv.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/fts0priv.h +/** @file include/fts0priv.h Full text search internal header file Created 2011/09/02 Sunny Bains @@ -120,31 +119,23 @@ component. /** Maximum length of an integer stored in the config table value column. */ #define FTS_MAX_INT_LEN 32 -/******************************************************************/ /** - Parse an SQL string. %s is replaced with the table's id. +/** Parse an SQL string. %s is replaced with the table's id. @return query graph */ -que_t *fts_parse_sql( - /*==========*/ - fts_table_t *fts_table, /*!< in: FTS aux table */ - pars_info_t *info, /*!< in: info struct, or NULL */ - const char *sql) /*!< in: SQL string to evaluate */ +que_t *fts_parse_sql(fts_table_t *fts_table, /*!< in: FTS aux table */ + pars_info_t *info, /*!< in: info struct, or NULL */ + const char *sql) /*!< in: SQL string to evaluate */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************************/ /** - Evaluate a parsed SQL statement +/** Evaluate a parsed SQL statement @return DB_SUCCESS or error code */ -dberr_t fts_eval_sql( - /*=========*/ - trx_t *trx, /*!< in: transaction */ - que_t *graph) /*!< in: Parsed statement */ +dberr_t fts_eval_sql(trx_t *trx, /*!< in: transaction */ + que_t *graph) /*!< in: Parsed statement */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************************/ /** - Construct the name of an ancillary FTS table for the given table. +/** Construct the name of an ancillary FTS table for the given table. Caller must allocate enough memory(usually size of MAX_FULL_NAME_LEN) for param 'table_name'. */ void fts_get_table_name( - /*===============*/ const fts_table_t *fts_table, /*!< in: FTS aux table info */ char *table_name); /*!< in/out: aux table name */ @@ -155,8 +146,7 @@ of MAX_FULL_NAME_LEN) for param 'table_name' @param[in,out] table_name aux table name */ void fts_get_table_name_5_7(const fts_table_t *fts_table, char *table_name); -/******************************************************************/ /** - Construct the column specification part of the SQL string for selecting the +/** Construct the column specification part of the SQL string for selecting the indexed FTS columns for the given table. Adds the necessary bound ids to the given 'info' and returns the SQL string. Examples: @@ -171,7 +161,6 @@ void fts_get_table_name_5_7(const fts_table_t *fts_table, char *table_name); info/ids: sel0 -> "subject", sel1 -> "content", @return heap-allocated WHERE string */ const char *fts_get_select_columns_str( - /*=======================*/ dict_index_t *index, /*!< in: FTS index */ pars_info_t *info, /*!< in/out: parser info */ mem_heap_t *heap) /*!< in: memory heap */ @@ -183,12 +172,10 @@ ID */ #define FTS_FETCH_DOC_BY_ID_EQUAL 1 #define FTS_FETCH_DOC_BY_ID_LARGE 2 -/*************************************************************/ /** - Fetch document (= a single row's indexed text) with the given +/** Fetch document (= a single row's indexed text) with the given document id. @return: DB_SUCCESS if fetch is successful, else error */ dberr_t fts_doc_fetch_by_doc_id( - /*====================*/ fts_get_doc_t *get_doc, /*!< in: state */ doc_id_t doc_id, /*!< in: id of document to fetch */ dict_index_t *index_to_use, /*!< in: caller supplied FTS index, @@ -199,25 +186,20 @@ dberr_t fts_doc_fetch_by_doc_id( records */ void *arg); /*!< in: callback arg */ -/*******************************************************************/ /** - Callback function for fetch that stores the text of an FTS document, +/** Callback function for fetch that stores the text of an FTS document, converting each column to UTF-16. @return always false */ -ibool fts_query_expansion_fetch_doc( - /*==========================*/ - void *row, /*!< in: sel_node_t* */ - void *user_arg); /*!< in: fts_doc_t* */ +ibool fts_query_expansion_fetch_doc(void *row, /*!< in: sel_node_t* */ + void *user_arg); /*!< in: fts_doc_t* */ /******************************************************************** Write out a single word's data as new entry/entries in the INDEX table. @return DB_SUCCESS if all OK. */ -dberr_t fts_write_node( - /*===========*/ - trx_t *trx, /*!< in: transaction */ - que_t **graph, /*!< in: query graph */ - fts_table_t *fts_table, /*!< in: the FTS aux index */ - fts_string_t *word, /*!< in: word in UTF-8 */ - fts_node_t *node) /*!< in: node columns */ +dberr_t fts_write_node(trx_t *trx, /*!< in: transaction */ + que_t **graph, /*!< in: query graph */ + fts_table_t *fts_table, /*!< in: the FTS aux index */ + fts_string_t *word, /*!< in: word in UTF-8 */ + fts_node_t *node) /*!< in: node columns */ MY_ATTRIBUTE((warn_unused_result)); /** Check fts token @@ -233,40 +215,26 @@ or greater than fts_max_token_size. bool fts_check_token(const fts_string_t *token, const ib_rbt_t *stopwords, bool is_ngram, const CHARSET_INFO *cs); -/******************************************************************/ /** - Initialize a document. */ -void fts_doc_init( - /*=========*/ - fts_doc_t *doc); /*!< in: doc to initialize */ +/** Initialize a document. */ +void fts_doc_init(fts_doc_t *doc); /*!< in: doc to initialize */ -/******************************************************************/ /** - Do a binary search for a doc id in the array +/** Do a binary search for a doc id in the array @return +ve index if found -ve index where it should be inserted if not found */ -int fts_bsearch( - /*========*/ - fts_update_t *array, /*!< in: array to sort */ - int lower, /*!< in: lower bound of array*/ - int upper, /*!< in: upper bound of array*/ - doc_id_t doc_id) /*!< in: doc id to lookup */ +int fts_bsearch(fts_update_t *array, /*!< in: array to sort */ + int lower, /*!< in: lower bound of array*/ + int upper, /*!< in: upper bound of array*/ + doc_id_t doc_id) /*!< in: doc id to lookup */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************************/ /** - Free document. */ -void fts_doc_free( - /*=========*/ - fts_doc_t *doc); /*!< in: document */ - -/******************************************************************/ /** - Free fts_optimizer_word_t instanace.*/ -void fts_word_free( - /*==========*/ - fts_word_t *word); /*!< in: instance to free.*/ - -/******************************************************************/ /** - Read the rows from the FTS inde +/** Free document. */ +void fts_doc_free(fts_doc_t *doc); /*!< in: document */ + +/** Free fts_optimizer_word_t instanace.*/ +void fts_word_free(fts_word_t *word); /*!< in: instance to free.*/ + +/** Read the rows from the FTS inde @return DB_SUCCESS or error code */ dberr_t fts_index_fetch_nodes( - /*==================*/ trx_t *trx, /*!< in: transaction */ que_t **graph, /*!< in: prepared statement */ fts_table_t *fts_table, /*!< in: FTS aux table */ @@ -288,39 +256,29 @@ int fts_trx_table_cmp(const void *v1, const void *v2); UNIV_INLINE int fts_trx_table_id_cmp(const void *p1, const void *p2); -/******************************************************************/ /** - Commit a transaction. +/** Commit a transaction. @return DB_SUCCESS if all OK */ -dberr_t fts_sql_commit( - /*===========*/ - trx_t *trx); /*!< in: transaction */ +dberr_t fts_sql_commit(trx_t *trx); /*!< in: transaction */ -/******************************************************************/ /** - Rollback a transaction. +/** Rollback a transaction. @return DB_SUCCESS if all OK */ -dberr_t fts_sql_rollback( - /*=============*/ - trx_t *trx); /*!< in: transaction */ +dberr_t fts_sql_rollback(trx_t *trx); /*!< in: transaction */ -/******************************************************************/ /** - Get value from config table. The caller must ensure that enough +/** Get value from config table. The caller must ensure that enough space is allocated for value to hold the column contents @return DB_SUCCESS or error code */ dberr_t fts_config_get_value( - /*=================*/ trx_t *trx, /* transaction */ fts_table_t *fts_table, /*!< in: the indexed FTS table */ const char *name, /*!< in: get config value for this parameter name */ fts_string_t *value); /*!< out: value read from config table */ -/******************************************************************/ /** - Get value specific to an FTS index from the config table. The caller +/** Get value specific to an FTS index from the config table. The caller must ensure that enough space is allocated for value to hold the column contents. @return DB_SUCCESS or error code */ dberr_t fts_config_get_index_value( - /*=======================*/ trx_t *trx, /*!< transaction */ dict_index_t *index, /*!< in: index */ const char *param, /*!< in: get config value for @@ -329,33 +287,27 @@ dberr_t fts_config_get_index_value( config table */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************************/ /** - Set the value in the config table for name. +/** Set the value in the config table for name. @return DB_SUCCESS or error code */ dberr_t fts_config_set_value( - /*=================*/ trx_t *trx, /*!< transaction */ fts_table_t *fts_table, /*!< in: the indexed FTS table */ const char *name, /*!< in: get config value for this parameter name */ const fts_string_t *value); /*!< in: value to update */ -/****************************************************************/ /** - Set an ulint value in the config table. +/** Set an ulint value in the config table. @return DB_SUCCESS if all OK else error code */ dberr_t fts_config_set_ulint( - /*=================*/ trx_t *trx, /*!< in: transaction */ fts_table_t *fts_table, /*!< in: the indexed FTS table */ const char *name, /*!< in: param name */ ulint int_value) /*!< in: value */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************************/ /** - Set the value specific to an FTS index in the config table. +/** Set the value specific to an FTS index in the config table. @return DB_SUCCESS or error code */ dberr_t fts_config_set_index_value( - /*=======================*/ trx_t *trx, /*!< transaction */ dict_index_t *index, /*!< in: index */ const char *param, /*!< in: get config value for @@ -365,71 +317,55 @@ dberr_t fts_config_set_index_value( MY_ATTRIBUTE((warn_unused_result)); #ifdef FTS_OPTIMIZE_DEBUG -/******************************************************************/ /** - Get an ulint value from the config table. +/** Get an ulint value from the config table. @return DB_SUCCESS or error code */ -dberr_t fts_config_get_index_ulint( - /*=======================*/ - trx_t *trx, /*!< in: transaction */ - dict_index_t *index, /*!< in: FTS index */ - const char *name, /*!< in: param name */ - ulint *int_value) /*!< out: value */ +dberr_t fts_config_get_index_ulint(trx_t *trx, /*!< in: transaction */ + dict_index_t *index, /*!< in: FTS index */ + const char *name, /*!< in: param name */ + ulint *int_value) /*!< out: value */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************************/ /** - Set an ulint value int the config table. +/** Set an ulint value int the config table. @return DB_SUCCESS or error code */ -dberr_t fts_config_set_index_ulint( - /*=======================*/ - trx_t *trx, /*!< in: transaction */ - dict_index_t *index, /*!< in: FTS index */ - const char *name, /*!< in: param name */ - ulint int_value) /*!< in: value */ +dberr_t fts_config_set_index_ulint(trx_t *trx, /*!< in: transaction */ + dict_index_t *index, /*!< in: FTS index */ + const char *name, /*!< in: param name */ + ulint int_value) /*!< in: value */ MY_ATTRIBUTE((warn_unused_result)); #endif /* FTS_OPTIMIZE_DEBUG */ -/******************************************************************/ /** - Get an ulint value from the config table. +/** Get an ulint value from the config table. @return DB_SUCCESS or error code */ dberr_t fts_config_get_ulint( - /*=================*/ trx_t *trx, /*!< in: transaction */ fts_table_t *fts_table, /*!< in: the indexed FTS table */ const char *name, /*!< in: param name */ ulint *int_value); /*!< out: value */ -/******************************************************************/ /** - Search cache for word. +/** Search cache for word. @return the word node vector if found else NULL */ const ib_vector_t *fts_cache_find_word( - /*================*/ const fts_index_cache_t *index_cache, /*!< in: cache to search */ const fts_string_t *text) /*!< in: word to search for */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************************/ /** - Append deleted doc ids to vector and sort the vector. */ +/** Append deleted doc ids to vector and sort the vector. */ void fts_cache_append_deleted_doc_ids( - /*=============================*/ const fts_cache_t *cache, /*!< in: cache to use */ ib_vector_t *vector); /*!< in: append to this vector */ -/******************************************************************/ /** - Wait for the background thread to start. We poll to detect change +/** Wait for the background thread to start. We poll to detect change of state, which is acceptable, since the wait should happen only once during startup. @return true if the thread started else false (i.e timed out) */ ibool fts_wait_for_background_thread_to_start( - /*====================================*/ dict_table_t *table, /*!< in: table to which the thread is attached */ ulint max_wait); /*!< in: time in microseconds, if set to 0 then it disables timeout checking */ -/******************************************************************/ /** - Search the index specific cache for a particular FTS index. +/** Search the index specific cache for a particular FTS index. @return the index specific cache else NULL */ fts_index_cache_t *fts_find_index_cache( - /*================*/ const fts_cache_t *cache, /*!< in: cache to search */ const dict_index_t *index) /*!< in: index to search for */ MY_ATTRIBUTE((warn_unused_result)); @@ -442,55 +378,41 @@ be at least FTS_AUX_MIN_TABLE_ID_LENGTH bytes long. UNIV_INLINE int fts_write_object_id(ib_id_t id, char *str); -/******************************************************************/ /** - Read the table id from the string generated by fts_write_object_id(). +/** Read the table id from the string generated by fts_write_object_id(). @return true if parse successful */ UNIV_INLINE -ibool fts_read_object_id( - /*===============*/ - ib_id_t *id, /*!< out: a table id */ - const char *str) /*!< in: buffer to read from */ +ibool fts_read_object_id(ib_id_t *id, /*!< out: a table id */ + const char *str) /*!< in: buffer to read from */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************************/ /** - Get the table id. +/** Get the table id. @return number of bytes written */ int fts_get_table_id( - /*=============*/ const fts_table_t *fts_table, /*!< in: FTS Auxiliary table */ char *table_id) /*!< out: table id, must be at least FTS_AUX_MIN_TABLE_ID_LENGTH bytes long */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************************/ /** - Add the table to add to the OPTIMIZER's list. */ -void fts_optimize_add_table( - /*===================*/ - dict_table_t *table); /*!< in: table to add */ +/** Add the table to add to the OPTIMIZER's list. */ +void fts_optimize_add_table(dict_table_t *table); /*!< in: table to add */ -/******************************************************************/ /** - Construct the prefix name of an FTS table. +/** Construct the prefix name of an FTS table. @return own: table name, must be freed with ut_free() */ char *fts_get_table_name_prefix( - /*======================*/ const fts_table_t *fts_table) /*!< in: Auxiliary table type */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************************/ /** - Add node positions. */ +/** Add node positions. */ void fts_cache_node_add_positions( - /*=========================*/ fts_cache_t *cache, /*!< in: cache */ fts_node_t *node, /*!< in: word node */ doc_id_t doc_id, /*!< in: doc id */ ib_vector_t *positions); /*!< in: fts_token_t::positions */ -/******************************************************************/ /** - Create the config table name for retrieving index specific value. +/** Create the config table name for retrieving index specific value. @return index config parameter name */ char *fts_config_create_index_param_name( - /*===============================*/ const char *param, /*!< in: base name of param */ const dict_index_t *index) /*!< in: index for config */ MY_ATTRIBUTE((warn_unused_result)); diff --git a/storage/innobase/include/fts0priv.ic b/storage/innobase/include/fts0priv.ic index ea7c9005b786..c374a0c29b81 100644 --- a/storage/innobase/include/fts0priv.ic +++ b/storage/innobase/include/fts0priv.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,15 +24,13 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/fts0priv.ic +/** @file include/fts0priv.ic Full text search internal header file Created 2011/11/12 Sunny Bains ***********************************************************************/ -/******************************************************************/ /** - Write the table id to the given buffer (including final NUL). Buffer must be +/** Write the table id to the given buffer (including final NUL). Buffer must be at least FTS_AUX_MIN_TABLE_ID_LENGTH bytes long. @param[in] id a table/index id @param[in] str buffer to write the id to @@ -42,14 +40,11 @@ int fts_write_object_id(ib_id_t id, char *str) { return (sprintf(str, UINT64PFx, id)); } -/******************************************************************/ /** - Read the table id from the string generated by fts_write_object_id(). +/** Read the table id from the string generated by fts_write_object_id(). @return true if parse successful */ UNIV_INLINE -ibool fts_read_object_id( - /*===============*/ - ib_id_t *id, /* out: an id */ - const char *str) /* in: buffer to read from */ +ibool fts_read_object_id(ib_id_t *id, /* out: an id */ + const char *str) /* in: buffer to read from */ { /* NOTE: this func doesn't care about whether current table is set with HEX_NAME, the user of the id read here will check @@ -57,14 +52,11 @@ ibool fts_read_object_id( return (sscanf(str, UINT64PFx, id) == 1); } -/******************************************************************/ /** - Compare two fts_trx_table_t instances. +/** Compare two fts_trx_table_t instances. @return < 0 if n1 < n2, 0 if n1 == n2, > 0 if n1 > n2 */ UNIV_INLINE -int fts_trx_table_cmp( - /*==============*/ - const void *p1, /*!< in: id1 */ - const void *p2) /*!< in: id2 */ +int fts_trx_table_cmp(const void *p1, /*!< in: id1 */ + const void *p2) /*!< in: id2 */ { const dict_table_t *table1 = (*static_cast(p1))->table; @@ -75,14 +67,11 @@ int fts_trx_table_cmp( return ((table1->id > table2->id) ? 1 : (table1->id == table2->id) ? 0 : -1); } -/******************************************************************/ /** - Compare a table id with a fts_trx_table_t table id. +/** Compare a table id with a fts_trx_table_t table id. @return < 0 if n1 < n2, 0 if n1 == n2,> 0 if n1 > n2 */ UNIV_INLINE -int fts_trx_table_id_cmp( - /*=================*/ - const void *p1, /*!< in: id1 */ - const void *p2) /*!< in: id2 */ +int fts_trx_table_id_cmp(const void *p1, /*!< in: id1 */ + const void *p2) /*!< in: id2 */ { const uintmax_t *table_id = static_cast(p1); const dict_table_t *table2 = diff --git a/storage/innobase/include/fts0tokenize.h b/storage/innobase/include/fts0tokenize.h index 93a948e34a36..cd77ac24f5b3 100644 --- a/storage/innobase/include/fts0tokenize.h +++ b/storage/innobase/include/fts0tokenize.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2014, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2014, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/fts0tokenize.h +/** @file include/fts0tokenize.h Full Text Search plugin tokenizer refer to MyISAM Created 2014/11/17 Shaohua Wang diff --git a/storage/innobase/include/fts0types.h b/storage/innobase/include/fts0types.h index cf5367782e48..0fd28da4e2bc 100644 --- a/storage/innobase/include/fts0types.h +++ b/storage/innobase/include/fts0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/fts0types.h +/** @file include/fts0types.h Full text search types file Created 2007-03-27 Sunny Bains @@ -323,11 +322,9 @@ int fts_ranking_doc_id_cmp(const void *p1, const void *p2); UNIV_INLINE int fts_update_doc_id_cmp(const void *p1, const void *p2); -/******************************************************************/ /** - Decode and return the integer that was encoded using our VLC scheme.*/ +/** Decode and return the integer that was encoded using our VLC scheme.*/ UNIV_INLINE ulint fts_decode_vlc( - /*===========*/ /*!< out: value decoded */ byte **ptr); /*!< in: ptr to decode from, this ptr is incremented by the number of bytes decoded */ @@ -341,11 +338,9 @@ UNIV_INLINE void fts_string_dup(fts_string_t *dst, const fts_string_t *src, mem_heap_t *heap); -/******************************************************************/ /** - Return length of val if it were encoded using our VLC scheme. */ +/** Return length of val if it were encoded using our VLC scheme. */ UNIV_INLINE ulint fts_get_encoded_len( - /*================*/ /*!< out: length of value encoded, in bytes */ ulint val); /*!< in: value to encode */ @@ -357,12 +352,9 @@ ulint fts_get_encoded_len( UNIV_INLINE ulint fts_encode_int(ulint val, byte *buf); -/******************************************************************/ /** - Get the selected FTS aux INDEX suffix. */ +/** Get the selected FTS aux INDEX suffix. */ UNIV_INLINE -const char *fts_get_suffix( - /*===========*/ - ulint selected); /*!< in: selected index */ +const char *fts_get_suffix(ulint selected); /*!< in: selected index */ /** Return the selected FTS aux index suffix in 5.7 compatible format @param[in] selected selected index diff --git a/storage/innobase/include/fts0types.ic b/storage/innobase/include/fts0types.ic index 9ffd5a5235e8..f74db0ede12a 100644 --- a/storage/innobase/include/fts0types.ic +++ b/storage/innobase/include/fts0types.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/fts0types.ic +/** @file include/fts0types.ic Full text search types. Created 2007-03-27 Sunny Bains @@ -37,15 +36,12 @@ this program; if not, write to the Free Software Foundation, Inc., #include "ha_prototypes.h" #include "rem0cmp.h" -/******************************************************************/ /** - Duplicate a string. +/** Duplicate a string. @return < 0 if n1 < n2, 0 if n1 == n2, > 0 if n1 > n2 */ UNIV_INLINE -void fts_string_dup( - /*===========*/ - fts_string_t *dst, /*!< in: dup to here */ - const fts_string_t *src, /*!< in: src string */ - mem_heap_t *heap) /*!< in: heap to use */ +void fts_string_dup(fts_string_t *dst, /*!< in: dup to here */ + const fts_string_t *src, /*!< in: src string */ + mem_heap_t *heap) /*!< in: heap to use */ { dst->f_str = (byte *)mem_heap_alloc(heap, src->f_len + 1); memcpy(dst->f_str, src->f_str, src->f_len); @@ -55,14 +51,11 @@ void fts_string_dup( dst->f_n_char = src->f_n_char; } -/******************************************************************/ /** - Compare two fts_trx_row_t doc_ids. +/** Compare two fts_trx_row_t doc_ids. @return < 0 if n1 < n2, 0 if n1 == n2, > 0 if n1 > n2 */ UNIV_INLINE -int fts_trx_row_doc_id_cmp( - /*===================*/ - const void *p1, /*!< in: id1 */ - const void *p2) /*!< in: id2 */ +int fts_trx_row_doc_id_cmp(const void *p1, /*!< in: id1 */ + const void *p2) /*!< in: id2 */ { const fts_trx_row_t *tr1 = (const fts_trx_row_t *)p1; const fts_trx_row_t *tr2 = (const fts_trx_row_t *)p2; @@ -70,14 +63,11 @@ int fts_trx_row_doc_id_cmp( return ((int)(tr1->doc_id - tr2->doc_id)); } -/******************************************************************/ /** - Compare two fts_ranking_t doc_ids. +/** Compare two fts_ranking_t doc_ids. @return < 0 if n1 < n2, 0 if n1 == n2, > 0 if n1 > n2 */ UNIV_INLINE -int fts_ranking_doc_id_cmp( - /*===================*/ - const void *p1, /*!< in: id1 */ - const void *p2) /*!< in: id2 */ +int fts_ranking_doc_id_cmp(const void *p1, /*!< in: id1 */ + const void *p2) /*!< in: id2 */ { const fts_ranking_t *rk1 = (const fts_ranking_t *)p1; const fts_ranking_t *rk2 = (const fts_ranking_t *)p2; @@ -85,14 +75,11 @@ int fts_ranking_doc_id_cmp( return ((int)(rk1->doc_id - rk2->doc_id)); } -/******************************************************************/ /** - Compare two fts_update_t doc_ids. +/** Compare two fts_update_t doc_ids. @return < 0 if n1 < n2, 0 if n1 == n2, > 0 if n1 > n2 */ UNIV_INLINE -int fts_update_doc_id_cmp( - /*==================*/ - const void *p1, /*!< in: id1 */ - const void *p2) /*!< in: id2 */ +int fts_update_doc_id_cmp(const void *p1, /*!< in: id1 */ + const void *p2) /*!< in: id2 */ { const fts_update_t *up1 = (const fts_update_t *)p1; const fts_update_t *up2 = (const fts_update_t *)p2; @@ -100,13 +87,10 @@ int fts_update_doc_id_cmp( return ((int)(up1->doc_id - up2->doc_id)); } -/******************************************************************/ /** - Get the first character's code position for FTS index partition */ -extern ulint innobase_strnxfrm( - /*==============*/ - const CHARSET_INFO *cs, /*!< in: Character set */ - const uchar *p2, /*!< in: string */ - const ulint len2); /*!< in: string length */ +/** Get the first character's code position for FTS index partition */ +extern ulint innobase_strnxfrm(const CHARSET_INFO *cs, /*!< in: Character set */ + const uchar *p2, /*!< in: string */ + const ulint len2); /*!< in: string length */ /** Check if fts index charset is cjk @param[in] cs charset @@ -203,12 +187,9 @@ ulint fts_select_index(const CHARSET_INFO *cs, const byte *str, ulint len) { return (selected); } -/******************************************************************/ /** - Return the selected FTS aux index suffix. */ +/** Return the selected FTS aux index suffix. */ UNIV_INLINE -const char *fts_get_suffix( - /*===========*/ - ulint selected) /*!< in: selected index */ +const char *fts_get_suffix(ulint selected) /*!< in: selected index */ { return (fts_index_selector[selected].suffix); } diff --git a/storage/innobase/include/fts0vlc.ic b/storage/innobase/include/fts0vlc.ic index 0db04cdf9d95..80bc3c7c896e 100644 --- a/storage/innobase/include/fts0vlc.ic +++ b/storage/innobase/include/fts0vlc.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/fts0vlc.ic +/** @file include/fts0vlc.ic Full text variable length integer encoding/decoding. Created 2007-03-27 Sunny Bains @@ -36,14 +35,11 @@ this program; if not, write to the Free Software Foundation, Inc., #include "fts0types.h" -/******************************************************************/ /** - Return length of val if it were encoded using our VLC scheme. +/** Return length of val if it were encoded using our VLC scheme. FIXME: We will need to be able encode 8 bytes value @return length of value encoded, in bytes */ UNIV_INLINE -ulint fts_get_encoded_len( - /*================*/ - ulint val) /* in: value to encode */ +ulint fts_get_encoded_len(ulint val) /* in: value to encode */ { if (val <= 127) { return (1); @@ -63,14 +59,11 @@ ulint fts_get_encoded_len( } } -/******************************************************************/ /** - Encode an integer using our VLC scheme and return the length in bytes. +/** Encode an integer using our VLC scheme and return the length in bytes. @return length of value encoded, in bytes */ UNIV_INLINE -ulint fts_encode_int( - /*===========*/ - ulint val, /* in: value to encode */ - byte *buf) /* in: buffer, must have enough space */ +ulint fts_encode_int(ulint val, /* in: value to encode */ + byte *buf) /* in: buffer, must have enough space */ { ulint len; @@ -116,14 +109,11 @@ ulint fts_encode_int( return (len); } -/******************************************************************/ /** - Decode and return the integer that was encoded using our VLC scheme. +/** Decode and return the integer that was encoded using our VLC scheme. @return value decoded */ UNIV_INLINE -ulint fts_decode_vlc( - /*===========*/ - byte **ptr) /* in: ptr to decode from, this ptr is - incremented by the number of bytes decoded */ +ulint fts_decode_vlc(byte **ptr) /* in: ptr to decode from, this ptr is + incremented by the number of bytes decoded */ { ulint val = 0; diff --git a/storage/innobase/include/fut0fut.h b/storage/innobase/include/fut0fut.h index 991e193961de..dc1513ec80b7 100644 --- a/storage/innobase/include/fut0fut.h +++ b/storage/innobase/include/fut0fut.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/fut0fut.h +/** @file include/fut0fut.h File-based utilities Created 12/13/1995 Heikki Tuuri diff --git a/storage/innobase/include/fut0fut.ic b/storage/innobase/include/fut0fut.ic index 67ce24f1c4bb..1521518f9eb7 100644 --- a/storage/innobase/include/fut0fut.ic +++ b/storage/innobase/include/fut0fut.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/fut0fut.ic +/** @file include/fut0fut.ic File-based utilities Created 12/13/1995 Heikki Tuuri diff --git a/storage/innobase/include/fut0lst.h b/storage/innobase/include/fut0lst.h index 1691e4d9cda8..8190712258f6 100644 --- a/storage/innobase/include/fut0lst.h +++ b/storage/innobase/include/fut0lst.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/fut0lst.h +/** @file include/fut0lst.h File-based list utilities Created 11/28/1995 Heikki Tuuri @@ -58,24 +57,18 @@ constexpr ulint FLST_NODE_SIZE = 2 * FIL_ADDR_SIZE; UNIV_INLINE void flst_init(flst_base_node_t *base, mtr_t *mtr); -/********************************************************************/ /** - Adds a node as the last node in a list. */ +/** Adds a node as the last node in a list. */ void flst_add_last( - /*==========*/ flst_base_node_t *base, /*!< in: pointer to base node of list */ flst_node_t *node, /*!< in: node to add */ mtr_t *mtr); /*!< in: mini-transaction handle */ -/********************************************************************/ /** - Adds a node as the first node in a list. */ +/** Adds a node as the first node in a list. */ void flst_add_first( - /*===========*/ flst_base_node_t *base, /*!< in: pointer to base node of list */ flst_node_t *node, /*!< in: node to add */ mtr_t *mtr); /*!< in: mini-transaction handle */ -/********************************************************************/ /** - Removes a node. */ +/** Removes a node. */ void flst_remove( - /*========*/ flst_base_node_t *base, /*!< in: pointer to base node of list */ flst_node_t *node2, /*!< in: node to remove */ mtr_t *mtr); /*!< in: mini-transaction handle */ @@ -127,11 +120,9 @@ void flst_write_addr(fil_faddr_t *faddr, fil_addr_t addr, mtr_t *mtr); UNIV_INLINE fil_addr_t flst_read_addr(const fil_faddr_t *faddr, mtr_t *mtr); -/********************************************************************/ /** - Validates a file-based list. +/** Validates a file-based list. @return true if ok */ ibool flst_validate( - /*==========*/ const flst_base_node_t *base, /*!< in: pointer to base node of list */ mtr_t *mtr1); /*!< in: mtr */ diff --git a/storage/innobase/include/fut0lst.ic b/storage/innobase/include/fut0lst.ic index c7a10b893a3a..e9bf25e5f3f7 100644 --- a/storage/innobase/include/fut0lst.ic +++ b/storage/innobase/include/fut0lst.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/fut0lst.ic +/** @file include/fut0lst.ic File-based list utilities Created 11/28/1995 Heikki Tuuri @@ -55,14 +54,11 @@ this program; if not, write to the Free Software Foundation, Inc., last element of the list; undefined \ if empty list */ -/********************************************************************/ /** - Writes a file address. */ +/** Writes a file address. */ UNIV_INLINE -void flst_write_addr( - /*============*/ - fil_faddr_t *faddr, /*!< in: pointer to file faddress */ - fil_addr_t addr, /*!< in: file address */ - mtr_t *mtr) /*!< in: mini-transaction handle */ +void flst_write_addr(fil_faddr_t *faddr, /*!< in: pointer to file faddress */ + fil_addr_t addr, /*!< in: file address */ + mtr_t *mtr) /*!< in: mini-transaction handle */ { ut_ad(faddr && mtr); ut_ad(mtr_memo_contains_page_flagged( @@ -74,12 +70,10 @@ void flst_write_addr( mlog_write_ulint(faddr + FIL_ADDR_BYTE, addr.boffset, MLOG_2BYTES, mtr); } -/********************************************************************/ /** - Reads a file address. +/** Reads a file address. @return file address */ UNIV_INLINE fil_addr_t flst_read_addr( - /*===========*/ const fil_faddr_t *faddr, /*!< in: pointer to file faddress */ mtr_t *mtr) /*!< in: mini-transaction handle */ { @@ -94,13 +88,10 @@ fil_addr_t flst_read_addr( return (addr); } -/********************************************************************/ /** - Initializes a list base node. */ +/** Initializes a list base node. */ UNIV_INLINE -void flst_init( - /*======*/ - flst_base_node_t *base, /*!< in: pointer to base node */ - mtr_t *mtr) /*!< in: mini-transaction handle */ +void flst_init(flst_base_node_t *base, /*!< in: pointer to base node */ + mtr_t *mtr) /*!< in: mini-transaction handle */ { ut_ad(mtr_memo_contains_page_flagged( mtr, base, MTR_MEMO_PAGE_X_FIX | MTR_MEMO_PAGE_SX_FIX)); @@ -118,48 +109,40 @@ ulint flst_get_len(const flst_base_node_t *base) { return (mach_read_from_4(base + FLST_LEN)); } -/********************************************************************/ /** - Gets list first node address. +/** Gets list first node address. @return file address */ UNIV_INLINE fil_addr_t flst_get_first( - /*===========*/ const flst_base_node_t *base, /*!< in: pointer to base node */ mtr_t *mtr) /*!< in: mini-transaction handle */ { return (flst_read_addr(base + FLST_FIRST, mtr)); } -/********************************************************************/ /** - Gets list last node address. +/** Gets list last node address. @return file address */ UNIV_INLINE fil_addr_t flst_get_last( - /*==========*/ const flst_base_node_t *base, /*!< in: pointer to base node */ mtr_t *mtr) /*!< in: mini-transaction handle */ { return (flst_read_addr(base + FLST_LAST, mtr)); } -/********************************************************************/ /** - Gets list next node address. +/** Gets list next node address. @return file address */ UNIV_INLINE fil_addr_t flst_get_next_addr( - /*===============*/ const flst_node_t *node, /*!< in: pointer to node */ mtr_t *mtr) /*!< in: mini-transaction handle */ { return (flst_read_addr(node + FLST_NEXT, mtr)); } -/********************************************************************/ /** - Gets list prev node address. +/** Gets list prev node address. @return file address */ UNIV_INLINE fil_addr_t flst_get_prev_addr( - /*===============*/ const flst_node_t *node, /*!< in: pointer to node */ mtr_t *mtr) /*!< in: mini-transaction handle */ { diff --git a/storage/innobase/include/gis0geo.h b/storage/innobase/include/gis0geo.h index 3d3290eba372..03643b08bef4 100644 --- a/storage/innobase/include/gis0geo.h +++ b/storage/innobase/include/gis0geo.h @@ -1,5 +1,5 @@ /***************************************************************************** -Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -22,8 +22,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *****************************************************************************/ -/**************************************************/ /** - @file gis0geo.h +/** @file gis0geo.h The r-tree define from MyISAM *******************************************************/ @@ -48,22 +47,18 @@ struct rtr_split_node_t { double *coords; /* mbr. */ }; -/*************************************************************/ /** - Inline function for reserving coords */ +/** Inline function for reserving coords */ inline static double *reserve_coords(double **d_buffer, /*!< in/out: buffer. */ int n_dim) /*!< in: dimensions. */ -/*===========*/ { double *coords = *d_buffer; (*d_buffer) += n_dim * 2; return coords; } -/*************************************************************/ /** - Split rtree nodes. +/** Split rtree nodes. Return which group the first rec is in. */ int split_rtree_node( - /*=============*/ rtr_split_node_t *node, /*!< in: split nodes.*/ int n_entries, /*!< in: entries number.*/ int all_size, /*!< in: total key's size.*/ @@ -76,8 +71,7 @@ int split_rtree_node( uchar *first_rec, /*!< in: the first rec. */ const dd::Spatial_reference_system *srs); /*!< in: SRS of R-tree */ -/*************************************************************/ /** - Compares two keys a and b depending on nextflag +/** Compares two keys a and b depending on nextflag nextflag can contain these flags: MBR_INTERSECT(a,b) a overlaps b MBR_CONTAIN(a,b) a contains b diff --git a/storage/innobase/include/gis0rtree.h b/storage/innobase/include/gis0rtree.h index 2e1fde3f488f..1ba88f6d9d8a 100644 --- a/storage/innobase/include/gis0rtree.h +++ b/storage/innobase/include/gis0rtree.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2014, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2014, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/gis0rtree.h +/** @file include/gis0rtree.h R-tree header file Created 2013/03/27 Jimmy Yang and Allen Lai @@ -59,11 +58,9 @@ this program; if not, write to the Free Software Foundation, Inc., /* Geometry data header */ #define GEO_DATA_HEADER_SIZE 4 -/**********************************************************************/ /** - Builds a Rtree node pointer out of a physical record and a page number. +/** Builds a Rtree node pointer out of a physical record and a page number. @return own: node pointer */ dtuple_t *rtr_index_build_node_ptr( - /*=====================*/ const dict_index_t *index, /*!< in: index */ const rtr_mbr_t *mbr, /*!< in: mbr of lower page */ const rec_t *rec, /*!< in: record for which to build node @@ -75,8 +72,7 @@ dtuple_t *rtr_index_build_node_ptr( ulint level); /*!< in: level of rec in tree: 0 means leaf level */ -/*************************************************************/ /** - Splits an R-tree index page to halves and inserts the tuple. It is assumed +/** Splits an R-tree index page to halves and inserts the tuple. It is assumed that mtr holds an x-latch to the index tree. NOTE: the tree x-latch is released within this function! NOTE that the operation of this function must always succeed, we cannot reverse it: therefore enough @@ -84,7 +80,6 @@ dtuple_t *rtr_index_build_node_ptr( this function is called. @return inserted record */ rec_t *rtr_page_split_and_insert( - /*======================*/ ulint flags, /*!< in: undo logging and locking flags */ btr_cur_t *cursor, /*!< in/out: cursor at which to insert; when the function returns, the cursor is positioned @@ -123,10 +118,8 @@ bool rtr_pcur_move_to_next(const dtuple_t *tuple, page_cur_mode_t mode, select_mode sel_mode, btr_pcur_t *cursor, ulint cur_level, mtr_t *mtr); -/****************************************************************/ /** - Searches the right position in rtree for a page cursor. */ +/** Searches the right position in rtree for a page cursor. */ bool rtr_cur_search_with_match( - /*======================*/ const buf_block_t *block, /*!< in: buffer block */ dict_index_t *index, /*!< in: index descriptor */ const dtuple_t *tuple, /*!< in: data tuple */ @@ -136,11 +129,9 @@ bool rtr_cur_search_with_match( page_cur_t *cursor, /*!< in/out: page cursor */ rtr_info_t *rtr_info); /*!< in/out: search stack */ -/****************************************************************/ /** - Calculate the area increased for a new record +/** Calculate the area increased for a new record @return area increased */ double rtr_rec_cal_increase( - /*=================*/ const dtuple_t *dtuple, /*!< in: data tuple to insert, which cause area increase */ const rec_t *rec, /*!< in: physical record which differs from @@ -151,19 +142,14 @@ double rtr_rec_cal_increase( double *area, /*!< out: increased area */ const dd::Spatial_reference_system *srs); /*!< in: SRS of R-tree */ -/****************************************************************/ /** - Following the right link to find the proper block for insert. +/** Following the right link to find the proper block for insert. @return the proper block.*/ -dberr_t rtr_ins_enlarge_mbr( - /*=================*/ - btr_cur_t *cursor, /*!< in: btr cursor */ - que_thr_t *thr, /*!< in: query thread */ - mtr_t *mtr); /*!< in: mtr */ - -/********************************************************************/ /** - */ +dberr_t rtr_ins_enlarge_mbr(btr_cur_t *cursor, /*!< in: btr cursor */ + que_thr_t *thr, /*!< in: query thread */ + mtr_t *mtr); /*!< in: mtr */ + +/** */ void rtr_get_father_node( - /*================*/ dict_index_t *index, /*!< in: index */ ulint level, /*!< in: the tree level of search */ const dtuple_t *tuple, /*!< in: data tuple; NOTE: n_fields_cmp in @@ -199,24 +185,18 @@ void rtr_non_leaf_insert_stack_push(dict_index_t *index, rtr_node_path_t *path, ulint level, const buf_block_t *block, const rec_t *rec, double mbr_inc); -/*****************************************************************/ /** - Allocates a new Split Sequence Number. +/** Allocates a new Split Sequence Number. @return new SSN id */ UNIV_INLINE -node_seq_t rtr_get_new_ssn_id( - /*===============*/ - dict_index_t *index); /*!< in: the index struct */ +node_seq_t rtr_get_new_ssn_id(dict_index_t *index); /*!< in: the index struct */ -/*****************************************************************/ /** - Get the current Split Sequence Number. +/** Get the current Split Sequence Number. @return current SSN id */ UNIV_INLINE node_seq_t rtr_get_current_ssn_id( - /*===================*/ dict_index_t *index); /*!< in/out: the index struct */ -/********************************************************************/ /** - Create a RTree search info structure */ +/** Create a RTree search info structure */ rtr_info_t *rtr_create_rtr_info( /******************/ bool need_prdt, /*!< in: Whether predicate lock is @@ -227,16 +207,14 @@ rtr_info_t *rtr_create_rtr_info( btr_cur_t *cursor, /*!< in: tree search cursor */ dict_index_t *index); /*!< in: index struct */ -/********************************************************************/ /** - Update a btr_cur_t with rtr_info */ +/** Update a btr_cur_t with rtr_info */ void rtr_info_update_btr( /******************/ btr_cur_t *cursor, /*!< in/out: tree cursor */ rtr_info_t *rtr_info); /*!< in: rtr_info to set to the cursor */ -/********************************************************************/ /** - Update a btr_cur_t with rtr_info */ +/** Update a btr_cur_t with rtr_info */ void rtr_init_rtr_info( /****************/ rtr_info_t *rtr_info, /*!< in: rtr_info to set to the @@ -247,27 +225,18 @@ void rtr_init_rtr_info( dict_index_t *index, /*!< in: index structure */ bool reinit); /*!< in: Whether this is a reinit */ -/**************************************************************/ /** - Clean up Rtree cursor */ -void rtr_clean_rtr_info( - /*===============*/ - rtr_info_t *rtr_info, /*!< in: RTree search info */ - bool free_all); /*!< in: need to free rtr_info itself */ - -/****************************************************************/ /** - Get the bounding box content from an index record*/ -void rtr_get_mbr_from_rec( - /*=================*/ - const rec_t *rec, /*!< in: data tuple */ - const ulint *offsets, /*!< in: offsets array */ - rtr_mbr_t *mbr); /*!< out MBR */ - -/****************************************************************/ /** - Get the bounding box content from a MBR data record */ -void rtr_get_mbr_from_tuple( - /*===================*/ - const dtuple_t *dtuple, /*!< in: data tuple */ - rtr_mbr *mbr); /*!< out: mbr to fill */ +/** Clean up Rtree cursor */ +void rtr_clean_rtr_info(rtr_info_t *rtr_info, /*!< in: RTree search info */ + bool free_all); /*!< in: need to free rtr_info itself */ + +/** Get the bounding box content from an index record*/ +void rtr_get_mbr_from_rec(const rec_t *rec, /*!< in: data tuple */ + const ulint *offsets, /*!< in: offsets array */ + rtr_mbr_t *mbr); /*!< out MBR */ + +/** Get the bounding box content from a MBR data record */ +void rtr_get_mbr_from_tuple(const dtuple_t *dtuple, /*!< in: data tuple */ + rtr_mbr *mbr); /*!< out: mbr to fill */ /* Get the rtree page father. @param[in] offsets work area for the return value @@ -281,12 +250,10 @@ void rtr_get_mbr_from_tuple( void rtr_page_get_father(dict_index_t *index, buf_block_t *block, mtr_t *mtr, btr_cur_t *sea_cur, btr_cur_t *cursor); -/************************************************************/ /** - Returns the father block to a page. It is assumed that mtr holds +/** Returns the father block to a page. It is assumed that mtr holds an X or SX latch on the tree. @return rec_get_offsets() of the node pointer record */ ulint *rtr_page_get_father_block( - /*======================*/ ulint *offsets, /*!< in: work area for the return value */ mem_heap_t *heap, /*!< in: memory heap to use */ dict_index_t *index, /*!< in: b-tree index */ @@ -296,11 +263,9 @@ ulint *rtr_page_get_father_block( about parent nodes in search */ btr_cur_t *cursor); /*!< out: cursor on node pointer record, its page x-latched */ -/**************************************************************/ /** - Store the parent path cursor +/** Store the parent path cursor @return number of cursor stored */ ulint rtr_store_parent_path( - /*==================*/ const buf_block_t *block, /*!< in: block of the page */ btr_cur_t *btr_cur, /*!< in/out: persistent cursor */ ulint latch_mode, @@ -308,11 +273,9 @@ ulint rtr_store_parent_path( ulint level, /*!< in: index level */ mtr_t *mtr); /*!< in: mtr */ -/**************************************************************/ /** - Initializes and opens a persistent cursor to an index tree. It should be +/** Initializes and opens a persistent cursor to an index tree. It should be closed with btr_pcur_close. */ void rtr_pcur_open_low( - /*==============*/ dict_index_t *index, /*!< in: index */ ulint level, /*!< in: level in the btree */ const dtuple_t *tuple, /*!< in: tuple on which search done */ @@ -351,10 +314,8 @@ UNIV_INLINE btr_pcur_t *rtr_get_parent_cursor(btr_cur_t *btr_cur, ulint level, ulint is_insert); -/*************************************************************/ /** - Copy recs from a page to new_block of rtree. */ +/** Copy recs from a page to new_block of rtree. */ void rtr_page_copy_rec_list_end_no_locks( - /*================================*/ buf_block_t *new_block, /*!< in: index page to copy to */ buf_block_t *block, /*!< in: index page of rec */ rec_t *rec, /*!< in: record on page */ @@ -365,10 +326,8 @@ void rtr_page_copy_rec_list_end_no_locks( ulint *num_moved, /*!< out: num of rec to move */ mtr_t *mtr); /*!< in: mtr */ -/*************************************************************/ /** - Copy recs till a specified rec from a page to new_block of rtree. */ +/** Copy recs till a specified rec from a page to new_block of rtree. */ void rtr_page_copy_rec_list_start_no_locks( - /*==================================*/ buf_block_t *new_block, /*!< in: index page to copy to */ buf_block_t *block, /*!< in: index page of rec */ rec_t *rec, /*!< in: record on page */ @@ -379,10 +338,8 @@ void rtr_page_copy_rec_list_start_no_locks( ulint *num_moved, /*!< out: num of rec to move */ mtr_t *mtr); /*!< in: mtr */ -/****************************************************************/ /** - Merge 2 mbrs and update the the mbr that cursor is on. */ +/** Merge 2 mbrs and update the the mbr that cursor is on. */ dberr_t rtr_merge_and_update_mbr( - /*=====================*/ btr_cur_t *cursor, /*!< in/out: cursor */ btr_cur_t *cursor2, /*!< in: the other cursor */ ulint *offsets, /*!< in: rec offsets */ @@ -393,34 +350,27 @@ dberr_t rtr_merge_and_update_mbr( dict_index_t *index, /*!< in: index */ mtr_t *mtr); /*!< in: mtr */ -/*************************************************************/ /** - Deletes on the upper level the node pointer to a page. */ +/** Deletes on the upper level the node pointer to a page. */ void rtr_node_ptr_delete( - /*================*/ dict_index_t *index, /*!< in: index tree */ btr_cur_t *sea_cur, /*!< in: search cursor, contains information about parent nodes in search */ buf_block_t *block, /*!< in: page whose node pointer is deleted */ mtr_t *mtr); /*!< in: mtr */ -/****************************************************************/ /** - Check two MBRs are identical or need to be merged */ -bool rtr_merge_mbr_changed( - /*==================*/ - btr_cur_t *cursor, /*!< in: cursor */ - btr_cur_t *cursor2, /*!< in: the other cursor */ - ulint *offsets, /*!< in: rec offsets */ - ulint *offsets2, /*!< in: rec offsets */ - rtr_mbr_t *new_mbr, /*!< out: MBR to update */ - buf_block_t *merge_block, /*!< in: page to merge */ - buf_block_t *block, /*!< in: page be merged */ - dict_index_t *index); /*!< in: index */ - -/**************************************************************/ /** - Update the mbr field of a spatial index row. +/** Check two MBRs are identical or need to be merged */ +bool rtr_merge_mbr_changed(btr_cur_t *cursor, /*!< in: cursor */ + btr_cur_t *cursor2, /*!< in: the other cursor */ + ulint *offsets, /*!< in: rec offsets */ + ulint *offsets2, /*!< in: rec offsets */ + rtr_mbr_t *new_mbr, /*!< out: MBR to update */ + buf_block_t *merge_block, /*!< in: page to merge */ + buf_block_t *block, /*!< in: page be merged */ + dict_index_t *index); /*!< in: index */ + +/** Update the mbr field of a spatial index row. @return true if successful */ bool rtr_update_mbr_field( - /*=================*/ btr_cur_t *cursor, /*!< in: cursor pointed to rec.*/ ulint *offsets, /*!< in: offsets on rec. */ btr_cur_t *cursor2, /*!< in/out: cursor pointed to rec @@ -432,11 +382,9 @@ bool rtr_update_mbr_field( rec_t *new_rec, /*!< in: rec to use */ mtr_t *mtr); /*!< in: mtr */ -/**************************************************************/ /** - Check whether a Rtree page is child of a parent page +/** Check whether a Rtree page is child of a parent page @return true if there is child/parent relationship */ bool rtr_check_same_block( - /*=================*/ dict_index_t *index, /*!< in: index tree */ btr_cur_t *cur, /*!< in/out: position at the parent entry pointing to the child if successful */ @@ -456,10 +404,8 @@ void rtr_write_mbr(byte *data, const rtr_mbr_t *mbr); UNIV_INLINE void rtr_read_mbr(const byte *data, rtr_mbr_t *mbr); -/**************************************************************/ /** - Check whether a discarding page is in anyone's search path */ +/** Check whether a discarding page is in anyone's search path */ void rtr_check_discard_page( - /*===================*/ dict_index_t *index, /*!< in: index */ btr_cur_t *cursor, /*!< in: cursor on the page to discard: not on the root page */ diff --git a/storage/innobase/include/gis0rtree.ic b/storage/innobase/include/gis0rtree.ic index 28677f304266..c43d7b31d70a 100644 --- a/storage/innobase/include/gis0rtree.ic +++ b/storage/innobase/include/gis0rtree.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2014, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2014, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,23 +24,19 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include gis0rtree.h +/** @file include gis0rtree.h R-tree Inline code Created 2013/03/27 Jimmy Yang and Allen Lai ***********************************************************************/ -/**************************************************************/ /** - Sets the child node mbr in a node pointer. */ +/** Sets the child node mbr in a node pointer. */ UNIV_INLINE -void rtr_page_cal_mbr( - /*=============*/ - const dict_index_t *index, /*!< in: index */ - const buf_block_t *block, /*!< in: buffer block */ - rtr_mbr_t *rtr_mbr, /*!< out: MBR encapsulates the page */ - mem_heap_t *heap) /*!< in: heap for the memory - allocation */ +void rtr_page_cal_mbr(const dict_index_t *index, /*!< in: index */ + const buf_block_t *block, /*!< in: buffer block */ + rtr_mbr_t *rtr_mbr, /*!< out: MBR encapsulates the page */ + mem_heap_t *heap) /*!< in: heap for the memory + allocation */ { page_t *page; rec_t *rec; @@ -92,19 +88,16 @@ void rtr_page_cal_mbr( } while (!page_rec_is_supremum(rec)); } -/**************************************************************/ /** - push a nonleaf index node to the search path */ +/** push a nonleaf index node to the search path */ UNIV_INLINE -void rtr_non_leaf_stack_push( - /*====================*/ - rtr_node_path_t *path, /*!< in/out: search path */ - page_no_t pageno, /*!< in: pageno to insert */ - node_seq_t seq_no, /*!< in: Node sequence num */ - ulint level, /*!< in: index page level */ - page_no_t child_no, /*!< in: child page no */ - btr_pcur_t *cursor, /*!< in: position cursor */ - double mbr_inc) /*!< in: MBR needs to be - enlarged */ +void rtr_non_leaf_stack_push(rtr_node_path_t *path, /*!< in/out: search path */ + page_no_t pageno, /*!< in: pageno to insert */ + node_seq_t seq_no, /*!< in: Node sequence num */ + ulint level, /*!< in: index page level */ + page_no_t child_no, /*!< in: child page no */ + btr_pcur_t *cursor, /*!< in: position cursor */ + double mbr_inc) /*!< in: MBR needs to be + enlarged */ { node_visit_t insert_val; @@ -126,12 +119,10 @@ void rtr_non_leaf_stack_push( #endif /* RTR_SEARCH_DIAGNOSTIC */ } -/*****************************************************************/ /** - Allocates a new Split Sequence Number. +/** Allocates a new Split Sequence Number. @return new SSN id */ UNIV_INLINE node_seq_t rtr_get_new_ssn_id( - /*===============*/ dict_index_t *index) /*!< in/out: the index struct */ { node_seq_t ssn; @@ -142,13 +133,10 @@ node_seq_t rtr_get_new_ssn_id( return (ssn); } -/*****************************************************************/ /** - Get the current Split Sequence Number. +/** Get the current Split Sequence Number. @return current SSN id */ UNIV_INLINE -node_seq_t rtr_get_current_ssn_id( - /*===================*/ - dict_index_t *index) /*!< in: index struct */ +node_seq_t rtr_get_current_ssn_id(dict_index_t *index) /*!< in: index struct */ { node_seq_t ssn; @@ -159,13 +147,10 @@ node_seq_t rtr_get_current_ssn_id( return (ssn); } -/*********************************************************************/ /** - Sets pointer to the data and length in a field. */ +/** Sets pointer to the data and length in a field. */ UNIV_INLINE -void rtr_write_mbr( - /*==========*/ - byte *data, /*!< out: data */ - const rtr_mbr_t *mbr) /*!< in: data */ +void rtr_write_mbr(byte *data, /*!< out: data */ + const rtr_mbr_t *mbr) /*!< in: data */ { const double *my_mbr = reinterpret_cast(mbr); @@ -174,13 +159,10 @@ void rtr_write_mbr( } } -/*********************************************************************/ /** - Sets pointer to the data and length in a field. */ +/** Sets pointer to the data and length in a field. */ UNIV_INLINE -void rtr_read_mbr( - /*==========*/ - const byte *data, /*!< in: data */ - rtr_mbr_t *mbr) /*!< out: MBR */ +void rtr_read_mbr(const byte *data, /*!< in: data */ + rtr_mbr_t *mbr) /*!< out: MBR */ { for (int i = 0; i < SPDIMS * 2; i++) { (reinterpret_cast(mbr))[i] = @@ -188,13 +170,11 @@ void rtr_read_mbr( } } -/*********************************************************/ /** - Returns the R-Tree node stored in the parent search path +/** Returns the R-Tree node stored in the parent search path @return pointer to R-Tree cursor component in the parent path, NULL if parent path is empty or index is larger than num of items contained */ UNIV_INLINE node_visit_t *rtr_get_parent_node( - /*================*/ btr_cur_t *btr_cur, /*!< in: persistent cursor */ ulint level, /*!< in: index level of buffer page */ ulint is_insert) /*!< in: whether it is insert */ @@ -240,12 +220,10 @@ node_visit_t *rtr_get_parent_node( return (found_node); } -/*********************************************************/ /** - Returns the R-Tree cursor stored in the parent search path +/** Returns the R-Tree cursor stored in the parent search path @return pointer to R-Tree cursor component */ UNIV_INLINE btr_pcur_t *rtr_get_parent_cursor( - /*==================*/ btr_cur_t *btr_cur, /*!< in: persistent cursor */ ulint level, /*!< in: index level of buffer page */ ulint is_insert) /*!< in: whether insert operation */ @@ -255,8 +233,7 @@ btr_pcur_t *rtr_get_parent_cursor( return ((found_node) ? found_node->cursor : NULL); } -/********************************************************************/ /** - Reinitialize a R-Tree search info in btr_cur_t */ +/** Reinitialize a R-Tree search info in btr_cur_t */ UNIV_INLINE void rtr_info_reinit_in_cursor( /************************/ diff --git a/storage/innobase/include/gis0type.h b/storage/innobase/include/gis0type.h index 4ce059ee7c4e..31781bddc780 100644 --- a/storage/innobase/include/gis0type.h +++ b/storage/innobase/include/gis0type.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2014, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2014, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/gis0type.h +/** @file include/gis0type.h R-tree header file Created 2013/03/27 Jimmy Yang diff --git a/storage/innobase/include/ha0ha.h b/storage/innobase/include/ha0ha.h index 548a573bad77..2bdc613b58a9 100644 --- a/storage/innobase/include/ha0ha.h +++ b/storage/innobase/include/ha0ha.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/ha0ha.h +/** @file include/ha0ha.h The hash table with external chains Created 8/18/1994 Heikki Tuuri @@ -49,12 +48,10 @@ having the fold number, NULL if not found */ UNIV_INLINE const rec_t *ha_search_and_get_data(hash_table_t *table, ulint fold); -/*********************************************************/ /** - Looks for an element when we know the pointer to the data and updates +/** Looks for an element when we know the pointer to the data and updates the pointer to data if found. @return true if found */ ibool ha_search_and_update_if_found_func( - /*===============================*/ hash_table_t *table, /*!< in/out: hash table */ ulint fold, /*!< in: folded value of the searched data */ const rec_t *data, /*!< in: pointer to the data */ @@ -85,12 +82,10 @@ updates the pointer to data if found. ha_search_and_update_if_found_func(table, fold, data, new_data) #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ -/*************************************************************/ /** - Creates a hash table with at least n array cells. The actual number +/** Creates a hash table with at least n array cells. The actual number of cells is chosen to be a prime number slightly bigger than n. @return own: created table */ hash_table_t *ib_create( - /*======*/ ulint n, /*!< in: number of array cells */ latch_id_t id, /*!< in: latch ID */ ulint n_mutexes, /*!< in: number of mutexes to protect the @@ -109,19 +104,14 @@ The sync objects are reused. @return resized new table */ hash_table_t *ib_recreate(hash_table_t *table, ulint n); -/*************************************************************/ /** - Empties a hash table and frees the memory heaps. */ -void ha_clear( - /*=====*/ - hash_table_t *table); /*!< in, own: hash table */ +/** Empties a hash table and frees the memory heaps. */ +void ha_clear(hash_table_t *table); /*!< in, own: hash table */ -/*************************************************************/ /** - Inserts an entry into a hash table. If an entry with the same fold number +/** Inserts an entry into a hash table. If an entry with the same fold number is found, its node is updated to point to the new data, and no new node is inserted. @return true if succeed, false if no more memory could be allocated */ ibool ha_insert_for_fold_func( - /*====================*/ hash_table_t *table, /*!< in: hash table */ ulint fold, /*!< in: folded value of data; if a node with the same fold value already exists, it is @@ -175,31 +165,22 @@ ibool ha_search_and_delete_if_found(hash_table_t *table, ulint fold, const rec_t *data); #ifndef UNIV_HOTBACKUP -/*****************************************************************/ /** - Removes from the chain determined by fold all nodes whose data pointer +/** Removes from the chain determined by fold all nodes whose data pointer points to the page given. */ -void ha_remove_all_nodes_to_page( - /*========================*/ - hash_table_t *table, /*!< in: hash table */ - ulint fold, /*!< in: fold value */ - const page_t *page); /*!< in: buffer page */ +void ha_remove_all_nodes_to_page(hash_table_t *table, /*!< in: hash table */ + ulint fold, /*!< in: fold value */ + const page_t *page); /*!< in: buffer page */ #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG -/*************************************************************/ /** - Validates a given range of the cells in hash table. +/** Validates a given range of the cells in hash table. @return true if ok */ -ibool ha_validate( - /*========*/ - hash_table_t *table, /*!< in: hash table */ - ulint start_index, /*!< in: start index */ - ulint end_index); /*!< in: end index */ -#endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */ -/*************************************************************/ /** - Prints info of a hash table. */ -void ha_print_info( - /*==========*/ - FILE *file, /*!< in: file where to print */ - hash_table_t *table); /*!< in: hash table */ -#endif /* !UNIV_HOTBACKUP */ +ibool ha_validate(hash_table_t *table, /*!< in: hash table */ + ulint start_index, /*!< in: start index */ + ulint end_index); /*!< in: end index */ +#endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */ +/** Prints info of a hash table. */ +void ha_print_info(FILE *file, /*!< in: file where to print */ + hash_table_t *table); /*!< in: hash table */ +#endif /* !UNIV_HOTBACKUP */ /** The hash table external chain node */ struct ha_node_t { diff --git a/storage/innobase/include/ha0ha.ic b/storage/innobase/include/ha0ha.ic index 7db4dcb0e1f7..44ad0bbe7e10 100644 --- a/storage/innobase/include/ha0ha.ic +++ b/storage/innobase/include/ha0ha.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file include/ha0ha.ic +/** @file include/ha0ha.ic The hash table with external chains Created 8/18/1994 Heikki Tuuri @@ -35,29 +34,21 @@ this program; if not, write to the Free Software Foundation, Inc., #include "mem0mem.h" #include "ut0rnd.h" -/***********************************************************/ /** - Deletes a hash node. */ -void ha_delete_hash_node( - /*================*/ - hash_table_t *table, /*!< in: hash table */ - ha_node_t *del_node); /*!< in: node to be deleted */ +/** Deletes a hash node. */ +void ha_delete_hash_node(hash_table_t *table, /*!< in: hash table */ + ha_node_t *del_node); /*!< in: node to be deleted */ -/******************************************************************/ /** - Gets a hash node data. +/** Gets a hash node data. @return pointer to the data */ UNIV_INLINE -const rec_t *ha_node_get_data( - /*=============*/ - const ha_node_t *node) /*!< in: hash chain node */ +const rec_t *ha_node_get_data(const ha_node_t *node) /*!< in: hash chain node */ { return (node->data); } -/******************************************************************/ /** - Sets hash node data. */ +/** Sets hash node data. */ UNIV_INLINE void ha_node_set_data_func( - /*==================*/ ha_node_t *node, /*!< in: hash chain node */ #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG buf_block_t *block, /*!< in: buffer block containing the data */ @@ -84,23 +75,18 @@ void ha_node_set_data_func( #define ha_node_set_data(n, b, d) ha_node_set_data_func(n, d) #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ -/******************************************************************/ /** - Gets the next node in a hash chain. +/** Gets the next node in a hash chain. @return next node, NULL if none */ UNIV_INLINE -ha_node_t *ha_chain_get_next( - /*==============*/ - const ha_node_t *node) /*!< in: hash chain node */ +ha_node_t *ha_chain_get_next(const ha_node_t *node) /*!< in: hash chain node */ { return (node->next); } -/******************************************************************/ /** - Gets the first node in a hash chain. +/** Gets the first node in a hash chain. @return first node, NULL if none */ UNIV_INLINE ha_node_t *ha_chain_get_first( - /*===============*/ hash_table_t *table, /*!< in: hash table */ ulint fold) /*!< in: fold value determining the chain */ { @@ -109,16 +95,13 @@ ha_node_t *ha_chain_get_first( } #ifdef UNIV_DEBUG -/********************************************************************/ /** - Assert that the synchronization object in a hash operation involving +/** Assert that the synchronization object in a hash operation involving possible change in the hash table is held. Note that in case of mutexes we assert that mutex is owned while in case of rw-locks we assert that it is held in exclusive mode. */ UNIV_INLINE -void hash_assert_can_modify( - /*===================*/ - hash_table_t *table, /*!< in: hash table */ - ulint fold) /*!< in: fold value */ +void hash_assert_can_modify(hash_table_t *table, /*!< in: hash table */ + ulint fold) /*!< in: fold value */ { if (table->type == HASH_TABLE_SYNC_MUTEX) { ut_ad(mutex_own(hash_get_mutex(table, fold))); @@ -132,15 +115,12 @@ void hash_assert_can_modify( } } -/********************************************************************/ /** - Assert that the synchronization object in a hash search operation is held. +/** Assert that the synchronization object in a hash search operation is held. Note that in case of mutexes we assert that mutex is owned while in case of rw-locks we assert that it is held either in x-mode or s-mode. */ UNIV_INLINE -void hash_assert_can_search( - /*===================*/ - hash_table_t *table, /*!< in: hash table */ - ulint fold) /*!< in: fold value */ +void hash_assert_can_search(hash_table_t *table, /*!< in: hash table */ + ulint fold) /*!< in: fold value */ { if (table->type == HASH_TABLE_SYNC_MUTEX) { ut_ad(mutex_own(hash_get_mutex(table, fold))); @@ -155,13 +135,11 @@ void hash_assert_can_search( } #endif /* UNIV_DEBUG */ -/*************************************************************/ /** - Looks for an element in a hash table. +/** Looks for an element in a hash table. @return pointer to the data of the first hash table node in chain having the fold number, NULL if not found */ UNIV_INLINE const rec_t *ha_search_and_get_data( - /*===================*/ hash_table_t *table, /*!< in: hash table */ ulint fold) /*!< in: folded value of the searched data */ { @@ -178,12 +156,10 @@ const rec_t *ha_search_and_get_data( return (NULL); } -/*********************************************************/ /** - Looks for an element when we know the pointer to the data. +/** Looks for an element when we know the pointer to the data. @return pointer to the hash table node, NULL if not found in the table */ UNIV_INLINE ha_node_t *ha_search_with_data( - /*================*/ hash_table_t *table, /*!< in: hash table */ ulint fold, /*!< in: folded value of the searched data */ const rec_t *data) /*!< in: pointer to the data */ @@ -207,13 +183,11 @@ ha_node_t *ha_search_with_data( return (NULL); } -/*********************************************************/ /** - Looks for an element when we know the pointer to the data, and deletes +/** Looks for an element when we know the pointer to the data, and deletes it from the hash table, if found. @return true if found */ UNIV_INLINE ibool ha_search_and_delete_if_found( - /*==========================*/ hash_table_t *table, /*!< in: hash table */ ulint fold, /*!< in: folded value of the searched data */ const rec_t *data) /*!< in: pointer to the data */ diff --git a/storage/innobase/include/ha0storage.h b/storage/innobase/include/ha0storage.h index afd91ee59b8a..225a2db05dc2 100644 --- a/storage/innobase/include/ha0storage.h +++ b/storage/innobase/include/ha0storage.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/ha0storage.h +/** @file include/ha0storage.h Hash storage. Provides a data structure that stores chunks of data in its own storage, avoiding duplicates. @@ -59,8 +58,7 @@ UNIV_INLINE ha_storage_t *ha_storage_create(ulint initial_heap_bytes, ulint initial_hash_cells); -/*******************************************************************/ /** - Copies data into the storage and returns a pointer to the copy. If the +/** Copies data into the storage and returns a pointer to the copy. If the same data chunk is already present, then pointer to it is returned. Data chunks are considered to be equal if len1 == len2 and memcmp(data1, data2, len1) == 0. If "data" is not present (and thus @@ -70,14 +68,12 @@ ha_storage_t *ha_storage_create(ulint initial_heap_bytes, "no limit". @return pointer to the copy */ const void *ha_storage_put_memlim( - /*==================*/ ha_storage_t *storage, /*!< in/out: hash storage */ const void *data, /*!< in: data to store */ ulint data_len, /*!< in: data length */ ulint memlim); /*!< in: memory limit to obey */ -/*******************************************************************/ /** - Same as ha_storage_put_memlim() but without memory limit. +/** Same as ha_storage_put_memlim() but without memory limit. @param storage in/out: hash storage @param data in: data to store @param data_len in: data length @@ -85,8 +81,7 @@ const void *ha_storage_put_memlim( #define ha_storage_put(storage, data, data_len) \ ha_storage_put_memlim((storage), (data), (data_len), 0) -/*******************************************************************/ /** - Copies string into the storage and returns a pointer to the copy. If the +/** Copies string into the storage and returns a pointer to the copy. If the same string is already present, then pointer to it is returned. Strings are considered to be equal if strcmp(str1, str2) == 0. @param storage in/out: hash storage @@ -95,8 +90,7 @@ const void *ha_storage_put_memlim( #define ha_storage_put_str(storage, str) \ ((const char *)ha_storage_put((storage), (str), strlen(str) + 1)) -/*******************************************************************/ /** - Copies string into the storage and returns a pointer to the copy obeying +/** Copies string into the storage and returns a pointer to the copy obeying a memory limit. If the same string is already present, then pointer to it is returned. Strings are considered to be equal if strcmp(str1, str2) == 0. @@ -108,31 +102,22 @@ const void *ha_storage_put_memlim( ((const char *)ha_storage_put_memlim((storage), (str), strlen(str) + 1, \ (memlim))) -/*******************************************************************/ /** - Empties a hash storage, freeing memory occupied by data chunks. +/** Empties a hash storage, freeing memory occupied by data chunks. This invalidates any pointers previously returned by ha_storage_put(). The hash storage is not invalidated itself and can be used again. */ UNIV_INLINE -void ha_storage_empty( - /*=============*/ - ha_storage_t **storage); /*!< in/out: hash storage */ +void ha_storage_empty(ha_storage_t **storage); /*!< in/out: hash storage */ -/*******************************************************************/ /** - Frees a hash storage and everything it contains, it cannot be used after +/** Frees a hash storage and everything it contains, it cannot be used after this call. This invalidates any pointers previously returned by ha_storage_put(). */ UNIV_INLINE -void ha_storage_free( - /*============*/ - ha_storage_t *storage); /*!< in, own: hash storage */ +void ha_storage_free(ha_storage_t *storage); /*!< in, own: hash storage */ -/*******************************************************************/ /** - Gets the size of the memory used by a storage. +/** Gets the size of the memory used by a storage. @return bytes used */ UNIV_INLINE -ulint ha_storage_get_size( - /*================*/ - const ha_storage_t *storage); /*!< in: hash storage */ +ulint ha_storage_get_size(const ha_storage_t *storage); /*!< in: hash storage */ #include "ha0storage.ic" diff --git a/storage/innobase/include/ha0storage.ic b/storage/innobase/include/ha0storage.ic index 185b851f57e4..5df4e9d3c300 100644 --- a/storage/innobase/include/ha0storage.ic +++ b/storage/innobase/include/ha0storage.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/ha0storage.ic +/** @file include/ha0storage.ic Hash storage. Provides a data structure that stores chunks of data in its own storage, avoiding duplicates. @@ -53,13 +52,11 @@ struct ha_storage_node_t { ha_storage_node_t *next; /*!< next node in hash chain */ }; -/*******************************************************************/ /** - Creates a hash storage. If any of the parameters is 0, then a default +/** Creates a hash storage. If any of the parameters is 0, then a default value is used. @return own: hash storage */ UNIV_INLINE ha_storage_t *ha_storage_create( - /*==============*/ ulint initial_heap_bytes, /*!< in: initial heap's size */ ulint initial_hash_cells) /*!< in: initial number of cells in the hash table */ @@ -87,14 +84,11 @@ ha_storage_t *ha_storage_create( return (storage); } -/*******************************************************************/ /** - Empties a hash storage, freeing memory occupied by data chunks. +/** Empties a hash storage, freeing memory occupied by data chunks. This invalidates any pointers previously returned by ha_storage_put(). The hash storage is not invalidated itself and can be used again. */ UNIV_INLINE -void ha_storage_empty( - /*=============*/ - ha_storage_t **storage) /*!< in/out: hash storage */ +void ha_storage_empty(ha_storage_t **storage) /*!< in/out: hash storage */ { ha_storage_t temp_storage; @@ -111,14 +105,11 @@ void ha_storage_empty( (*storage)->hash = temp_storage.hash; } -/*******************************************************************/ /** - Frees a hash storage and everything it contains, it cannot be used after +/** Frees a hash storage and everything it contains, it cannot be used after this call. This invalidates any pointers previously returned by ha_storage_put(). */ UNIV_INLINE -void ha_storage_free( - /*============*/ - ha_storage_t *storage) /*!< in, own: hash storage */ +void ha_storage_free(ha_storage_t *storage) /*!< in, own: hash storage */ { /* order is important because the pointer storage->hash is within the heap */ @@ -126,13 +117,10 @@ void ha_storage_free( mem_heap_free(storage->heap); } -/*******************************************************************/ /** - Gets the size of the memory used by a storage. +/** Gets the size of the memory used by a storage. @return bytes used */ UNIV_INLINE -ulint ha_storage_get_size( - /*================*/ - const ha_storage_t *storage) /*!< in: hash storage */ +ulint ha_storage_get_size(const ha_storage_t *storage) /*!< in: hash storage */ { ulint ret; diff --git a/storage/innobase/include/ha_prototypes.h b/storage/innobase/include/ha_prototypes.h index bda3c83be326..44831a437c8e 100644 --- a/storage/innobase/include/ha_prototypes.h +++ b/storage/innobase/include/ha_prototypes.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/*******************************************************************/ /** - @file include/ha_prototypes.h +/** @file include/ha_prototypes.h Prototypes for global functions in ha_innodb.cc that are called by InnoDB C code. @@ -46,8 +45,7 @@ class MDL_ticket; struct CHARSET_INFO; struct dict_table_t; -/*******************************************************************/ /** - Formats the raw data in "data" (in InnoDB on-disk format) that is of +/** Formats the raw data in "data" (in InnoDB on-disk format) that is of type DATA_(CHAR|VARCHAR|MYSQL|VARMYSQL) using "charset_coll" and writes the result to "buf". The result is converted to "system_charset_info". Not more than "buf_size" bytes are written to "buf". @@ -55,15 +53,13 @@ struct dict_table_t; number of bytes that were written to "buf" is returned (including the terminating NUL). @return number of bytes that were written */ -ulint innobase_raw_format( - /*================*/ - const char *data, /*!< in: raw data */ - ulint data_len, /*!< in: raw data length - in bytes */ - ulint charset_coll, /*!< in: charset collation */ - char *buf, /*!< out: output buffer */ - ulint buf_size); /*!< in: output buffer size - in bytes */ +ulint innobase_raw_format(const char *data, /*!< in: raw data */ + ulint data_len, /*!< in: raw data length + in bytes */ + ulint charset_coll, /*!< in: charset collation */ + char *buf, /*!< out: output buffer */ + ulint buf_size); /*!< in: output buffer size + in bytes */ /** Quote a standard SQL identifier like tablespace, index or column name. @param[in] file output stream @@ -78,42 +74,32 @@ Return the string as an std:string object. @return a std::string with id properly quoted. */ std::string innobase_quote_identifier(trx_t *trx, const char *id); -/*****************************************************************/ /** - Convert a table name to the MySQL system_charset_info (UTF-8). +/** Convert a table name to the MySQL system_charset_info (UTF-8). @return pointer to the end of buf */ char *innobase_convert_name( - /*==================*/ char *buf, /*!< out: buffer for converted identifier */ ulint buflen, /*!< in: length of buf, in bytes */ const char *id, /*!< in: table name to convert */ ulint idlen, /*!< in: length of id, in bytes */ THD *thd); /*!< in: MySQL connection thread, or NULL */ -/******************************************************************/ /** - Returns true if the thread is the replication thread on the slave +/** Returns true if the thread is the replication thread on the slave server. Used in srv_conc_enter_innodb() to determine if the thread should be allowed to enter InnoDB - the replication thread is treated differently than other threads. Also used in srv_conc_force_exit_innodb(). @return true if thd is the replication thread */ -ibool thd_is_replication_slave_thread( - /*============================*/ - THD *thd); /*!< in: thread handle */ +ibool thd_is_replication_slave_thread(THD *thd); /*!< in: thread handle */ -/******************************************************************/ /** - Returns true if the transaction this thread is processing has edited +/** Returns true if the transaction this thread is processing has edited non-transactional tables. Used by the deadlock detector when deciding which transaction to rollback in case of a deadlock - we try to avoid rolling back transactions that have edited non-transactional tables. @return true if non-transactional tables have been edited */ -ibool thd_has_edited_nontrans_tables( - /*===========================*/ - THD *thd); /*!< in: thread handle */ +ibool thd_has_edited_nontrans_tables(THD *thd); /*!< in: thread handle */ -/*************************************************************/ /** - Prints info of a THD object (== user session thread) to the given file. */ +/** Prints info of a THD object (== user session thread) to the given file. */ void innobase_mysql_print_thd( - /*=====================*/ FILE *f, /*!< in: output stream */ THD *thd, /*!< in: pointer to a MySQL THD object */ uint max_query_len); /*!< in: max query length to print, or 0 to @@ -128,63 +114,46 @@ at least ENUM and SET, and unsigned integer types are 'unsigned types' @return DATA_BINARY, DATA_VARCHAR, ... */ ulint get_innobase_type_from_mysql_type(ulint *unsigned_flag, const void *f); -/******************************************************************/ /** - Get the variable length bounds of the given character set. */ +/** Get the variable length bounds of the given character set. */ void innobase_get_cset_width( - /*====================*/ ulint cset, /*!< in: MySQL charset-collation code */ ulint *mbminlen, /*!< out: minimum length of a char (in bytes) */ ulint *mbmaxlen); /*!< out: maximum length of a char (in bytes) */ -/******************************************************************/ /** - Compares NUL-terminated UTF-8 strings case insensitively. +/** Compares NUL-terminated UTF-8 strings case insensitively. @return 0 if a=b, < 0 if a < b, > 1 if a > b */ -int innobase_strcasecmp( - /*================*/ - const char *a, /*!< in: first string to compare */ - const char *b); /*!< in: second string to compare */ +int innobase_strcasecmp(const char *a, /*!< in: first string to compare */ + const char *b); /*!< in: second string to compare */ /** Strip dir name from a full path name and return only the file name @param[in] path_name full path name @return file name or "null" if no file name */ const char *innobase_basename(const char *path_name); -/******************************************************************/ /** - Returns true if the thread is executing a SELECT statement. +/** Returns true if the thread is executing a SELECT statement. @return true if thd is executing SELECT */ -ibool thd_is_select( - /*==========*/ - const THD *thd); /*!< in: thread handle */ +ibool thd_is_select(const THD *thd); /*!< in: thread handle */ -/******************************************************************/ /** - Converts an identifier to a table name. */ +/** Converts an identifier to a table name. */ void innobase_convert_from_table_id( - /*===========================*/ const CHARSET_INFO *cs, /*!< in: the 'from' character set */ char *to, /*!< out: converted identifier */ const char *from, /*!< in: identifier to convert */ ulint len); /*!< in: length of 'to', in bytes; should be at least 5 * strlen(to) + 1 */ -/******************************************************************/ /** - Converts an identifier to UTF-8. */ +/** Converts an identifier to UTF-8. */ void innobase_convert_from_id( - /*=====================*/ const CHARSET_INFO *cs, /*!< in: the 'from' character set */ char *to, /*!< out: converted identifier */ const char *from, /*!< in: identifier to convert */ ulint len); /*!< in: length of 'to', in bytes; should be at least 3 * strlen(to) + 1 */ -/******************************************************************/ /** - Makes all characters in a NUL-terminated UTF-8 string lower case. */ -void innobase_casedn_str( - /*================*/ - char *a); /*!< in/out: string to put in lower case */ - -/**********************************************************************/ /** - Determines the connection character set. +/** Makes all characters in a NUL-terminated UTF-8 string lower case. */ +void innobase_casedn_str(char *a); /*!< in/out: string to put in lower case */ + +/** Determines the connection character set. @return connection character set */ const CHARSET_INFO *innobase_get_charset( - /*=================*/ THD *thd); /*!< in: MySQL thread handle */ /** Determines the current SQL statement. @@ -203,14 +172,12 @@ into the provided buffer. @return Length of the SQL statement */ size_t innobase_get_stmt_safe(THD *thd, char *buf, size_t buflen); -/******************************************************************/ /** - This function is used to find the storage length in bytes of the first n +/** This function is used to find the storage length in bytes of the first n characters for prefix indexes using a multibyte character set. The function finds charset information and returns length of prefix_len characters in the index field in bytes. @return number of bytes occupied by the first n characters */ ulint innobase_get_at_most_n_mbchars( - /*===========================*/ ulint charset_id, /*!< in: character set id */ ulint prefix_len, /*!< in: prefix length in bytes of the index (this has to be divided by mbmaxlen to get the @@ -218,19 +185,13 @@ ulint innobase_get_at_most_n_mbchars( ulint data_len, /*!< in: length of the string in bytes */ const char *str); /*!< in: character string */ -/******************************************************************/ /** - Returns the lock wait timeout for the current connection. +/** Returns the lock wait timeout for the current connection. @return the lock wait timeout, in seconds */ -ulong thd_lock_wait_timeout( - /*==================*/ - THD *thd); /*!< in: thread handle, or NULL to query - the global innodb_lock_wait_timeout */ -/******************************************************************/ /** - Add up the time waited for the lock for the current query. */ -void thd_set_lock_wait_time( - /*===================*/ - THD *thd, /*!< in/out: thread handle */ - ulint value); /*!< in: time waited for the lock */ +ulong thd_lock_wait_timeout(THD *thd); /*!< in: thread handle, or NULL to query + the global innodb_lock_wait_timeout */ +/** Add up the time waited for the lock for the current query. */ +void thd_set_lock_wait_time(THD *thd, /*!< in/out: thread handle */ + ulint value); /*!< in: time waited for the lock */ /** Get status of innodb_tmpdir. @param[in] thd thread handle, or NULL to query @@ -238,37 +199,28 @@ void thd_set_lock_wait_time( @retval NULL if innodb_tmpdir="" */ const char *thd_innodb_tmpdir(THD *thd); -/**********************************************************************/ /** - Get the current setting of the table_cache_size global parameter. We do +/** Get the current setting of the table_cache_size global parameter. We do a dirty read because for one there is no synchronization object and secondly there is little harm in doing so even if we get a torn read. @return SQL statement string */ ulint innobase_get_table_cache_size(void); -/*===============================*/ -/**********************************************************************/ /** - Get the current setting of the lower_case_table_names global parameter from +/** Get the current setting of the lower_case_table_names global parameter from mysqld.cc. We do a dirty read because for one there is no synchronization object and secondly there is little harm in doing so even if we get a torn read. @return value of lower_case_table_names */ ulint innobase_get_lower_case_table_names(void); -/*=====================================*/ - -/******************************************************************/ /** - compare two character string case insensitively according to their charset. */ -int innobase_fts_text_case_cmp( - /*=======================*/ - const void *cs, /*!< in: Character set */ - const void *p1, /*!< in: key */ - const void *p2); /*!< in: node */ - -/******************************************************************/ /** - Returns true if transaction should be flagged as read-only. + +/** compare two character string case insensitively according to their charset. + */ +int innobase_fts_text_case_cmp(const void *cs, /*!< in: Character set */ + const void *p1, /*!< in: key */ + const void *p2); /*!< in: node */ + +/** Returns true if transaction should be flagged as read-only. @return true if the thd is marked as read-only */ -bool thd_trx_is_read_only( - /*=================*/ - THD *thd); /*!< in/out: thread handle */ +bool thd_trx_is_read_only(THD *thd); /*!< in/out: thread handle */ /** Check if the transaction can be rolled back @@ -284,26 +236,18 @@ THD *thd_trx_arbitrate(THD *requestor, THD *holder); int thd_trx_priority(THD *thd); -/******************************************************************/ /** - Check if the transaction is an auto-commit transaction. TRUE also +/** Check if the transaction is an auto-commit transaction. TRUE also implies that it is a SELECT (read-only) transaction. @return true if the transaction is an auto commit read-only transaction. */ -ibool thd_trx_is_auto_commit( - /*===================*/ - THD *thd); /*!< in: thread handle, or NULL */ +ibool thd_trx_is_auto_commit(THD *thd); /*!< in: thread handle, or NULL */ -/******************************************************************/ /** - Get the thread start time. +/** Get the thread start time. @return the thread start time in seconds since the epoch. */ -ulint thd_start_time_in_secs( - /*===================*/ - THD *thd); /*!< in: thread handle, or NULL */ +ulint thd_start_time_in_secs(THD *thd); /*!< in: thread handle, or NULL */ -/*****************************************************************/ /** - A wrapper function of innobase_convert_name(), convert a table name +/** A wrapper function of innobase_convert_name(), convert a table name to the MySQL system_charset_info (UTF-8) and quote it if needed. */ void innobase_format_name( - /*==================*/ char *buf, /*!< out: buffer for converted identifier */ ulint buflen, /*!< in: length of buf, in bytes */ const char *name); /*!< in: table name to format */ @@ -316,8 +260,7 @@ enum ib_log_level_t { IB_LOG_LEVEL_FATAL }; -/******************************************************************/ /** - Use this when the args are first converted to a formatted string and then +/** Use this when the args are first converted to a formatted string and then passed to the format string from errmsg-utf8.txt. The error message format must be: "Some string ... %s". @@ -327,17 +270,14 @@ enum ib_log_level_t { THD *thd, Sql_condition::enum_warning_level level, uint code, const char *format, ...); */ -void ib_errf( - /*====*/ - THD *thd, /*!< in/out: session */ - ib_log_level_t level, /*!< in: warning level */ - ib_uint32_t code, /*!< MySQL error code */ - const char *format, /*!< printf format */ - ...) /*!< Args */ +void ib_errf(THD *thd, /*!< in/out: session */ + ib_log_level_t level, /*!< in: warning level */ + ib_uint32_t code, /*!< MySQL error code */ + const char *format, /*!< printf format */ + ...) /*!< Args */ MY_ATTRIBUTE((format(printf, 4, 5))); -/******************************************************************/ /** - Use this when the args are passed to the format string from +/** Use this when the args are passed to the format string from errmsg-utf8.txt directly as is. Push a warning message to the client, it is a wrapper around: @@ -346,12 +286,10 @@ void ib_errf( THD *thd, Sql_condition::enum_warning_level level, uint code, const char *format, ...); */ -void ib_senderrf( - /*========*/ - THD *thd, /*!< in/out: session */ - ib_log_level_t level, /*!< in: warning level */ - ib_uint32_t code, /*!< MySQL error code */ - ...); /*!< Args */ +void ib_senderrf(THD *thd, /*!< in/out: session */ + ib_log_level_t level, /*!< in: warning level */ + ib_uint32_t code, /*!< MySQL error code */ + ...); /*!< Args */ extern const char *TROUBLESHOOTING_MSG; extern const char *TROUBLESHOOT_DATADICT_MSG; @@ -362,21 +300,15 @@ extern const char *OPERATING_SYSTEM_ERROR_MSG; extern const char *FOREIGN_KEY_CONSTRAINTS_MSG; extern const char *INNODB_PARAMETERS_MSG; -/******************************************************************/ /** - Returns the NUL terminated value of glob_hostname. +/** Returns the NUL terminated value of glob_hostname. @return pointer to glob_hostname. */ const char *server_get_hostname(); -/*=================*/ -/******************************************************************/ /** - Get the error message format string. +/** Get the error message format string. @return the format string or 0 if not found. */ -const char *innobase_get_err_msg( - /*=================*/ - int error_code); /*!< in: MySQL error code */ +const char *innobase_get_err_msg(int error_code); /*!< in: MySQL error code */ -/*********************************************************************/ /** - Compute the next autoinc value. +/** Compute the next autoinc value. For MySQL replication the autoincrement values can be partitioned among the nodes. The offset is the start or origin of the autoincrement value @@ -394,7 +326,6 @@ const char *innobase_get_err_msg( the multi-value INSERT above. @return the next value */ ulonglong innobase_next_autoinc( - /*==================*/ ulonglong current, /*!< in: Current value */ ulonglong need, /*!< in: count of values needed */ ulonglong step, /*!< in: AUTOINC increment step */ @@ -407,14 +338,12 @@ Check if the length of the identifier exceeds the maximum allowed. The input to this function is an identifier in charset my_charset_filename. return true when length of identifier is too long. */ bool innobase_check_identifier_length( - /*=============================*/ const char *id); /* in: identifier to check. it must belong to charset my_charset_filename */ /********************************************************************** Converts an identifier from my_charset_filename to UTF-8 charset. */ uint innobase_convert_to_system_charset( - /*===============================*/ char *to, /* out: converted identifier */ const char *from, /* in: identifier to convert */ ulint len, /* in: length of 'to', in bytes */ @@ -423,7 +352,6 @@ uint innobase_convert_to_system_charset( /********************************************************************** Converts an identifier from my_charset_filename to UTF-8 charset. */ uint innobase_convert_to_filename_charset( - /*=================================*/ char *to, /* out: converted identifier */ const char *from, /* in: identifier to convert */ ulint len); /* in: length of 'to', in bytes */ @@ -432,20 +360,16 @@ uint innobase_convert_to_filename_charset( Issue a warning that the row is too big. */ void ib_warn_row_too_big(const dict_table_t *table); -/*************************************************************/ /** - InnoDB index push-down condition check defined in ha_innodb.cc +/** InnoDB index push-down condition check defined in ha_innodb.cc @return ICP_NO_MATCH, ICP_MATCH, or ICP_OUT_OF_RANGE */ #include ICP_RESULT -innobase_index_cond( - /*================*/ - ha_innobase *h) /*!< in/out: pointer to ha_innobase */ +innobase_index_cond(ha_innobase *h) /*!< in/out: pointer to ha_innobase */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************************/ /** - Gets information on the durability property requested by thread. +/** Gets information on the durability property requested by thread. Used when writing either a prepare or commit record to the log buffer. @return the durability property. */ @@ -453,7 +377,6 @@ innobase_index_cond( #include enum durability_properties thd_requested_durability( - /*=====================*/ const THD *thd) /*!< in: thread handle */ MY_ATTRIBUTE((warn_unused_result)); diff --git a/storage/innobase/include/handler0alter.h b/storage/innobase/include/handler0alter.h index 9206f9fa2431..c107bd57a062 100644 --- a/storage/innobase/include/handler0alter.h +++ b/storage/innobase/include/handler0alter.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,45 +24,33 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/handler0alter.h +/** @file include/handler0alter.h Smart ALTER TABLE *******************************************************/ #ifndef handler0alter_h #define handler0alter_h -/*************************************************************/ /** - Copies an InnoDB record to table->record[0]. */ -void innobase_rec_to_mysql( - /*==================*/ - struct TABLE *table, /*!< in/out: MySQL table */ - const rec_t *rec, /*!< in: record */ - const dict_index_t *index, /*!< in: index */ - const ulint *offsets); /*!< in: rec_get_offsets( - rec, index, ...) */ +/** Copies an InnoDB record to table->record[0]. */ +void innobase_rec_to_mysql(struct TABLE *table, /*!< in/out: MySQL table */ + const rec_t *rec, /*!< in: record */ + const dict_index_t *index, /*!< in: index */ + const ulint *offsets); /*!< in: rec_get_offsets( + rec, index, ...) */ -/*************************************************************/ /** - Copies an InnoDB index entry to table->record[0]. */ +/** Copies an InnoDB index entry to table->record[0]. */ void innobase_fields_to_mysql( - /*=====================*/ struct TABLE *table, /*!< in/out: MySQL table */ const dict_index_t *index, /*!< in: InnoDB index */ const dfield_t *fields); /*!< in: InnoDB index fields */ -/*************************************************************/ /** - Copies an InnoDB row to table->record[0]. */ -void innobase_row_to_mysql( - /*==================*/ - struct TABLE *table, /*!< in/out: MySQL table */ - const dict_table_t *itab, /*!< in: InnoDB table */ - const dtuple_t *row); /*!< in: InnoDB row */ - -/*************************************************************/ /** - Resets table->record[0]. */ -void innobase_rec_reset( - /*===============*/ - struct TABLE *table); /*!< in/out: MySQL table */ +/** Copies an InnoDB row to table->record[0]. */ +void innobase_row_to_mysql(struct TABLE *table, /*!< in/out: MySQL table */ + const dict_table_t *itab, /*!< in: InnoDB table */ + const dtuple_t *row); /*!< in: InnoDB row */ + +/** Resets table->record[0]. */ +void innobase_rec_reset(struct TABLE *table); /*!< in/out: MySQL table */ /** Generate the next autoinc based on a snapshot of the session auto_increment_increment and auto_increment_offset variables. */ diff --git a/storage/innobase/include/hash0hash.h b/storage/innobase/include/hash0hash.h index 0f35400195af..0148e3daf98f 100644 --- a/storage/innobase/include/hash0hash.h +++ b/storage/innobase/include/hash0hash.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/hash0hash.h +/** @file include/hash0hash.h The simple hash table utility Created 5/20/1997 Heikki Tuuri @@ -62,13 +61,10 @@ enum hash_table_sync_t { access to this hash_table. */ }; -/*************************************************************/ /** - Creates a hash table with >= n array cells. The actual number +/** Creates a hash table with >= n array cells. The actual number of cells is chosen to be a prime number slightly bigger than n. @return own: created table */ -hash_table_t *hash_create( - /*========*/ - ulint n); /*!< in: number of array cells */ +hash_table_t *hash_create(ulint n); /*!< in: number of array cells */ #ifndef UNIV_HOTBACKUP /** Creates a sync object array array to protect a hash table. "::sync_obj" @@ -81,11 +77,8 @@ void hash_create_sync_obj(hash_table_t *table, hash_table_sync_t type, latch_id_t id, ulint n_sync_obj); #endif /* !UNIV_HOTBACKUP */ -/*************************************************************/ /** - Frees a hash table. */ -void hash_table_free( - /*============*/ - hash_table_t *table); /*!< in, own: hash table */ +/** Frees a hash table. */ +void hash_table_free(hash_table_t *table); /*!< in, own: hash table */ /** Calculates the hash value from a folded value. @param[in] fold folded value @@ -95,8 +88,7 @@ UNIV_INLINE ulint hash_calc_hash(ulint fold, hash_table_t *table); #ifndef UNIV_HOTBACKUP -/********************************************************************/ /** - Assert that the mutex for the table is held */ +/** Assert that the mutex for the table is held */ #define HASH_ASSERT_OWN(TABLE, FOLD) \ ut_ad((TABLE)->type != HASH_TABLE_SYNC_MUTEX || \ (mutex_own(hash_get_mutex((TABLE), FOLD)))); @@ -104,8 +96,7 @@ ulint hash_calc_hash(ulint fold, hash_table_t *table); #define HASH_ASSERT_OWN(TABLE, FOLD) #endif /* !UNIV_HOTBACKUP */ -/*******************************************************************/ /** - Inserts a struct to a hash table. */ +/** Inserts a struct to a hash table. */ #define HASH_INSERT(TYPE, NAME, TABLE, FOLD, DATA) \ do { \ @@ -143,8 +134,7 @@ ulint hash_calc_hash(ulint fold, hash_table_t *table); } while (0) #endif -/*******************************************************************/ /** - Deletes a struct from a hash table. */ +/** Deletes a struct from a hash table. */ #define HASH_DELETE(TYPE, NAME, TABLE, FOLD, DATA) \ do { \ @@ -171,19 +161,16 @@ ulint hash_calc_hash(ulint fold, hash_table_t *table); HASH_INVALIDATE(DATA, NAME); \ } while (0) -/*******************************************************************/ /** - Gets the first struct in a hash chain, NULL if none. */ +/** Gets the first struct in a hash chain, NULL if none. */ #define HASH_GET_FIRST(TABLE, HASH_VAL) \ (hash_get_nth_cell(TABLE, HASH_VAL)->node) -/*******************************************************************/ /** - Gets the next struct in a hash chain, NULL if none. */ +/** Gets the next struct in a hash chain, NULL if none. */ #define HASH_GET_NEXT(NAME, DATA) ((DATA)->NAME) -/********************************************************************/ /** - Looks for a struct in a hash table. */ +/** Looks for a struct in a hash table. */ #define HASH_SEARCH(NAME, TABLE, FOLD, TYPE, DATA, ASSERTION, TEST) \ { \ HASH_ASSERT_OWN(TABLE, FOLD) \ @@ -202,8 +189,7 @@ ulint hash_calc_hash(ulint fold, hash_table_t *table); } \ } -/********************************************************************/ /** - Looks for an item in all hash buckets. */ +/** Looks for an item in all hash buckets. */ #define HASH_SEARCH_ALL(NAME, TABLE, TYPE, DATA, ASSERTION, TEST) \ do { \ ulint i3333; \ @@ -235,22 +221,15 @@ ulint hash_calc_hash(ulint fold, hash_table_t *table); UNIV_INLINE hash_cell_t *hash_get_nth_cell(hash_table_t *table, ulint n); -/*************************************************************/ /** - Clears a hash table so that all the cells become empty. */ +/** Clears a hash table so that all the cells become empty. */ UNIV_INLINE -void hash_table_clear( - /*=============*/ - hash_table_t *table); /*!< in/out: hash table */ +void hash_table_clear(hash_table_t *table); /*!< in/out: hash table */ -/*************************************************************/ /** - Returns the number of cells in a hash table. +/** Returns the number of cells in a hash table. @return number of cells */ UNIV_INLINE -ulint hash_get_n_cells( - /*=============*/ - hash_table_t *table); /*!< in: table */ -/*******************************************************************/ /** - Deletes a struct which is stored in the heap of the hash table, and compacts +ulint hash_get_n_cells(hash_table_t *table); /*!< in: table */ +/** Deletes a struct which is stored in the heap of the hash table, and compacts the heap. The fold value must be stored in the struct NODE in a field named 'fold'. */ @@ -306,8 +285,7 @@ ulint hash_get_n_cells( } while (0) #ifndef UNIV_HOTBACKUP -/****************************************************************/ /** - Move all hash table entries from OLD_TABLE to NEW_TABLE. */ +/** Move all hash table entries from OLD_TABLE to NEW_TABLE. */ #define HASH_MIGRATE(OLD_TABLE, NEW_TABLE, NODE_TYPE, PTR_NAME, FOLD_FUNC) \ do { \ @@ -400,22 +378,13 @@ UNIV_INLINE rw_lock_t *hash_lock_x_confirm(rw_lock_t *hash_lock, hash_table_t *table, ulint fold); -/************************************************************/ /** - Reserves all the locks of a hash table, in an ascending order. */ -void hash_lock_x_all( - /*============*/ - hash_table_t *table); /*!< in: hash table */ -/************************************************************/ /** - Releases all the locks of a hash table, in an ascending order. */ -void hash_unlock_x_all( - /*==============*/ - hash_table_t *table); /*!< in: hash table */ -/************************************************************/ /** - Releases all but passed in lock of a hash table, */ -void hash_unlock_x_all_but( - /*==================*/ - hash_table_t *table, /*!< in: hash table */ - rw_lock_t *keep_lock); /*!< in: lock to keep */ +/** Reserves all the locks of a hash table, in an ascending order. */ +void hash_lock_x_all(hash_table_t *table); /*!< in: hash table */ +/** Releases all the locks of a hash table, in an ascending order. */ +void hash_unlock_x_all(hash_table_t *table); /*!< in: hash table */ +/** Releases all but passed in lock of a hash table, */ +void hash_unlock_x_all_but(hash_table_t *table, /*!< in: hash table */ + rw_lock_t *keep_lock); /*!< in: lock to keep */ #else /* !UNIV_HOTBACKUP */ #define hash_get_heap(table, fold) ((table)->heap) diff --git a/storage/innobase/include/hash0hash.ic b/storage/innobase/include/hash0hash.ic index 15afe0e8fe2a..50455e8e5c6f 100644 --- a/storage/innobase/include/hash0hash.ic +++ b/storage/innobase/include/hash0hash.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/hash0hash.ic +/** @file include/hash0hash.ic The simple hash table utility Created 5/20/1997 Heikki Tuuri @@ -33,14 +32,11 @@ this program; if not, write to the Free Software Foundation, Inc., #include "ut0rnd.h" -/************************************************************/ /** - Gets the nth cell in a hash table. +/** Gets the nth cell in a hash table. @return pointer to cell */ UNIV_INLINE -hash_cell_t *hash_get_nth_cell( - /*==============*/ - hash_table_t *table, /*!< in: hash table */ - ulint n) /*!< in: cell index */ +hash_cell_t *hash_get_nth_cell(hash_table_t *table, /*!< in: hash table */ + ulint n) /*!< in: cell index */ { ut_ad(table); ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); @@ -49,39 +45,30 @@ hash_cell_t *hash_get_nth_cell( return (table->cells + n); } -/*************************************************************/ /** - Clears a hash table so that all the cells become empty. */ +/** Clears a hash table so that all the cells become empty. */ UNIV_INLINE -void hash_table_clear( - /*=============*/ - hash_table_t *table) /*!< in/out: hash table */ +void hash_table_clear(hash_table_t *table) /*!< in/out: hash table */ { ut_ad(table); ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); memset(table->cells, 0x0, table->n_cells * sizeof(*table->cells)); } -/*************************************************************/ /** - Returns the number of cells in a hash table. +/** Returns the number of cells in a hash table. @return number of cells */ UNIV_INLINE -ulint hash_get_n_cells( - /*=============*/ - hash_table_t *table) /*!< in: table */ +ulint hash_get_n_cells(hash_table_t *table) /*!< in: table */ { ut_ad(table); ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); return (table->n_cells); } -/**************************************************************/ /** - Calculates the hash value from a folded value. +/** Calculates the hash value from a folded value. @return hashed value */ UNIV_INLINE -ulint hash_calc_hash( - /*===========*/ - ulint fold, /*!< in: folded value */ - hash_table_t *table) /*!< in: hash table */ +ulint hash_calc_hash(ulint fold, /*!< in: folded value */ + hash_table_t *table) /*!< in: hash table */ { ut_ad(table); ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); @@ -89,14 +76,11 @@ ulint hash_calc_hash( } #ifndef UNIV_HOTBACKUP -/************************************************************/ /** - Gets the sync object index for a fold value in a hash table. +/** Gets the sync object index for a fold value in a hash table. @return index */ UNIV_INLINE -ulint hash_get_sync_obj_index( - /*====================*/ - hash_table_t *table, /*!< in: hash table */ - ulint fold) /*!< in: fold */ +ulint hash_get_sync_obj_index(hash_table_t *table, /*!< in: hash table */ + ulint fold) /*!< in: fold */ { ut_ad(table); ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); @@ -105,14 +89,11 @@ ulint hash_get_sync_obj_index( return (ut_2pow_remainder(hash_calc_hash(fold, table), table->n_sync_obj)); } -/************************************************************/ /** - Gets the nth heap in a hash table. +/** Gets the nth heap in a hash table. @return mem heap */ UNIV_INLINE -mem_heap_t *hash_get_nth_heap( - /*==============*/ - hash_table_t *table, /*!< in: hash table */ - ulint i) /*!< in: index of the heap */ +mem_heap_t *hash_get_nth_heap(hash_table_t *table, /*!< in: hash table */ + ulint i) /*!< in: index of the heap */ { ut_ad(table); ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); @@ -122,14 +103,11 @@ mem_heap_t *hash_get_nth_heap( return (table->heaps[i]); } -/************************************************************/ /** - Gets the heap for a fold value in a hash table. +/** Gets the heap for a fold value in a hash table. @return mem heap */ UNIV_INLINE -mem_heap_t *hash_get_heap( - /*==========*/ - hash_table_t *table, /*!< in: hash table */ - ulint fold) /*!< in: fold */ +mem_heap_t *hash_get_heap(hash_table_t *table, /*!< in: hash table */ + ulint fold) /*!< in: fold */ { ulint i; @@ -145,14 +123,11 @@ mem_heap_t *hash_get_heap( return (hash_get_nth_heap(table, i)); } -/************************************************************/ /** - Gets the nth mutex in a hash table. +/** Gets the nth mutex in a hash table. @return mutex */ UNIV_INLINE -ib_mutex_t *hash_get_nth_mutex( - /*===============*/ - hash_table_t *table, /*!< in: hash table */ - ulint i) /*!< in: index of the mutex */ +ib_mutex_t *hash_get_nth_mutex(hash_table_t *table, /*!< in: hash table */ + ulint i) /*!< in: index of the mutex */ { ut_ad(table); ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); @@ -162,14 +137,11 @@ ib_mutex_t *hash_get_nth_mutex( return (table->sync_obj.mutexes + i); } -/************************************************************/ /** - Gets the mutex for a fold value in a hash table. +/** Gets the mutex for a fold value in a hash table. @return mutex */ UNIV_INLINE -ib_mutex_t *hash_get_mutex( - /*===========*/ - hash_table_t *table, /*!< in: hash table */ - ulint fold) /*!< in: fold */ +ib_mutex_t *hash_get_mutex(hash_table_t *table, /*!< in: hash table */ + ulint fold) /*!< in: fold */ { ulint i; @@ -181,14 +153,11 @@ ib_mutex_t *hash_get_mutex( return (hash_get_nth_mutex(table, i)); } -/************************************************************/ /** - Gets the nth rw_lock in a hash table. +/** Gets the nth rw_lock in a hash table. @return rw_lock */ UNIV_INLINE -rw_lock_t *hash_get_nth_lock( - /*==============*/ - hash_table_t *table, /*!< in: hash table */ - ulint i) /*!< in: index of the rw_lock */ +rw_lock_t *hash_get_nth_lock(hash_table_t *table, /*!< in: hash table */ + ulint i) /*!< in: index of the rw_lock */ { ut_ad(table); ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); @@ -198,14 +167,11 @@ rw_lock_t *hash_get_nth_lock( return (table->sync_obj.rw_locks + i); } -/************************************************************/ /** - Gets the rw_lock for a fold value in a hash table. +/** Gets the rw_lock for a fold value in a hash table. @return rw_lock */ UNIV_INLINE -rw_lock_t *hash_get_lock( - /*==========*/ - hash_table_t *table, /*!< in: hash table */ - ulint fold) /*!< in: fold */ +rw_lock_t *hash_get_lock(hash_table_t *table, /*!< in: hash table */ + ulint fold) /*!< in: fold */ { ulint i; diff --git a/storage/innobase/include/ib0mutex.h b/storage/innobase/include/ib0mutex.h index 77242fb25450..7eeae16337c1 100644 --- a/storage/innobase/include/ib0mutex.h +++ b/storage/innobase/include/ib0mutex.h @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/ib0mutex.h +/** @file include/ib0mutex.h Policy based mutexes. Created 2013-03-26 Sunny Bains. diff --git a/storage/innobase/include/ibuf0ibuf.h b/storage/innobase/include/ibuf0ibuf.h index ab1619910c8d..edc58dfcc309 100644 --- a/storage/innobase/include/ibuf0ibuf.h +++ b/storage/innobase/include/ibuf0ibuf.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/ibuf0ibuf.h +/** @file include/ibuf0ibuf.h Insert buffer Created 7/19/1997 Heikki Tuuri @@ -95,41 +94,24 @@ affects the free space. It is unsafe to increment the bits in a separately committed mini-transaction, because in crash recovery, the free bits could momentarily be set too high. */ -/******************************************************************/ /** - Creates the insert buffer data structure at a database startup. */ +/** Creates the insert buffer data structure at a database startup. */ void ibuf_init_at_db_start(void); -/*=======================*/ -/*********************************************************************/ /** - Updates the max_size value for ibuf. */ -void ibuf_max_size_update( - /*=================*/ - ulint new_val); /*!< in: new value in terms of - percentage of the buffer pool size */ -/*********************************************************************/ /** - Reads the biggest tablespace id from the high end of the insert buffer +/** Updates the max_size value for ibuf. */ +void ibuf_max_size_update(ulint new_val); /*!< in: new value in terms of + percentage of the buffer pool size */ +/** Reads the biggest tablespace id from the high end of the insert buffer tree and updates the counter in fil_system. */ void ibuf_update_max_tablespace_id(void); -/*===============================*/ -/***************************************************************/ /** - Starts an insert buffer mini-transaction. */ +/** Starts an insert buffer mini-transaction. */ UNIV_INLINE -void ibuf_mtr_start( - /*===========*/ - mtr_t *mtr); /*!< out: mini-transaction */ -/***************************************************************/ /** - Commits an insert buffer mini-transaction. */ +void ibuf_mtr_start(mtr_t *mtr); /*!< out: mini-transaction */ +/** Commits an insert buffer mini-transaction. */ UNIV_INLINE -void ibuf_mtr_commit( - /*============*/ - mtr_t *mtr); /*!< in/out: mini-transaction */ -/*********************************************************************/ /** - Initializes an ibuf bitmap page. */ -void ibuf_bitmap_page_init( - /*==================*/ - buf_block_t *block, /*!< in: bitmap page */ - mtr_t *mtr); /*!< in: mtr */ -/************************************************************************/ /** - Resets the free bits of the page in the ibuf bitmap. This is done in a +void ibuf_mtr_commit(mtr_t *mtr); /*!< in/out: mini-transaction */ +/** Initializes an ibuf bitmap page. */ +void ibuf_bitmap_page_init(buf_block_t *block, /*!< in: bitmap page */ + mtr_t *mtr); /*!< in: mtr */ +/** Resets the free bits of the page in the ibuf bitmap. This is done in a separate mini-transaction, hence this operation does not restrict further work to only ibuf bitmap operations, which would result if the latch to the bitmap page were kept. NOTE: The free bits in the insert @@ -138,7 +120,6 @@ void ibuf_bitmap_page_init( that is committed before the mini-transaction that affects the free space. */ void ibuf_reset_free_bits( - /*=================*/ buf_block_t *block); /*!< in: index page; free bits are set to 0 if the index is a non-clustered non-unique, and page level is 0 */ @@ -167,44 +148,36 @@ UNIV_INLINE void ibuf_update_free_bits_if_full(buf_block_t *block, ulint max_ins_size, ulint increase); -/**********************************************************************/ /** - Updates the free bits for an uncompressed page to reflect the present +/** Updates the free bits for an uncompressed page to reflect the present state. Does this in the mtr given, which means that the latching order rules virtually prevent any further operations for this OS thread until mtr is committed. NOTE: The free bits in the insert buffer bitmap must never exceed the free space on a page. It is safe to set the free bits in the same mini-transaction that updated the page. */ -void ibuf_update_free_bits_low( - /*======================*/ - const buf_block_t *block, /*!< in: index page */ - ulint max_ins_size, /*!< in: value of - maximum insert size - with reorganize before - the latest operation - performed to the page */ - mtr_t *mtr); /*!< in/out: mtr */ -/**********************************************************************/ /** - Updates the free bits for a compressed page to reflect the present +void ibuf_update_free_bits_low(const buf_block_t *block, /*!< in: index page */ + ulint max_ins_size, /*!< in: value of + maximum insert size + with reorganize before + the latest operation + performed to the page */ + mtr_t *mtr); /*!< in/out: mtr */ +/** Updates the free bits for a compressed page to reflect the present state. Does this in the mtr given, which means that the latching order rules virtually prevent any further operations for this OS thread until mtr is committed. NOTE: The free bits in the insert buffer bitmap must never exceed the free space on a page. It is safe to set the free bits in the same mini-transaction that updated the page. */ -void ibuf_update_free_bits_zip( - /*======================*/ - buf_block_t *block, /*!< in/out: index page */ - mtr_t *mtr); /*!< in/out: mtr */ -/**********************************************************************/ /** - Updates the free bits for the two pages to reflect the present state. +void ibuf_update_free_bits_zip(buf_block_t *block, /*!< in/out: index page */ + mtr_t *mtr); /*!< in/out: mtr */ +/** Updates the free bits for the two pages to reflect the present state. Does this in the mtr given, which means that the latching order rules virtually prevent any further operations until mtr is committed. NOTE: The free bits in the insert buffer bitmap must never exceed the free space on a page. It is safe to set the free bits in the same mini-transaction that updated the pages. */ void ibuf_update_free_bits_for_two_pages_low( - /*====================================*/ buf_block_t *block1, /*!< in: index page */ buf_block_t *block2, /*!< in: index page */ mtr_t *mtr); /*!< in: mtr */ @@ -218,17 +191,14 @@ and recommended. UNIV_INLINE ibool ibuf_should_try(dict_index_t *index, ulint ignore_sec_unique); -/******************************************************************/ /** - Returns TRUE if the current OS thread is performing an insert buffer +/** Returns TRUE if the current OS thread is performing an insert buffer routine. For instance, a read-ahead of non-ibuf pages is forbidden by threads that are executing an insert buffer routine. @return true if inside an insert buffer routine */ UNIV_INLINE -ibool ibuf_inside( - /*========*/ - const mtr_t *mtr) /*!< in: mini-transaction */ +ibool ibuf_inside(const mtr_t *mtr) /*!< in: mini-transaction */ MY_ATTRIBUTE((warn_unused_result)); /** Checks if a page address is an ibuf bitmap page (level 3 page) address. @@ -280,12 +250,10 @@ Must not be called when recv_no_ibuf_operations==true. ibuf_page_low(page_id, page_size, __FILE__, __LINE__, mtr) #endif /* UVIV_DEBUG */ -/***********************************************************************/ /** - Frees excess pages from the ibuf free list. This function is called when an OS - thread calls fsp services to allocate a new file segment, or a new page to a +/** Frees excess pages from the ibuf free list. This function is called when an + OS thread calls fsp services to allocate a new file segment, or a new page to a file segment, and the thread did not own the fsp latch before this call. */ void ibuf_free_excess_pages(void); -/*========================*/ /** Buffer an operation in the insert/delete buffer, instead of doing it directly to the disk page, if this is possible. Does not do it if the index @@ -317,14 +285,11 @@ void ibuf_merge_or_delete_for_page(buf_block_t *block, const page_id_t &page_id, const page_size_t *page_size, ibool update_ibuf_bitmap); -/*********************************************************************/ /** - Deletes all entries in the insert buffer for a given space id. This is used +/** Deletes all entries in the insert buffer for a given space id. This is used in DISCARD TABLESPACE and IMPORT TABLESPACE. NOTE: this does not update the page free bitmaps in the space. The space will become CORRUPT when you call this function! */ -void ibuf_delete_for_discarded_space( - /*============================*/ - space_id_t space); /*!< in: space id */ +void ibuf_delete_for_discarded_space(space_id_t space); /*!< in: space id */ /** Contract the change buffer by reading pages to the buffer pool. @param[in] full If true, do a full contraction based on PCT_IO(100). If false, the size of contract batch is determined @@ -337,20 +302,15 @@ ulint ibuf_merge_in_background(bool full); /** Contracts insert buffer trees by reading pages referring to space_id to the buffer pool. @returns number of pages merged.*/ -ulint ibuf_merge_space( - /*=============*/ - space_id_t space); /*!< in: space id */ +ulint ibuf_merge_space(space_id_t space); /*!< in: space id */ #endif /* !UNIV_HOTBACKUP */ -/*********************************************************************/ /** - Parses a redo log record of an ibuf bitmap page init. +/** Parses a redo log record of an ibuf bitmap page init. @return end of log record or NULL */ -byte *ibuf_parse_bitmap_init( - /*===================*/ - byte *ptr, /*!< in: buffer */ - byte *end_ptr, /*!< in: buffer end */ - buf_block_t *block, /*!< in: block or NULL */ - mtr_t *mtr); /*!< in: mtr or NULL */ +byte *ibuf_parse_bitmap_init(byte *ptr, /*!< in: buffer */ + byte *end_ptr, /*!< in: buffer end */ + buf_block_t *block, /*!< in: block or NULL */ + mtr_t *mtr); /*!< in: mtr or NULL */ #ifndef UNIV_HOTBACKUP #ifdef UNIV_IBUF_COUNT_DEBUG @@ -361,34 +321,23 @@ this page */ ulint ibuf_count_get(const page_id_t &page_id); #endif -/******************************************************************/ /** - Looks if the insert buffer is empty. +/** Looks if the insert buffer is empty. @return true if empty */ bool ibuf_is_empty(void); -/*===============*/ -/******************************************************************/ /** - Prints info of ibuf. */ -void ibuf_print( - /*=======*/ - FILE *file); /*!< in: file where to print */ +/** Prints info of ibuf. */ +void ibuf_print(FILE *file); /*!< in: file where to print */ /******************************************************************** Read the first two bytes from a record's fourth field (counter field in new records; something else in older records). @return "counter" field, or ULINT_UNDEFINED if for some reason it can't be read */ -ulint ibuf_rec_get_counter( - /*=================*/ - const rec_t *rec); /*!< in: ibuf record */ -/******************************************************************/ /** - Closes insert buffer and frees the data structures. */ +ulint ibuf_rec_get_counter(const rec_t *rec); /*!< in: ibuf record */ +/** Closes insert buffer and frees the data structures. */ void ibuf_close(void); -/*============*/ -/******************************************************************/ /** - Checks the insert buffer bitmaps on IMPORT TABLESPACE. +/** Checks the insert buffer bitmaps on IMPORT TABLESPACE. @return DB_SUCCESS or error code */ dberr_t ibuf_check_bitmap_on_import( - /*========================*/ const trx_t *trx, /*!< in: transaction */ space_id_t space_id) /*!< in: tablespace identifier */ MY_ATTRIBUTE((warn_unused_result)); diff --git a/storage/innobase/include/ibuf0ibuf.ic b/storage/innobase/include/ibuf0ibuf.ic index 8a75a422a781..be502e71a76f 100644 --- a/storage/innobase/include/ibuf0ibuf.ic +++ b/storage/innobase/include/ibuf0ibuf.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/ibuf0ibuf.ic +/** @file include/ibuf0ibuf.ic Insert buffer Created 7/19/1997 Heikki Tuuri @@ -43,22 +42,16 @@ buffer inserts to this page. If there is this much of free space, the corresponding bits are set in the ibuf bitmap. */ #define IBUF_PAGE_SIZE_PER_FREE_SPACE 32 -/***************************************************************/ /** - Starts an insert buffer mini-transaction. */ +/** Starts an insert buffer mini-transaction. */ UNIV_INLINE -void ibuf_mtr_start( - /*===========*/ - mtr_t *mtr) /*!< out: mini-transaction */ +void ibuf_mtr_start(mtr_t *mtr) /*!< out: mini-transaction */ { mtr_start(mtr); mtr->enter_ibuf(); } -/***************************************************************/ /** - Commits an insert buffer mini-transaction. */ +/** Commits an insert buffer mini-transaction. */ UNIV_INLINE -void ibuf_mtr_commit( - /*============*/ - mtr_t *mtr) /*!< in/out: mini-transaction */ +void ibuf_mtr_commit(mtr_t *mtr) /*!< in/out: mini-transaction */ { ut_ad(mtr->is_inside_ibuf()); ut_d(mtr->exit_ibuf()); @@ -96,13 +89,11 @@ struct ibuf_t { index being dropped */ }; -/************************************************************************/ /** - Sets the free bit of the page in the ibuf bitmap. This is done in a separate +/** Sets the free bit of the page in the ibuf bitmap. This is done in a separate mini-transaction, hence this operation does not restrict further work to only ibuf bitmap operations, which would result if the latch to the bitmap page were kept. */ void ibuf_set_free_bits_func( - /*====================*/ buf_block_t *block, /*!< in: index page of a non-clustered index; free bit is reset if page level is 0 */ #ifdef UNIV_IBUF_DEBUG @@ -117,17 +108,14 @@ void ibuf_set_free_bits_func( #define ibuf_set_free_bits(b, v, max) ibuf_set_free_bits_func(b, v) #endif /* UNIV_IBUF_DEBUG */ -/**********************************************************************/ /** - A basic partial test if an insert to the insert buffer could be possible and +/** A basic partial test if an insert to the insert buffer could be possible and recommended. */ UNIV_INLINE -ibool ibuf_should_try( - /*============*/ - dict_index_t *index, /*!< in: index where to insert */ - ulint ignore_sec_unique) /*!< in: if != 0, we should - ignore UNIQUE constraint on - a secondary index when we - decide */ +ibool ibuf_should_try(dict_index_t *index, /*!< in: index where to insert */ + ulint ignore_sec_unique) /*!< in: if != 0, we should + ignore UNIQUE constraint on + a secondary index when we + decide */ { return (innodb_change_buffering != IBUF_USE_NONE && ibuf->max_size != 0 && index->space != dict_sys_t::s_space_id && !index->is_clustered() && @@ -137,17 +125,14 @@ ibool ibuf_should_try( srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE); } -/******************************************************************/ /** - Returns TRUE if the current OS thread is performing an insert buffer +/** Returns TRUE if the current OS thread is performing an insert buffer routine. For instance, a read-ahead of non-ibuf pages is forbidden by threads that are executing an insert buffer routine. @return true if inside an insert buffer routine */ UNIV_INLINE -ibool ibuf_inside( - /*========*/ - const mtr_t *mtr) /*!< in: mini-transaction */ +ibool ibuf_inside(const mtr_t *mtr) /*!< in: mini-transaction */ { return (mtr->is_inside_ibuf()); } @@ -204,12 +189,11 @@ ulint ibuf_index_page_calc_free_from_bits(const page_size_t &page_size, return (bits * (page_size.physical() / IBUF_PAGE_SIZE_PER_FREE_SPACE)); } -/*********************************************************************/ /** - Translates the free space on a compressed page to a value in the ibuf bitmap. +/** Translates the free space on a compressed page to a value in the ibuf + bitmap. @return value for ibuf bitmap bits */ UNIV_INLINE ulint ibuf_index_page_calc_free_zip( - /*==========================*/ const buf_block_t *block) /*!< in: buffer block */ { ulint max_ins_size; @@ -241,12 +225,10 @@ ulint ibuf_index_page_calc_free_zip( max_ins_size)); } -/*********************************************************************/ /** - Translates the free space on a page to a value in the ibuf bitmap. +/** Translates the free space on a page to a value in the ibuf bitmap. @return value for ibuf bitmap bits */ UNIV_INLINE ulint ibuf_index_page_calc_free( - /*======================*/ const buf_block_t *block) /*!< in: buffer block */ { if (!block->page.size.is_compressed()) { @@ -262,8 +244,7 @@ ulint ibuf_index_page_calc_free( } } -/************************************************************************/ /** - Updates the free bits of an uncompressed page in the ibuf bitmap if +/** Updates the free bits of an uncompressed page in the ibuf bitmap if there is not enough free on the page any more. This is done in a separate mini-transaction, hence this operation does not restrict further work to only ibuf bitmap operations, which would result if the @@ -277,7 +258,6 @@ ulint ibuf_index_page_calc_free( recovery. */ UNIV_INLINE void ibuf_update_free_bits_if_full( - /*==========================*/ buf_block_t *block, /*!< in: index page to which we have added new records; the free bits are updated if the index is non-clustered and non-unique and diff --git a/storage/innobase/include/ibuf0types.h b/storage/innobase/include/ibuf0types.h index b4833156deb9..57184f1d8918 100644 --- a/storage/innobase/include/ibuf0types.h +++ b/storage/innobase/include/ibuf0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/ibuf0types.h +/** @file include/ibuf0types.h Insert buffer global types Created 7/29/1997 Heikki Tuuri diff --git a/storage/innobase/include/lock0iter.h b/storage/innobase/include/lock0iter.h index 21569d167a3f..54e42a96b4a4 100644 --- a/storage/innobase/include/lock0iter.h +++ b/storage/innobase/include/lock0iter.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/lock0iter.h +/** @file include/lock0iter.h Lock queue iterator type and function prototypes. Created July 16, 2007 Vasil Dimov @@ -45,8 +44,7 @@ struct lock_queue_iterator_t { ulint bit_no; }; -/*******************************************************************/ /** - Initialize lock queue iterator so that it starts to iterate from +/** Initialize lock queue iterator so that it starts to iterate from "lock". bit_no specifies the record number within the heap where the record is stored. It can be undefined (ULINT_UNDEFINED) in two cases: 1. If the lock is a table lock, thus we have a table lock queue; @@ -55,19 +53,16 @@ struct lock_queue_iterator_t { lock_rec_find_set_bit(). There is exactly one bit set in the bitmap of a wait lock. */ void lock_queue_iterator_reset( - /*======================*/ lock_queue_iterator_t *iter, /*!< out: iterator */ const lock_t *lock, /*!< in: lock to start from */ ulint bit_no); /*!< in: record number in the heap */ -/*******************************************************************/ /** - Gets the previous lock in the lock queue, returns NULL if there are no +/** Gets the previous lock in the lock queue, returns NULL if there are no more locks (i.e. the current lock is the first one). The iterator is receded (if not-NULL is returned). @return previous lock or NULL */ const lock_t *lock_queue_iterator_get_prev( - /*=========================*/ lock_queue_iterator_t *iter); /*!< in/out: iterator */ #endif /* lock0iter_h */ diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h index b165969e4295..175f9a74bc38 100644 --- a/storage/innobase/include/lock0lock.h +++ b/storage/innobase/include/lock0lock.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/lock0lock.h +/** @file include/lock0lock.h The transaction lock system Created 5/7/1996 Heikki Tuuri @@ -55,56 +54,41 @@ class ReadView; extern bool innobase_deadlock_detect; -/*********************************************************************/ /** - Gets the size of a lock struct. +/** Gets the size of a lock struct. @return size in bytes */ ulint lock_get_size(void); -/*===============*/ -/*********************************************************************/ /** - Creates the lock system at database start. */ +/** Creates the lock system at database start. */ void lock_sys_create( - /*============*/ ulint n_cells); /*!< in: number of slots in lock hash table */ /** Resize the lock hash table. @param[in] n_cells number of slots in lock hash table */ void lock_sys_resize(ulint n_cells); -/*********************************************************************/ /** - Closes the lock system at database shutdown. */ +/** Closes the lock system at database shutdown. */ void lock_sys_close(void); -/*================*/ -/*********************************************************************/ /** - Gets the heap_no of the smallest user record on a page. +/** Gets the heap_no of the smallest user record on a page. @return heap_no of smallest user record, or PAGE_HEAP_NO_SUPREMUM */ UNIV_INLINE -ulint lock_get_min_heap_no( - /*=================*/ - const buf_block_t *block); /*!< in: buffer block */ -/*************************************************************/ /** - Updates the lock table when we have reorganized a page. NOTE: we copy +ulint lock_get_min_heap_no(const buf_block_t *block); /*!< in: buffer block */ +/** Updates the lock table when we have reorganized a page. NOTE: we copy also the locks set on the infimum of the page; the infimum may carry locks if an update of a record is occurring on the page, and its locks were temporarily stored on the infimum. */ void lock_move_reorganize_page( - /*======================*/ const buf_block_t *block, /*!< in: old index page, now reorganized */ const buf_block_t *oblock); /*!< in: copy of the old, not reorganized page */ -/*************************************************************/ /** - Moves the explicit locks on user records to another page if a record +/** Moves the explicit locks on user records to another page if a record list end is moved to another page. */ void lock_move_rec_list_end( - /*===================*/ const buf_block_t *new_block, /*!< in: index page to move to */ const buf_block_t *block, /*!< in: index page */ const rec_t *rec); /*!< in: record on page: this is the first record moved */ -/*************************************************************/ /** - Moves the explicit locks on user records to another page if a record +/** Moves the explicit locks on user records to another page if a record list start is moved to another page. */ void lock_move_rec_list_start( - /*=====================*/ const buf_block_t *new_block, /*!< in: index page to move to */ const buf_block_t *block, /*!< in: index page */ const rec_t *rec, /*!< in: record on page: @@ -115,16 +99,12 @@ void lock_move_rec_list_start( record on new_page before the records were copied */ -/*************************************************************/ /** - Updates the lock table when a page is split to the right. */ +/** Updates the lock table when a page is split to the right. */ void lock_update_split_right( - /*====================*/ const buf_block_t *right_block, /*!< in: right page */ const buf_block_t *left_block); /*!< in: left page */ -/*************************************************************/ /** - Updates the lock table when a page is merged to the right. */ +/** Updates the lock table when a page is merged to the right. */ void lock_update_merge_right( - /*====================*/ const buf_block_t *right_block, /*!< in: right page to which merged */ const rec_t *orig_succ, /*!< in: original @@ -134,36 +114,28 @@ void lock_update_merge_right( const buf_block_t *left_block); /*!< in: merged index page which will be discarded */ -/*************************************************************/ /** - Updates the lock table when the root page is copied to another in +/** Updates the lock table when the root page is copied to another in btr_root_raise_and_insert. Note that we leave lock structs on the root page, even though they do not make sense on other than leaf pages: the reason is that in a pessimistic update the infimum record of the root page will act as a dummy carrier of the locks of the record to be updated. */ void lock_update_root_raise( - /*===================*/ const buf_block_t *block, /*!< in: index page to which copied */ const buf_block_t *root); /*!< in: root page */ -/*************************************************************/ /** - Updates the lock table when a page is copied to another and the original page - is removed from the chain of leaf pages, except if page is the root! */ +/** Updates the lock table when a page is copied to another and the original + page is removed from the chain of leaf pages, except if page is the root! */ void lock_update_copy_and_discard( - /*=========================*/ const buf_block_t *new_block, /*!< in: index page to which copied */ const buf_block_t *block); /*!< in: index page; NOT the root! */ -/*************************************************************/ /** - Updates the lock table when a page is split to the left. */ +/** Updates the lock table when a page is split to the left. */ void lock_update_split_left( - /*===================*/ const buf_block_t *right_block, /*!< in: right page */ const buf_block_t *left_block); /*!< in: left page */ -/*************************************************************/ /** - Updates the lock table when a page is merged to the left. */ +/** Updates the lock table when a page is merged to the left. */ void lock_update_merge_left( - /*===================*/ const buf_block_t *left_block, /*!< in: left page to which merged */ const rec_t *orig_pred, /*!< in: original predecessor @@ -171,11 +143,9 @@ void lock_update_merge_left( before merge */ const buf_block_t *right_block); /*!< in: merged index page which will be discarded */ -/*************************************************************/ /** - Resets the original locks on heir and replaces them with gap type locks +/** Resets the original locks on heir and replaces them with gap type locks inherited from rec. */ void lock_rec_reset_and_inherit_gap_locks( - /*=================================*/ const buf_block_t *heir_block, /*!< in: block containing the record which inherits */ const buf_block_t *block, /*!< in: block containing the @@ -186,48 +156,38 @@ void lock_rec_reset_and_inherit_gap_locks( inheriting record */ ulint heap_no); /*!< in: heap_no of the donating record */ -/*************************************************************/ /** - Updates the lock table when a page is discarded. */ +/** Updates the lock table when a page is discarded. */ void lock_update_discard( - /*================*/ const buf_block_t *heir_block, /*!< in: index page which will inherit the locks */ ulint heir_heap_no, /*!< in: heap_no of the record which will inherit the locks */ const buf_block_t *block); /*!< in: index page which will be discarded */ -/*************************************************************/ /** - Updates the lock table when a new user record is inserted. */ +/** Updates the lock table when a new user record is inserted. */ void lock_update_insert( - /*===============*/ const buf_block_t *block, /*!< in: buffer block containing rec */ const rec_t *rec); /*!< in: the inserted record */ -/*************************************************************/ /** - Updates the lock table when a record is removed. */ +/** Updates the lock table when a record is removed. */ void lock_update_delete( - /*===============*/ const buf_block_t *block, /*!< in: buffer block containing rec */ const rec_t *rec); /*!< in: the record to be removed */ -/*********************************************************************/ /** - Stores on the page infimum record the explicit locks of another record. +/** Stores on the page infimum record the explicit locks of another record. This function is used to store the lock state of a record when it is updated and the size of the record changes in the update. The record is in such an update moved, perhaps to another page. The infimum record acts as a dummy carrier record, taking care of lock releases while the actual record is being moved. */ void lock_rec_store_on_page_infimum( - /*===========================*/ const buf_block_t *block, /*!< in: buffer block containing rec */ const rec_t *rec); /*!< in: record whose lock state is stored on the infimum record of the same page; lock bits are reset on the record */ -/*********************************************************************/ /** - Restores the state of explicit lock requests on a single record, where the +/** Restores the state of explicit lock requests on a single record, where the state was stored on the infimum of the page. */ void lock_rec_restore_from_page_infimum( - /*===============================*/ const buf_block_t *block, /*!< in: buffer block containing rec */ const rec_t *rec, /*!< in: record whose lock state is restored */ @@ -236,23 +196,18 @@ void lock_rec_restore_from_page_infimum( whose infimum stored the lock state; lock bits are reset on the infimum */ -/*********************************************************************/ /** - Determines if there are explicit record locks on a page. +/** Determines if there are explicit record locks on a page. @return an explicit record lock on the page, or NULL if there are none */ -lock_t *lock_rec_expl_exist_on_page( - /*========================*/ - space_id_t space, /*!< in: space id */ - page_no_t page_no) /*!< in: page number */ +lock_t *lock_rec_expl_exist_on_page(space_id_t space, /*!< in: space id */ + page_no_t page_no) /*!< in: page number */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Checks if locks of other transactions prevent an immediate insert of +/** Checks if locks of other transactions prevent an immediate insert of a record. If they do, first tests if the query thread should anyway be suspended for some reason; if not, then puts the transaction and the query thread to the lock wait state and inserts a waiting request for a gap x-lock to the lock queue. @return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ dberr_t lock_rec_insert_check_and_lock( - /*===========================*/ ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG bit is set, does nothing */ const rec_t *rec, /*!< in: record after which to insert */ @@ -287,8 +242,7 @@ dberr_t lock_rec_enqueue_waiting(ulint type_mode, const buf_block_t *block, ulint heap_no, dict_index_t *index, que_thr_t *thr, lock_prdt_t *prdt); -/*********************************************************************/ /** - Checks if locks of other transactions prevent an immediate modify (update, +/** Checks if locks of other transactions prevent an immediate modify (update, delete mark, or delete unmark) of a clustered index record. If they do, first tests if the query thread should anyway be suspended for some reason; if not, then puts the transaction and the query thread to the @@ -296,7 +250,6 @@ dberr_t lock_rec_enqueue_waiting(ulint type_mode, const buf_block_t *block, lock queue. @return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ dberr_t lock_clust_rec_modify_check_and_lock( - /*=================================*/ ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG bit is set, does nothing */ const buf_block_t *block, /*!< in: buffer block of rec */ @@ -306,12 +259,10 @@ dberr_t lock_clust_rec_modify_check_and_lock( const ulint *offsets, /*!< in: rec_get_offsets(rec, index) */ que_thr_t *thr) /*!< in: query thread */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Checks if locks of other transactions prevent an immediate modify +/** Checks if locks of other transactions prevent an immediate modify (delete mark or delete unmark) of a secondary index record. @return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ dberr_t lock_sec_rec_modify_check_and_lock( - /*===============================*/ ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG bit is set, does nothing */ buf_block_t *block, /*!< in/out: buffer block of rec */ @@ -375,8 +326,7 @@ dberr_t lock_clust_rec_read_check_and_lock( dict_index_t *index, const ulint *offsets, select_mode sel_mode, lock_mode mode, ulint gap_mode, que_thr_t *thr); -/*********************************************************************/ /** - Checks if locks of other transactions prevent an immediate read, or passing +/** Checks if locks of other transactions prevent an immediate read, or passing over by a read cursor, of a clustered index record. If they do, first tests if the query thread should anyway be suspended for some reason; if not, then puts the transaction and the query thread to the lock wait state and inserts a @@ -386,7 +336,6 @@ dberr_t lock_clust_rec_read_check_and_lock( "offsets". @return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ dberr_t lock_clust_rec_read_check_and_lock_alt( - /*===================================*/ ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG bit is set, does nothing */ const buf_block_t *block, /*!< in: buffer block of rec */ @@ -404,19 +353,16 @@ dberr_t lock_clust_rec_read_check_and_lock_alt( LOCK_REC_NOT_GAP */ que_thr_t *thr) /*!< in: query thread */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Checks that a record is seen in a consistent read. +/** Checks that a record is seen in a consistent read. @return true if sees, or false if an earlier version of the record should be retrieved */ bool lock_clust_rec_cons_read_sees( - /*==========================*/ const rec_t *rec, /*!< in: user record which should be read or passed over by a read cursor */ dict_index_t *index, /*!< in: clustered index */ const ulint *offsets, /*!< in: rec_get_offsets(rec, index) */ ReadView *view); /*!< in: consistent read view */ -/*********************************************************************/ /** - Checks that a non-clustered index record is seen in a consistent read. +/** Checks that a non-clustered index record is seen in a consistent read. NOTE that a non-clustered index page contains so little information on its modifications that also in the case false, the present version of @@ -426,32 +372,25 @@ bool lock_clust_rec_cons_read_sees( @return true if certainly sees, or false if an earlier version of the clustered index record might be needed */ bool lock_sec_rec_cons_read_sees( - /*========================*/ const rec_t *rec, /*!< in: user record which should be read or passed over by a read cursor */ const dict_index_t *index, /*!< in: index */ const ReadView *view) /*!< in: consistent read view */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Locks the specified database table in the mode given. If the lock cannot +/** Locks the specified database table in the mode given. If the lock cannot be granted immediately, the query thread is put to wait. @return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ -dberr_t lock_table( - /*=======*/ - ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG bit is set, - does nothing */ - dict_table_t *table, /*!< in/out: database table - in dictionary cache */ - lock_mode mode, /*!< in: lock mode */ - que_thr_t *thr) /*!< in: query thread */ +dberr_t lock_table(ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG bit is set, + does nothing */ + dict_table_t *table, /*!< in/out: database table + in dictionary cache */ + lock_mode mode, /*!< in: lock mode */ + que_thr_t *thr) /*!< in: query thread */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Creates a table IX lock object for a resurrected transaction. */ -void lock_table_ix_resurrect( - /*====================*/ - dict_table_t *table, /*!< in/out: table */ - trx_t *trx); /*!< in/out: transaction */ +/** Creates a table IX lock object for a resurrected transaction. */ +void lock_table_ix_resurrect(dict_table_t *table, /*!< in/out: table */ + trx_t *trx); /*!< in/out: transaction */ /** Sets a lock on a table based on the given mode. @param[in] table table to lock @@ -461,24 +400,19 @@ void lock_table_ix_resurrect( dberr_t lock_table_for_trx(dict_table_t *table, trx_t *trx, enum lock_mode mode) MY_ATTRIBUTE((nonnull, warn_unused_result)); -/*************************************************************/ /** - Removes a granted record lock of a transaction from the queue and grants +/** Removes a granted record lock of a transaction from the queue and grants locks to other transactions waiting in the queue if they now are entitled to a lock. */ void lock_rec_unlock( - /*============*/ trx_t *trx, /*!< in/out: transaction that has set a record lock */ const buf_block_t *block, /*!< in: buffer block containing rec */ const rec_t *rec, /*!< in: record */ lock_mode lock_mode); /*!< in: LOCK_S or LOCK_X */ -/*********************************************************************/ /** - Releases a transaction's locks, and releases possible other transactions +/** Releases a transaction's locks, and releases possible other transactions waiting because of these locks. Change the state of the transaction to TRX_STATE_COMMITTED_IN_MEMORY. */ -void lock_trx_release_locks( - /*===================*/ - trx_t *trx); /*!< in/out: transaction */ +void lock_trx_release_locks(trx_t *trx); /*!< in/out: transaction */ /** Release read locks of a transacion. It is called during XA prepare to release locks early. @@ -486,27 +420,22 @@ prepare to release locks early. @param[in] only_gap release only GAP locks */ void lock_trx_release_read_locks(trx_t *trx, bool only_gap); -/*********************************************************************/ /** - Removes locks on a table to be dropped. +/** Removes locks on a table to be dropped. If remove_also_table_sx_locks is TRUE then table-level S and X locks are also removed in addition to other table-level and record-level locks. No lock, that is going to be removed, is allowed to be a wait lock. */ void lock_remove_all_on_table( - /*=====================*/ dict_table_t *table, /*!< in: table to be dropped or discarded */ ibool remove_also_table_sx_locks); /*!< in: also removes table S and X locks */ -/*********************************************************************/ /** - Calculates the fold value of a page file address: used in inserting or +/** Calculates the fold value of a page file address: used in inserting or searching for a lock in the hash table. @return folded value */ UNIV_INLINE -ulint lock_rec_fold( - /*==========*/ - space_id_t space, /*!< in: space */ - page_no_t page_no) /*!< in: page number */ +ulint lock_rec_fold(space_id_t space, /*!< in: space */ + page_no_t page_no) /*!< in: page number */ MY_ATTRIBUTE((const)); /** Calculates the hash value of a page file address: used in inserting or @@ -517,20 +446,15 @@ searching for a lock in the hash table. UNIV_INLINE ulint lock_rec_hash(space_id_t space, page_no_t page_no); -/*************************************************************/ /** - Get the lock hash table */ +/** Get the lock hash table */ UNIV_INLINE -hash_table_t *lock_hash_get( - /*==========*/ - ulint mode); /*!< in: lock mode */ +hash_table_t *lock_hash_get(ulint mode); /*!< in: lock mode */ -/**********************************************************************/ /** - Looks for a set bit in a record lock bitmap. Returns ULINT_UNDEFINED, +/** Looks for a set bit in a record lock bitmap. Returns ULINT_UNDEFINED, if none found. @return bit index == heap number of the record, or ULINT_UNDEFINED if none found */ ulint lock_rec_find_set_bit( - /*==================*/ const lock_t *lock); /*!< in: record lock with at least one bit set */ @@ -541,31 +465,25 @@ ulint lock_rec_find_set_bit( if none found */ ulint lock_rec_find_next_set_bit(const lock_t *lock, ulint heap_no); -/*********************************************************************/ /** - Checks if a lock request lock1 has to wait for request lock2. +/** Checks if a lock request lock1 has to wait for request lock2. @return TRUE if lock1 has to wait for lock2 to be removed */ bool lock_has_to_wait( - /*=============*/ const lock_t *lock1, /*!< in: waiting lock */ const lock_t *lock2); /*!< in: another lock; NOTE that it is assumed that this has a lock bit set on the same record as in lock1 if the locks are record locks */ -/*********************************************************************/ /** - Reports that a transaction id is insensible, i.e., in the future. */ +/** Reports that a transaction id is insensible, i.e., in the future. */ void lock_report_trx_id_insanity( - /*========================*/ trx_id_t trx_id, /*!< in: trx id */ const rec_t *rec, /*!< in: user record */ const dict_index_t *index, /*!< in: index */ const ulint *offsets, /*!< in: rec_get_offsets(rec, index) */ trx_id_t max_trx_id); /*!< in: trx_sys_get_max_trx_id() */ -/*********************************************************************/ /** - Prints info of locks for all transactions. +/** Prints info of locks for all transactions. @return false if not able to obtain lock mutex and exits without printing info */ bool lock_print_info_summary( - /*====================*/ FILE *file, /*!< in: file where to print */ ibool nowait) /*!< in: whether to wait for the lock mutex */ MY_ATTRIBUTE((warn_unused_result)); @@ -575,45 +493,33 @@ bool lock_print_info_summary( @param[in] trx transaction */ void lock_trx_print_wait_and_mvcc_state(FILE *file, const trx_t *trx); -/*********************************************************************/ /** - Prints info of locks for each transaction. This function assumes that the +/** Prints info of locks for each transaction. This function assumes that the caller holds the lock mutex and more importantly it will release the lock mutex on behalf of the caller. (This should be fixed in the future). */ void lock_print_info_all_transactions( - /*=============================*/ FILE *file); /*!< in: file where to print */ -/*********************************************************************/ /** - Return approximate number or record locks (bits set in the bitmap) for +/** Return approximate number or record locks (bits set in the bitmap) for this transaction. Since delete-marked records may be removed, the record count will not be precise. The caller must be holding lock_sys->mutex. */ ulint lock_number_of_rows_locked( - /*=======================*/ const trx_lock_t *trx_lock) /*!< in: transaction locks */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Return the number of table locks for a transaction. +/** Return the number of table locks for a transaction. The caller must be holding lock_sys->mutex. */ ulint lock_number_of_tables_locked( - /*=========================*/ const trx_lock_t *trx_lock) /*!< in: transaction locks */ MY_ATTRIBUTE((warn_unused_result)); -/*******************************************************************/ /** - Gets the type of a lock. Non-inline version for using outside of the +/** Gets the type of a lock. Non-inline version for using outside of the lock module. @return LOCK_TABLE or LOCK_REC */ -uint32_t lock_get_type( - /*==========*/ - const lock_t *lock); /*!< in: lock */ +uint32_t lock_get_type(const lock_t *lock); /*!< in: lock */ -/*******************************************************************/ /** - Gets the id of the transaction owning a lock. +/** Gets the id of the transaction owning a lock. @return transaction id */ -trx_id_t lock_get_trx_id( - /*============*/ - const lock_t *lock); /*!< in: lock */ +trx_id_t lock_get_trx_id(const lock_t *lock); /*!< in: lock */ /** Get the performance schema event (thread_id, event_id) that created the lock. @@ -636,67 +542,44 @@ const lock_t *lock_get_first_trx_locks(const trx_lock_t *trx_lock); */ const lock_t *lock_get_next_trx_locks(const lock_t *lock); -/*******************************************************************/ /** - Gets the mode of a lock in a human readable string. +/** Gets the mode of a lock in a human readable string. The string should not be free()'d or modified. @return lock mode */ -const char *lock_get_mode_str( - /*==============*/ - const lock_t *lock); /*!< in: lock */ +const char *lock_get_mode_str(const lock_t *lock); /*!< in: lock */ -/*******************************************************************/ /** - Gets the type of a lock in a human readable string. +/** Gets the type of a lock in a human readable string. The string should not be free()'d or modified. @return lock type */ -const char *lock_get_type_str( - /*==============*/ - const lock_t *lock); /*!< in: lock */ +const char *lock_get_type_str(const lock_t *lock); /*!< in: lock */ -/*******************************************************************/ /** - Gets the id of the table on which the lock is. +/** Gets the id of the table on which the lock is. @return id of the table */ -table_id_t lock_get_table_id( - /*==============*/ - const lock_t *lock); /*!< in: lock */ +table_id_t lock_get_table_id(const lock_t *lock); /*!< in: lock */ /** Determine which table a lock is associated with. @param[in] lock the lock @return name of the table */ const table_name_t &lock_get_table_name(const lock_t *lock); -/*******************************************************************/ /** - For a record lock, gets the index on which the lock is. +/** For a record lock, gets the index on which the lock is. @return index */ -const dict_index_t *lock_rec_get_index( - /*===============*/ - const lock_t *lock); /*!< in: lock */ +const dict_index_t *lock_rec_get_index(const lock_t *lock); /*!< in: lock */ -/*******************************************************************/ /** - For a record lock, gets the name of the index on which the lock is. +/** For a record lock, gets the name of the index on which the lock is. The string should not be free()'d or modified. @return name of the index */ -const char *lock_rec_get_index_name( - /*====================*/ - const lock_t *lock); /*!< in: lock */ +const char *lock_rec_get_index_name(const lock_t *lock); /*!< in: lock */ -/*******************************************************************/ /** - For a record lock, gets the tablespace number on which the lock is. +/** For a record lock, gets the tablespace number on which the lock is. @return tablespace number */ -space_id_t lock_rec_get_space_id( - /*==================*/ - const lock_t *lock); /*!< in: lock */ +space_id_t lock_rec_get_space_id(const lock_t *lock); /*!< in: lock */ -/*******************************************************************/ /** - For a record lock, gets the page number on which the lock is. +/** For a record lock, gets the page number on which the lock is. @return page number */ -page_no_t lock_rec_get_page_no( - /*=================*/ - const lock_t *lock); /*!< in: lock */ -/*******************************************************************/ /** - Check if there are any locks (table or rec) against table. +page_no_t lock_rec_get_page_no(const lock_t *lock); /*!< in: lock */ +/** Check if there are any locks (table or rec) against table. @return true if locks exist */ bool lock_table_has_locks( - /*=================*/ const dict_table_t *table); /*!< in: check if there are any locks held on records in this table or on the table itself */ @@ -704,71 +587,50 @@ bool lock_table_has_locks( /** A thread which wakes up threads whose lock wait may have lasted too long. */ void lock_wait_timeout_thread(); -/********************************************************************/ /** - Releases a user OS thread waiting for a lock to be released, if the +/** Releases a user OS thread waiting for a lock to be released, if the thread is already suspended. */ void lock_wait_release_thread_if_suspended( - /*==================================*/ que_thr_t *thr); /*!< in: query thread associated with the user OS thread */ -/***************************************************************/ /** - Puts a user OS thread to wait for a lock to be released. If an error +/** Puts a user OS thread to wait for a lock to be released. If an error occurs during the wait trx->error_state associated with thr is != DB_SUCCESS when we return. DB_LOCK_WAIT_TIMEOUT and DB_DEADLOCK are possible errors. DB_DEADLOCK is returned if selective deadlock resolution chose this transaction as a victim. */ void lock_wait_suspend_thread( - /*=====================*/ que_thr_t *thr); /*!< in: query thread associated with the user OS thread */ -/*********************************************************************/ /** - Unlocks AUTO_INC type locks that were possibly reserved by a trx. This +/** Unlocks AUTO_INC type locks that were possibly reserved by a trx. This function should be called at the the end of an SQL statement, by the connection thread that owns the transaction (trx->mysql_thd). */ -void lock_unlock_table_autoinc( - /*======================*/ - trx_t *trx); /*!< in/out: transaction */ -/*********************************************************************/ /** - Check whether the transaction has already been rolled back because it +void lock_unlock_table_autoinc(trx_t *trx); /*!< in/out: transaction */ +/** Check whether the transaction has already been rolled back because it was selected as a deadlock victim, or if it has to wait then cancel the wait lock. @return DB_DEADLOCK, DB_LOCK_WAIT or DB_SUCCESS */ -dberr_t lock_trx_handle_wait( - /*=================*/ - trx_t *trx); /*!< in/out: trx lock state */ -/*********************************************************************/ /** - Get the number of locks on a table. +dberr_t lock_trx_handle_wait(trx_t *trx); /*!< in/out: trx lock state */ +/** Get the number of locks on a table. @return number of locks */ -ulint lock_table_get_n_locks( - /*===================*/ - const dict_table_t *table); /*!< in: table */ -/*******************************************************************/ /** - Initialise the trx lock list. */ +ulint lock_table_get_n_locks(const dict_table_t *table); /*!< in: table */ +/** Initialise the trx lock list. */ void lock_trx_lock_list_init( - /*====================*/ trx_lock_list_t *lock_list); /*!< List to initialise */ -/*******************************************************************/ /** - Set the lock system timeout event. */ +/** Set the lock system timeout event. */ void lock_set_timeout_event(); -/*====================*/ #ifdef UNIV_DEBUG -/*********************************************************************/ /** - Checks that a transaction id is sensible, i.e., not in the future. +/** Checks that a transaction id is sensible, i.e., not in the future. @return true if ok */ bool lock_check_trx_id_sanity( - /*=====================*/ trx_id_t trx_id, /*!< in: trx id */ const rec_t *rec, /*!< in: user record */ const dict_index_t *index, /*!< in: index */ const ulint *offsets) /*!< in: rec_get_offsets(rec, index) */ MY_ATTRIBUTE((warn_unused_result)); -/*******************************************************************/ /** - Check if the transaction holds an exclusive lock on a record. +/** Check if the transaction holds an exclusive lock on a record. @return whether the locks are held */ bool lock_trx_has_rec_x_lock( - /*====================*/ const trx_t *trx, /*!< in: transaction to check */ const dict_table_t *table, /*!< in: table to check */ const buf_block_t *block, /*!< in: buffer block of the record */ @@ -910,32 +772,24 @@ struct lock_sys_t { #endif /* UNIV_DEBUG */ }; -/*************************************************************/ /** - Removes a record lock request, waiting or granted, from the queue. */ -void lock_rec_discard( - /*=============*/ - lock_t *in_lock); /*!< in: record lock object: all - record locks which are contained - in this lock object are removed */ +/** Removes a record lock request, waiting or granted, from the queue. */ +void lock_rec_discard(lock_t *in_lock); /*!< in: record lock object: all + record locks which are contained + in this lock object are removed */ -/*************************************************************/ /** - Moves the explicit locks on user records to another page if a record +/** Moves the explicit locks on user records to another page if a record list start is moved to another page. */ -void lock_rtr_move_rec_list( - /*===================*/ - const buf_block_t *new_block, /*!< in: index page to - move to */ - const buf_block_t *block, /*!< in: index page */ - rtr_rec_move_t *rec_move, /*!< in: recording records - moved */ - ulint num_move); /*!< in: num of rec to move */ - -/*************************************************************/ /** - Removes record lock objects set on an index page which is discarded. This +void lock_rtr_move_rec_list(const buf_block_t *new_block, /*!< in: index page to + move to */ + const buf_block_t *block, /*!< in: index page */ + rtr_rec_move_t *rec_move, /*!< in: recording records + moved */ + ulint num_move); /*!< in: num of rec to move */ + +/** Removes record lock objects set on an index page which is discarded. This function does not move locks, or check for waiting locks, therefore the lock bitmaps must already be reset when this function is called. */ void lock_rec_free_all_from_discard_page( - /*================================*/ const buf_block_t *block); /*!< in: page to be discarded */ /** Reset the nth bit of a record lock. diff --git a/storage/innobase/include/lock0lock.ic b/storage/innobase/include/lock0lock.ic index 4c6fdb7653b8..5051a49d6dd5 100644 --- a/storage/innobase/include/lock0lock.ic +++ b/storage/innobase/include/lock0lock.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/lock0lock.ic +/** @file include/lock0lock.ic The transaction lock system Created 5/7/1996 Heikki Tuuri @@ -45,39 +44,30 @@ this program; if not, write to the Free Software Foundation, Inc., #include "trx0sys.h" #include "trx0trx.h" -/*********************************************************************/ /** - Calculates the fold value of a page file address: used in inserting or +/** Calculates the fold value of a page file address: used in inserting or searching for a lock in the hash table. @return folded value */ UNIV_INLINE -ulint lock_rec_fold( - /*==========*/ - space_id_t space, /*!< in: space */ - page_no_t page_no) /*!< in: page number */ +ulint lock_rec_fold(space_id_t space, /*!< in: space */ + page_no_t page_no) /*!< in: page number */ { return (ut_fold_ulint_pair(space, page_no)); } -/*********************************************************************/ /** - Calculates the hash value of a page file address: used in inserting or +/** Calculates the hash value of a page file address: used in inserting or searching for a lock in the hash table. @return hashed value */ UNIV_INLINE -ulint lock_rec_hash( - /*==========*/ - space_id_t space, /*!< in: space */ - page_no_t page_no) /*!< in: page number */ +ulint lock_rec_hash(space_id_t space, /*!< in: space */ + page_no_t page_no) /*!< in: page number */ { return (hash_calc_hash(lock_rec_fold(space, page_no), lock_sys->rec_hash)); } -/*********************************************************************/ /** - Gets the heap_no of the smallest user record on a page. +/** Gets the heap_no of the smallest user record on a page. @return heap_no of smallest user record, or PAGE_HEAP_NO_SUPREMUM */ UNIV_INLINE -ulint lock_get_min_heap_no( - /*=================*/ - const buf_block_t *block) /*!< in: buffer block */ +ulint lock_get_min_heap_no(const buf_block_t *block) /*!< in: buffer block */ { const page_t *page = block->frame; @@ -90,12 +80,9 @@ ulint lock_get_min_heap_no( } } -/*************************************************************/ /** - Get the lock hash table */ +/** Get the lock hash table */ UNIV_INLINE -hash_table_t *lock_hash_get( - /*==========*/ - ulint mode) /*!< in: lock mode */ +hash_table_t *lock_hash_get(ulint mode) /*!< in: lock mode */ { if (mode & LOCK_PREDICATE) { return (lock_sys->prdt_hash); diff --git a/storage/innobase/include/lock0prdt.h b/storage/innobase/include/lock0prdt.h index fb2e58c01930..0b3c6fe363ae 100644 --- a/storage/innobase/include/lock0prdt.h +++ b/storage/innobase/include/lock0prdt.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2014, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2014, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/lock0prdt.h +/** @file include/lock0prdt.h The predicate lock system Created 9/7/2013 Jimmy Yang @@ -42,57 +41,45 @@ typedef struct lock_prdt { uint16 op; /* Predicate operator */ } lock_prdt_t; -/*********************************************************************/ /** - Acquire a predicate lock on a block +/** Acquire a predicate lock on a block @return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ -dberr_t lock_prdt_lock( - /*===========*/ - buf_block_t *block, /*!< in/out: buffer block of rec */ - lock_prdt_t *prdt, /*!< in: Predicate for the lock */ - dict_index_t *index, /*!< in: secondary index */ - enum lock_mode mode, /*!< in: mode of the lock which - the read cursor should set on - records: LOCK_S or LOCK_X; the - latter is possible in - SELECT FOR UPDATE */ - ulint type_mode, - /*!< in: LOCK_PREDICATE or LOCK_PRDT_PAGE */ - que_thr_t *thr, /*!< in: query thread - (can be NULL if BTR_NO_LOCKING_FLAG) */ - mtr_t *mtr); /*!< in/out: mini-transaction */ - -/*********************************************************************/ /** - Acquire a "Page" lock on a block +dberr_t lock_prdt_lock(buf_block_t *block, /*!< in/out: buffer block of rec */ + lock_prdt_t *prdt, /*!< in: Predicate for the lock */ + dict_index_t *index, /*!< in: secondary index */ + enum lock_mode mode, /*!< in: mode of the lock which + the read cursor should set on + records: LOCK_S or LOCK_X; the + latter is possible in + SELECT FOR UPDATE */ + ulint type_mode, + /*!< in: LOCK_PREDICATE or LOCK_PRDT_PAGE */ + que_thr_t *thr, /*!< in: query thread + (can be NULL if BTR_NO_LOCKING_FLAG) */ + mtr_t *mtr); /*!< in/out: mini-transaction */ + +/** Acquire a "Page" lock on a block @return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ dberr_t lock_place_prdt_page_lock( - /*======================*/ space_id_t space, /*!< in: space for the page to lock */ page_no_t pageno, /*!< in: page number */ dict_index_t *index, /*!< in: secondary index */ que_thr_t *thr); /*!< in: query thread */ -/*********************************************************************/ /** - Initiate a Predicate lock from a MBR */ +/** Initiate a Predicate lock from a MBR */ void lock_init_prdt_from_mbr( - /*====================*/ lock_prdt_t *prdt, /*!< in/out: predicate to initialized */ rtr_mbr_t *mbr, /*!< in: Minimum Bounding Rectangle */ ulint mode, /*!< in: Search mode */ mem_heap_t *heap); /*!< in: heap for allocating memory */ -/*********************************************************************/ /** - Get predicate lock's minimum bounding box +/** Get predicate lock's minimum bounding box @return the minimum bounding box*/ -lock_prdt_t *lock_get_prdt_from_lock( - /*====================*/ - const lock_t *lock); /*!< in: the lock */ +lock_prdt_t *lock_get_prdt_from_lock(const lock_t *lock); /*!< in: the lock */ -/*********************************************************************/ /** - Checks if a predicate lock request for a new lock has to wait for +/** Checks if a predicate lock request for a new lock has to wait for request lock2. @return true if new lock has to wait for lock2 to be removed */ bool lock_prdt_has_to_wait( - /*==================*/ const trx_t *trx, /*!< in: trx of new lock */ ulint type_mode, /*!< in: precise mode of the new lock to set: LOCK_S or LOCK_X, possibly @@ -104,10 +91,8 @@ bool lock_prdt_has_to_wait( set on the same record as in the new lock we are setting */ -/**************************************************************/ /** - Update predicate lock when page splits */ +/** Update predicate lock when page splits */ void lock_prdt_update_split( - /*===================*/ buf_block_t *block, /*!< in/out: page to be split */ buf_block_t *new_block, /*!< in/out: the new half page */ lock_prdt_t *prdt, /*!< in: MBR on the old page */ @@ -115,10 +100,8 @@ void lock_prdt_update_split( space_id_t space, /*!< in: space id */ page_no_t page_no); /*!< in: page number */ -/**************************************************************/ /** - Ajust locks from an ancester page of Rtree on the appropriate level . */ +/** Ajust locks from an ancester page of Rtree on the appropriate level . */ void lock_prdt_update_parent( - /*====================*/ buf_block_t *left_block, /*!< in/out: page to be split */ buf_block_t *right_block, /*!< in/out: the new half page */ lock_prdt_t *left_prdt, /*!< in: MBR on the old page */ @@ -127,12 +110,10 @@ void lock_prdt_update_parent( space_id_t space, /*!< in: space id */ page_no_t page_no); /*!< in: page number */ -/*********************************************************************/ /** - Checks if locks of other transactions prevent an immediate insert of +/** Checks if locks of other transactions prevent an immediate insert of a predicate record. @return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ dberr_t lock_prdt_insert_check_and_lock( - /*============================*/ ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG bit is set, does nothing */ const rec_t *rec, /*!< in: record after which to insert */ @@ -142,12 +123,9 @@ dberr_t lock_prdt_insert_check_and_lock( mtr_t *mtr, /*!< in/out: mini-transaction */ lock_prdt_t *prdt); /*!< in: Minimum Bound Rectangle */ -/*********************************************************************/ /** - Append a predicate to the lock */ -void lock_prdt_set_prdt( - /*===============*/ - lock_t *lock, /*!< in: lock */ - const lock_prdt_t *prdt); /*!< in: Predicate */ +/** Append a predicate to the lock */ +void lock_prdt_set_prdt(lock_t *lock, /*!< in: lock */ + const lock_prdt_t *prdt); /*!< in: Predicate */ #if 0 @@ -158,7 +136,6 @@ request lock2. UNIV_INLINE bool lock_prdt_has_to_wait( -/*==================*/ const trx_t* trx, /*!< in: trx of new lock */ ulint type_mode,/*!< in: precise mode of the new lock to set: LOCK_S or LOCK_X, possibly @@ -176,15 +153,12 @@ Get predicate lock's minimum bounding box UNIV_INLINE rtr_mbr_t* prdt_get_mbr_from_prdt( -/*===================*/ const lock_prdt_t* prdt); /*!< in: the lock predicate */ #endif -/*************************************************************/ /** - Moves the locks of a record to another record and resets the lock bits of +/** Moves the locks of a record to another record and resets the lock bits of the donating record. */ void lock_prdt_rec_move( - /*===============*/ const buf_block_t *receiver, /*!< in: buffer block containing the receiving record */ const buf_block_t *donator); /*!< in: buffer block containing diff --git a/storage/innobase/include/lock0priv.h b/storage/innobase/include/lock0priv.h index d924355d518c..2edf60538e49 100644 --- a/storage/innobase/include/lock0priv.h +++ b/storage/innobase/include/lock0priv.h @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/lock0priv.h +/** @file include/lock0priv.h Lock module internal structures and methods. Created July 12, 2007 Vasil Dimov @@ -956,19 +955,14 @@ class RecLock { static const ulint lock_types = UT_ARR_SIZE(lock_compatibility_matrix); #endif /* UNIV_DEBUG */ -/*********************************************************************/ /** - Gets the type of a lock. +/** Gets the type of a lock. @return LOCK_TABLE or LOCK_REC */ UNIV_INLINE -uint32_t lock_get_type_low( - /*==============*/ - const lock_t *lock); /*!< in: lock */ +uint32_t lock_get_type_low(const lock_t *lock); /*!< in: lock */ -/*********************************************************************/ /** - Gets the previous record lock set on a record. +/** Gets the previous record lock set on a record. @return previous lock on the same record, NULL if none exists */ const lock_t *lock_rec_get_prev( - /*==============*/ const lock_t *in_lock, /*!< in: record lock */ ulint heap_no); /*!< in: heap number of the record */ @@ -978,24 +972,20 @@ waiting behind it. @param[in] use_fcfs true -> use first come first served strategy */ void lock_cancel_waiting_and_release(lock_t *lock, bool use_fcfs); -/*********************************************************************/ /** - Checks if some transaction has an implicit x-lock on a record in a clustered +/** Checks if some transaction has an implicit x-lock on a record in a clustered index. @return transaction id of the transaction which has the x-lock, or 0 */ UNIV_INLINE trx_id_t lock_clust_rec_some_has_impl( - /*=========================*/ const rec_t *rec, /*!< in: user record */ const dict_index_t *index, /*!< in: clustered index */ const ulint *offsets) /*!< in: rec_get_offsets(rec, index) */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Gets the first or next record lock on a page. +/** Gets the first or next record lock on a page. @return next lock, NULL if none exists */ UNIV_INLINE const lock_t *lock_rec_get_next_on_page_const( - /*============================*/ const lock_t *lock); /*!< in: a record lock */ /** Gets the nth bit of a record lock. @@ -1005,13 +995,10 @@ const lock_t *lock_rec_get_next_on_page_const( UNIV_INLINE bool lock_rec_get_nth_bit(const lock_t *lock, ulint i); -/*********************************************************************/ /** - Gets the number of bits in a record lock bitmap. +/** Gets the number of bits in a record lock bitmap. @return number of bits */ UNIV_INLINE -ulint lock_rec_get_n_bits( - /*================*/ - const lock_t *lock); /*!< in: record lock */ +ulint lock_rec_get_n_bits(const lock_t *lock); /*!< in: record lock */ /** Sets the nth bit of a record lock to TRUE. @param[in] lock record lock @@ -1019,13 +1006,10 @@ ulint lock_rec_get_n_bits( UNIV_INLINE void lock_rec_set_nth_bit(lock_t *lock, ulint i); -/*********************************************************************/ /** - Gets the first or next record lock on a page. +/** Gets the first or next record lock on a page. @return next lock, NULL if none exists */ UNIV_INLINE -lock_t *lock_rec_get_next_on_page( - /*======================*/ - lock_t *lock); /*!< in: a record lock */ +lock_t *lock_rec_get_next_on_page(lock_t *lock); /*!< in: a record lock */ /** Gets the first record lock on a page, where the page is identified by its file address. @@ -1076,13 +1060,10 @@ UNIV_INLINE lock_t *lock_rec_get_first(hash_table_t *hash, const buf_block_t *block, ulint heap_no); -/*********************************************************************/ /** - Gets the mode of a lock. +/** Gets the mode of a lock. @return mode */ UNIV_INLINE -enum lock_mode lock_get_mode( - /*==========*/ - const lock_t *lock); /*!< in: lock */ +enum lock_mode lock_get_mode(const lock_t *lock); /*!< in: lock */ /** Calculates if lock mode 1 is compatible with lock mode 2. @param[in] mode1 lock mode @@ -1098,13 +1079,10 @@ ulint lock_mode_compatible(enum lock_mode mode1, enum lock_mode mode2); UNIV_INLINE ulint lock_mode_stronger_or_eq(enum lock_mode mode1, enum lock_mode mode2); -/*********************************************************************/ /** - Gets the wait flag of a lock. +/** Gets the wait flag of a lock. @return LOCK_WAIT if waiting, 0 if not */ UNIV_INLINE -ulint lock_get_wait( - /*==========*/ - const lock_t *lock); /*!< in: lock */ +ulint lock_get_wait(const lock_t *lock); /*!< in: lock */ /** Looks for a suitable type record lock struct by the same trx on the same page. This can be used to save space when a new record lock should be set on a diff --git a/storage/innobase/include/lock0priv.ic b/storage/innobase/include/lock0priv.ic index 146e43c0f5f8..66bda73b1542 100644 --- a/storage/innobase/include/lock0priv.ic +++ b/storage/innobase/include/lock0priv.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/lock0priv.ic +/** @file include/lock0priv.ic Lock module internal inline methods. Created July 16, 2007 Vasil Dimov @@ -40,26 +39,21 @@ methods but they are used only in that file. */ #error Do not include lock0priv.ic outside of the lock/ module #endif -/*********************************************************************/ /** - Gets the type of a lock. +/** Gets the type of a lock. @return LOCK_TABLE or LOCK_REC */ UNIV_INLINE -uint32_t lock_get_type_low( - /*==============*/ - const lock_t *lock) /*!< in: lock */ +uint32_t lock_get_type_low(const lock_t *lock) /*!< in: lock */ { ut_ad(lock); return (lock->type_mode & LOCK_TYPE_MASK); } -/*********************************************************************/ /** - Checks if some transaction has an implicit x-lock on a record in a clustered +/** Checks if some transaction has an implicit x-lock on a record in a clustered index. @return transaction id of the transaction which has the x-lock, or 0 */ UNIV_INLINE trx_id_t lock_clust_rec_some_has_impl( - /*=========================*/ const rec_t *rec, /*!< in: user record */ const dict_index_t *index, /*!< in: clustered index */ const ulint *offsets) /*!< in: rec_get_offsets(rec, index) */ @@ -70,24 +64,18 @@ trx_id_t lock_clust_rec_some_has_impl( return (row_get_rec_trx_id(rec, index, offsets)); } -/*********************************************************************/ /** - Gets the number of bits in a record lock bitmap. +/** Gets the number of bits in a record lock bitmap. @return number of bits */ UNIV_INLINE -ulint lock_rec_get_n_bits( - /*================*/ - const lock_t *lock) /*!< in: record lock */ +ulint lock_rec_get_n_bits(const lock_t *lock) /*!< in: record lock */ { return (lock->rec_lock.n_bits); } -/**********************************************************************/ /** - Sets the nth bit of a record lock to TRUE. */ +/** Sets the nth bit of a record lock to TRUE. */ UNIV_INLINE -void lock_rec_set_nth_bit( - /*=================*/ - lock_t *lock, /*!< in: record lock */ - ulint i) /*!< in: index of the bit */ +void lock_rec_set_nth_bit(lock_t *lock, /*!< in: record lock */ + ulint i) /*!< in: index of the bit */ { ulint byte_index; ulint bit_index; @@ -104,24 +92,19 @@ void lock_rec_set_nth_bit( ++lock->trx->lock.n_rec_locks; } -/*********************************************************************/ /** - Gets the first or next record lock on a page. +/** Gets the first or next record lock on a page. @return next lock, NULL if none exists */ UNIV_INLINE -lock_t *lock_rec_get_next_on_page( - /*======================*/ - lock_t *lock) /*!< in: a record lock */ +lock_t *lock_rec_get_next_on_page(lock_t *lock) /*!< in: a record lock */ { return ((lock_t *)lock_rec_get_next_on_page_const(lock)); } -/*********************************************************************/ /** - Gets the first record lock on a page, where the page is identified by its +/** Gets the first record lock on a page, where the page is identified by its file address. @return first lock, NULL if none exists */ UNIV_INLINE lock_t *lock_rec_get_first_on_page_addr( - /*============================*/ hash_table_t *lock_hash, /*!< in: Lock hash table */ space_id_t space, /*!< in: space */ page_no_t page_no) /*!< in: page number */ @@ -139,13 +122,11 @@ lock_t *lock_rec_get_first_on_page_addr( return (NULL); } -/*********************************************************************/ /** - Gets the first record lock on a page, where the page is identified by a +/** Gets the first record lock on a page, where the page is identified by a pointer to it. @return first lock, NULL if none exists */ UNIV_INLINE lock_t *lock_rec_get_first_on_page( - /*=======================*/ hash_table_t *lock_hash, /*!< in: lock hash table */ const buf_block_t *block) /*!< in: buffer block */ { @@ -165,15 +146,12 @@ lock_t *lock_rec_get_first_on_page( return (NULL); } -/*********************************************************************/ /** - Gets the next explicit lock request on a record. +/** Gets the next explicit lock request on a record. @return next lock, NULL if none exists or if heap_no == ULINT_UNDEFINED */ UNIV_INLINE -lock_t *lock_rec_get_next( - /*==============*/ - ulint heap_no, /*!< in: heap number of the record */ - lock_t *lock) /*!< in: lock */ +lock_t *lock_rec_get_next(ulint heap_no, /*!< in: heap number of the record */ + lock_t *lock) /*!< in: lock */ { ut_ad(lock_mutex_own()); @@ -185,13 +163,11 @@ lock_t *lock_rec_get_next( return (lock); } -/*********************************************************************/ /** - Gets the next explicit lock request on a record. +/** Gets the next explicit lock request on a record. @return next lock, NULL if none exists or if heap_no == ULINT_UNDEFINED */ UNIV_INLINE const lock_t *lock_rec_get_next_const( - /*====================*/ ulint heap_no, /*!< in: heap number of the record */ const lock_t *lock) /*!< in: lock */ { @@ -216,12 +192,10 @@ lock_t *lock_rec_get_first(hash_table_t *hash, const RecID &rec_id) { return (lock); } -/*********************************************************************/ /** - Gets the first explicit lock request on a record. +/** Gets the first explicit lock request on a record. @return first lock, NULL if none exists */ UNIV_INLINE lock_t *lock_rec_get_first( - /*===============*/ hash_table_t *hash, /*!< in: hash chain the lock on */ const buf_block_t *block, /*!< in: block containing the record */ ulint heap_no) /*!< in: heap number of the record */ @@ -258,12 +232,10 @@ bool lock_rec_get_nth_bit(const lock_t *lock, ulint i) { return (true & *b >> (i % 8)); } -/*********************************************************************/ /** - Gets the first or next record lock on a page. +/** Gets the first or next record lock on a page. @return next lock, NULL if none exists */ UNIV_INLINE const lock_t *lock_rec_get_next_on_page_const( - /*============================*/ const lock_t *lock) /*!< in: a record lock */ { ut_ad(lock_mutex_own()); @@ -282,27 +254,21 @@ const lock_t *lock_rec_get_next_on_page_const( return (NULL); } -/*********************************************************************/ /** - Gets the mode of a lock. +/** Gets the mode of a lock. @return mode */ UNIV_INLINE -enum lock_mode lock_get_mode( - /*==========*/ - const lock_t *lock) /*!< in: lock */ +enum lock_mode lock_get_mode(const lock_t *lock) /*!< in: lock */ { ut_ad(lock); return (static_cast(lock->type_mode & LOCK_MODE_MASK)); } -/*********************************************************************/ /** - Calculates if lock mode 1 is compatible with lock mode 2. +/** Calculates if lock mode 1 is compatible with lock mode 2. @return nonzero if mode1 compatible with mode2 */ UNIV_INLINE -ulint lock_mode_compatible( - /*=================*/ - enum lock_mode mode1, /*!< in: lock mode */ - enum lock_mode mode2) /*!< in: lock mode */ +ulint lock_mode_compatible(enum lock_mode mode1, /*!< in: lock mode */ + enum lock_mode mode2) /*!< in: lock mode */ { ut_ad((ulint)mode1 < lock_types); ut_ad((ulint)mode2 < lock_types); @@ -310,14 +276,11 @@ ulint lock_mode_compatible( return (lock_compatibility_matrix[mode1][mode2]); } -/*********************************************************************/ /** - Calculates if lock mode 1 is stronger or equal to lock mode 2. +/** Calculates if lock mode 1 is stronger or equal to lock mode 2. @return nonzero if mode1 stronger or equal to mode2 */ UNIV_INLINE -ulint lock_mode_stronger_or_eq( - /*=====================*/ - enum lock_mode mode1, /*!< in: lock mode */ - enum lock_mode mode2) /*!< in: lock mode */ +ulint lock_mode_stronger_or_eq(enum lock_mode mode1, /*!< in: lock mode */ + enum lock_mode mode2) /*!< in: lock mode */ { ut_ad((ulint)mode1 < lock_types); ut_ad((ulint)mode2 < lock_types); @@ -325,27 +288,22 @@ ulint lock_mode_stronger_or_eq( return (lock_strength_matrix[mode1][mode2]); } -/*********************************************************************/ /** - Gets the wait flag of a lock. +/** Gets the wait flag of a lock. @return LOCK_WAIT if waiting, 0 if not */ UNIV_INLINE -ulint lock_get_wait( - /*==========*/ - const lock_t *lock) /*!< in: lock */ +ulint lock_get_wait(const lock_t *lock) /*!< in: lock */ { ut_ad(lock); return (lock->type_mode & LOCK_WAIT); } -/*********************************************************************/ /** - Looks for a suitable type record lock struct by the same trx on the same page. - This can be used to save space when a new record lock should be set on a page: - no new struct is needed, if a suitable old is found. +/** Looks for a suitable type record lock struct by the same trx on the same + page. This can be used to save space when a new record lock should be set on a + page: no new struct is needed, if a suitable old is found. @return lock or NULL */ UNIV_INLINE lock_t *lock_rec_find_similar_on_page( - /*==========================*/ ulint type_mode, /*!< in: lock type_mode field */ ulint heap_no, /*!< in: heap number of the record */ lock_t *lock, /*!< in: lock_rec_get_first_on_page() */ @@ -363,16 +321,13 @@ lock_t *lock_rec_find_similar_on_page( return (NULL); } -/*********************************************************************/ /** - Checks if a transaction has the specified table lock, or stronger. This +/** Checks if a transaction has the specified table lock, or stronger. This function should only be called by the thread that owns the transaction. @return lock or NULL */ UNIV_INLINE -const lock_t *lock_table_has( - /*===========*/ - const trx_t *trx, /*!< in: transaction */ - const dict_table_t *table, /*!< in: table */ - lock_mode in_mode) /*!< in: lock mode */ +const lock_t *lock_table_has(const trx_t *trx, /*!< in: transaction */ + const dict_table_t *table, /*!< in: table */ + lock_mode in_mode) /*!< in: lock mode */ { if (trx->lock.table_locks.empty()) { return (NULL); diff --git a/storage/innobase/include/lock0types.h b/storage/innobase/include/lock0types.h index 23af6cd7ee64..3d37154d3af2 100644 --- a/storage/innobase/include/lock0types.h +++ b/storage/innobase/include/lock0types.h @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/lock0types.h +/** @file include/lock0types.h The transaction lock system global types Created 5/7/1996 Heikki Tuuri diff --git a/storage/innobase/include/log0ddl.h b/storage/innobase/include/log0ddl.h index 74953dab32be..8eb060b38d1a 100644 --- a/storage/innobase/include/log0ddl.h +++ b/storage/innobase/include/log0ddl.h @@ -30,8 +30,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/log0ddl.h +/** @file include/log0ddl.h DDL log Created 12/1/2016 Shaohua Wang diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h index a946218115f5..182e10af4516 100644 --- a/storage/innobase/include/log0log.h +++ b/storage/innobase/include/log0log.h @@ -31,8 +31,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/log0log.h +/** @file include/log0log.h Database log Created 12/9/1995 Heikki Tuuri @@ -88,14 +87,12 @@ extern log_checksum_func_t log_checksum_algorithm_ptr; @return end lsn of the log record, zero if did not succeed */ UNIV_INLINE lsn_t log_reserve_and_write_fast(const void *str, ulint len, lsn_t *start_lsn); -/***********************************************************************/ /** - Checks if there is need for a log buffer flush or a new checkpoint, and does +/** Checks if there is need for a log buffer flush or a new checkpoint, and does this if yes. Any database operation should call this when it has modified more than about 4 pages. NOTE that this function may only be called when the OS thread owns no synchronization objects except the dictionary mutex. */ UNIV_INLINE void log_free_check(void); -/*================*/ /** Extends the log buffer. @param[in] len requested minimum size in bytes */ @@ -112,54 +109,40 @@ void log_margin_checkpoint_age(ulint len); @param[in] len length of the data to be written @return start lsn of the log record */ lsn_t log_reserve_and_open(ulint len); -/************************************************************/ /** - Writes to the log the string given. It is assumed that the caller holds the +/** Writes to the log the string given. It is assumed that the caller holds the log mutex. */ -void log_write_low( - /*==========*/ - const byte *str, /*!< in: string */ - ulint str_len); /*!< in: string length */ -/************************************************************/ /** - Closes the log. +void log_write_low(const byte *str, /*!< in: string */ + ulint str_len); /*!< in: string length */ +/** Closes the log. @return lsn */ lsn_t log_close(void); -/*===========*/ -/************************************************************/ /** - Gets the current lsn. +/** Gets the current lsn. @return current lsn */ UNIV_INLINE lsn_t log_get_lsn(void); -/*=============*/ /**************************************************************** Gets the log group capacity. It is OK to read the value without holding log_sys->mutex because it is constant. @return log group capacity */ UNIV_INLINE lsn_t log_get_capacity(void); -/*==================*/ /**************************************************************** Get log_sys::max_modified_age_async. It is OK to read the value without holding log_sys::mutex because it is constant. @return max_modified_age_async */ UNIV_INLINE lsn_t log_get_max_modified_age_async(void); -/*================================*/ -/******************************************************/ /** - Initializes the log. */ +/** Initializes the log. */ void log_init(void); -/*==========*/ -/******************************************************************/ /** - Inits a log group to the log system. +/** Inits a log group to the log system. @return true if success, false if not */ MY_ATTRIBUTE((warn_unused_result)) -bool log_group_init( - /*===========*/ - ulint id, /*!< in: group id */ - ulint n_files, /*!< in: number of log files */ - lsn_t file_size, /*!< in: log file size in bytes */ - space_id_t space_id); /*!< in: space id of the file space - which contains the log files of this - group */ +bool log_group_init(ulint id, /*!< in: group id */ + ulint n_files, /*!< in: number of log files */ + lsn_t file_size, /*!< in: log file size in bytes */ + space_id_t space_id); /*!< in: space id of the file space + which contains the log files of this + group */ /** Completes an i/o to a log file. @param[in,out] group log group or a dummy pointer */ void log_io_complete(log_group_t *group); @@ -202,13 +185,11 @@ void log_write_up_to(lsn_t lsn, bool flush_to_disk); @param[in] sync whether we want the written log also to be flushed to disk. */ void log_buffer_flush_to_disk(bool sync = true); -/****************************************************************/ /** - This functions writes the log buffer to the log file and if 'flush' +/** This functions writes the log buffer to the log file and if 'flush' is set it forces a flush of the log file as well. This is meant to be called from background master thread only as it does not wait for the write (+ possible flush) to finish. */ void log_buffer_sync_in_background( - /*==========================*/ bool flush); /*!< in: flush the logs to disk */ /** Make a checkpoint. Note that this function does not flush dirty blocks from the buffer pool: it only checks what is lsn of the oldest @@ -227,13 +208,11 @@ for the latest LSN has been generated since the latest checkpoint */ void log_make_checkpoint_at(lsn_t lsn, bool write_always); -/****************************************************************/ /** - Makes a checkpoint at the latest lsn and writes it to first page of each +/** Makes a checkpoint at the latest lsn and writes it to first page of each data file in the database, so that we know that the file spaces contain all modifications up to that lsn. This can only be called at database shutdown. This function also writes all log in log files to the log archive. */ void logs_empty_and_mark_files_at_shutdown(void); -/*=======================================*/ /** Read a log group header page to log_sys->checkpoint_buf. @param[in] group log group @param[in] header 0 or LOG_CHECKPOINT_1 or LOG_CHECKPOINT2 */ @@ -250,23 +229,18 @@ function may only be called if the calling thread owns no synchronization objects! */ void log_check_margins(void); #ifndef UNIV_HOTBACKUP -/********************************************************/ /** - Sets the field values in group to correspond to a given lsn. For this function - to work, the values must already be correctly initialized to correspond to - some lsn, for instance, a checkpoint lsn. */ +/** Sets the field values in group to correspond to a given lsn. For this + function to work, the values must already be correctly initialized to + correspond to some lsn, for instance, a checkpoint lsn. */ void log_group_set_fields( - /*=================*/ log_group_t *group, /*!< in/out: group */ lsn_t lsn); /*!< in: lsn for which the values should be set */ #endif /* !UNIV_HOTBACKUP */ -/************************************************************/ /** - Gets a log block flush bit. +/** Gets a log block flush bit. @return true if this block was the first to be written in a log flush */ UNIV_INLINE -ibool log_block_get_flush_bit( - /*====================*/ - const byte *log_block); /*!< in: log block */ +ibool log_block_get_flush_bit(const byte *log_block); /*!< in: log block */ /** Gets a log block encrypt bit. @param[in] log_block log block @@ -280,20 +254,14 @@ bool log_block_get_encrypt_bit(const byte *log_block); UNIV_INLINE void log_block_set_encrypt_bit(byte *log_block, ibool val); -/************************************************************/ /** - Gets a log block number stored in the header. +/** Gets a log block number stored in the header. @return log block number stored in the block header */ UNIV_INLINE -ulint log_block_get_hdr_no( - /*=================*/ - const byte *log_block); /*!< in: log block */ -/************************************************************/ /** - Gets a log block data length. +ulint log_block_get_hdr_no(const byte *log_block); /*!< in: log block */ +/** Gets a log block data length. @return log block data length measured as a byte offset from the block start */ UNIV_INLINE -ulint log_block_get_data_len( - /*===================*/ - const byte *log_block); /*!< in: log block */ +ulint log_block_get_data_len(const byte *log_block); /*!< in: log block */ /** Sets the log block data length. @param[in,out] log_block log block @@ -301,13 +269,10 @@ ulint log_block_get_data_len( UNIV_INLINE void log_block_set_data_len(byte *log_block, ulint len); -/************************************************************/ /** - Calculates the checksum for a log block. +/** Calculates the checksum for a log block. @return checksum */ UNIV_INLINE -ulint log_block_calc_checksum( - /*====================*/ - const byte *block); /*!< in: log block */ +ulint log_block_calc_checksum(const byte *block); /*!< in: log block */ /** Calculates the checksum for a log block using the CRC32 algorithm. @param[in] block log block @@ -321,13 +286,10 @@ ulint log_block_calc_checksum_crc32(const byte *block); UNIV_INLINE ulint log_block_calc_checksum_none(const byte *block); -/************************************************************/ /** - Gets a log block checksum field value. +/** Gets a log block checksum field value. @return checksum */ UNIV_INLINE -ulint log_block_get_checksum( - /*===================*/ - const byte *log_block); /*!< in: log block */ +ulint log_block_get_checksum(const byte *log_block); /*!< in: log block */ /** Sets a log block checksum field value. @param[in,out] log_block log block @@ -335,13 +297,11 @@ ulint log_block_get_checksum( UNIV_INLINE void log_block_set_checksum(byte *log_block, ulint checksum); -/************************************************************/ /** - Gets a log block first mtr log record group offset. +/** Gets a log block first mtr log record group offset. @return first mtr log record group byte offset from the block start, 0 if none */ UNIV_INLINE ulint log_block_get_first_rec_group( - /*==========================*/ const byte *log_block); /*!< in: log block */ /** Sets the log block first mtr log record group offset. @@ -350,13 +310,10 @@ ulint log_block_get_first_rec_group( UNIV_INLINE void log_block_set_first_rec_group(byte *log_block, ulint offset); -/************************************************************/ /** - Gets a log block checkpoint number field (4 lowest bytes). +/** Gets a log block checkpoint number field (4 lowest bytes). @return checkpoint no (4 lowest bytes) */ UNIV_INLINE -ulint log_block_get_checkpoint_no( - /*========================*/ - const byte *log_block); /*!< in: log block */ +ulint log_block_get_checkpoint_no(const byte *log_block); /*!< in: log block */ /** Initializes a log block in the log buffer. @param[in] log_block pointer to the log buffer @@ -364,48 +321,31 @@ ulint log_block_get_checkpoint_no( UNIV_INLINE void log_block_init(byte *log_block, lsn_t lsn); -/************************************************************/ /** - Converts a lsn to a log block number. +/** Converts a lsn to a log block number. @return log block number, it is > 0 and <= 1G */ UNIV_INLINE ulint log_block_convert_lsn_to_no( - /*========================*/ lsn_t lsn); /*!< in: lsn of a byte within the block */ -/******************************************************/ /** - Prints info of the log. */ -void log_print( - /*======*/ - FILE *file); /*!< in: file where to print */ -/******************************************************/ /** - Peeks the current lsn. +/** Prints info of the log. */ +void log_print(FILE *file); /*!< in: file where to print */ +/** Peeks the current lsn. @return true if success, false if could not get the log system mutex */ ibool log_peek_lsn( - /*=========*/ lsn_t *lsn); /*!< out: if returns TRUE, current lsn is here */ -/******************************************************/ /** - Lock log. */ +/** Lock log. */ void log_lock(void); -/******************************************************/ /** - Unlock log. */ +/** Unlock log. */ void log_unlock(void); -/******************************************************/ /** - Collect log info. */ +/** Collect log info. */ void log_collect_lsn_info( - /*=========*/ lsn_t *lsn, /*!< out: current lsn */ lsn_t *lsn_checkpoint); /*!< out: current last_checkpoint_lsn */ -/**********************************************************************/ /** - Refreshes the statistics used to print per-second averages. */ +/** Refreshes the statistics used to print per-second averages. */ void log_refresh_stats(void); -/*===================*/ -/********************************************************/ /** - Closes all log groups. */ +/** Closes all log groups. */ void log_group_close_all(void); -/*=====================*/ -/********************************************************/ /** - Shutdown the log system but do not release all the memory. */ +/** Shutdown the log system but do not release all the memory. */ void log_shutdown(void); -/*==============*/ /** Get last redo block from redo buffer and end LSN @param[out] last_lsn end lsn of last mtr diff --git a/storage/innobase/include/log0log.ic b/storage/innobase/include/log0log.ic index 7a3e898acebc..fb98e7fd28cf 100644 --- a/storage/innobase/include/log0log.ic +++ b/storage/innobase/include/log0log.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/log0log.ic +/** @file include/log0log.ic Database log Created 12/9/1995 Heikki Tuuri @@ -41,13 +40,10 @@ this program; if not, write to the Free Software Foundation, Inc., #include "mtr0types.h" #endif /* UNIV_LOG_LSN_DEBUG */ -/************************************************************/ /** - Gets a log block flush bit. +/** Gets a log block flush bit. @return true if this block was the first to be written in a log flush */ UNIV_INLINE -ibool log_block_get_flush_bit( - /*====================*/ - const byte *log_block) /*!< in: log block */ +ibool log_block_get_flush_bit(const byte *log_block) /*!< in: log block */ { if (LOG_BLOCK_FLUSH_BIT_MASK & mach_read_from_4(log_block + LOG_BLOCK_HDR_NO)) { @@ -59,10 +55,8 @@ ibool log_block_get_flush_bit( /** Sets the log block encryption bit. */ UNIV_INLINE -void log_block_set_flush_bit( - /*====================*/ - byte *log_block, /*!< in/out: log block */ - ibool val) /*!< in: value to set */ +void log_block_set_flush_bit(byte *log_block, /*!< in/out: log block */ + ibool val) /*!< in: value to set */ { ulint field; @@ -108,27 +102,21 @@ void log_block_set_encrypt_bit(byte *log_block, ibool val) { mach_write_to_2(log_block + LOG_BLOCK_HDR_DATA_LEN, field); } -/************************************************************/ /** - Gets a log block number stored in the header. +/** Gets a log block number stored in the header. @return log block number stored in the block header */ UNIV_INLINE -ulint log_block_get_hdr_no( - /*=================*/ - const byte *log_block) /*!< in: log block */ +ulint log_block_get_hdr_no(const byte *log_block) /*!< in: log block */ { return (~LOG_BLOCK_FLUSH_BIT_MASK & mach_read_from_4(log_block + LOG_BLOCK_HDR_NO)); } -/************************************************************/ /** - Sets the log block number stored in the header; NOTE that this must be set +/** Sets the log block number stored in the header; NOTE that this must be set before the flush bit! */ UNIV_INLINE -void log_block_set_hdr_no( - /*=================*/ - byte *log_block, /*!< in/out: log block */ - ulint n) /*!< in: log block number: must be > 0 and - < LOG_BLOCK_FLUSH_BIT_MASK */ +void log_block_set_hdr_no(byte *log_block, /*!< in/out: log block */ + ulint n) /*!< in: log block number: must be > 0 and + < LOG_BLOCK_FLUSH_BIT_MASK */ { ut_ad(n > 0); ut_ad(n < LOG_BLOCK_FLUSH_BIT_MASK); @@ -136,91 +124,68 @@ void log_block_set_hdr_no( mach_write_to_4(log_block + LOG_BLOCK_HDR_NO, n); } -/************************************************************/ /** - Gets a log block data length. +/** Gets a log block data length. @return log block data length measured as a byte offset from the block start */ UNIV_INLINE -ulint log_block_get_data_len( - /*===================*/ - const byte *log_block) /*!< in: log block */ +ulint log_block_get_data_len(const byte *log_block) /*!< in: log block */ { return (mach_read_from_2(log_block + LOG_BLOCK_HDR_DATA_LEN)); } -/************************************************************/ /** - Sets the log block data length. */ +/** Sets the log block data length. */ UNIV_INLINE -void log_block_set_data_len( - /*===================*/ - byte *log_block, /*!< in/out: log block */ - ulint len) /*!< in: data length */ +void log_block_set_data_len(byte *log_block, /*!< in/out: log block */ + ulint len) /*!< in: data length */ { mach_write_to_2(log_block + LOG_BLOCK_HDR_DATA_LEN, len); } -/************************************************************/ /** - Gets a log block first mtr log record group offset. +/** Gets a log block first mtr log record group offset. @return first mtr log record group byte offset from the block start, 0 if none */ UNIV_INLINE -ulint log_block_get_first_rec_group( - /*==========================*/ - const byte *log_block) /*!< in: log block */ +ulint log_block_get_first_rec_group(const byte *log_block) /*!< in: log block */ { return (mach_read_from_2(log_block + LOG_BLOCK_FIRST_REC_GROUP)); } -/************************************************************/ /** - Sets the log block first mtr log record group offset. */ +/** Sets the log block first mtr log record group offset. */ UNIV_INLINE -void log_block_set_first_rec_group( - /*==========================*/ - byte *log_block, /*!< in/out: log block */ - ulint offset) /*!< in: offset, 0 if none */ +void log_block_set_first_rec_group(byte *log_block, /*!< in/out: log block */ + ulint offset) /*!< in: offset, 0 if none */ { mach_write_to_2(log_block + LOG_BLOCK_FIRST_REC_GROUP, offset); } -/************************************************************/ /** - Gets a log block checkpoint number field (4 lowest bytes). +/** Gets a log block checkpoint number field (4 lowest bytes). @return checkpoint no (4 lowest bytes) */ UNIV_INLINE -ulint log_block_get_checkpoint_no( - /*========================*/ - const byte *log_block) /*!< in: log block */ +ulint log_block_get_checkpoint_no(const byte *log_block) /*!< in: log block */ { return (mach_read_from_4(log_block + LOG_BLOCK_CHECKPOINT_NO)); } -/************************************************************/ /** - Sets a log block checkpoint number field (4 lowest bytes). */ +/** Sets a log block checkpoint number field (4 lowest bytes). */ UNIV_INLINE -void log_block_set_checkpoint_no( - /*========================*/ - byte *log_block, /*!< in/out: log block */ - ib_uint64_t no) /*!< in: checkpoint no */ +void log_block_set_checkpoint_no(byte *log_block, /*!< in/out: log block */ + ib_uint64_t no) /*!< in: checkpoint no */ { mach_write_to_4(log_block + LOG_BLOCK_CHECKPOINT_NO, (ulint)no); } -/************************************************************/ /** - Converts a lsn to a log block number. +/** Converts a lsn to a log block number. @return log block number, it is > 0 and <= 1G */ UNIV_INLINE ulint log_block_convert_lsn_to_no( - /*========================*/ lsn_t lsn) /*!< in: lsn of a byte within the block */ { return (((ulint)(lsn / OS_FILE_LOG_BLOCK_SIZE) & 0x3FFFFFFFUL) + 1); } -/************************************************************/ /** - Calculates the checksum for a log block. +/** Calculates the checksum for a log block. @return checksum */ UNIV_INLINE -ulint log_block_calc_checksum( - /*====================*/ - const byte *block) /*!< in: log block */ +ulint log_block_calc_checksum(const byte *block) /*!< in: log block */ { return (log_checksum_algorithm_ptr(block)); } @@ -241,37 +206,28 @@ ulint log_block_calc_checksum_none(const byte *block) { return (LOG_NO_CHECKSUM_MAGIC); } -/************************************************************/ /** - Gets a log block checksum field value. +/** Gets a log block checksum field value. @return checksum */ UNIV_INLINE -ulint log_block_get_checksum( - /*===================*/ - const byte *log_block) /*!< in: log block */ +ulint log_block_get_checksum(const byte *log_block) /*!< in: log block */ { return (mach_read_from_4(log_block + OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_CHECKSUM)); } -/************************************************************/ /** - Sets a log block checksum field value. */ +/** Sets a log block checksum field value. */ UNIV_INLINE -void log_block_set_checksum( - /*===================*/ - byte *log_block, /*!< in/out: log block */ - ulint checksum) /*!< in: checksum */ +void log_block_set_checksum(byte *log_block, /*!< in/out: log block */ + ulint checksum) /*!< in: checksum */ { mach_write_to_4(log_block + OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_CHECKSUM, checksum); } -/************************************************************/ /** - Initializes a log block in the log buffer. */ +/** Initializes a log block in the log buffer. */ UNIV_INLINE -void log_block_init( - /*===========*/ - byte *log_block, /*!< in: pointer to the log buffer */ - lsn_t lsn) /*!< in: lsn within the log block */ +void log_block_init(byte *log_block, /*!< in: pointer to the log buffer */ + lsn_t lsn) /*!< in: lsn within the log block */ { ulint no; @@ -351,13 +307,10 @@ lsn_t log_reserve_and_write_fast(const void *str, ulint len, lsn_t *start_lsn) { return (log_sys->lsn); } -/************************************************************/ /** - Gets the current lsn. +/** Gets the current lsn. @return current lsn */ UNIV_INLINE -lsn_t log_get_lsn(void) -/*=============*/ -{ +lsn_t log_get_lsn(void) { lsn_t lsn; log_mutex_enter(); @@ -374,32 +327,23 @@ Gets the log group capacity. It is OK to read the value without holding log_sys->mutex because it is constant. @return log group capacity */ UNIV_INLINE -lsn_t log_get_capacity(void) -/*==================*/ -{ - return (log_sys->log_group_capacity); -} +lsn_t log_get_capacity(void) { return (log_sys->log_group_capacity); } /**************************************************************** Get log_sys::max_modified_age_async. It is OK to read the value without holding log_sys::mutex because it is constant. @return max_modified_age_async */ UNIV_INLINE -lsn_t log_get_max_modified_age_async(void) -/*================================*/ -{ +lsn_t log_get_max_modified_age_async(void) { return (log_sys->max_modified_age_async); } -/***********************************************************************/ /** - Checks if there is need for a log buffer flush or a new checkpoint, and does +/** Checks if there is need for a log buffer flush or a new checkpoint, and does this if yes. Any database operation should call this when it has modified more than about 4 pages. NOTE that this function may only be called when the OS thread owns no synchronization objects except the dictionary mutex. */ UNIV_INLINE -void log_free_check(void) -/*================*/ -{ +void log_free_check(void) { #ifdef UNIV_DEBUG /* During row_log_table_apply(), this function will be called while we are holding some latches. This is OK, as long as we are not holding diff --git a/storage/innobase/include/log0recv.h b/storage/innobase/include/log0recv.h index b38eba52835d..a02be69c9e50 100644 --- a/storage/innobase/include/log0recv.h +++ b/storage/innobase/include/log0recv.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/log0recv.h +/** @file include/log0recv.h Recovery Created 9/20/1997 Heikki Tuuri diff --git a/storage/innobase/include/log0recv.ic b/storage/innobase/include/log0recv.ic index df8e7e9fe769..0193d35295ee 100644 --- a/storage/innobase/include/log0recv.ic +++ b/storage/innobase/include/log0recv.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/log0recv.ic +/** @file include/log0recv.ic Recovery Created 9/20/1997 Heikki Tuuri diff --git a/storage/innobase/include/log0types.h b/storage/innobase/include/log0types.h index 4156a4b542ed..a66c80b7f6ca 100644 --- a/storage/innobase/include/log0types.h +++ b/storage/innobase/include/log0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -30,8 +30,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/log0types.h +/** @file include/log0types.h Log types Created 2013-03-15 Sunny Bains diff --git a/storage/innobase/include/mach0data.h b/storage/innobase/include/mach0data.h index d2875603227a..f3b26cd23bd7 100644 --- a/storage/innobase/include/mach0data.h +++ b/storage/innobase/include/mach0data.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -27,8 +27,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "my_compiler.h" #include "my_inttypes.h" -/******************************************************************/ /** - @file include/mach0data.h +/** @file include/mach0data.h Utilities for converting data from the database file to the machine format. @@ -76,25 +75,19 @@ bytes. The most significant byte is at the lowest address. UNIV_INLINE uint16_t mach_read_from_2(const byte *b) MY_ATTRIBUTE((warn_unused_result)); -/********************************************************/ /** - The following function is used to convert a 16-bit data item +/** The following function is used to convert a 16-bit data item to the canonical format, for fast bytewise equality test against memory. @return 16-bit integer in canonical format */ UNIV_INLINE -uint16_t mach_encode_2( - /*==========*/ - ulint n) /*!< in: integer in machine-dependent format */ +uint16_t mach_encode_2(ulint n) /*!< in: integer in machine-dependent format */ MY_ATTRIBUTE((const)); -/********************************************************/ /** - The following function is used to convert a 16-bit data item +/** The following function is used to convert a 16-bit data item from the canonical format, for fast bytewise equality test against memory. @return integer in machine-dependent format */ UNIV_INLINE -ulint mach_decode_2( - /*==========*/ - uint16 n) /*!< in: 16-bit integer in canonical format */ +ulint mach_decode_2(uint16 n) /*!< in: 16-bit integer in canonical format */ MY_ATTRIBUTE((const)); /** The following function is used to store data in 3 consecutive @@ -237,12 +230,10 @@ advanced by the number of bytes consumed, or set NULL if out of space UNIV_INLINE ib_uint64_t mach_u64_parse_compressed(const byte **ptr, const byte *end_ptr); -/*********************************************************/ /** - Reads a double. It is stored in a little-endian format. +/** Reads a double. It is stored in a little-endian format. @return double read */ UNIV_INLINE double mach_double_read( - /*=============*/ const byte *b) /*!< in: pointer to memory from where to read */ MY_ATTRIBUTE((warn_unused_result)); @@ -252,12 +243,10 @@ double mach_double_read( UNIV_INLINE void mach_double_write(byte *b, double d); -/*********************************************************/ /** - Reads a float. It is stored in a little-endian format. +/** Reads a float. It is stored in a little-endian format. @return float read */ UNIV_INLINE float mach_float_read( - /*============*/ const byte *b) /*!< in: pointer to memory from where to read */ MY_ATTRIBUTE((warn_unused_result)); @@ -267,12 +256,10 @@ float mach_float_read( UNIV_INLINE void mach_float_write(byte *b, float d); -/*********************************************************/ /** - Reads a ulint stored in the little-endian format. +/** Reads a ulint stored in the little-endian format. @return unsigned long int */ UNIV_INLINE ulint mach_read_from_n_little_endian( - /*===========================*/ const byte *buf, /*!< in: from where to read */ ulint buf_size) /*!< in: from how many bytes to read */ MY_ATTRIBUTE((warn_unused_result)); @@ -284,12 +271,10 @@ ulint mach_read_from_n_little_endian( UNIV_INLINE void mach_write_to_n_little_endian(byte *dest, ulint dest_size, ulint n); -/*********************************************************/ /** - Reads a ulint stored in the little-endian format. +/** Reads a ulint stored in the little-endian format. @return unsigned long int */ UNIV_INLINE ulint mach_read_from_2_little_endian( - /*===========================*/ const byte *buf) /*!< in: from where to read */ MY_ATTRIBUTE((warn_unused_result)); diff --git a/storage/innobase/include/mach0data.ic b/storage/innobase/include/mach0data.ic index d8a2cf52975b..836298ff860c 100644 --- a/storage/innobase/include/mach0data.ic +++ b/storage/innobase/include/mach0data.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/mach0data.ic +/** @file include/mach0data.ic Utilities for converting data from the database file to the machine format. @@ -77,30 +76,24 @@ uint16_t mach_read_from_2(const byte *b) { return (((ulint)(b[0]) << 8) | (ulint)(b[1])); } -/********************************************************/ /** - The following function is used to convert a 16-bit data item +/** The following function is used to convert a 16-bit data item to the canonical format, for fast bytewise equality test against memory. @return 16-bit integer in canonical format */ UNIV_INLINE -uint16_t mach_encode_2( - /*==========*/ - ulint n) /*!< in: integer in machine-dependent format */ +uint16_t mach_encode_2(ulint n) /*!< in: integer in machine-dependent format */ { uint16 ret; ut_ad(2 == sizeof ret); mach_write_to_2((byte *)&ret, n); return (ret); } -/********************************************************/ /** - The following function is used to convert a 16-bit data item +/** The following function is used to convert a 16-bit data item from the canonical format, for fast bytewise equality test against memory. @return integer in machine-dependent format */ UNIV_INLINE -ulint mach_decode_2( - /*==========*/ - uint16 n) /*!< in: 16-bit integer in canonical format */ +ulint mach_decode_2(uint16 n) /*!< in: 16-bit integer in canonical format */ { ut_ad(2 == sizeof n); return (mach_read_from_2((const byte *)&n)); @@ -362,12 +355,10 @@ ib_uint64_t mach_read_from_6(const byte *b) { return (ut_ull_create(mach_read_from_2(b), mach_read_from_4(b + 2))); } -/*********************************************************/ /** - Writes a 64-bit integer in a compressed form (5..9 bytes). +/** Writes a 64-bit integer in a compressed form (5..9 bytes). @return size in bytes */ UNIV_INLINE ulint mach_u64_write_compressed( - /*======================*/ byte *b, /*!< in: pointer to memory where to store */ ib_uint64_t n) /*!< in: 64-bit integer to be stored */ { @@ -396,12 +387,10 @@ ib_uint64_t mach_u64_read_next_compressed(const byte **b) { return (val); } -/*********************************************************/ /** - Writes a 64-bit integer in a compressed form (1..11 bytes). +/** Writes a 64-bit integer in a compressed form (1..11 bytes). @return size in bytes */ UNIV_INLINE ulint mach_u64_write_much_compressed( - /*===========================*/ byte *b, /*!< in: pointer to memory where to store */ ib_uint64_t n) /*!< in: 64-bit integer to be stored */ { @@ -421,13 +410,11 @@ ulint mach_u64_write_much_compressed( return (size); } -/*********************************************************/ /** - Reads a 64-bit integer in a compressed form. +/** Reads a 64-bit integer in a compressed form. @return the value read @see mach_parse_u64_much_compressed() */ UNIV_INLINE ib_uint64_t mach_u64_read_much_compressed( - /*==========================*/ const byte *b) /*!< in: pointer to memory from where to read */ { ib_uint64_t n; @@ -515,12 +502,10 @@ ib_uint64_t mach_u64_parse_compressed(const byte **ptr, const byte *end_ptr) { return (val); } -/*********************************************************/ /** - Reads a double. It is stored in a little-endian format. +/** Reads a double. It is stored in a little-endian format. @return double read */ UNIV_INLINE double mach_double_read( - /*=============*/ const byte *b) /*!< in: pointer to memory from where to read */ { double d; @@ -540,13 +525,10 @@ double mach_double_read( return (d); } -/*********************************************************/ /** - Writes a double. It is stored in a little-endian format. */ +/** Writes a double. It is stored in a little-endian format. */ UNIV_INLINE -void mach_double_write( - /*==============*/ - byte *b, /*!< in: pointer to memory where to write */ - double d) /*!< in: double */ +void mach_double_write(byte *b, /*!< in: pointer to memory where to write */ + double d) /*!< in: double */ { ulint i; byte *ptr; @@ -562,12 +544,10 @@ void mach_double_write( } } -/*********************************************************/ /** - Reads a float. It is stored in a little-endian format. +/** Reads a float. It is stored in a little-endian format. @return float read */ UNIV_INLINE float mach_float_read( - /*============*/ const byte *b) /*!< in: pointer to memory from where to read */ { float d; @@ -587,13 +567,10 @@ float mach_float_read( return (d); } -/*********************************************************/ /** - Writes a float. It is stored in a little-endian format. */ +/** Writes a float. It is stored in a little-endian format. */ UNIV_INLINE -void mach_float_write( - /*=============*/ - byte *b, /*!< in: pointer to memory where to write */ - float d) /*!< in: float */ +void mach_float_write(byte *b, /*!< in: pointer to memory where to write */ + float d) /*!< in: float */ { ulint i; byte *ptr; @@ -610,12 +587,10 @@ void mach_float_write( } #ifndef UNIV_HOTBACKUP -/*********************************************************/ /** - Reads a ulint stored in the little-endian format. +/** Reads a ulint stored in the little-endian format. @return unsigned long int */ UNIV_INLINE ulint mach_read_from_n_little_endian( - /*===========================*/ const byte *buf, /*!< in: from where to read */ ulint buf_size) /*!< in: from how many bytes to read */ { @@ -641,11 +616,9 @@ ulint mach_read_from_n_little_endian( return (n); } -/*********************************************************/ /** - Writes a ulint in the little-endian format. */ +/** Writes a ulint in the little-endian format. */ UNIV_INLINE void mach_write_to_n_little_endian( - /*==========================*/ byte *dest, /*!< in: where to write */ ulint dest_size, /*!< in: into how many bytes to write */ ulint n) /*!< in: unsigned long int to write */ @@ -672,22 +645,18 @@ void mach_write_to_n_little_endian( ut_ad(n == 0); } -/*********************************************************/ /** - Reads a ulint stored in the little-endian format. +/** Reads a ulint stored in the little-endian format. @return unsigned long int */ UNIV_INLINE ulint mach_read_from_2_little_endian( - /*===========================*/ const byte *buf) /*!< in: from where to read */ { return ((ulint)(buf[0]) | ((ulint)(buf[1]) << 8)); } -/*********************************************************/ /** - Writes a ulint in the little-endian format. */ +/** Writes a ulint in the little-endian format. */ UNIV_INLINE void mach_write_to_2_little_endian( - /*==========================*/ byte *dest, /*!< in: where to write */ ulint n) /*!< in: unsigned long int to write */ { @@ -702,13 +671,11 @@ void mach_write_to_2_little_endian( } #endif /* !UNIV_HOTBACKUP */ -/*********************************************************/ /** - Convert integral type from storage byte order (big endian) to +/** Convert integral type from storage byte order (big endian) to host byte order. @return integer value */ UNIV_INLINE ib_uint64_t mach_read_int_type( - /*===============*/ const byte *src, /*!< in: where to read from */ ulint len, /*!< in: length of src */ ibool unsigned_type) /*!< in: signed or unsigned flag */ @@ -738,14 +705,11 @@ ib_uint64_t mach_read_int_type( return (ret); } #ifndef UNIV_HOTBACKUP -/*********************************************************/ /** - Swap byte ordering. */ -UNIV_INLINE -void mach_swap_byte_order( - /*=================*/ - byte *dest, /*!< out: where to write */ - const byte *from, /*!< in: where to read from */ - ulint len) /*!< in: length of src */ +/** Swap byte ordering. */ +UNIV_INLINE +void mach_swap_byte_order(byte *dest, /*!< out: where to write */ + const byte *from, /*!< in: where to read from */ + ulint len) /*!< in: length of src */ { ut_ad(len > 0); ut_ad(len <= 8); @@ -776,12 +740,10 @@ void mach_swap_byte_order( Convert integral type from host byte order (big-endian) storage byte order. */ UNIV_INLINE -void mach_write_int_type( - /*================*/ - byte *dest, /*!< in: where to write */ - const byte *src, /*!< in: where to read from */ - ulint len, /*!< in: length of src */ - bool usign) /*!< in: signed or unsigned flag */ +void mach_write_int_type(byte *dest, /*!< in: where to write */ + const byte *src, /*!< in: where to read from */ + ulint len, /*!< in: length of src */ + bool usign) /*!< in: signed or unsigned flag */ { ut_ad(len >= 1 && len <= 8); @@ -800,12 +762,10 @@ void mach_write_int_type( Convert a ulonglong integer from host byte order to (big-endian) storage byte order. */ UNIV_INLINE -void mach_write_ulonglong( - /*=================*/ - byte *dest, /*!< in: where to write */ - ulonglong src, /*!< in: where to read from */ - ulint len, /*!< in: length of dest */ - bool usign) /*!< in: signed or unsigned flag */ +void mach_write_ulonglong(byte *dest, /*!< in: where to write */ + ulonglong src, /*!< in: where to read from */ + ulint len, /*!< in: length of dest */ + bool usign) /*!< in: signed or unsigned flag */ { byte *ptr = reinterpret_cast(&src); diff --git a/storage/innobase/include/mem0mem.h b/storage/innobase/include/mem0mem.h index 201c5823fea7..ac0d331afcba 100644 --- a/storage/innobase/include/mem0mem.h +++ b/storage/innobase/include/mem0mem.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/mem0mem.h +/** @file include/mem0mem.h The memory management Created 6/9/1994 Heikki Tuuri @@ -270,12 +269,9 @@ The size of the element must be given. */ UNIV_INLINE void mem_heap_free_top(mem_heap_t *heap, ulint n); -/*****************************************************************/ /** - Returns the space in bytes occupied by a memory heap. */ +/** Returns the space in bytes occupied by a memory heap. */ UNIV_INLINE -ulint mem_heap_get_size( - /*==============*/ - mem_heap_t *heap); /*!< in: heap */ +ulint mem_heap_get_size(mem_heap_t *heap); /*!< in: heap */ /** Duplicates a NUL-terminated string. @param[in] str string to be copied @@ -305,35 +301,28 @@ memory heap. UNIV_INLINE char *mem_heap_strdupl(mem_heap_t *heap, const char *str, ulint len); -/**********************************************************************/ /** - Concatenate two strings and return the result, using a memory heap. +/** Concatenate two strings and return the result, using a memory heap. @return own: the result */ char *mem_heap_strcat( - /*============*/ mem_heap_t *heap, /*!< in: memory heap where string is allocated */ const char *s1, /*!< in: string 1 */ const char *s2); /*!< in: string 2 */ -/**********************************************************************/ /** - Duplicate a block of data, allocated from a memory heap. +/** Duplicate a block of data, allocated from a memory heap. @return own: a copy of the data */ void *mem_heap_dup( - /*=========*/ mem_heap_t *heap, /*!< in: memory heap where copy is allocated */ const void *data, /*!< in: data to be copied */ ulint len); /*!< in: length of data, in bytes */ -/****************************************************************/ /** - A simple sprintf replacement that dynamically allocates the space for the +/** A simple sprintf replacement that dynamically allocates the space for the formatted string from the given heap. This supports a very limited set of the printf syntax: types 's' and 'u' and length modifier 'l' (which is required for the 'u' type). @return heap-allocated formatted string */ -char *mem_heap_printf( - /*============*/ - mem_heap_t *heap, /*!< in: memory heap */ - const char *format, /*!< in: format string */ - ...) MY_ATTRIBUTE((format(printf, 2, 3))); +char *mem_heap_printf(mem_heap_t *heap, /*!< in: memory heap */ + const char *format, /*!< in: format string */ + ...) MY_ATTRIBUTE((format(printf, 2, 3))); /** Checks that an object is a memory heap (or a block of it) @param[in] heap Memory heap to check */ diff --git a/storage/innobase/include/mem0mem.ic b/storage/innobase/include/mem0mem.ic index 34db25c453ee..b111941ed96f 100644 --- a/storage/innobase/include/mem0mem.ic +++ b/storage/innobase/include/mem0mem.ic @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file include/mem0mem.ic +/** @file include/mem0mem.ic The memory management Created 6/8/1994 Heikki Tuuri @@ -44,12 +43,10 @@ this program; if not, write to the Free Software Foundation, Inc., #define mem_heap_create_at(N, file_name, line) \ mem_heap_create_func(N, MEM_HEAP_DYNAMIC) #endif /* UNIV_DEBUG */ -/***************************************************************/ /** - Creates a memory heap block where data can be allocated. +/** Creates a memory heap block where data can be allocated. @return own: memory heap block, NULL if did not succeed (only possible for MEM_HEAP_BTR_SEARCH type heaps) */ mem_block_t *mem_heap_create_block_func( - /*=======================*/ mem_heap_t *heap, /*!< in: memory heap or NULL if first block should be created */ ulint n, /*!< in: number of bytes needed for user data */ @@ -60,25 +57,18 @@ mem_block_t *mem_heap_create_block_func( ulint type); /*!< in: type of heap: MEM_HEAP_DYNAMIC or MEM_HEAP_BUFFER */ -/******************************************************************/ /** - Frees a block from a memory heap. */ -void mem_heap_block_free( - /*================*/ - mem_heap_t *heap, /*!< in: heap */ - mem_block_t *block); /*!< in: block to free */ +/** Frees a block from a memory heap. */ +void mem_heap_block_free(mem_heap_t *heap, /*!< in: heap */ + mem_block_t *block); /*!< in: block to free */ #ifndef UNIV_HOTBACKUP #ifndef UNIV_LIBRARY -/******************************************************************/ /** - Frees the free_block field from a memory heap. */ -void mem_heap_free_block_free( - /*=====================*/ - mem_heap_t *heap); /*!< in: heap */ -#endif /* !UNIV_LIBRARY */ -#endif /* !UNIV_HOTBACKUP */ - -/***************************************************************/ /** - Adds a new block to a memory heap. +/** Frees the free_block field from a memory heap. */ +void mem_heap_free_block_free(mem_heap_t *heap); /*!< in: heap */ +#endif /* !UNIV_LIBRARY */ +#endif /* !UNIV_HOTBACKUP */ + +/** Adds a new block to a memory heap. @param[in] heap memory heap @param[in] n number of bytes needed @return created block, NULL if did not succeed (only possible for @@ -353,8 +343,7 @@ bool mem_heap_is_top(mem_heap_t *heap, const void *buf, ulint buf_sz) { return (presumed_start_of_buf == buf); } -/*****************************************************************/ /** - Allocate a new chunk of memory from a memory heap, possibly discarding +/** Allocate a new chunk of memory from a memory heap, possibly discarding the topmost element. If the memory chunk specified with (top, top_sz) is the topmost element, then it will be discarded, otherwise it will be left untouched and this function will be equivallent to @@ -362,12 +351,10 @@ bool mem_heap_is_top(mem_heap_t *heap, const void *buf, ulint buf_sz) { @return allocated storage, NULL if did not succeed (only possible for MEM_HEAP_BTR_SEARCH type heaps) */ UNIV_INLINE -void *mem_heap_replace( - /*=============*/ - mem_heap_t *heap, /*!< in/out: memory heap */ - const void *top, /*!< in: chunk to discard if possible */ - ulint top_sz, /*!< in: size of top in bytes */ - ulint new_sz) /*!< in: desired size of the new chunk */ +void *mem_heap_replace(mem_heap_t *heap, /*!< in/out: memory heap */ + const void *top, /*!< in: chunk to discard if possible */ + ulint top_sz, /*!< in: size of top in bytes */ + ulint new_sz) /*!< in: desired size of the new chunk */ { if (mem_heap_is_top(heap, top, top_sz)) { mem_heap_free_top(heap, top_sz); @@ -376,8 +363,7 @@ void *mem_heap_replace( return (mem_heap_alloc(heap, new_sz)); } -/*****************************************************************/ /** - Allocate a new chunk of memory from a memory heap, possibly discarding +/** Allocate a new chunk of memory from a memory heap, possibly discarding the topmost element and then copy the specified data to it. If the memory chunk specified with (top, top_sz) is the topmost element, then it will be discarded, otherwise it will be left untouched and this function will be @@ -386,7 +372,6 @@ void *mem_heap_replace( MEM_HEAP_BTR_SEARCH type heaps) */ UNIV_INLINE void *mem_heap_dup_replace( - /*=================*/ mem_heap_t *heap, /*!< in/out: memory heap */ const void *top, /*!< in: chunk to discard if possible */ ulint top_sz, /*!< in: size of top in bytes */ @@ -400,8 +385,7 @@ void *mem_heap_dup_replace( return (p); } -/*****************************************************************/ /** - Allocate a new chunk of memory from a memory heap, possibly discarding +/** Allocate a new chunk of memory from a memory heap, possibly discarding the topmost element and then copy the specified string to it. If the memory chunk specified with (top, top_sz) is the topmost element, then it will be discarded, otherwise it will be left untouched and this function will be @@ -410,7 +394,6 @@ void *mem_heap_dup_replace( MEM_HEAP_BTR_SEARCH type heaps) */ UNIV_INLINE char *mem_heap_strdup_replace( - /*====================*/ mem_heap_t *heap, /*!< in/out: memory heap */ const void *top, /*!< in: chunk to discard if possible */ ulint top_sz, /*!< in: size of top in bytes */ @@ -420,14 +403,11 @@ char *mem_heap_strdup_replace( mem_heap_dup_replace(heap, top, top_sz, str, strlen(str) + 1))); } -/*****************************************************************/ /** - Frees the topmost element in a memory heap. The size of the element must be +/** Frees the topmost element in a memory heap. The size of the element must be given. */ UNIV_INLINE -void mem_heap_free_top( - /*==============*/ - mem_heap_t *heap, /*!< in: memory heap */ - ulint n) /*!< in: size of the topmost element */ +void mem_heap_free_top(mem_heap_t *heap, /*!< in: memory heap */ + ulint n) /*!< in: size of the topmost element */ { mem_block_t *block; @@ -535,12 +515,9 @@ void mem_heap_free(mem_heap_t *heap) { } } -/*****************************************************************/ /** - Returns the space in bytes occupied by a memory heap. */ +/** Returns the space in bytes occupied by a memory heap. */ UNIV_INLINE -ulint mem_heap_get_size( - /*==============*/ - mem_heap_t *heap) /*!< in: heap */ +ulint mem_heap_get_size(mem_heap_t *heap) /*!< in: heap */ { ulint size = 0; @@ -557,26 +534,20 @@ ulint mem_heap_get_size( return (size); } -/**********************************************************************/ /** - Duplicates a NUL-terminated string. +/** Duplicates a NUL-terminated string. @return own: a copy of the string, must be deallocated with ut_free */ UNIV_INLINE -char *mem_strdup( - /*=======*/ - const char *str) /*!< in: string to be copied */ +char *mem_strdup(const char *str) /*!< in: string to be copied */ { ulint len = strlen(str) + 1; return (static_cast(memcpy(ut_malloc_nokey(len), str, len))); } -/**********************************************************************/ /** - Makes a NUL-terminated copy of a nonterminated string. +/** Makes a NUL-terminated copy of a nonterminated string. @return own: a copy of the string, must be deallocated with ut_free */ UNIV_INLINE -char *mem_strdupl( - /*========*/ - const char *str, /*!< in: string to be copied */ - ulint len) /*!< in: length of str, in bytes */ +char *mem_strdupl(const char *str, /*!< in: string to be copied */ + ulint len) /*!< in: length of str, in bytes */ { char *s = static_cast(ut_malloc_nokey(len + 1)); s[len] = 0; @@ -586,13 +557,11 @@ char *mem_strdupl( return s; } -/**********************************************************************/ /** - Makes a NUL-terminated copy of a nonterminated string, +/** Makes a NUL-terminated copy of a nonterminated string, allocated from a memory heap. @return own: a copy of the string */ UNIV_INLINE char *mem_heap_strdupl( - /*=============*/ mem_heap_t *heap, /*!< in: memory heap where string is allocated */ const char *str, /*!< in: string to be copied */ ulint len) /*!< in: length of str, in bytes */ diff --git a/storage/innobase/include/mtr0log.h b/storage/innobase/include/mtr0log.h index 9af4a3b2854a..84e86b6b790f 100644 --- a/storage/innobase/include/mtr0log.h +++ b/storage/innobase/include/mtr0log.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/mtr0log.h +/** @file include/mtr0log.h Mini-transaction logging routines Created 12/7/1995 Heikki Tuuri @@ -41,46 +40,33 @@ this program; if not, write to the Free Software Foundation, Inc., // Forward declaration struct dict_index_t; -/********************************************************/ /** - Writes 1, 2 or 4 bytes to a file page. Writes the corresponding log +/** Writes 1, 2 or 4 bytes to a file page. Writes the corresponding log record to the mini-transaction log if mtr is not NULL. */ void mlog_write_ulint( - /*=============*/ byte *ptr, /*!< in: pointer where to write */ ulint val, /*!< in: value to write */ mlog_id_t type, /*!< in: MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES */ mtr_t *mtr); /*!< in: mini-transaction handle */ -/********************************************************/ /** - Writes 8 bytes to a file page. Writes the corresponding log +/** Writes 8 bytes to a file page. Writes the corresponding log record to the mini-transaction log, only if mtr is not NULL */ -void mlog_write_ull( - /*===========*/ - byte *ptr, /*!< in: pointer where to write */ - ib_uint64_t val, /*!< in: value to write */ - mtr_t *mtr); /*!< in: mini-transaction handle */ -/********************************************************/ /** - Writes a string to a file page buffered in the buffer pool. Writes the +void mlog_write_ull(byte *ptr, /*!< in: pointer where to write */ + ib_uint64_t val, /*!< in: value to write */ + mtr_t *mtr); /*!< in: mini-transaction handle */ +/** Writes a string to a file page buffered in the buffer pool. Writes the corresponding log record to the mini-transaction log. */ -void mlog_write_string( - /*==============*/ - byte *ptr, /*!< in: pointer where to write */ - const byte *str, /*!< in: string to write */ - ulint len, /*!< in: string length */ - mtr_t *mtr); /*!< in: mini-transaction handle */ -/********************************************************/ /** - Logs a write of a string to a file page buffered in the buffer pool. +void mlog_write_string(byte *ptr, /*!< in: pointer where to write */ + const byte *str, /*!< in: string to write */ + ulint len, /*!< in: string length */ + mtr_t *mtr); /*!< in: mini-transaction handle */ +/** Logs a write of a string to a file page buffered in the buffer pool. Writes the corresponding log record to the mini-transaction log. */ -void mlog_log_string( - /*============*/ - byte *ptr, /*!< in: pointer written to */ - ulint len, /*!< in: string length */ - mtr_t *mtr); /*!< in: mini-transaction handle */ -/********************************************************/ /** - Writes initial part of a log record consisting of one-byte item +void mlog_log_string(byte *ptr, /*!< in: pointer written to */ + ulint len, /*!< in: string length */ + mtr_t *mtr); /*!< in: mini-transaction handle */ +/** Writes initial part of a log record consisting of one-byte item type and four-byte space and page numbers. */ void mlog_write_initial_log_record( - /*==========================*/ const byte *ptr, /*!< in: pointer to (inside) a buffer frame holding the file page where modification is made */ @@ -101,13 +87,10 @@ void mlog_catenate_ulint(mtr_buf_t *dyn_buf, ulint val, mlog_id_t type); UNIV_INLINE void mlog_catenate_ulint(mtr_t *mtr, ulint val, mlog_id_t type); -/********************************************************/ /** - Catenates n bytes to the mtr log. */ -void mlog_catenate_string( - /*=================*/ - mtr_t *mtr, /*!< in: mtr */ - const byte *str, /*!< in: string to write */ - ulint len); /*!< in: string length */ +/** Catenates n bytes to the mtr log. */ +void mlog_catenate_string(mtr_t *mtr, /*!< in: mtr */ + const byte *str, /*!< in: string to write */ + ulint len); /*!< in: string length */ /** Catenates a compressed ulint to mlog. @param[in] mtr mtr @@ -198,45 +181,37 @@ byte *mlog_parse_initial_dict_log_record(const byte *ptr, const byte *end_ptr, mlog_id_t *type, table_id_t *id, uint64 *version); -/********************************************************/ /** - Parses an initial log record written by mlog_write_initial_log_record. +/** Parses an initial log record written by mlog_write_initial_log_record. @return parsed record end, NULL if not a complete record */ byte *mlog_parse_initial_log_record( - /*==========================*/ const byte *ptr, /*!< in: buffer */ const byte *end_ptr, /*!< in: buffer end */ mlog_id_t *type, /*!< out: log record type: MLOG_1BYTE, ... */ space_id_t *space, /*!< out: space id */ page_no_t *page_no); /*!< out: page number */ -/********************************************************/ /** - Parses a log record written by mlog_write_ulint or mlog_write_ull. +/** Parses a log record written by mlog_write_ulint or mlog_write_ull. @return parsed record end, NULL if not a complete record */ byte *mlog_parse_nbytes( - /*==============*/ mlog_id_t type, /*!< in: log record type: MLOG_1BYTE, ... */ const byte *ptr, /*!< in: buffer */ const byte *end_ptr, /*!< in: buffer end */ byte *page, /*!< in: page where to apply the log record, or NULL */ void *page_zip); /*!< in/out: compressed page, or NULL */ -/********************************************************/ /** - Parses a log record written by mlog_write_string. +/** Parses a log record written by mlog_write_string. @return parsed record end, NULL if not a complete record */ byte *mlog_parse_string( - /*==============*/ byte *ptr, /*!< in: buffer */ byte *end_ptr, /*!< in: buffer end */ byte *page, /*!< in: page where to apply the log record, or NULL */ void *page_zip); /*!< in/out: compressed page, or NULL */ -/********************************************************/ /** - Opens a buffer for mlog, writes the initial log record and, +/** Opens a buffer for mlog, writes the initial log record and, if needed, the field lengths of an index. Reserves space for further log entries. The log entry must be closed with mtr_close(). @return buffer, NULL if log mode MTR_LOG_NONE */ byte *mlog_open_and_write_index( - /*======================*/ mtr_t *mtr, /*!< in: mtr */ const byte *rec, /*!< in: index record or page */ const dict_index_t *index, /*!< in: record descriptor */ @@ -245,15 +220,12 @@ byte *mlog_open_and_write_index( (if 0, calls mlog_close() and returns NULL) */ -/********************************************************/ /** - Parses a log record written by mlog_open_and_write_index. +/** Parses a log record written by mlog_open_and_write_index. @return parsed record end, NULL if not a complete record */ -byte *mlog_parse_index( - /*=============*/ - byte *ptr, /*!< in: buffer */ - const byte *end_ptr, /*!< in: buffer end */ - ibool comp, /*!< in: TRUE=compact record format */ - dict_index_t **index); /*!< out, own: dummy index */ +byte *mlog_parse_index(byte *ptr, /*!< in: buffer */ + const byte *end_ptr, /*!< in: buffer end */ + ibool comp, /*!< in: TRUE=compact record format */ + dict_index_t **index); /*!< out, own: dummy index */ /** Insert, update, and maybe other functions may use this value to define an extra mlog buffer size for variable size data */ diff --git a/storage/innobase/include/mtr0log.ic b/storage/innobase/include/mtr0log.ic index 4eb3a3af67e6..13d290ecfba0 100644 --- a/storage/innobase/include/mtr0log.ic +++ b/storage/innobase/include/mtr0log.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/mtr0log.ic +/** @file include/mtr0log.ic Mini-transaction logging routines Created 12/7/1995 Heikki Tuuri @@ -64,13 +63,10 @@ byte *mlog_open_metadata(mtr_t *mtr, ulint size) { return (mtr->get_log()->open(size)); } -/********************************************************/ /** - Closes a buffer opened to mlog. */ +/** Closes a buffer opened to mlog. */ UNIV_INLINE -void mlog_close( - /*=======*/ - mtr_t *mtr, /*!< in: mtr */ - byte *ptr) /*!< in: buffer space from ptr up was not used */ +void mlog_close(mtr_t *mtr, /*!< in: mtr */ + byte *ptr) /*!< in: buffer space from ptr up was not used */ { ut_ad(mtr_get_log_mode(mtr) != MTR_LOG_NONE); ut_ad(mtr_get_log_mode(mtr) != MTR_LOG_NO_REDO); @@ -78,14 +74,11 @@ void mlog_close( mtr->get_log()->close(ptr); } -/********************************************************/ /** - Catenates 1 - 4 bytes to the mtr log. The value is not compressed. */ +/** Catenates 1 - 4 bytes to the mtr log. The value is not compressed. */ UNIV_INLINE -void mlog_catenate_ulint( - /*================*/ - mtr_buf_t *mtr_buf, /*!< in/out: buffer to write */ - ulint val, /*!< in: value to write */ - mlog_id_t type) /*!< in: type of value to write */ +void mlog_catenate_ulint(mtr_buf_t *mtr_buf, /*!< in/out: buffer to write */ + ulint val, /*!< in: value to write */ + mlog_id_t type) /*!< in: type of value to write */ { ut_ad(MLOG_1BYTE == 1); ut_ad(MLOG_2BYTES == 2); @@ -109,11 +102,9 @@ void mlog_catenate_ulint( } } -/********************************************************/ /** - Catenates 1 - 4 bytes to the mtr log. The value is not compressed. */ +/** Catenates 1 - 4 bytes to the mtr log. The value is not compressed. */ UNIV_INLINE void mlog_catenate_ulint( - /*================*/ mtr_t *mtr, /*!< in/out: mtr */ ulint val, /*!< in: value to write */ mlog_id_t type) /*!< in: MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES */ @@ -126,13 +117,10 @@ void mlog_catenate_ulint( mlog_catenate_ulint(mtr->get_log(), val, type); } -/********************************************************/ /** - Catenates a compressed ulint to mlog. */ +/** Catenates a compressed ulint to mlog. */ UNIV_INLINE -void mlog_catenate_ulint_compressed( - /*===========================*/ - mtr_t *mtr, /*!< in: mtr */ - ulint val) /*!< in: value to write */ +void mlog_catenate_ulint_compressed(mtr_t *mtr, /*!< in: mtr */ + ulint val) /*!< in: value to write */ { byte *log_ptr; @@ -148,13 +136,10 @@ void mlog_catenate_ulint_compressed( mlog_close(mtr, log_ptr); } -/********************************************************/ /** - Catenates a compressed 64-bit integer to mlog. */ +/** Catenates a compressed 64-bit integer to mlog. */ UNIV_INLINE -void mlog_catenate_ull_compressed( - /*=========================*/ - mtr_t *mtr, /*!< in: mtr */ - ib_uint64_t val) /*!< in: value to write */ +void mlog_catenate_ull_compressed(mtr_t *mtr, /*!< in: mtr */ + ib_uint64_t val) /*!< in: value to write */ { byte *log_ptr; @@ -218,14 +203,12 @@ byte *mlog_write_initial_log_record_low(mlog_id_t type, space_id_t space_id, } #ifndef UNIV_HOTBACKUP -/********************************************************/ /** - Writes the initial part of a log record (3..11 bytes). +/** Writes the initial part of a log record (3..11 bytes). If the implementation of this function is changed, all size parameters to mlog_open() should be adjusted accordingly! @return new value of log_ptr */ UNIV_INLINE byte *mlog_write_initial_log_record_fast( - /*===============================*/ const byte *ptr, /*!< in: pointer to (inside) a buffer frame holding the file page where modification is made */ diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h index 42a81b0fa9aa..aed6a0e396b0 100644 --- a/storage/innobase/include/mtr0mtr.h +++ b/storage/innobase/include/mtr0mtr.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -25,8 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/mtr0mtr.h +/** @file include/mtr0mtr.h Mini-transaction buffer Created 11/26/1995 Heikki Tuuri diff --git a/storage/innobase/include/mtr0mtr.ic b/storage/innobase/include/mtr0mtr.ic index a80858b4e02d..c28b7d92eaa0 100644 --- a/storage/innobase/include/mtr0mtr.ic +++ b/storage/innobase/include/mtr0mtr.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/mtr0mtr.ic +/** @file include/mtr0mtr.ic Mini-transaction buffer Created 11/26/1995 Heikki Tuuri diff --git a/storage/innobase/include/mtr0types.h b/storage/innobase/include/mtr0types.h index d674bcc722b0..86fbd0f1f589 100644 --- a/storage/innobase/include/mtr0types.h +++ b/storage/innobase/include/mtr0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/mtr0types.h +/** @file include/mtr0types.h Mini-transaction buffer global types Created 11/26/1995 Heikki Tuuri diff --git a/storage/innobase/include/os0atomic.h b/storage/innobase/include/os0atomic.h index 00f25dcf0927..51137f341529 100644 --- a/storage/innobase/include/os0atomic.h +++ b/storage/innobase/include/os0atomic.h @@ -1,5 +1,5 @@ /***************************************************************************** -Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -30,8 +30,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/os0atomic.h +/** @file include/os0atomic.h Macros for using atomics Created 2012-09-23 Sunny Bains (Split from os0sync.h) @@ -64,8 +63,7 @@ typedef ulint lock_word_t; #endif /* __i386__ || __x86_64__ || _M_IX86 || _M_X64 || __WIN__ */ -/**********************************************************/ /** - Atomic compare-and-swap and increment for InnoDB. */ +/** Atomic compare-and-swap and increment for InnoDB. */ /** Do an atomic test and set. @param[in,out] ptr Memory location to set @@ -87,51 +85,40 @@ lock_word_t os_atomic_val_compare_and_swap(volatile lock_word_t *ptr, #ifdef _WIN32 -/**********************************************************/ /** - Atomic compare and exchange of signed integers (both 32 and 64 bit). +/** Atomic compare and exchange of signed integers (both 32 and 64 bit). @return value found before the exchange. If it is not equal to old_value the exchange did not happen. */ UNIV_INLINE lint win_cmp_and_xchg_lint( - /*==================*/ volatile lint *ptr, /*!< in/out: source/destination */ lint new_val, /*!< in: exchange value */ lint old_val); /*!< in: value to compare to */ -/**********************************************************/ /** - Atomic addition of signed integers. +/** Atomic addition of signed integers. @return Initial value of the variable pointed to by ptr */ UNIV_INLINE -lint win_xchg_and_add( - /*=============*/ - volatile lint *ptr, /*!< in/out: address of destination */ - lint val); /*!< in: number to be added */ +lint win_xchg_and_add(volatile lint *ptr, /*!< in/out: address of destination */ + lint val); /*!< in: number to be added */ -/**********************************************************/ /** - Atomic compare and exchange of unsigned integers. +/** Atomic compare and exchange of unsigned integers. @return value found before the exchange. If it is not equal to old_value the exchange did not happen. */ UNIV_INLINE ulint win_cmp_and_xchg_ulint( - /*===================*/ volatile ulint *ptr, /*!< in/out: source/destination */ ulint new_val, /*!< in: exchange value */ ulint old_val); /*!< in: value to compare to */ -/**********************************************************/ /** - Atomic compare and exchange of 32 bit unsigned integers. +/** Atomic compare and exchange of 32 bit unsigned integers. @return value found before the exchange. If it is not equal to old_value the exchange did not happen. */ UNIV_INLINE DWORD -win_cmp_and_xchg_dword( - /*===================*/ - volatile DWORD *ptr, /*!< in/out: source/destination */ - DWORD new_val, /*!< in: exchange value */ - DWORD old_val); /*!< in: value to compare to */ - -/**********************************************************/ /** - Returns true if swapped, ptr is pointer to target, old_val is value to +win_cmp_and_xchg_dword(volatile DWORD *ptr, /*!< in/out: source/destination */ + DWORD new_val, /*!< in: exchange value */ + DWORD old_val); /*!< in: value to compare to */ + +/** Returns true if swapped, ptr is pointer to target, old_val is value to compare to, new_val is the value to swap in. */ #define os_compare_and_swap_lint(ptr, old_val, new_val) \ @@ -159,8 +146,7 @@ win_cmp_and_xchg_dword( #define IB_ATOMICS_STARTUP_MSG \ "Mutexes and rw_locks use Windows interlocked functions" -/**********************************************************/ /** - Returns the resulting value, ptr is pointer to target, amount is the +/** Returns the resulting value, ptr is pointer to target, amount is the amount of increment. */ #define os_atomic_increment_lint(ptr, amount) \ @@ -181,8 +167,7 @@ win_cmp_and_xchg_dword( reinterpret_cast(ptr), static_cast(amount))) + \ static_cast(amount)) -/**********************************************************/ /** - Returns the resulting value, ptr is pointer to target, amount is the +/** Returns the resulting value, ptr is pointer to target, amount is the amount to decrement. There is no atomic substract function on Windows */ #define os_atomic_decrement_lint(ptr, amount) \ @@ -206,8 +191,7 @@ win_cmp_and_xchg_dword( #else /* Fall back to GCC-style atomic builtins. */ -/**********************************************************/ /** - Returns true if swapped, ptr is pointer to target, old_val is value to +/** Returns true if swapped, ptr is pointer to target, old_val is value to compare to, new_val is the value to swap in. */ #if defined(HAVE_GCC_SYNC_BUILTINS) @@ -278,8 +262,7 @@ bool os_compare_and_swap_thread_id(volatile os_thread_id_t *ptr, "Mutexes use GCC atomic builtins, rw_locks do not" #endif /* HAVE_IB_ATOMIC_PTHREAD_T_GCC */ -/**********************************************************/ /** - Returns the resulting value, ptr is pointer to target, amount is the +/** Returns the resulting value, ptr is pointer to target, amount is the amount of increment. */ #if defined(HAVE_GCC_SYNC_BUILTINS) diff --git a/storage/innobase/include/os0atomic.ic b/storage/innobase/include/os0atomic.ic index 66327a164d0e..4ff9520ca41e 100644 --- a/storage/innobase/include/os0atomic.ic +++ b/storage/innobase/include/os0atomic.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2013, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/os0atomics.ic +/** @file include/os0atomics.ic The interface to the operating system synchronization primitives. Created 2012-09-23 Sunny Bains (Split from include/os0sync.ic) @@ -40,13 +39,11 @@ functions so that typecasts are evaluated at compile time. Take advantage that lint is either __int64 or long int and windows atomic functions work on __int64 and LONG */ -/**********************************************************/ /** - Atomic compare and exchange of unsigned integers. +/** Atomic compare and exchange of unsigned integers. @return value found before the exchange. If it is not equal to old_value the exchange did not happen. */ UNIV_INLINE lint win_cmp_and_xchg_lint( - /*==================*/ volatile lint *ptr, /*!< in/out: source/destination */ lint new_val, /*!< in: exchange value */ lint old_val) /*!< in: value to compare to */ @@ -58,14 +55,11 @@ lint win_cmp_and_xchg_lint( #endif /* _WIN64 */ } -/**********************************************************/ /** - Atomic addition of signed integers. +/** Atomic addition of signed integers. @return Initial value of the variable pointed to by ptr */ UNIV_INLINE -lint win_xchg_and_add( - /*=============*/ - volatile lint *ptr, /*!< in/out: address of destination */ - lint val) /*!< in: number to be added */ +lint win_xchg_and_add(volatile lint *ptr, /*!< in/out: address of destination */ + lint val) /*!< in: number to be added */ { #ifdef _WIN64 return (InterlockedExchangeAdd64(ptr, val)); @@ -74,13 +68,11 @@ lint win_xchg_and_add( #endif /* _WIN64 */ } -/**********************************************************/ /** - Atomic compare and exchange of unsigned integers. +/** Atomic compare and exchange of unsigned integers. @return value found before the exchange. If it is not equal to old_value the exchange did not happen. */ UNIV_INLINE ulint win_cmp_and_xchg_ulint( - /*===================*/ volatile ulint *ptr, /*!< in/out: source/destination */ ulint new_val, /*!< in: exchange value */ ulint old_val) /*!< in: value to compare to */ @@ -89,17 +81,14 @@ ulint win_cmp_and_xchg_ulint( (lint)old_val)); } -/**********************************************************/ /** - Atomic compare and exchange of 32-bit unsigned integers. +/** Atomic compare and exchange of 32-bit unsigned integers. @return value found before the exchange. If it is not equal to old_value the exchange did not happen. */ UNIV_INLINE DWORD -win_cmp_and_xchg_dword( - /*===================*/ - volatile DWORD *ptr, /*!< in/out: source/destination */ - DWORD new_val, /*!< in: exchange value */ - DWORD old_val) /*!< in: value to compare to */ +win_cmp_and_xchg_dword(volatile DWORD *ptr, /*!< in/out: source/destination */ + DWORD new_val, /*!< in: exchange value */ + DWORD old_val) /*!< in: value to compare to */ { ut_ad(sizeof(DWORD) == sizeof(LONG)); /* We assume this. */ return (InterlockedCompareExchange((volatile LONG *)ptr, (LONG)new_val, diff --git a/storage/innobase/include/os0event.h b/storage/innobase/include/os0event.h index ae942cd73293..2665fd624033 100644 --- a/storage/innobase/include/os0event.h +++ b/storage/innobase/include/os0event.h @@ -1,5 +1,5 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -23,8 +23,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/os0event.h +/** @file include/os0event.h The interface to the operating system condition variables Created 2012-09-23 Sunny Bains (split from os0sync.h) @@ -54,23 +53,18 @@ signaled and nonsignaled. The created event is manual reset: it must be reset explicitly by calling os_event_reset(). @return the event handle */ os_event_t os_event_create( - /*============*/ const char *name); /*!< in: the name of the event, if NULL the event is created without a name */ /** Sets an event semaphore to the signaled state: lets waiting threads proceed. */ -void os_event_set( - /*=========*/ - os_event_t event); /*!< in/out: event to set */ +void os_event_set(os_event_t event); /*!< in/out: event to set */ /** Check if the event is set. @return true if set */ -bool os_event_is_set( - /*============*/ - const os_event_t event); /*!< in: event to set */ +bool os_event_is_set(const os_event_t event); /*!< in: event to set */ /** Resets an event semaphore to the nonsignaled state. Waiting threads will @@ -79,15 +73,11 @@ The return value should be passed to os_even_wait_low() if it is desired that this thread should not wait in case of an intervening call to os_event_set() between this os_event_reset() and the os_event_wait_low() call. See comments for os_event_wait_low(). */ -int64_t os_event_reset( - /*===========*/ - os_event_t event); /*!< in/out: event to reset */ +int64_t os_event_reset(os_event_t event); /*!< in/out: event to reset */ /** Frees an event object. */ -void os_event_destroy( - /*=============*/ - os_event_t &event); /*!< in/own: event to free */ +void os_event_destroy(os_event_t &event); /*!< in/own: event to free */ /** Waits for an event object until it is in the signaled state. @@ -106,12 +96,10 @@ thread C calls os_event_wait() [infinite wait!] Where such a scenario is possible, to avoid infinite wait, the value returned by os_event_reset() should be passed in as reset_sig_count. */ -void os_event_wait_low( - /*==============*/ - os_event_t event, /*!< in/out: event to wait */ - int64_t reset_sig_count); /*!< in: zero or the value - returned by previous call of - os_event_reset(). */ +void os_event_wait_low(os_event_t event, /*!< in/out: event to wait */ + int64_t reset_sig_count); /*!< in: zero or the value + returned by previous call of + os_event_reset(). */ /** Blocking infinite wait on an event, until signealled. @param e - event to wait on. */ @@ -122,7 +110,6 @@ Waits for an event object until it is in the signaled state or a timeout is exceeded. In Unix the timeout is always infinite. @return 0 if success, OS_SYNC_TIME_EXCEEDED if timeout was exceeded */ ulint os_event_wait_time_low( - /*===================*/ os_event_t event, /*!< in/out: event to wait */ ulint time_in_usec, /*!< in: timeout in microseconds, or diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h index b7c046c583e6..063915ec2c8a 100644 --- a/storage/innobase/include/os0file.h +++ b/storage/innobase/include/os0file.h @@ -1,6 +1,6 @@ /*********************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Percona Inc. Portions of this file contain modifications contributed and copyrighted @@ -32,8 +32,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ***********************************************************************/ -/**************************************************/ /** - @file include/os0file.h +/** @file include/os0file.h The interface to the operating system file io Created 10/21/1995 Heikki Tuuri diff --git a/storage/innobase/include/os0file.ic b/storage/innobase/include/os0file.ic index 69a6d13326da..180f29b40139 100644 --- a/storage/innobase/include/os0file.ic +++ b/storage/innobase/include/os0file.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2010, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2010, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/os0file.ic +/** @file include/os0file.ic The interface to the operating system file io Created 2/20/2010 Jimmy Yang diff --git a/storage/innobase/include/os0numa.h b/storage/innobase/include/os0numa.h index a7dafdd63d9e..79e705c07b8e 100644 --- a/storage/innobase/include/os0numa.h +++ b/storage/innobase/include/os0numa.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2015, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2015, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/os0numa.h +/** @file include/os0numa.h NUMA API wrapper over various operating system specific APIs. The os_numa*() functions in this file mimic the numa*() Linux API that is diff --git a/storage/innobase/include/os0once.h b/storage/innobase/include/os0once.h index a407427edf0b..043f934126b8 100644 --- a/storage/innobase/include/os0once.h +++ b/storage/innobase/include/os0once.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2014, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2014, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/os0once.h +/** @file include/os0once.h A class that aids executing a given function exactly once in a multi-threaded environment. diff --git a/storage/innobase/include/os0proc.h b/storage/innobase/include/os0proc.h index 1e4223bf425b..13633bb12d3b 100644 --- a/storage/innobase/include/os0proc.h +++ b/storage/innobase/include/os0proc.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/os0proc.h +/** @file include/os0proc.h The interface to the operating system process control primitives diff --git a/storage/innobase/include/os0proc.ic b/storage/innobase/include/os0proc.ic index b66833af4f3f..246438830eae 100644 --- a/storage/innobase/include/os0proc.ic +++ b/storage/innobase/include/os0proc.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/os0proc.ic +/** @file include/os0proc.ic The interface to the operating system process control primitives diff --git a/storage/innobase/include/os0thread-create.h b/storage/innobase/include/os0thread-create.h index d647a96f5844..eeda2e1caf13 100644 --- a/storage/innobase/include/os0thread-create.h +++ b/storage/innobase/include/os0thread-create.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/os0thread-create.h +/** @file include/os0thread-create.h The interface to the threading wrapper Created 2016-May-17 Sunny Bains diff --git a/storage/innobase/include/os0thread.h b/storage/innobase/include/os0thread.h index 429166f03ca6..cbf80d4621da 100644 --- a/storage/innobase/include/os0thread.h +++ b/storage/innobase/include/os0thread.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/os0thread.h +/** @file include/os0thread.h The interface to the operating system process and thread control primitives diff --git a/storage/innobase/include/page0cur.h b/storage/innobase/include/page0cur.h index 7a3b8a6c8acd..6364a5066ce0 100644 --- a/storage/innobase/include/page0cur.h +++ b/storage/innobase/include/page0cur.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file include/page0cur.h +/** @file include/page0cur.h The page cursor Created 10/4/1994 Heikki Tuuri @@ -46,35 +45,23 @@ this program; if not, write to the Free Software Foundation, Inc., #define PAGE_CUR_ADAPT #ifdef UNIV_DEBUG -/*********************************************************/ /** - Gets pointer to the page frame where the cursor is positioned. +/** Gets pointer to the page frame where the cursor is positioned. @return page */ UNIV_INLINE -page_t *page_cur_get_page( - /*==============*/ - page_cur_t *cur); /*!< in: page cursor */ -/*********************************************************/ /** - Gets pointer to the buffer block where the cursor is positioned. +page_t *page_cur_get_page(page_cur_t *cur); /*!< in: page cursor */ +/** Gets pointer to the buffer block where the cursor is positioned. @return page */ UNIV_INLINE -buf_block_t *page_cur_get_block( - /*===============*/ - page_cur_t *cur); /*!< in: page cursor */ -/*********************************************************/ /** - Gets pointer to the page frame where the cursor is positioned. +buf_block_t *page_cur_get_block(page_cur_t *cur); /*!< in: page cursor */ +/** Gets pointer to the page frame where the cursor is positioned. @return page */ UNIV_INLINE -page_zip_des_t *page_cur_get_page_zip( - /*==================*/ - page_cur_t *cur); /*!< in: page cursor */ -/*********************************************************/ /** - Gets the record where the cursor is positioned. +page_zip_des_t *page_cur_get_page_zip(page_cur_t *cur); /*!< in: page cursor */ +/** Gets the record where the cursor is positioned. @return record */ UNIV_INLINE -rec_t *page_cur_get_rec( - /*=============*/ - page_cur_t *cur); /*!< in: page cursor */ -#else /* UNIV_DEBUG */ +rec_t *page_cur_get_rec(page_cur_t *cur); /*!< in: page cursor */ +#else /* UNIV_DEBUG */ #define page_cur_get_page(cur) page_align((cur)->rec) #define page_cur_get_block(cur) (cur)->block #define page_cur_get_page_zip(cur) buf_block_get_page_zip((cur)->block) @@ -93,20 +80,14 @@ void page_cur_set_before_first(const buf_block_t *block, page_cur_t *cur); UNIV_INLINE void page_cur_set_after_last(const buf_block_t *block, page_cur_t *cur); -/*********************************************************/ /** - Returns TRUE if the cursor is before first user record on page. +/** Returns TRUE if the cursor is before first user record on page. @return true if at start */ UNIV_INLINE -ibool page_cur_is_before_first( - /*=====================*/ - const page_cur_t *cur); /*!< in: cursor */ -/*********************************************************/ /** - Returns TRUE if the cursor is after last user record. +ibool page_cur_is_before_first(const page_cur_t *cur); /*!< in: cursor */ +/** Returns TRUE if the cursor is after last user record. @return true if at end */ UNIV_INLINE -ibool page_cur_is_after_last( - /*===================*/ - const page_cur_t *cur); /*!< in: cursor */ +ibool page_cur_is_after_last(const page_cur_t *cur); /*!< in: cursor */ /** Positions the cursor on the given record. @param[in] rec record on a page @@ -116,20 +97,15 @@ UNIV_INLINE void page_cur_position(const rec_t *rec, const buf_block_t *block, page_cur_t *cur); -/**********************************************************/ /** - Moves the cursor to the next record on page. */ +/** Moves the cursor to the next record on page. */ UNIV_INLINE void page_cur_move_to_next( - /*==================*/ page_cur_t *cur); /*!< in/out: cursor; must not be after last */ -/**********************************************************/ /** - Moves the cursor to the previous record on page. */ +/** Moves the cursor to the previous record on page. */ UNIV_INLINE void page_cur_move_to_prev( - /*==================*/ page_cur_t *cur); /*!< in/out: cursor; not before first */ -/***********************************************************/ /** - Inserts a record next to page cursor. Returns pointer to inserted record if +/** Inserts a record next to page cursor. Returns pointer to inserted record if succeed, i.e., enough space available, NULL otherwise. The cursor stays at the same logical position, but the physical position may change if it is pointing to a compressed page that was reorganized. @@ -142,7 +118,6 @@ void page_cur_move_to_prev( @return pointer to record if succeed, NULL otherwise */ UNIV_INLINE rec_t *page_cur_tuple_insert( - /*==================*/ page_cur_t *cursor, /*!< in/out: a page cursor */ const dtuple_t *tuple, /*!< in: pointer to a data tuple */ dict_index_t *index, /*!< in: record descriptor */ @@ -175,13 +150,11 @@ UNIV_INLINE rec_t *page_cur_rec_insert(page_cur_t *cursor, const rec_t *rec, dict_index_t *index, ulint *offsets, mtr_t *mtr); -/***********************************************************/ /** - Inserts a record next to page cursor on an uncompressed page. +/** Inserts a record next to page cursor on an uncompressed page. Returns pointer to inserted record if succeed, i.e., enough space available, NULL otherwise. The cursor stays at the same position. @return pointer to record if succeed, NULL otherwise */ rec_t *page_cur_insert_rec_low( - /*====================*/ rec_t *current_rec, /*!< in: pointer to current record after which the new record is inserted */ dict_index_t *index, /*!< in: record descriptor */ @@ -203,8 +176,7 @@ rec_t *page_cur_direct_insert_rec_low(rec_t *current_rec, dict_index_t *index, const dtuple_t *tuple, ulint n_ext, mtr_t *mtr); -/***********************************************************/ /** - Inserts a record next to page cursor on a compressed and uncompressed +/** Inserts a record next to page cursor on a compressed and uncompressed page. Returns pointer to inserted record if succeed, i.e., enough space available, NULL otherwise. The cursor stays at the same position. @@ -216,32 +188,27 @@ rec_t *page_cur_direct_insert_rec_low(rec_t *current_rec, dict_index_t *index, @return pointer to record if succeed, NULL otherwise */ rec_t *page_cur_insert_rec_zip( - /*====================*/ page_cur_t *cursor, /*!< in/out: page cursor */ dict_index_t *index, /*!< in: record descriptor */ const rec_t *rec, /*!< in: pointer to a physical record */ ulint *offsets, /*!< in/out: rec_get_offsets(rec, index) */ mtr_t *mtr) /*!< in: mini-transaction handle, or NULL */ MY_ATTRIBUTE((warn_unused_result)); -/*************************************************************/ /** - Copies records from page to a newly created page, from a given record onward, - including that record. Infimum and supremum records are not copied. +/** Copies records from page to a newly created page, from a given record + onward, including that record. Infimum and supremum records are not copied. IMPORTANT: The caller will have to update IBUF_BITMAP_FREE if this is a compressed leaf page in a secondary index. This has to be done either within the same mini-transaction, or by invoking ibuf_reset_free_bits() before mtr_commit(). */ void page_copy_rec_list_end_to_created_page( - /*===================================*/ page_t *new_page, /*!< in/out: index page to copy to */ rec_t *rec, /*!< in: first record to copy */ dict_index_t *index, /*!< in: record descriptor */ mtr_t *mtr); /*!< in: mtr */ -/***********************************************************/ /** - Deletes a record at the page cursor. The cursor is moved to the +/** Deletes a record at the page cursor. The cursor is moved to the next record after the deleted one. */ void page_cur_delete_rec( - /*================*/ page_cur_t *cursor, /*!< in/out: a page cursor */ const dict_index_t *index, /*!< in: record descriptor */ const ulint *offsets, /*!< in: rec_get_offsets( @@ -269,10 +236,8 @@ UNIV_INLINE ulint page_cur_search(const buf_block_t *block, const dict_index_t *index, const dtuple_t *tuple, page_cur_t *cursor); -/****************************************************************/ /** - Searches the right position for a page cursor. */ +/** Searches the right position for a page cursor. */ void page_cur_search_with_match( - /*=======================*/ const buf_block_t *block, /*!< in: buffer block */ const dict_index_t *index, /*!< in: record descriptor */ const dtuple_t *tuple, /*!< in: data tuple */ @@ -305,50 +270,39 @@ void page_cur_search_with_match_bytes( const buf_block_t *block, const dict_index_t *index, const dtuple_t *tuple, page_cur_mode_t mode, ulint *iup_matched_fields, ulint *iup_matched_bytes, ulint *ilow_matched_fields, ulint *ilow_matched_bytes, page_cur_t *cursor); -/***********************************************************/ /** - Positions a page cursor on a randomly chosen user record on a page. If there +/** Positions a page cursor on a randomly chosen user record on a page. If there are no user records, sets the cursor on the infimum record. */ -void page_cur_open_on_rnd_user_rec( - /*==========================*/ - buf_block_t *block, /*!< in: page */ - page_cur_t *cursor); /*!< out: page cursor */ -/***********************************************************/ /** - Parses a log record of a record insert on a page. +void page_cur_open_on_rnd_user_rec(buf_block_t *block, /*!< in: page */ + page_cur_t *cursor); /*!< out: page cursor */ +/** Parses a log record of a record insert on a page. @return end of log record or NULL */ byte *page_cur_parse_insert_rec( - /*======================*/ ibool is_short, /*!< in: TRUE if short inserts */ const byte *ptr, /*!< in: buffer */ const byte *end_ptr, /*!< in: buffer end */ buf_block_t *block, /*!< in: page or NULL */ dict_index_t *index, /*!< in: record descriptor */ mtr_t *mtr); /*!< in: mtr or NULL */ -/**********************************************************/ /** - Parses a log record of copying a record list end to a new created page. +/** Parses a log record of copying a record list end to a new created page. @return end of log record or NULL */ byte *page_parse_copy_rec_list_to_created_page( - /*=====================================*/ byte *ptr, /*!< in: buffer */ byte *end_ptr, /*!< in: buffer end */ buf_block_t *block, /*!< in: page or NULL */ dict_index_t *index, /*!< in: record descriptor */ mtr_t *mtr); /*!< in: mtr or NULL */ -/***********************************************************/ /** - Parses log record of a record delete on a page. +/** Parses log record of a record delete on a page. @return pointer to record end or NULL */ byte *page_cur_parse_delete_rec( - /*======================*/ byte *ptr, /*!< in: buffer */ byte *end_ptr, /*!< in: buffer end */ buf_block_t *block, /*!< in: page or NULL */ dict_index_t *index, /*!< in: record descriptor */ mtr_t *mtr); /*!< in: mtr or NULL */ -/*******************************************************/ /** - Removes the record from a leaf page. This function does not log +/** Removes the record from a leaf page. This function does not log any changes. It is used by the IMPORT tablespace functions. @return true if success, i.e., the page did not become too empty */ bool page_delete_rec( - /*============*/ const dict_index_t *index, /*!< in: The index that the record belongs to */ page_cur_t *pcur, /*!< in/out: page cursor on record diff --git a/storage/innobase/include/page0cur.ic b/storage/innobase/include/page0cur.ic index b6a2748be33a..d26d81adee1e 100644 --- a/storage/innobase/include/page0cur.ic +++ b/storage/innobase/include/page0cur.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file include/page0cur.ic +/** @file include/page0cur.ic The page cursor Created 10/4/1994 Heikki Tuuri @@ -39,13 +38,10 @@ this program; if not, write to the Free Software Foundation, Inc., #include "rem0cmp.h" #endif /* !UNIV_HOTBACKUP */ -/*********************************************************/ /** - Gets pointer to the page frame where the cursor is positioned. +/** Gets pointer to the page frame where the cursor is positioned. @return page */ UNIV_INLINE -page_t *page_cur_get_page( - /*==============*/ - page_cur_t *cur) /*!< in: page cursor */ +page_t *page_cur_get_page(page_cur_t *cur) /*!< in: page cursor */ { ut_ad(cur); ut_ad(page_align(cur->rec) == cur->block->frame); @@ -53,37 +49,28 @@ page_t *page_cur_get_page( return (page_align(cur->rec)); } -/*********************************************************/ /** - Gets pointer to the buffer block where the cursor is positioned. +/** Gets pointer to the buffer block where the cursor is positioned. @return page */ UNIV_INLINE -buf_block_t *page_cur_get_block( - /*===============*/ - page_cur_t *cur) /*!< in: page cursor */ +buf_block_t *page_cur_get_block(page_cur_t *cur) /*!< in: page cursor */ { ut_ad(cur); ut_ad(page_align(cur->rec) == cur->block->frame); return (cur->block); } -/*********************************************************/ /** - Gets pointer to the page frame where the cursor is positioned. +/** Gets pointer to the page frame where the cursor is positioned. @return page */ UNIV_INLINE -page_zip_des_t *page_cur_get_page_zip( - /*==================*/ - page_cur_t *cur) /*!< in: page cursor */ +page_zip_des_t *page_cur_get_page_zip(page_cur_t *cur) /*!< in: page cursor */ { return (buf_block_get_page_zip(page_cur_get_block(cur))); } -/*********************************************************/ /** - Gets the record where the cursor is positioned. +/** Gets the record where the cursor is positioned. @return record */ UNIV_INLINE -rec_t *page_cur_get_rec( - /*=============*/ - page_cur_t *cur) /*!< in: page cursor */ +rec_t *page_cur_get_rec(page_cur_t *cur) /*!< in: page cursor */ { ut_ad(cur); ut_ad(page_align(cur->rec) == cur->block->frame); @@ -92,63 +79,49 @@ rec_t *page_cur_get_rec( } #endif /* UNIV_DEBUG */ -/*********************************************************/ /** - Sets the cursor object to point before the first user record +/** Sets the cursor object to point before the first user record on the page. */ UNIV_INLINE -void page_cur_set_before_first( - /*======================*/ - const buf_block_t *block, /*!< in: index page */ - page_cur_t *cur) /*!< in: cursor */ +void page_cur_set_before_first(const buf_block_t *block, /*!< in: index page */ + page_cur_t *cur) /*!< in: cursor */ { cur->block = (buf_block_t *)block; cur->rec = page_get_infimum_rec(buf_block_get_frame(cur->block)); } -/*********************************************************/ /** - Sets the cursor object to point after the last user record on +/** Sets the cursor object to point after the last user record on the page. */ UNIV_INLINE -void page_cur_set_after_last( - /*====================*/ - const buf_block_t *block, /*!< in: index page */ - page_cur_t *cur) /*!< in: cursor */ +void page_cur_set_after_last(const buf_block_t *block, /*!< in: index page */ + page_cur_t *cur) /*!< in: cursor */ { cur->block = (buf_block_t *)block; cur->rec = page_get_supremum_rec(buf_block_get_frame(cur->block)); } -/*********************************************************/ /** - Returns TRUE if the cursor is before first user record on page. +/** Returns TRUE if the cursor is before first user record on page. @return true if at start */ UNIV_INLINE -ibool page_cur_is_before_first( - /*=====================*/ - const page_cur_t *cur) /*!< in: cursor */ +ibool page_cur_is_before_first(const page_cur_t *cur) /*!< in: cursor */ { ut_ad(cur); ut_ad(page_align(cur->rec) == cur->block->frame); return (page_rec_is_infimum(cur->rec)); } -/*********************************************************/ /** - Returns TRUE if the cursor is after last user record. +/** Returns TRUE if the cursor is after last user record. @return true if at end */ UNIV_INLINE -ibool page_cur_is_after_last( - /*===================*/ - const page_cur_t *cur) /*!< in: cursor */ +ibool page_cur_is_after_last(const page_cur_t *cur) /*!< in: cursor */ { ut_ad(cur); ut_ad(page_align(cur->rec) == cur->block->frame); return (page_rec_is_supremum(cur->rec)); } -/**********************************************************/ /** - Positions the cursor on the given record. */ +/** Positions the cursor on the given record. */ UNIV_INLINE void page_cur_position( - /*==============*/ const rec_t *rec, /*!< in: record on a page */ const buf_block_t *block, /*!< in: buffer block containing the record */ @@ -161,11 +134,9 @@ void page_cur_position( cur->block = (buf_block_t *)block; } -/**********************************************************/ /** - Moves the cursor to the next record on page. */ +/** Moves the cursor to the next record on page. */ UNIV_INLINE void page_cur_move_to_next( - /*==================*/ page_cur_t *cur) /*!< in/out: cursor; must not be after last */ { ut_ad(!page_cur_is_after_last(cur)); @@ -173,11 +144,9 @@ void page_cur_move_to_next( cur->rec = page_rec_get_next(cur->rec); } -/**********************************************************/ /** - Moves the cursor to the previous record on page. */ +/** Moves the cursor to the previous record on page. */ UNIV_INLINE void page_cur_move_to_prev( - /*==================*/ page_cur_t *cur) /*!< in/out: page cursor, not before first */ { ut_ad(!page_cur_is_before_first(cur)); @@ -219,8 +188,7 @@ ulint page_cur_search(const buf_block_t *block, const dict_index_t *index, return (page_cur_search(block, index, tuple, PAGE_CUR_LE, cursor)); } -/***********************************************************/ /** - Inserts a record next to page cursor. Returns pointer to inserted record if +/** Inserts a record next to page cursor. Returns pointer to inserted record if succeed, i.e., enough space available, NULL otherwise. The cursor stays at the same logical position, but the physical position may change if it is pointing to a compressed page that was reorganized. @@ -233,7 +201,6 @@ ulint page_cur_search(const buf_block_t *block, const dict_index_t *index, @return pointer to record if succeed, NULL otherwise */ UNIV_INLINE rec_t *page_cur_tuple_insert( - /*==================*/ page_cur_t *cursor, /*!< in/out: a page cursor */ const dtuple_t *tuple, /*!< in: pointer to a data tuple */ dict_index_t *index, /*!< in: record descriptor */ @@ -293,8 +260,7 @@ rec_t *page_cur_tuple_direct_insert(page_cur_t *cursor, const dtuple_t *tuple, } #endif /* !UNIV_HOTBACKUP */ -/***********************************************************/ /** - Inserts a record next to page cursor. Returns pointer to inserted record if +/** Inserts a record next to page cursor. Returns pointer to inserted record if succeed, i.e., enough space available, NULL otherwise. The cursor stays at the same logical position, but the physical position may change if it is pointing to a compressed page that was reorganized. @@ -307,7 +273,6 @@ rec_t *page_cur_tuple_direct_insert(page_cur_t *cursor, const dtuple_t *tuple, @return pointer to record if succeed, NULL otherwise */ UNIV_INLINE rec_t *page_cur_rec_insert( - /*================*/ page_cur_t *cursor, /*!< in/out: a page cursor */ const rec_t *rec, /*!< in: record to insert */ dict_index_t *index, /*!< in: record descriptor */ diff --git a/storage/innobase/include/page0page.h b/storage/innobase/include/page0page.h index ae62c195f169..dc06465909ae 100644 --- a/storage/innobase/include/page0page.h +++ b/storage/innobase/include/page0page.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -29,8 +29,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "my_compiler.h" -/**************************************************/ /** - @file include/page0page.h +/** @file include/page0page.h Index page routines Created 2/2/1994 Heikki Tuuri @@ -109,32 +108,21 @@ static const byte supremum_extra_data[] = { 0x6d /* "supremum" */ }; -/************************************************************/ /** - Gets the start of a page. +/** Gets the start of a page. @return start of the page */ UNIV_INLINE -page_t *page_align( - /*=======*/ - const void *ptr) /*!< in: pointer to page frame */ +page_t *page_align(const void *ptr) /*!< in: pointer to page frame */ MY_ATTRIBUTE((const)); -/************************************************************/ /** - Gets the offset within a page. +/** Gets the offset within a page. @return offset from the start of the page */ UNIV_INLINE -ulint page_offset( - /*========*/ - const void *ptr) /*!< in: pointer to page frame */ +ulint page_offset(const void *ptr) /*!< in: pointer to page frame */ MY_ATTRIBUTE((const)); -/*************************************************************/ /** - Returns the max trx id field value. */ -UNIV_INLINE -trx_id_t page_get_max_trx_id( - /*================*/ - const page_t *page); /*!< in: page */ -/*************************************************************/ /** - Sets the max trx id field value. */ +/** Returns the max trx id field value. */ +UNIV_INLINE +trx_id_t page_get_max_trx_id(const page_t *page); /*!< in: page */ +/** Sets the max trx id field value. */ void page_set_max_trx_id( - /*================*/ buf_block_t *block, /*!< in/out: page */ page_zip_des_t *page_zip, /*!< in/out: compressed page, or NULL */ trx_id_t trx_id, /*!< in: transaction id */ @@ -183,18 +171,14 @@ UNIV_INLINE void page_header_set_field(page_t *page, page_zip_des_t *page_zip, ulint field, ulint val); -/*************************************************************/ /** - Returns the offset stored in the given header field. +/** Returns the offset stored in the given header field. @return offset from the start of the page, or 0 */ UNIV_INLINE -ulint page_header_get_offs( - /*=================*/ - const page_t *page, /*!< in: page */ - ulint field) /*!< in: PAGE_FREE, ... */ +ulint page_header_get_offs(const page_t *page, /*!< in: page */ + ulint field) /*!< in: PAGE_FREE, ... */ MY_ATTRIBUTE((warn_unused_result)); -/*************************************************************/ /** - Returns the pointer stored in the given header field, or NULL. */ +/** Returns the pointer stored in the given header field, or NULL. */ #define page_header_get_ptr(page, field) \ (page_header_get_offs(page, field) \ ? page + page_header_get_offs(page, field) \ @@ -222,31 +206,24 @@ void page_header_reset_last_insert(page_t *page, page_zip_des_t *page_zip, mtr_t *mtr); #endif /* !UNIV_HOTBACKUP */ -/************************************************************/ /** - Gets the offset of the first record on the page. +/** Gets the offset of the first record on the page. @return offset of the first record in record list, relative from page */ UNIV_INLINE ulint page_get_infimum_offset( - /*====================*/ const page_t *page); /*!< in: page which must have record(s) */ -/************************************************************/ /** - Gets the offset of the last record on the page. +/** Gets the offset of the last record on the page. @return offset of the last record in record list, relative from page */ UNIV_INLINE ulint page_get_supremum_offset( - /*=====================*/ const page_t *page); /*!< in: page which must have record(s) */ #define page_get_infimum_rec(page) ((page) + page_get_infimum_offset(page)) #define page_get_supremum_rec(page) ((page) + page_get_supremum_offset(page)) -/************************************************************/ /** - Returns the nth record of the record list. +/** Returns the nth record of the record list. This is the inverse function of page_rec_get_n_recs_before(). @return nth record */ -const rec_t *page_rec_get_nth_const( - /*===================*/ - const page_t *page, /*!< in: page */ - ulint nth) /*!< in: nth record */ +const rec_t *page_rec_get_nth_const(const page_t *page, /*!< in: page */ + ulint nth) /*!< in: nth record */ MY_ATTRIBUTE((warn_unused_result)); /** Returns the nth record of the record list. @@ -259,54 +236,37 @@ rec_t *page_rec_get_nth(page_t *page, ulint nth) MY_ATTRIBUTE((warn_unused_result)); #ifndef UNIV_HOTBACKUP -/************************************************************/ /** - Returns the middle record of the records on the page. If there is an +/** Returns the middle record of the records on the page. If there is an even number of records in the list, returns the first record of the upper half-list. @return middle record */ UNIV_INLINE -rec_t *page_get_middle_rec( - /*================*/ - page_t *page) /*!< in: page */ +rec_t *page_get_middle_rec(page_t *page) /*!< in: page */ MY_ATTRIBUTE((warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ -/*************************************************************/ /** - Gets the page number. +/** Gets the page number. @return page number */ UNIV_INLINE -page_no_t page_get_page_no( - /*=============*/ - const page_t *page); /*!< in: page */ -/*************************************************************/ /** - Gets the tablespace identifier. +page_no_t page_get_page_no(const page_t *page); /*!< in: page */ +/** Gets the tablespace identifier. @return space id */ UNIV_INLINE -space_id_t page_get_space_id( - /*==============*/ - const page_t *page); /*!< in: page */ -/*************************************************************/ /** - Gets the number of user records on page (the infimum and supremum records +space_id_t page_get_space_id(const page_t *page); /*!< in: page */ +/** Gets the number of user records on page (the infimum and supremum records are not user records). @return number of user records */ UNIV_INLINE -ulint page_get_n_recs( - /*============*/ - const page_t *page); /*!< in: index page */ -/***************************************************************/ /** - Returns the number of records before the given record in chain. +ulint page_get_n_recs(const page_t *page); /*!< in: index page */ +/** Returns the number of records before the given record in chain. The number includes infimum and supremum records. This is the inverse function of page_rec_get_nth(). @return number of records */ ulint page_rec_get_n_recs_before( - /*=======================*/ const rec_t *rec); /*!< in: the physical record */ -/*************************************************************/ /** - Gets the number of records in the heap. +/** Gets the number of records in the heap. @return number of user records */ UNIV_INLINE -ulint page_dir_get_n_heap( - /*================*/ - const page_t *page); /*!< in: index page */ +ulint page_dir_get_n_heap(const page_t *page); /*!< in: index page */ /** Sets the number of records in the heap. @param[in,out] page index page @@ -318,13 +278,10 @@ ulint page_dir_get_n_heap( UNIV_INLINE void page_dir_set_n_heap(page_t *page, page_zip_des_t *page_zip, ulint n_heap); -/*************************************************************/ /** - Gets the number of dir slots in directory. +/** Gets the number of dir slots in directory. @return number of slots */ UNIV_INLINE -ulint page_dir_get_n_slots( - /*=================*/ - const page_t *page); /*!< in: index page */ +ulint page_dir_get_n_slots(const page_t *page); /*!< in: index page */ /** Sets the number of dir slots in directory. @param[in,out] page page @@ -347,19 +304,14 @@ page_dir_slot_t *page_dir_get_nth_slot(const page_t *page, ulint n); ((page) + (UNIV_PAGE_SIZE - PAGE_DIR - (n + 1) * PAGE_DIR_SLOT_SIZE)) #endif /* UNIV_DEBUG */ -/**************************************************************/ /** - Used to check the consistency of a record on a page. +/** Used to check the consistency of a record on a page. @return true if succeed */ UNIV_INLINE -ibool page_rec_check( - /*===========*/ - const rec_t *rec); /*!< in: record */ -/***************************************************************/ /** - Gets the record pointed to by a directory slot. +ibool page_rec_check(const rec_t *rec); /*!< in: record */ +/** Gets the record pointed to by a directory slot. @return pointer to record */ UNIV_INLINE const rec_t *page_dir_slot_get_rec( - /*==================*/ const page_dir_slot_t *slot); /*!< in: directory slot */ /** This is used to set the record offset in a directory slot. @@ -368,12 +320,10 @@ const rec_t *page_dir_slot_get_rec( UNIV_INLINE void page_dir_slot_set_rec(page_dir_slot_t *slot, rec_t *rec); -/***************************************************************/ /** - Gets the number of records owned by a directory slot. +/** Gets the number of records owned by a directory slot. @return number of records */ UNIV_INLINE ulint page_dir_slot_get_n_owned( - /*======================*/ const page_dir_slot_t *slot); /*!< in: page directory slot */ /** This is used to set the owned records field of a directory slot. @@ -384,71 +334,48 @@ UNIV_INLINE void page_dir_slot_set_n_owned(page_dir_slot_t *slot, page_zip_des_t *page_zip, ulint n); -/************************************************************/ /** - Calculates the space reserved for directory slots of a given +/** Calculates the space reserved for directory slots of a given number of records. The exact value is a fraction number n * PAGE_DIR_SLOT_SIZE / PAGE_DIR_SLOT_MIN_N_OWNED, and it is rounded upwards to an integer. */ UNIV_INLINE -ulint page_dir_calc_reserved_space( - /*=========================*/ - ulint n_recs); /*!< in: number of records */ -/***************************************************************/ /** - Looks for the directory slot which owns the given record. +ulint page_dir_calc_reserved_space(ulint n_recs); /*!< in: number of records */ +/** Looks for the directory slot which owns the given record. @return the directory slot number */ ulint page_dir_find_owner_slot( - /*=====================*/ const rec_t *rec); /*!< in: the physical record */ -/************************************************************/ /** - Determine whether the page is in new-style compact format. +/** Determine whether the page is in new-style compact format. @return nonzero if the page is in compact format, zero if it is in old-style format */ UNIV_INLINE -ulint page_is_comp( - /*=========*/ - const page_t *page); /*!< in: index page */ -/************************************************************/ /** - TRUE if the record is on a page in compact format. +ulint page_is_comp(const page_t *page); /*!< in: index page */ +/** TRUE if the record is on a page in compact format. @return nonzero if in compact format */ UNIV_INLINE -ulint page_rec_is_comp( - /*=============*/ - const rec_t *rec); /*!< in: record */ -/***************************************************************/ /** - Returns the heap number of a record. +ulint page_rec_is_comp(const rec_t *rec); /*!< in: record */ +/** Returns the heap number of a record. @return heap number */ UNIV_INLINE -ulint page_rec_get_heap_no( - /*=================*/ - const rec_t *rec); /*!< in: the physical record */ -/************************************************************/ /** - Determine whether the page is a B-tree leaf. +ulint page_rec_get_heap_no(const rec_t *rec); /*!< in: the physical record */ +/** Determine whether the page is a B-tree leaf. @return true if the page is a B-tree leaf (PAGE_LEVEL = 0) */ UNIV_INLINE -bool page_is_leaf( - /*=========*/ - const page_t *page) /*!< in: page */ +bool page_is_leaf(const page_t *page) /*!< in: page */ MY_ATTRIBUTE((warn_unused_result)); -/************************************************************/ /** - Determine whether the page is empty. +/** Determine whether the page is empty. @return true if the page is empty (PAGE_N_RECS = 0) */ UNIV_INLINE -bool page_is_empty( - /*==========*/ - const page_t *page) /*!< in: page */ +bool page_is_empty(const page_t *page) /*!< in: page */ MY_ATTRIBUTE((warn_unused_result)); /** Determine whether a page is an index root page. @param[in] page page frame @return true if the page is a root page of an index */ UNIV_INLINE bool page_is_root(const page_t *page) MY_ATTRIBUTE((warn_unused_result)); -/************************************************************/ /** - Determine whether the page contains garbage. +/** Determine whether the page contains garbage. @return true if the page contains garbage (PAGE_GARBAGE is not 0) */ UNIV_INLINE -bool page_has_garbage( - /*=============*/ - const page_t *page) /*!< in: page */ +bool page_has_garbage(const page_t *page) /*!< in: page */ MY_ATTRIBUTE((warn_unused_result)); /** Gets the pointer to the next record on the page. @@ -458,28 +385,21 @@ bool page_has_garbage( UNIV_INLINE const rec_t *page_rec_get_next_low(const rec_t *rec, ulint comp); -/************************************************************/ /** - Gets the pointer to the next record on the page. +/** Gets the pointer to the next record on the page. @return pointer to next record */ UNIV_INLINE -rec_t *page_rec_get_next( - /*==============*/ - rec_t *rec); /*!< in: pointer to record */ -/************************************************************/ /** - Gets the pointer to the next record on the page. +rec_t *page_rec_get_next(rec_t *rec); /*!< in: pointer to record */ +/** Gets the pointer to the next record on the page. @return pointer to next record */ UNIV_INLINE const rec_t *page_rec_get_next_const( - /*====================*/ const rec_t *rec); /*!< in: pointer to record */ -/************************************************************/ /** - Gets the pointer to the next non delete-marked record on the page. +/** Gets the pointer to the next non delete-marked record on the page. If all subsequent records are delete-marked, then this function will return the supremum record. @return pointer to next non delete-marked record or pointer to supremum */ UNIV_INLINE const rec_t *page_rec_get_next_non_del_marked( - /*=============================*/ const rec_t *rec); /*!< in: pointer to record */ /** Sets the pointer to the next record on the page. @@ -488,120 +408,82 @@ const rec_t *page_rec_get_next_non_del_marked( UNIV_INLINE void page_rec_set_next(rec_t *rec, const rec_t *next); -/************************************************************/ /** - Gets the pointer to the previous record. +/** Gets the pointer to the previous record. @return pointer to previous record */ UNIV_INLINE const rec_t *page_rec_get_prev_const( - /*====================*/ const rec_t *rec); /*!< in: pointer to record, must not be page infimum */ -/************************************************************/ /** - Gets the pointer to the previous record. +/** Gets the pointer to the previous record. @return pointer to previous record */ UNIV_INLINE -rec_t *page_rec_get_prev( - /*==============*/ - rec_t *rec); /*!< in: pointer to record, - must not be page infimum */ -/************************************************************/ /** - TRUE if the record is a user record on the page. +rec_t *page_rec_get_prev(rec_t *rec); /*!< in: pointer to record, + must not be page infimum */ +/** TRUE if the record is a user record on the page. @return true if a user record */ UNIV_INLINE -ibool page_rec_is_user_rec_low( - /*=====================*/ - ulint offset) /*!< in: record offset on page */ +ibool page_rec_is_user_rec_low(ulint offset) /*!< in: record offset on page */ MY_ATTRIBUTE((const)); -/************************************************************/ /** - TRUE if the record is the supremum record on a page. +/** TRUE if the record is the supremum record on a page. @return true if the supremum record */ UNIV_INLINE -ibool page_rec_is_supremum_low( - /*=====================*/ - ulint offset) /*!< in: record offset on page */ +ibool page_rec_is_supremum_low(ulint offset) /*!< in: record offset on page */ MY_ATTRIBUTE((const)); -/************************************************************/ /** - TRUE if the record is the infimum record on a page. +/** TRUE if the record is the infimum record on a page. @return true if the infimum record */ UNIV_INLINE -ibool page_rec_is_infimum_low( - /*====================*/ - ulint offset) /*!< in: record offset on page */ +ibool page_rec_is_infimum_low(ulint offset) /*!< in: record offset on page */ MY_ATTRIBUTE((const)); -/************************************************************/ /** - TRUE if the record is a user record on the page. +/** TRUE if the record is a user record on the page. @return true if a user record */ UNIV_INLINE -ibool page_rec_is_user_rec( - /*=================*/ - const rec_t *rec) /*!< in: record */ +ibool page_rec_is_user_rec(const rec_t *rec) /*!< in: record */ MY_ATTRIBUTE((warn_unused_result)); -/************************************************************/ /** - TRUE if the record is the supremum record on a page. +/** TRUE if the record is the supremum record on a page. @return true if the supremum record */ UNIV_INLINE -ibool page_rec_is_supremum( - /*=================*/ - const rec_t *rec) /*!< in: record */ +ibool page_rec_is_supremum(const rec_t *rec) /*!< in: record */ MY_ATTRIBUTE((warn_unused_result)); -/************************************************************/ /** - TRUE if the record is the infimum record on a page. +/** TRUE if the record is the infimum record on a page. @return true if the infimum record */ UNIV_INLINE -ibool page_rec_is_infimum( - /*================*/ - const rec_t *rec) /*!< in: record */ +ibool page_rec_is_infimum(const rec_t *rec) /*!< in: record */ MY_ATTRIBUTE((warn_unused_result)); -/************************************************************/ /** - true if the record is the first user record on a page. +/** true if the record is the first user record on a page. @return true if the first user record */ UNIV_INLINE -bool page_rec_is_first( - /*==============*/ - const rec_t *rec, /*!< in: record */ - const page_t *page) /*!< in: page */ +bool page_rec_is_first(const rec_t *rec, /*!< in: record */ + const page_t *page) /*!< in: page */ MY_ATTRIBUTE((warn_unused_result)); -/************************************************************/ /** - true if the record is the second user record on a page. +/** true if the record is the second user record on a page. @return true if the second user record */ UNIV_INLINE -bool page_rec_is_second( - /*===============*/ - const rec_t *rec, /*!< in: record */ - const page_t *page) /*!< in: page */ +bool page_rec_is_second(const rec_t *rec, /*!< in: record */ + const page_t *page) /*!< in: page */ MY_ATTRIBUTE((warn_unused_result)); -/************************************************************/ /** - true if the record is the last user record on a page. +/** true if the record is the last user record on a page. @return true if the last user record */ UNIV_INLINE -bool page_rec_is_last( - /*=============*/ - const rec_t *rec, /*!< in: record */ - const page_t *page) /*!< in: page */ +bool page_rec_is_last(const rec_t *rec, /*!< in: record */ + const page_t *page) /*!< in: page */ MY_ATTRIBUTE((warn_unused_result)); -/************************************************************/ /** - true if the record is the second last user record on a page. +/** true if the record is the second last user record on a page. @return true if the second last user record */ UNIV_INLINE -bool page_rec_is_second_last( - /*====================*/ - const rec_t *rec, /*!< in: record */ - const page_t *page) /*!< in: page */ +bool page_rec_is_second_last(const rec_t *rec, /*!< in: record */ + const page_t *page) /*!< in: page */ MY_ATTRIBUTE((warn_unused_result)); -/***************************************************************/ /** - Looks for the record which owns the given record. +/** Looks for the record which owns the given record. @return the owner record */ UNIV_INLINE -rec_t *page_rec_find_owner_rec( - /*====================*/ - rec_t *rec); /*!< in: the physical record */ +rec_t *page_rec_find_owner_rec(rec_t *rec); /*!< in: the physical record */ #ifndef UNIV_HOTBACKUP /** Write a 32-bit field in a data dictionary record. @@ -630,30 +512,23 @@ UNIV_INLINE ulint page_get_max_insert_size_after_reorganize(const page_t *page, ulint n_recs); -/*************************************************************/ /** - Calculates free space if a page is emptied. +/** Calculates free space if a page is emptied. @return free space */ UNIV_INLINE ulint page_get_free_space_of_empty( - /*=========================*/ ulint comp) /*!< in: nonzero=compact page format */ MY_ATTRIBUTE((const)); -/**********************************************************/ /** - Returns the base extra size of a physical record. This is the +/** Returns the base extra size of a physical record. This is the size of the fixed header, independent of the record size. @return REC_N_NEW_EXTRA_BYTES or REC_N_OLD_EXTRA_BYTES */ UNIV_INLINE ulint page_rec_get_base_extra_size( - /*=========================*/ const rec_t *rec); /*!< in: physical record */ -/************************************************************/ /** - Returns the sum of the sizes of the records in the record list +/** Returns the sum of the sizes of the records in the record list excluding the infimum and supremum records. @return data in bytes */ UNIV_INLINE -ulint page_get_data_size( - /*===============*/ - const page_t *page); /*!< in: index page */ +ulint page_get_data_size(const page_t *page); /*!< in: index page */ /** Allocates a block of memory from the head of the free list of an index page. @@ -667,11 +542,9 @@ UNIV_INLINE void page_mem_alloc_free(page_t *page, page_zip_des_t *page_zip, rec_t *next_rec, ulint need); -/************************************************************/ /** - Allocates a block of memory from the heap of an index page. +/** Allocates a block of memory from the heap of an index page. @return pointer to start of allocated buffer, or NULL if allocation fails */ byte *page_mem_alloc_heap( - /*================*/ page_t *page, /*!< in/out: index page */ page_zip_des_t *page_zip, /*!< in/out: compressed page with enough space available for inserting the record, @@ -712,15 +585,11 @@ page_t *page_create(buf_block_t *block, mtr_t *mtr, ulint comp, page_t *page_create_zip(buf_block_t *block, dict_index_t *index, ulint level, trx_id_t max_trx_id, mtr_t *mtr, page_type_t page_type); -/**********************************************************/ /** - Empty a previously created B-tree index page. */ -void page_create_empty( - /*==============*/ - buf_block_t *block, /*!< in/out: B-tree block */ - dict_index_t *index, /*!< in: the index of the page */ - mtr_t *mtr); /*!< in/out: mini-transaction */ -/*************************************************************/ /** - Differs from page_copy_rec_list_end, because this function does not +/** Empty a previously created B-tree index page. */ +void page_create_empty(buf_block_t *block, /*!< in/out: B-tree block */ + dict_index_t *index, /*!< in: the index of the page */ + mtr_t *mtr); /*!< in/out: mini-transaction */ +/** Differs from page_copy_rec_list_end, because this function does not touch the lock table and max trx id on page or compress the page. IMPORTANT: The caller will have to update IBUF_BITMAP_FREE @@ -728,14 +597,12 @@ void page_create_empty( This has to be done either within the same mini-transaction, or by invoking ibuf_reset_free_bits() before mtr_commit(). */ void page_copy_rec_list_end_no_locks( - /*============================*/ buf_block_t *new_block, /*!< in: index page to copy to */ buf_block_t *block, /*!< in: index page of rec */ rec_t *rec, /*!< in: record on page */ dict_index_t *index, /*!< in: record descriptor */ mtr_t *mtr); /*!< in: mtr */ -/*************************************************************/ /** - Copies records from page to new_page, from the given record onward, +/** Copies records from page to new_page, from the given record onward, including that record. Infimum and supremum records are not copied. The records are copied to the start of the record list on new_page. @@ -747,14 +614,12 @@ void page_copy_rec_list_end_no_locks( @return pointer to the original successor of the infimum record on new_page, or NULL on zip overflow (new_block will be decompressed) */ rec_t *page_copy_rec_list_end( - /*===================*/ buf_block_t *new_block, /*!< in/out: index page to copy to */ buf_block_t *block, /*!< in: index page containing rec */ rec_t *rec, /*!< in: record on page */ dict_index_t *index, /*!< in: record descriptor */ mtr_t *mtr); /*!< in: mtr */ -/*************************************************************/ /** - Copies records from page to new_page, up to the given record, NOT +/** Copies records from page to new_page, up to the given record, NOT including that record. Infimum and supremum records are not copied. The records are copied to the end of the record list on new_page. @@ -766,17 +631,14 @@ rec_t *page_copy_rec_list_end( @return pointer to the original predecessor of the supremum record on new_page, or NULL on zip overflow (new_block will be decompressed) */ rec_t *page_copy_rec_list_start( - /*=====================*/ buf_block_t *new_block, /*!< in/out: index page to copy to */ buf_block_t *block, /*!< in: index page containing rec */ rec_t *rec, /*!< in: record on page */ dict_index_t *index, /*!< in: record descriptor */ mtr_t *mtr); /*!< in: mtr */ -/*************************************************************/ /** - Deletes records from a page from a given record onward, including that record. - The infimum and supremum records are not deleted. */ +/** Deletes records from a page from a given record onward, including that + record. The infimum and supremum records are not deleted. */ void page_delete_rec_list_end( - /*=====================*/ rec_t *rec, /*!< in: pointer to record on page */ buf_block_t *block, /*!< in: buffer block of the page */ dict_index_t *index, /*!< in: record descriptor */ @@ -786,17 +648,14 @@ void page_delete_rec_list_end( records in the end of the chain to delete, or ULINT_UNDEFINED if not known */ mtr_t *mtr); /*!< in: mtr */ -/*************************************************************/ /** - Deletes records from page, up to the given record, NOT including +/** Deletes records from page, up to the given record, NOT including that record. Infimum and supremum records are not deleted. */ void page_delete_rec_list_start( - /*=======================*/ rec_t *rec, /*!< in: record on page */ buf_block_t *block, /*!< in: buffer block of the page */ dict_index_t *index, /*!< in: record descriptor */ mtr_t *mtr); /*!< in: mtr */ -/*************************************************************/ /** - Moves record list end to another page. Moved records include +/** Moves record list end to another page. Moved records include split_rec. IMPORTANT: The caller will have to update IBUF_BITMAP_FREE @@ -807,14 +666,12 @@ void page_delete_rec_list_start( @return true on success; false on compression failure (new_block will be decompressed) */ ibool page_move_rec_list_end( - /*===================*/ buf_block_t *new_block, /*!< in/out: index page where to move */ buf_block_t *block, /*!< in: index page from where to move */ rec_t *split_rec, /*!< in: first record to move */ dict_index_t *index, /*!< in: record descriptor */ mtr_t *mtr); /*!< in: mtr */ -/*************************************************************/ /** - Moves record list start to another page. Moved records do not include +/** Moves record list start to another page. Moved records do not include split_rec. IMPORTANT: The caller will have to update IBUF_BITMAP_FREE @@ -824,35 +681,28 @@ ibool page_move_rec_list_end( @return true on success; false on compression failure */ ibool page_move_rec_list_start( - /*=====================*/ buf_block_t *new_block, /*!< in/out: index page where to move */ buf_block_t *block, /*!< in/out: page containing split_rec */ rec_t *split_rec, /*!< in: first record not to move */ dict_index_t *index, /*!< in: record descriptor */ mtr_t *mtr); /*!< in: mtr */ -/****************************************************************/ /** - Splits a directory slot which owns too many records. */ +/** Splits a directory slot which owns too many records. */ void page_dir_split_slot( - /*================*/ page_t *page, /*!< in: index page */ page_zip_des_t *page_zip, /*!< in/out: compressed page whose uncompressed part will be written, or NULL */ ulint slot_no); /*!< in: the directory slot */ -/*************************************************************/ /** - Tries to balance the given directory slot with too few records +/** Tries to balance the given directory slot with too few records with the upper neighbor, so that there are at least the minimum number of records owned by the slot; this may result in the merging of two slots. */ void page_dir_balance_slot( - /*==================*/ page_t *page, /*!< in/out: index page */ page_zip_des_t *page_zip, /*!< in/out: compressed page, or NULL */ ulint slot_no); /*!< in: the directory slot */ -/**********************************************************/ /** - Parses a log record of a record list end or start deletion. +/** Parses a log record of a record list end or start deletion. @return end of log record or NULL */ byte *page_parse_delete_rec_list( - /*=======================*/ mlog_id_t type, /*!< in: MLOG_LIST_END_DELETE, MLOG_LIST_START_DELETE, MLOG_COMP_LIST_END_DELETE or @@ -869,94 +719,67 @@ byte *page_parse_delete_rec_list( @param[in] page_type page type */ void page_parse_create(buf_block_t *block, ulint comp, page_type_t page_type); #ifndef UNIV_HOTBACKUP -/************************************************************/ /** - Prints record contents including the data relevant only in +/** Prints record contents including the data relevant only in the index page context. */ -void page_rec_print( - /*===========*/ - const rec_t *rec, /*!< in: physical record */ - const ulint *offsets); /*!< in: record descriptor */ +void page_rec_print(const rec_t *rec, /*!< in: physical record */ + const ulint *offsets); /*!< in: record descriptor */ #ifdef UNIV_BTR_PRINT -/***************************************************************/ /** - This is used to print the contents of the directory for +/** This is used to print the contents of the directory for debugging purposes. */ -void page_dir_print( - /*===========*/ - page_t *page, /*!< in: index page */ - ulint pr_n); /*!< in: print n first and n last entries */ -/***************************************************************/ /** - This is used to print the contents of the page record list for +void page_dir_print(page_t *page, /*!< in: index page */ + ulint pr_n); /*!< in: print n first and n last entries */ +/** This is used to print the contents of the page record list for debugging purposes. */ void page_print_list( - /*============*/ buf_block_t *block, /*!< in: index page */ dict_index_t *index, /*!< in: dictionary index of the page */ ulint pr_n); /*!< in: print n first and n last entries */ -/***************************************************************/ /** - Prints the info in a page header. */ -void page_header_print( - /*==============*/ - const page_t *page); /*!< in: index page */ -/***************************************************************/ /** - This is used to print the contents of the page for +/** Prints the info in a page header. */ +void page_header_print(const page_t *page); /*!< in: index page */ +/** This is used to print the contents of the page for debugging purposes. */ -void page_print( - /*=======*/ - buf_block_t *block, /*!< in: index page */ - dict_index_t *index, /*!< in: dictionary index of the page */ - ulint dn, /*!< in: print dn first and last entries - in directory */ - ulint rn); /*!< in: print rn first and last records - in directory */ -#endif /* UNIV_BTR_PRINT */ -#endif /* !UNIV_HOTBACKUP */ -/***************************************************************/ /** - The following is used to validate a record on a page. This function +void page_print(buf_block_t *block, /*!< in: index page */ + dict_index_t *index, /*!< in: dictionary index of the page */ + ulint dn, /*!< in: print dn first and last entries + in directory */ + ulint rn); /*!< in: print rn first and last records + in directory */ +#endif /* UNIV_BTR_PRINT */ +#endif /* !UNIV_HOTBACKUP */ +/** The following is used to validate a record on a page. This function differs from rec_validate as it can also check the n_owned field and the heap_no field. @return true if ok */ ibool page_rec_validate( - /*==============*/ const rec_t *rec, /*!< in: physical record */ const ulint *offsets); /*!< in: array returned by rec_get_offsets() */ #ifdef UNIV_DEBUG -/***************************************************************/ /** - Checks that the first directory slot points to the infimum record and +/** Checks that the first directory slot points to the infimum record and the last to the supremum. This function is intended to track if the bug fixed in 4.0.14 has caused corruption to users' databases. */ -void page_check_dir( - /*===========*/ - const page_t *page); /*!< in: index page */ -#endif /* UNIV_DEBUG */ -/***************************************************************/ /** - This function checks the consistency of an index page when we do not +void page_check_dir(const page_t *page); /*!< in: index page */ +#endif /* UNIV_DEBUG */ +/** This function checks the consistency of an index page when we do not know the index. This is also resilient so that this should never crash even if the page is total garbage. @return true if ok */ ibool page_simple_validate_old( - /*=====================*/ const page_t *page); /*!< in: index page in ROW_FORMAT=REDUNDANT */ -/***************************************************************/ /** - This function checks the consistency of an index page when we do not +/** This function checks the consistency of an index page when we do not know the index. This is also resilient so that this should never crash even if the page is total garbage. @return true if ok */ ibool page_simple_validate_new( - /*=====================*/ const page_t *page); /*!< in: index page in ROW_FORMAT!=REDUNDANT */ -/***************************************************************/ /** - This function checks the consistency of an index page. +/** This function checks the consistency of an index page. @return true if ok */ ibool page_validate( - /*==========*/ const page_t *page, /*!< in: index page */ dict_index_t *index); /*!< in: data dictionary index containing the page record type definition */ -/***************************************************************/ /** - Looks in the page record list for a record with the given heap number. +/** Looks in the page record list for a record with the given heap number. @return record, NULL if not found */ const rec_t *page_find_rec_with_heap_no( - /*=======================*/ const page_t *page, /*!< in: index page */ ulint heap_no); /*!< in: heap number */ /** Get the last non-delete-marked record on a page. diff --git a/storage/innobase/include/page0page.ic b/storage/innobase/include/page0page.ic index 364a8f13e3d8..45733b92c55d 100644 --- a/storage/innobase/include/page0page.ic +++ b/storage/innobase/include/page0page.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/page0page.ic +/** @file include/page0page.ic Index page routines Created 2/2/1994 Heikki Tuuri @@ -46,44 +45,33 @@ this program; if not, write to the Free Software Foundation, Inc., #define UNIV_INLINE #endif -/************************************************************/ /** - Gets the start of a page. +/** Gets the start of a page. @return start of the page */ UNIV_INLINE -page_t *page_align( - /*=======*/ - const void *ptr) /*!< in: pointer to page frame */ +page_t *page_align(const void *ptr) /*!< in: pointer to page frame */ { return ((page_t *)ut_align_down(ptr, UNIV_PAGE_SIZE)); } -/************************************************************/ /** - Gets the offset within a page. +/** Gets the offset within a page. @return offset from the start of the page */ UNIV_INLINE -ulint page_offset( - /*========*/ - const void *ptr) /*!< in: pointer to page frame */ +ulint page_offset(const void *ptr) /*!< in: pointer to page frame */ { return (ut_align_offset(ptr, UNIV_PAGE_SIZE)); } -/*************************************************************/ /** - Returns the max trx id field value. */ +/** Returns the max trx id field value. */ UNIV_INLINE -trx_id_t page_get_max_trx_id( - /*================*/ - const page_t *page) /*!< in: page */ +trx_id_t page_get_max_trx_id(const page_t *page) /*!< in: page */ { ut_ad(page); return (mach_read_from_8(page + PAGE_HEADER + PAGE_MAX_TRX_ID)); } -/*************************************************************/ /** - Sets the max trx id field value if trx_id is bigger than the previous +/** Sets the max trx id field value if trx_id is bigger than the previous value. */ UNIV_INLINE void page_update_max_trx_id( - /*===================*/ buf_block_t *block, /*!< in/out: page */ page_zip_des_t *page_zip, /*!< in/out: compressed page whose uncompressed part will be updated, or NULL */ @@ -146,11 +134,9 @@ void page_set_ssn_id(buf_block_t *block, page_zip_des_t *page_zip, } } -/*************************************************************/ /** - Sets the given header field. */ +/** Sets the given header field. */ UNIV_INLINE void page_header_set_field( - /*==================*/ page_t *page, /*!< in/out: page */ page_zip_des_t *page_zip, /*!< in/out: compressed page whose uncompressed part will be updated, or NULL */ @@ -168,14 +154,11 @@ void page_header_set_field( } } -/*************************************************************/ /** - Returns the offset stored in the given header field. +/** Returns the offset stored in the given header field. @return offset from the start of the page, or 0 */ UNIV_INLINE -ulint page_header_get_offs( - /*=================*/ - const page_t *page, /*!< in: page */ - ulint field) /*!< in: PAGE_FREE, ... */ +ulint page_header_get_offs(const page_t *page, /*!< in: page */ + ulint field) /*!< in: PAGE_FREE, ... */ { ulint offs; @@ -190,11 +173,9 @@ ulint page_header_get_offs( return (offs); } -/*************************************************************/ /** - Sets the pointer stored in the given header field. */ +/** Sets the pointer stored in the given header field. */ UNIV_INLINE void page_header_set_ptr( - /*================*/ page_t *page, /*!< in: page */ page_zip_des_t *page_zip, /*!< in/out: compressed page whose uncompressed part will be updated, or NULL */ @@ -219,12 +200,10 @@ void page_header_set_ptr( } #ifndef UNIV_HOTBACKUP -/*************************************************************/ /** - Resets the last insert info field in the page header. Writes to mlog +/** Resets the last insert info field in the page header. Writes to mlog about this operation. */ UNIV_INLINE void page_header_reset_last_insert( - /*==========================*/ page_t *page, /*!< in/out: page */ page_zip_des_t *page_zip, /*!< in/out: compressed page whose uncompressed part will be updated, or NULL */ @@ -244,36 +223,27 @@ void page_header_reset_last_insert( } #endif /* !UNIV_HOTBACKUP */ -/************************************************************/ /** - Determine whether the page is in new-style compact format. +/** Determine whether the page is in new-style compact format. @return nonzero if the page is in compact format, zero if it is in old-style format */ UNIV_INLINE -ulint page_is_comp( - /*=========*/ - const page_t *page) /*!< in: index page */ +ulint page_is_comp(const page_t *page) /*!< in: index page */ { return (page_header_get_field(page, PAGE_N_HEAP) & 0x8000); } -/************************************************************/ /** - TRUE if the record is on a page in compact format. +/** TRUE if the record is on a page in compact format. @return nonzero if in compact format */ UNIV_INLINE -ulint page_rec_is_comp( - /*=============*/ - const rec_t *rec) /*!< in: record */ +ulint page_rec_is_comp(const rec_t *rec) /*!< in: record */ { return (page_is_comp(page_align(rec))); } -/***************************************************************/ /** - Returns the heap number of a record. +/** Returns the heap number of a record. @return heap number */ UNIV_INLINE -ulint page_rec_get_heap_no( - /*=================*/ - const rec_t *rec) /*!< in: the physical record */ +ulint page_rec_get_heap_no(const rec_t *rec) /*!< in: the physical record */ { if (page_rec_is_comp(rec)) { return (rec_get_heap_no_new(rec)); @@ -282,24 +252,18 @@ ulint page_rec_get_heap_no( } } -/************************************************************/ /** - Determine whether the page is a B-tree leaf. +/** Determine whether the page is a B-tree leaf. @return true if the page is a B-tree leaf (PAGE_LEVEL = 0) */ UNIV_INLINE -bool page_is_leaf( - /*=========*/ - const page_t *page) /*!< in: page */ +bool page_is_leaf(const page_t *page) /*!< in: page */ { return (!*(const uint16 *)(page + (PAGE_HEADER + PAGE_LEVEL))); } -/************************************************************/ /** - Determine whether the page is empty. +/** Determine whether the page is empty. @return true if the page is empty (PAGE_N_RECS = 0) */ UNIV_INLINE -bool page_is_empty( - /*==========*/ - const page_t *page) /*!< in: page */ +bool page_is_empty(const page_t *page) /*!< in: page */ { return (!*(const uint16 *)(page + (PAGE_HEADER + PAGE_N_RECS))); } @@ -326,23 +290,18 @@ bool page_is_root(const page_t *page) { IB_UINT64_MAX); } -/************************************************************/ /** - Determine whether the page contains garbage. +/** Determine whether the page contains garbage. @return true if the page contains garbage (PAGE_GARBAGE is not 0) */ UNIV_INLINE -bool page_has_garbage( - /*=============*/ - const page_t *page) /*!< in: page */ +bool page_has_garbage(const page_t *page) /*!< in: page */ { return (!!*(const uint16 *)(page + (PAGE_HEADER + PAGE_GARBAGE))); } -/************************************************************/ /** - Gets the offset of the first record on the page. +/** Gets the offset of the first record on the page. @return offset of the first record in record list, relative from page */ UNIV_INLINE ulint page_get_infimum_offset( - /*====================*/ const page_t *page) /*!< in: page which must have record(s) */ { ut_ad(page); @@ -355,12 +314,10 @@ ulint page_get_infimum_offset( } } -/************************************************************/ /** - Gets the offset of the last record on the page. +/** Gets the offset of the last record on the page. @return offset of the last record in record list, relative from page */ UNIV_INLINE ulint page_get_supremum_offset( - /*=====================*/ const page_t *page) /*!< in: page which must have record(s) */ { ut_ad(page); @@ -373,13 +330,10 @@ ulint page_get_supremum_offset( } } -/************************************************************/ /** - TRUE if the record is a user record on the page. +/** TRUE if the record is a user record on the page. @return true if a user record */ UNIV_INLINE -ibool page_rec_is_user_rec_low( - /*=====================*/ - ulint offset) /*!< in: record offset on page */ +ibool page_rec_is_user_rec_low(ulint offset) /*!< in: record offset on page */ { ut_ad(offset >= PAGE_NEW_INFIMUM); @@ -407,13 +361,10 @@ ibool page_rec_is_user_rec_low( offset != PAGE_OLD_INFIMUM && offset != PAGE_OLD_SUPREMUM); } -/************************************************************/ /** - TRUE if the record is the supremum record on a page. +/** TRUE if the record is the supremum record on a page. @return true if the supremum record */ UNIV_INLINE -ibool page_rec_is_supremum_low( - /*=====================*/ - ulint offset) /*!< in: record offset on page */ +ibool page_rec_is_supremum_low(ulint offset) /*!< in: record offset on page */ { ut_ad(offset >= PAGE_NEW_INFIMUM); ut_ad(offset <= UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START); @@ -421,13 +372,10 @@ ibool page_rec_is_supremum_low( return (offset == PAGE_NEW_SUPREMUM || offset == PAGE_OLD_SUPREMUM); } -/************************************************************/ /** - TRUE if the record is the infimum record on a page. +/** TRUE if the record is the infimum record on a page. @return true if the infimum record */ UNIV_INLINE -ibool page_rec_is_infimum_low( - /*====================*/ - ulint offset) /*!< in: record offset on page */ +ibool page_rec_is_infimum_low(ulint offset) /*!< in: record offset on page */ { ut_ad(offset >= PAGE_NEW_INFIMUM); ut_ad(offset <= UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START); @@ -435,67 +383,52 @@ ibool page_rec_is_infimum_low( return (offset == PAGE_NEW_INFIMUM || offset == PAGE_OLD_INFIMUM); } -/************************************************************/ /** - TRUE if the record is a user record on the page. +/** TRUE if the record is a user record on the page. @return true if a user record */ UNIV_INLINE -ibool page_rec_is_user_rec( - /*=================*/ - const rec_t *rec) /*!< in: record */ +ibool page_rec_is_user_rec(const rec_t *rec) /*!< in: record */ { ut_ad(page_rec_check(rec)); return (page_rec_is_user_rec_low(page_offset(rec))); } -/************************************************************/ /** - TRUE if the record is the supremum record on a page. +/** TRUE if the record is the supremum record on a page. @return true if the supremum record */ UNIV_INLINE -ibool page_rec_is_supremum( - /*=================*/ - const rec_t *rec) /*!< in: record */ +ibool page_rec_is_supremum(const rec_t *rec) /*!< in: record */ { ut_ad(page_rec_check(rec)); return (page_rec_is_supremum_low(page_offset(rec))); } -/************************************************************/ /** - TRUE if the record is the infimum record on a page. +/** TRUE if the record is the infimum record on a page. @return true if the infimum record */ UNIV_INLINE -ibool page_rec_is_infimum( - /*================*/ - const rec_t *rec) /*!< in: record */ +ibool page_rec_is_infimum(const rec_t *rec) /*!< in: record */ { ut_ad(page_rec_check(rec)); return (page_rec_is_infimum_low(page_offset(rec))); } -/************************************************************/ /** - true if the record is the first user record on a page. +/** true if the record is the first user record on a page. @return true if the first user record */ UNIV_INLINE -bool page_rec_is_first( - /*==============*/ - const rec_t *rec, /*!< in: record */ - const page_t *page) /*!< in: page */ +bool page_rec_is_first(const rec_t *rec, /*!< in: record */ + const page_t *page) /*!< in: page */ { ut_ad(page_get_n_recs(page) > 0); return (page_rec_get_next_const(page_get_infimum_rec(page)) == rec); } -/************************************************************/ /** - true if the record is the second user record on a page. +/** true if the record is the second user record on a page. @return true if the second user record */ UNIV_INLINE -bool page_rec_is_second( - /*===============*/ - const rec_t *rec, /*!< in: record */ - const page_t *page) /*!< in: page */ +bool page_rec_is_second(const rec_t *rec, /*!< in: record */ + const page_t *page) /*!< in: page */ { ut_ad(page_get_n_recs(page) > 1); @@ -503,28 +436,22 @@ bool page_rec_is_second( page_rec_get_next_const(page_get_infimum_rec(page))) == rec); } -/************************************************************/ /** - true if the record is the last user record on a page. +/** true if the record is the last user record on a page. @return true if the last user record */ UNIV_INLINE -bool page_rec_is_last( - /*=============*/ - const rec_t *rec, /*!< in: record */ - const page_t *page) /*!< in: page */ +bool page_rec_is_last(const rec_t *rec, /*!< in: record */ + const page_t *page) /*!< in: page */ { ut_ad(page_get_n_recs(page) > 0); return (page_rec_get_next_const(rec) == page_get_supremum_rec(page)); } -/************************************************************/ /** - true if the record is the second last user record on a page. +/** true if the record is the second last user record on a page. @return true if the second last user record */ UNIV_INLINE -bool page_rec_is_second_last( - /*====================*/ - const rec_t *rec, /*!< in: record */ - const page_t *page) /*!< in: page */ +bool page_rec_is_second_last(const rec_t *rec, /*!< in: record */ + const page_t *page) /*!< in: page */ { ut_ad(page_get_n_recs(page) > 1); ut_ad(!page_rec_is_last(rec, page)); @@ -533,29 +460,23 @@ bool page_rec_is_second_last( page_get_supremum_rec(page)); } -/************************************************************/ /** - Returns the nth record of the record list. +/** Returns the nth record of the record list. This is the inverse function of page_rec_get_n_recs_before(). @return nth record */ UNIV_INLINE -rec_t *page_rec_get_nth( - /*=============*/ - page_t *page, /*!< in: page */ - ulint nth) /*!< in: nth record */ +rec_t *page_rec_get_nth(page_t *page, /*!< in: page */ + ulint nth) /*!< in: nth record */ { return ((rec_t *)page_rec_get_nth_const(page, nth)); } #ifndef UNIV_HOTBACKUP -/************************************************************/ /** - Returns the middle record of the records on the page. If there is an +/** Returns the middle record of the records on the page. If there is an even number of records in the list, returns the first record of the upper half-list. @return middle record */ UNIV_INLINE -rec_t *page_get_middle_rec( - /*================*/ - page_t *page) /*!< in: page */ +rec_t *page_get_middle_rec(page_t *page) /*!< in: page */ { ulint middle = (page_get_n_recs(page) + PAGE_HEAP_NO_USER_LOW) / 2; @@ -563,57 +484,43 @@ rec_t *page_get_middle_rec( } #endif /* !UNIV_HOTBACKUP */ -/*************************************************************/ /** - Gets the page number. +/** Gets the page number. @return page number */ UNIV_INLINE -page_no_t page_get_page_no( - /*=============*/ - const page_t *page) /*!< in: page */ +page_no_t page_get_page_no(const page_t *page) /*!< in: page */ { ut_ad(page == page_align((page_t *)page)); return (mach_read_from_4(page + FIL_PAGE_OFFSET)); } -/*************************************************************/ /** - Gets the tablespace identifier. +/** Gets the tablespace identifier. @return space id */ UNIV_INLINE -space_id_t page_get_space_id( - /*==============*/ - const page_t *page) /*!< in: page */ +space_id_t page_get_space_id(const page_t *page) /*!< in: page */ { ut_ad(page == page_align((page_t *)page)); return (mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID)); } -/*************************************************************/ /** - Gets the number of user records on page (infimum and supremum records +/** Gets the number of user records on page (infimum and supremum records are not user records). @return number of user records */ UNIV_INLINE -ulint page_get_n_recs( - /*============*/ - const page_t *page) /*!< in: index page */ +ulint page_get_n_recs(const page_t *page) /*!< in: index page */ { return (page_header_get_field(page, PAGE_N_RECS)); } -/*************************************************************/ /** - Gets the number of dir slots in directory. +/** Gets the number of dir slots in directory. @return number of slots */ UNIV_INLINE -ulint page_dir_get_n_slots( - /*=================*/ - const page_t *page) /*!< in: index page */ +ulint page_dir_get_n_slots(const page_t *page) /*!< in: index page */ { return (page_header_get_field(page, PAGE_N_DIR_SLOTS)); } -/*************************************************************/ /** - Sets the number of dir slots in directory. */ +/** Sets the number of dir slots in directory. */ UNIV_INLINE void page_dir_set_n_slots( - /*=================*/ page_t *page, /*!< in/out: page */ page_zip_des_t *page_zip, /*!< in/out: compressed page whose uncompressed part will be updated, or NULL */ @@ -622,11 +529,9 @@ void page_dir_set_n_slots( page_header_set_field(page, page_zip, PAGE_N_DIR_SLOTS, n_slots); } -/*************************************************************/ /** - Sets the number of records in the heap. */ +/** Sets the number of records in the heap. */ UNIV_INLINE void page_dir_set_n_heap( - /*================*/ page_t *page, /*!< in/out: index page */ page_zip_des_t *page_zip, /*!< in/out: compressed page whose uncompressed part will be updated, or NULL. @@ -645,12 +550,10 @@ void page_dir_set_n_heap( } #ifdef UNIV_DEBUG -/*************************************************************/ /** - Gets pointer to nth directory slot. +/** Gets pointer to nth directory slot. @return pointer to dir slot */ UNIV_INLINE page_dir_slot_t *page_dir_get_nth_slot( - /*==================*/ const page_t *page, /*!< in: index page */ ulint n) /*!< in: position */ { @@ -661,13 +564,10 @@ page_dir_slot_t *page_dir_get_nth_slot( } #endif /* UNIV_DEBUG */ -/**************************************************************/ /** - Used to check the consistency of a record on a page. +/** Used to check the consistency of a record on a page. @return true if succeed */ UNIV_INLINE -ibool page_rec_check( - /*===========*/ - const rec_t *rec) /*!< in: record */ +ibool page_rec_check(const rec_t *rec) /*!< in: record */ { const page_t *page = page_align(rec); @@ -679,36 +579,29 @@ ibool page_rec_check( return (TRUE); } -/***************************************************************/ /** - Gets the record pointed to by a directory slot. +/** Gets the record pointed to by a directory slot. @return pointer to record */ UNIV_INLINE const rec_t *page_dir_slot_get_rec( - /*==================*/ const page_dir_slot_t *slot) /*!< in: directory slot */ { return (page_align(slot) + mach_read_from_2(slot)); } -/***************************************************************/ /** - This is used to set the record offset in a directory slot. */ +/** This is used to set the record offset in a directory slot. */ UNIV_INLINE -void page_dir_slot_set_rec( - /*==================*/ - page_dir_slot_t *slot, /*!< in: directory slot */ - rec_t *rec) /*!< in: record on the page */ +void page_dir_slot_set_rec(page_dir_slot_t *slot, /*!< in: directory slot */ + rec_t *rec) /*!< in: record on the page */ { ut_ad(page_rec_check(rec)); mach_write_to_2(slot, page_offset(rec)); } -/***************************************************************/ /** - Gets the number of records owned by a directory slot. +/** Gets the number of records owned by a directory slot. @return number of records */ UNIV_INLINE ulint page_dir_slot_get_n_owned( - /*======================*/ const page_dir_slot_t *slot) /*!< in: page directory slot */ { const rec_t *rec = page_dir_slot_get_rec(slot); @@ -719,11 +612,9 @@ ulint page_dir_slot_get_n_owned( } } -/***************************************************************/ /** - This is used to set the owned records field of a directory slot. */ +/** This is used to set the owned records field of a directory slot. */ UNIV_INLINE void page_dir_slot_set_n_owned( - /*======================*/ page_dir_slot_t *slot, /*!< in/out: directory slot */ page_zip_des_t *page_zip, /*!< in/out: compressed page, or NULL */ ulint n) /*!< in: number of records owned by the slot */ @@ -737,25 +628,20 @@ void page_dir_slot_set_n_owned( } } -/************************************************************/ /** - Calculates the space reserved for directory slots of a given number of +/** Calculates the space reserved for directory slots of a given number of records. The exact value is a fraction number n * PAGE_DIR_SLOT_SIZE / PAGE_DIR_SLOT_MIN_N_OWNED, and it is rounded upwards to an integer. */ UNIV_INLINE -ulint page_dir_calc_reserved_space( - /*=========================*/ - ulint n_recs) /*!< in: number of records */ +ulint page_dir_calc_reserved_space(ulint n_recs) /*!< in: number of records */ { return ((PAGE_DIR_SLOT_SIZE * n_recs + PAGE_DIR_SLOT_MIN_N_OWNED - 1) / PAGE_DIR_SLOT_MIN_N_OWNED); } -/************************************************************/ /** - Gets the pointer to the next record on the page. +/** Gets the pointer to the next record on the page. @return pointer to next record */ UNIV_INLINE const rec_t *page_rec_get_next_low( - /*==================*/ const rec_t *rec, /*!< in: pointer to record */ ulint comp) /*!< in: nonzero=compact page layout */ { @@ -783,36 +669,29 @@ const rec_t *page_rec_get_next_low( return (page + offs); } -/************************************************************/ /** - Gets the pointer to the next record on the page. +/** Gets the pointer to the next record on the page. @return pointer to next record */ UNIV_INLINE -rec_t *page_rec_get_next( - /*==============*/ - rec_t *rec) /*!< in: pointer to record */ +rec_t *page_rec_get_next(rec_t *rec) /*!< in: pointer to record */ { return ((rec_t *)page_rec_get_next_low(rec, page_rec_is_comp(rec))); } -/************************************************************/ /** - Gets the pointer to the next record on the page. +/** Gets the pointer to the next record on the page. @return pointer to next record */ UNIV_INLINE const rec_t *page_rec_get_next_const( - /*====================*/ const rec_t *rec) /*!< in: pointer to record */ { return (page_rec_get_next_low(rec, page_rec_is_comp(rec))); } -/************************************************************/ /** - Gets the pointer to the next non delete-marked record on the page. +/** Gets the pointer to the next non delete-marked record on the page. If all subsequent records are delete-marked, then this function will return the supremum record. @return pointer to next non delete-marked record or pointer to supremum */ UNIV_INLINE const rec_t *page_rec_get_next_non_del_marked( - /*=============================*/ const rec_t *rec) /*!< in: pointer to record */ { const rec_t *r; @@ -827,15 +706,12 @@ const rec_t *page_rec_get_next_non_del_marked( return (r); } -/************************************************************/ /** - Sets the pointer to the next record on the page. */ +/** Sets the pointer to the next record on the page. */ UNIV_INLINE -void page_rec_set_next( - /*==============*/ - rec_t *rec, /*!< in: pointer to record, - must not be page supremum */ - const rec_t *next) /*!< in: pointer to next record, - must not be page infimum */ +void page_rec_set_next(rec_t *rec, /*!< in: pointer to record, + must not be page supremum */ + const rec_t *next) /*!< in: pointer to next record, + must not be page infimum */ { ulint offs; @@ -855,12 +731,10 @@ void page_rec_set_next( } } -/************************************************************/ /** - Gets the pointer to the previous record. +/** Gets the pointer to the previous record. @return pointer to previous record */ UNIV_INLINE const rec_t *page_rec_get_prev_const( - /*====================*/ const rec_t *rec) /*!< in: pointer to record, must not be page infimum */ { @@ -901,25 +775,20 @@ const rec_t *page_rec_get_prev_const( return (prev_rec); } -/************************************************************/ /** - Gets the pointer to the previous record. +/** Gets the pointer to the previous record. @return pointer to previous record */ UNIV_INLINE rec_t *page_rec_get_prev( - /*==============*/ rec_t *rec) /*!< in: pointer to record, must not be page infimum */ { return ((rec_t *)page_rec_get_prev_const(rec)); } -/***************************************************************/ /** - Looks for the record which owns the given record. +/** Looks for the record which owns the given record. @return the owner record */ UNIV_INLINE -rec_t *page_rec_find_owner_rec( - /*====================*/ - rec_t *rec) /*!< in: the physical record */ +rec_t *page_rec_find_owner_rec(rec_t *rec) /*!< in: the physical record */ { ut_ad(page_rec_check(rec)); @@ -936,14 +805,11 @@ rec_t *page_rec_find_owner_rec( return (rec); } -/**********************************************************/ /** - Returns the base extra size of a physical record. This is the +/** Returns the base extra size of a physical record. This is the size of the fixed header, independent of the record size. @return REC_N_NEW_EXTRA_BYTES or REC_N_OLD_EXTRA_BYTES */ UNIV_INLINE -ulint page_rec_get_base_extra_size( - /*=========================*/ - const rec_t *rec) /*!< in: physical record */ +ulint page_rec_get_base_extra_size(const rec_t *rec) /*!< in: physical record */ { #if REC_N_NEW_EXTRA_BYTES + 1 != REC_N_OLD_EXTRA_BYTES #error "REC_N_NEW_EXTRA_BYTES + 1 != REC_N_OLD_EXTRA_BYTES" @@ -951,14 +817,11 @@ ulint page_rec_get_base_extra_size( return (REC_N_NEW_EXTRA_BYTES + (ulint)!page_rec_is_comp(rec)); } -/************************************************************/ /** - Returns the sum of the sizes of the records in the record list, excluding +/** Returns the sum of the sizes of the records in the record list, excluding the infimum and supremum records. @return data in bytes */ UNIV_INLINE -ulint page_get_data_size( - /*===============*/ - const page_t *page) /*!< in: index page */ +ulint page_get_data_size(const page_t *page) /*!< in: index page */ { ulint ret; @@ -972,11 +835,9 @@ ulint page_get_data_size( return (ret); } -/************************************************************/ /** - Allocates a block of memory from the free list of an index page. */ +/** Allocates a block of memory from the free list of an index page. */ UNIV_INLINE void page_mem_alloc_free( - /*================*/ page_t *page, /*!< in/out: index page */ page_zip_des_t *page_zip, /*!< in/out: compressed page with enough space available for inserting the record, @@ -1004,12 +865,10 @@ void page_mem_alloc_free( page_header_set_field(page, page_zip, PAGE_GARBAGE, garbage - need); } -/*************************************************************/ /** - Calculates free space if a page is emptied. +/** Calculates free space if a page is emptied. @return free space */ UNIV_INLINE ulint page_get_free_space_of_empty( - /*=========================*/ ulint comp) /*!< in: nonzero=compact page layout */ { if (comp) { @@ -1022,15 +881,12 @@ ulint page_get_free_space_of_empty( } #ifndef UNIV_HOTBACKUP -/***********************************************************************/ /** - Write a 32-bit field in a data dictionary record. */ +/** Write a 32-bit field in a data dictionary record. */ UNIV_INLINE -void page_rec_write_field( - /*=================*/ - rec_t *rec, /*!< in/out: record to update */ - ulint i, /*!< in: index of the field to update */ - ulint val, /*!< in: value to write */ - mtr_t *mtr) /*!< in/out: mini-transaction */ +void page_rec_write_field(rec_t *rec, /*!< in/out: record to update */ + ulint i, /*!< in: index of the field to update */ + ulint val, /*!< in: value to write */ + mtr_t *mtr) /*!< in/out: mini-transaction */ { byte *data; ulint len; @@ -1043,8 +899,7 @@ void page_rec_write_field( } #endif /* !UNIV_HOTBACKUP */ -/************************************************************/ /** - Each user record on a page, and also the deleted user records in the heap +/** Each user record on a page, and also the deleted user records in the heap takes its size plus the fraction of the dir cell size / PAGE_DIR_SLOT_MIN_N_OWNED bytes for it. If the sum of these exceeds the value of page_get_free_space_of_empty, the insert is impossible, otherwise @@ -1052,10 +907,8 @@ void page_rec_write_field( which can be inserted on top of the record heap. @return maximum combined size for inserted records */ UNIV_INLINE -ulint page_get_max_insert_size( - /*=====================*/ - const page_t *page, /*!< in: index page */ - ulint n_recs) /*!< in: number of records */ +ulint page_get_max_insert_size(const page_t *page, /*!< in: index page */ + ulint n_recs) /*!< in: number of records */ { ulint occupied; ulint free_space; @@ -1085,13 +938,11 @@ ulint page_get_max_insert_size( return (free_space - occupied); } -/************************************************************/ /** - Returns the maximum combined size of records which can be inserted on top +/** Returns the maximum combined size of records which can be inserted on top of the record heap if a page is first reorganized. @return maximum combined size for inserted records */ UNIV_INLINE ulint page_get_max_insert_size_after_reorganize( - /*======================================*/ const page_t *page, /*!< in: index page */ ulint n_recs) /*!< in: number of records */ { @@ -1110,19 +961,16 @@ ulint page_get_max_insert_size_after_reorganize( return (free_space - occupied); } -/************************************************************/ /** - Puts a record to free list. */ +/** Puts a record to free list. */ UNIV_INLINE -void page_mem_free( - /*==========*/ - page_t *page, /*!< in/out: index page */ - page_zip_des_t *page_zip, /*!< in/out: compressed page, - or NULL */ - rec_t *rec, /*!< in: pointer to the - (origin of) record */ - const dict_index_t *index, /*!< in: index of rec */ - const ulint *offsets) /*!< in: array returned by - rec_get_offsets() */ +void page_mem_free(page_t *page, /*!< in/out: index page */ + page_zip_des_t *page_zip, /*!< in/out: compressed page, + or NULL */ + rec_t *rec, /*!< in: pointer to the + (origin of) record */ + const dict_index_t *index, /*!< in: index of rec */ + const ulint *offsets) /*!< in: array returned by + rec_get_offsets() */ { rec_t *free; ulint garbage; diff --git a/storage/innobase/include/page0size.h b/storage/innobase/include/page0size.h index d53a49082c1d..36c79d0ac163 100644 --- a/storage/innobase/include/page0size.h +++ b/storage/innobase/include/page0size.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2013, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/page0size.h +/** @file include/page0size.h A class describing a page size. Created Nov 14, 2013 Vasil Dimov diff --git a/storage/innobase/include/page0types.h b/storage/innobase/include/page0types.h index 82c35d087c03..63592814c0d7 100644 --- a/storage/innobase/include/page0types.h +++ b/storage/innobase/include/page0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/page0types.h +/** @file include/page0types.h Index page routines Created 2/2/1994 Heikki Tuuri @@ -247,20 +246,16 @@ extern page_zip_stat_t page_zip_stat[PAGE_ZIP_SSIZE_MAX]; /** Statistics on compression, indexed by dict_index_t::id */ extern page_zip_stat_per_index_t page_zip_stat_per_index; -/**********************************************************************/ /** - Write the "deleted" flag of a record on a compressed page. The flag must +/** Write the "deleted" flag of a record on a compressed page. The flag must already have been written on the uncompressed page. */ void page_zip_rec_set_deleted( - /*=====================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ const byte *rec, /*!< in: record on the uncompressed page */ ulint flag); /*!< in: the deleted flag (nonzero=TRUE) */ -/**********************************************************************/ /** - Write the "owned" flag of a record on a compressed page. The n_owned field +/** Write the "owned" flag of a record on a compressed page. The n_owned field must already have been written on the uncompressed page. */ void page_zip_rec_set_owned( - /*===================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ const byte *rec, /*!< in: record on the uncompressed page */ ulint flag); /*!< in: the owned flag (nonzero=TRUE) */ @@ -275,10 +270,8 @@ void page_zip_dir_delete(page_zip_des_t *page_zip, byte *rec, dict_index_t *index, const ulint *offsets, const byte *free); -/**********************************************************************/ /** - Add a slot to the dense page directory. */ +/** Add a slot to the dense page directory. */ void page_zip_dir_add_slot( - /*==================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ bool is_clustered); /*!< in: nonzero for clustered index, zero for others */ diff --git a/storage/innobase/include/page0zip.h b/storage/innobase/include/page0zip.h index 94d1c532acf1..e570a40faf96 100644 --- a/storage/innobase/include/page0zip.h +++ b/storage/innobase/include/page0zip.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -25,8 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/page0zip.h +/** @file include/page0zip.h Compressed page interface Created June 2005 by Marko Makela @@ -98,11 +97,9 @@ ibool page_zip_rec_needs_ext(ulint rec_size, ulint comp, ulint n_fields, const page_size_t &page_size) MY_ATTRIBUTE((warn_unused_result)); -/**********************************************************************/ /** - Determine the guaranteed free space on an empty page. +/** Determine the guaranteed free space on an empty page. @return minimum payload size on the page */ ulint page_zip_empty_size( - /*================*/ ulint n_fields, /*!< in: number of columns in the index */ ulint zip_size) /*!< in: compressed page size in bytes */ MY_ATTRIBUTE((const)); @@ -115,41 +112,30 @@ ulint page_zip_empty_size( bool page_zip_is_too_big(const dict_index_t *index, const dtuple_t *entry); #endif /* !UNIV_HOTBACKUP */ -/**********************************************************************/ /** - Initialize a compressed page descriptor. */ +/** Initialize a compressed page descriptor. */ UNIV_INLINE -void page_zip_des_init( - /*==============*/ - page_zip_des_t *page_zip); /*!< in/out: compressed page - descriptor */ - -/**********************************************************************/ /** - Configure the zlib allocator to use the given memory heap. */ -void page_zip_set_alloc( - /*===============*/ - void *stream, /*!< in/out: zlib stream */ - mem_heap_t *heap); /*!< in: memory heap to use */ - -/**********************************************************************/ /** - Compress a page. +void page_zip_des_init(page_zip_des_t *page_zip); /*!< in/out: compressed page + descriptor */ + +/** Configure the zlib allocator to use the given memory heap. */ +void page_zip_set_alloc(void *stream, /*!< in/out: zlib stream */ + mem_heap_t *heap); /*!< in: memory heap to use */ + +/** Compress a page. @return true on success, false on failure; page_zip will be left intact on failure. */ -ibool page_zip_compress( - /*==============*/ - page_zip_des_t *page_zip, /*!< in: size; out: data, - n_blobs, m_start, m_end, - m_nonempty */ - const page_t *page, /*!< in: uncompressed page */ - dict_index_t *index, /*!< in: index tree */ - ulint level, /*!< in: commpression level */ - mtr_t *mtr); /*!< in/out: mini-transaction, - or NULL */ - -/**********************************************************************/ /** - Write the index information for the compressed page. +ibool page_zip_compress(page_zip_des_t *page_zip, /*!< in: size; out: data, + n_blobs, m_start, m_end, + m_nonempty */ + const page_t *page, /*!< in: uncompressed page */ + dict_index_t *index, /*!< in: index tree */ + ulint level, /*!< in: commpression level */ + mtr_t *mtr); /*!< in/out: mini-transaction, + or NULL */ + +/** Write the index information for the compressed page. @return used size of buf */ ulint page_zip_fields_encode( - /*===================*/ ulint n, /*!< in: number of fields to compress */ const dict_index_t *index, /*!< in: index comprising @@ -160,13 +146,11 @@ ulint page_zip_fields_encode( this is a non-leaf page */ byte *buf); /*!< out: buffer of (n + 1) * 2 bytes */ -/**********************************************************************/ /** - Decompress a page. This function should tolerate errors on the compressed +/** Decompress a page. This function should tolerate errors on the compressed page. Instead of letting assertions fail, it will return FALSE if an inconsistency is detected. @return true on success, false on failure */ ibool page_zip_decompress( - /*================*/ page_zip_des_t *page_zip, /*!< in: data, ssize; out: m_start, m_end, m_nonempty, n_blobs */ page_t *page, /*!< out: uncompressed page, may be trashed */ @@ -176,42 +160,34 @@ ibool page_zip_decompress( after page creation */ #ifdef UNIV_ZIP_DEBUG -/**********************************************************************/ /** - Check that the compressed and decompressed pages match. +/** Check that the compressed and decompressed pages match. @return true if valid, false if not */ ibool page_zip_validate_low( - /*==================*/ const page_zip_des_t *page_zip, /*!< in: compressed page */ const page_t *page, /*!< in: uncompressed page */ const dict_index_t *index, /*!< in: index of the page, if known */ ibool sloppy); /*!< in: FALSE=strict, TRUE=ignore the MIN_REC_FLAG */ -/**********************************************************************/ /** - Check that the compressed and decompressed pages match. */ +/** Check that the compressed and decompressed pages match. */ ibool page_zip_validate( - /*==============*/ const page_zip_des_t *page_zip, /*!< in: compressed page */ const page_t *page, /*!< in: uncompressed page */ const dict_index_t *index); /*!< in: index of the page, if known */ #endif /* UNIV_ZIP_DEBUG */ -/**********************************************************************/ /** - Determine how big record can be inserted without recompressing the page. +/** Determine how big record can be inserted without recompressing the page. @return a positive number indicating the maximum size of a record whose insertion is guaranteed to succeed, or zero or negative */ UNIV_INLINE lint page_zip_max_ins_size( - /*==================*/ const page_zip_des_t *page_zip, /*!< in: compressed page */ ibool is_clust) /*!< in: TRUE if clustered index */ MY_ATTRIBUTE((warn_unused_result)); -/**********************************************************************/ /** - Determine if enough space is available in the modification log. +/** Determine if enough space is available in the modification log. @return true if page_zip_write_rec() will succeed */ UNIV_INLINE ibool page_zip_available( - /*===============*/ const page_zip_des_t *page_zip, /*!< in: compressed page */ bool is_clust, /*!< in: TRUE if clustered index */ ulint length, /*!< in: combined size of the record */ @@ -229,32 +205,26 @@ UNIV_INLINE void page_zip_write_header(page_zip_des_t *page_zip, const byte *str, ulint length, mtr_t *mtr); -/**********************************************************************/ /** - Write an entire record on the compressed page. The data must already +/** Write an entire record on the compressed page. The data must already have been written to the uncompressed page. */ void page_zip_write_rec( - /*===============*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ const byte *rec, /*!< in: record being written */ dict_index_t *index, /*!< in: the index the record belongs to */ const ulint *offsets, /*!< in: rec_get_offsets(rec, index) */ ulint create); /*!< in: nonzero=insert, zero=update */ -/***********************************************************/ /** - Parses a log record of writing a BLOB pointer of a record. +/** Parses a log record of writing a BLOB pointer of a record. @return end of log record or NULL */ byte *page_zip_parse_write_blob_ptr( - /*==========================*/ byte *ptr, /*!< in: redo log buffer */ byte *end_ptr, /*!< in: redo log buffer end */ page_t *page, /*!< in/out: uncompressed page */ page_zip_des_t *page_zip); /*!< in/out: compressed page */ -/**********************************************************************/ /** - Write a BLOB pointer of a record on the leaf page of a clustered index. +/** Write a BLOB pointer of a record on the leaf page of a clustered index. The information must already have been updated on the uncompressed page. */ void page_zip_write_blob_ptr( - /*====================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ const byte *rec, /*!< in/out: record whose data is being written */ @@ -264,30 +234,24 @@ void page_zip_write_blob_ptr( mtr_t *mtr); /*!< in: mini-transaction handle, or NULL if no logging is needed */ -/***********************************************************/ /** - Parses a log record of writing the node pointer of a record. +/** Parses a log record of writing the node pointer of a record. @return end of log record or NULL */ byte *page_zip_parse_write_node_ptr( - /*==========================*/ byte *ptr, /*!< in: redo log buffer */ byte *end_ptr, /*!< in: redo log buffer end */ page_t *page, /*!< in/out: uncompressed page */ page_zip_des_t *page_zip); /*!< in/out: compressed page */ -/**********************************************************************/ /** - Write the node pointer of a record on a non-leaf compressed page. */ +/** Write the node pointer of a record on a non-leaf compressed page. */ void page_zip_write_node_ptr( - /*====================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ byte *rec, /*!< in/out: record */ ulint size, /*!< in: data size of rec */ ulint ptr, /*!< in: node pointer */ mtr_t *mtr); /*!< in: mini-transaction, or NULL */ -/**********************************************************************/ /** - Write the trx_id and roll_ptr of a record on a B-tree leaf node page. */ +/** Write the trx_id and roll_ptr of a record on a B-tree leaf node page. */ void page_zip_write_trx_id_and_roll_ptr( - /*===============================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ byte *rec, /*!< in/out: record */ const ulint *offsets, /*!< in: rec_get_offsets(rec, index) */ @@ -295,28 +259,22 @@ void page_zip_write_trx_id_and_roll_ptr( trx_id_t trx_id, /*!< in: transaction identifier */ roll_ptr_t roll_ptr); /*!< in: roll_ptr */ -/**********************************************************************/ /** - Write the "deleted" flag of a record on a compressed page. The flag must +/** Write the "deleted" flag of a record on a compressed page. The flag must already have been written on the uncompressed page. */ void page_zip_rec_set_deleted( - /*=====================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ const byte *rec, /*!< in: record on the uncompressed page */ ulint flag); /*!< in: the deleted flag (nonzero=TRUE) */ -/**********************************************************************/ /** - Write the "owned" flag of a record on a compressed page. The n_owned field +/** Write the "owned" flag of a record on a compressed page. The n_owned field must already have been written on the uncompressed page. */ void page_zip_rec_set_owned( - /*===================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ const byte *rec, /*!< in: record on the uncompressed page */ ulint flag); /*!< in: the owned flag (nonzero=TRUE) */ -/**********************************************************************/ /** - Insert a record to the dense page directory. */ +/** Insert a record to the dense page directory. */ void page_zip_dir_insert( - /*================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ const byte *prev_rec, /*!< in: record after which to insert */ const byte *free_rec, /*!< in: record from which rec was @@ -334,19 +292,15 @@ void page_zip_dir_delete(page_zip_des_t *page_zip, byte *rec, const dict_index_t *index, const ulint *offsets, const byte *free); -/**********************************************************************/ /** - Add a slot to the dense page directory. */ +/** Add a slot to the dense page directory. */ void page_zip_dir_add_slot( - /*==================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ bool is_clustered); /*!< in: nonzero for clustered index, zero for others */ -/***********************************************************/ /** - Parses a log record of writing to the header of a page. +/** Parses a log record of writing to the header of a page. @return end of log record or NULL */ byte *page_zip_parse_write_header( - /*========================*/ byte *ptr, /*!< in: redo log buffer */ byte *end_ptr, /*!< in: redo log buffer end */ page_t *page, /*!< in/out: uncompressed page */ @@ -364,8 +318,7 @@ UNIV_INLINE void page_zip_write_header(page_zip_des_t *page_zip, const byte *str, ulint length, mtr_t *mtr); -/**********************************************************************/ /** - Reorganize and compress a page. This is a low-level operation for +/** Reorganize and compress a page. This is a low-level operation for compressed pages, to be used when page_zip_compress() fails. On success, a redo log entry MLOG_ZIP_PAGE_COMPRESS will be written. The function btr_page_reorganize() should be preferred whenever possible. @@ -376,20 +329,17 @@ void page_zip_write_header(page_zip_des_t *page_zip, const byte *str, @return true on success, false on failure; page_zip will be left intact on failure, but page will be overwritten. */ ibool page_zip_reorganize( - /*================*/ buf_block_t *block, /*!< in/out: page with compressed page; on the compressed page, in: size; out: data, n_blobs, m_start, m_end, m_nonempty */ dict_index_t *index, /*!< in: index of the B-tree node */ mtr_t *mtr); /*!< in: mini-transaction */ -/**********************************************************************/ /** - Copy the records of a page byte for byte. Do not copy the page header +/** Copy the records of a page byte for byte. Do not copy the page header or trailer, except those B-tree header fields that are directly related to the storage of records. Also copy PAGE_MAX_TRX_ID. NOTE: The caller must update the lock table and the adaptive hash index. */ void page_zip_copy_recs( - /*===============*/ page_zip_des_t *page_zip, /*!< out: copy of src_zip (n_blobs, m_start, m_end, m_nonempty, data[0..size-1]) */ @@ -401,11 +351,9 @@ void page_zip_copy_recs( #ifndef UNIV_HOTBACKUP #endif /* !UNIV_HOTBACKUP */ -/**********************************************************************/ /** - Parses a log record of compressing an index page. +/** Parses a log record of compressing an index page. @return end of log record or NULL */ byte *page_zip_parse_compress( - /*====================*/ byte *ptr, /*!< in: buffer */ byte *end_ptr, /*!< in: buffer end */ page_t *page, /*!< out: uncompressed page */ @@ -434,12 +382,10 @@ byte *page_zip_parse_compress_no_data(byte *ptr, byte *end_ptr, page_t *page, dict_index_t *index); #ifndef UNIV_HOTBACKUP -/**********************************************************************/ /** - Reset the counters used for filling +/** Reset the counters used for filling INFORMATION_SCHEMA.innodb_cmp_per_index. */ UNIV_INLINE void page_zip_reset_stat_per_index(); -/*===========================*/ #ifdef UNIV_MATERIALIZE #undef UNIV_INLINE diff --git a/storage/innobase/include/page0zip.ic b/storage/innobase/include/page0zip.ic index afef7d3b3566..c3529abf37bc 100644 --- a/storage/innobase/include/page0zip.ic +++ b/storage/innobase/include/page0zip.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -25,8 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/page0zip.ic +/** @file include/page0zip.ic Compressed page interface Created June 2005 by Marko Makela @@ -109,13 +108,10 @@ In summary, the compressed page looks like this: - deleted records (free list) in link order */ -/**********************************************************************/ /** - Set the size of a compressed page in bytes. */ +/** Set the size of a compressed page in bytes. */ UNIV_INLINE -void page_zip_set_size( - /*==============*/ - page_zip_des_t *page_zip, /*!< in/out: compressed page */ - ulint size) /*!< in: size in bytes */ +void page_zip_set_size(page_zip_des_t *page_zip, /*!< in/out: compressed page */ + ulint size) /*!< in: size in bytes */ { if (size) { int ssize; @@ -168,13 +164,11 @@ ibool page_zip_rec_needs_ext(ulint rec_size, ulint comp, ulint n_fields, } #endif /* !UNIV_HOTBACKUP */ -/**********************************************************************/ /** - Determine if the length of the page trailer. +/** Determine if the length of the page trailer. @return length of the page trailer, in bytes, not including the terminating zero byte of the modification log */ UNIV_INLINE ibool page_zip_get_trailer_len( - /*=====================*/ const page_zip_des_t *page_zip, /*!< in: compressed page */ bool is_clust) /*!< in: TRUE if clustered index */ { @@ -198,13 +192,11 @@ ibool page_zip_get_trailer_len( page_zip->n_blobs * BTR_EXTERN_FIELD_REF_SIZE); } -/**********************************************************************/ /** - Determine how big record can be inserted without recompressing the page. +/** Determine how big record can be inserted without recompressing the page. @return a positive number indicating the maximum size of a record whose insertion is guaranteed to succeed, or zero or negative */ UNIV_INLINE lint page_zip_max_ins_size( - /*==================*/ const page_zip_des_t *page_zip, /*!< in: compressed page */ ibool is_clust) /*!< in: TRUE if clustered index */ { @@ -225,12 +217,10 @@ lint page_zip_max_ins_size( (REC_N_NEW_EXTRA_BYTES - 2)); } -/**********************************************************************/ /** - Determine if enough space is available in the modification log. +/** Determine if enough space is available in the modification log. @return true if enough space is available */ UNIV_INLINE ibool page_zip_available( - /*===============*/ const page_zip_des_t *page_zip, /*!< in: compressed page */ bool is_clust, /*!< in: TRUE if clustered index */ ulint length, /*!< in: combined size of the record */ @@ -261,21 +251,17 @@ ibool page_zip_available( return (length + trailer_len + page_zip->m_end < page_zip_get_size(page_zip)); } -/**********************************************************************/ /** - Initialize a compressed page descriptor. */ +/** Initialize a compressed page descriptor. */ UNIV_INLINE -void page_zip_des_init( - /*==============*/ - page_zip_des_t *page_zip) /*!< in/out: compressed page - descriptor */ +void page_zip_des_init(page_zip_des_t *page_zip) /*!< in/out: compressed page + descriptor */ { memset(page_zip, 0, sizeof *page_zip); } -/**********************************************************************/ /** - Write a log record of writing to the uncompressed header portion of a page. */ +/** Write a log record of writing to the uncompressed header portion of a page. + */ void page_zip_write_header_log( - /*======================*/ const byte *data, /*!< in: data on the uncompressed page */ ulint length, /*!< in: length of the data */ mtr_t *mtr); /*!< in: mini-transaction */ @@ -310,12 +296,11 @@ void page_zip_write_header(page_zip_des_t *page_zip, const byte *str, } } -/**********************************************************************/ /** - Write a log record of compressing an index page without the data on the page. +/** Write a log record of compressing an index page without the data on the + * page. */ UNIV_INLINE void page_zip_compress_write_log_no_data( - /*================================*/ ulint level, /*!< in: compression level */ const page_t *page, /*!< in: page that is compressed */ dict_index_t *index, /*!< in: index */ @@ -332,12 +317,10 @@ void page_zip_compress_write_log_no_data( #endif /* !UNIV_HOTBACKUP */ } -/**********************************************************************/ /** - Parses a log record of compressing an index page without the data. +/** Parses a log record of compressing an index page without the data. @return end of log record or NULL */ UNIV_INLINE byte *page_zip_parse_compress_no_data( - /*============================*/ byte *ptr, /*!< in: buffer */ byte *end_ptr, /*!< in: buffer end */ page_t *page, /*!< in: uncompressed page */ @@ -363,13 +346,10 @@ byte *page_zip_parse_compress_no_data( } #ifndef UNIV_HOTBACKUP -/**********************************************************************/ /** - Reset the counters used for filling +/** Reset the counters used for filling INFORMATION_SCHEMA.innodb_cmp_per_index. */ UNIV_INLINE -void page_zip_reset_stat_per_index() -/*===========================*/ -{ +void page_zip_reset_stat_per_index() { mutex_enter(&page_zip_stat_per_index_mutex); page_zip_stat_per_index.erase(page_zip_stat_per_index.begin(), @@ -379,15 +359,12 @@ void page_zip_reset_stat_per_index() } #endif /* !UNIV_HOTBACKUP */ -/*************************************************************/ /** - Find the slot of the given record in the dense page directory. +/** Find the slot of the given record in the dense page directory. @return dense directory slot, or NULL if record not found */ UNIV_INLINE -byte *page_zip_dir_find_low( - /*==================*/ - byte *slot, /*!< in: start of records */ - byte *end, /*!< in: end of records */ - ulint offset) /*!< in: offset of user record */ +byte *page_zip_dir_find_low(byte *slot, /*!< in: start of records */ + byte *end, /*!< in: end of records */ + ulint offset) /*!< in: offset of user record */ { ut_ad(slot <= end); @@ -400,13 +377,11 @@ byte *page_zip_dir_find_low( return (NULL); } -/*************************************************************/ /** - Gets the size of the compressed page trailer (the dense page directory), +/** Gets the size of the compressed page trailer (the dense page directory), only including user records (excluding the free list). @return length of dense page directory comprising existing records, in bytes */ UNIV_INLINE ulint page_zip_dir_user_size( - /*===================*/ const page_zip_des_t *page_zip) /*!< in: compressed page */ { ulint size = PAGE_ZIP_DIR_SLOT_SIZE * page_get_n_recs(page_zip->data); @@ -414,12 +389,10 @@ ulint page_zip_dir_user_size( return (size); } -/*************************************************************/ /** - Find the slot of the given free record in the dense page directory. +/** Find the slot of the given free record in the dense page directory. @return dense directory slot, or NULL if record not found */ UNIV_INLINE byte *page_zip_dir_find_free( - /*===================*/ page_zip_des_t *page_zip, /*!< in: compressed page */ ulint offset) /*!< in: offset of user record */ { @@ -432,13 +405,11 @@ byte *page_zip_dir_find_free( offset)); } -/*************************************************************/ /** - Gets an offset to the compressed page trailer (the dense page directory), +/** Gets an offset to the compressed page trailer (the dense page directory), including deleted records (the free list). @return offset of the dense page directory */ UNIV_INLINE ulint page_zip_dir_start_offs( - /*====================*/ const page_zip_des_t *page_zip, /*!< in: compressed page */ ulint n_dense) /*!< in: directory size */ { diff --git a/storage/innobase/include/pars0opt.h b/storage/innobase/include/pars0opt.h index db9e47667c50..6cea50e498e2 100644 --- a/storage/innobase/include/pars0opt.h +++ b/storage/innobase/include/pars0opt.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/pars0opt.h +/** @file include/pars0opt.h Simple SQL optimizer Created 12/21/1997 Heikki Tuuri @@ -41,22 +40,17 @@ this program; if not, write to the Free Software Foundation, Inc., #include "univ.i" #include "usr0types.h" -/*******************************************************************/ /** - Optimizes a select. Decides which indexes to tables to use. The tables +/** Optimizes a select. Decides which indexes to tables to use. The tables are accessed in the order that they were written to the FROM part in the select statement. */ -void opt_search_plan( - /*============*/ - sel_node_t *sel_node); /*!< in: parsed select node */ -/*******************************************************************/ /** - Looks for occurrences of the columns of the table in the query subgraph and +void opt_search_plan(sel_node_t *sel_node); /*!< in: parsed select node */ +/** Looks for occurrences of the columns of the table in the query subgraph and adds them to the list of columns if an occurrence of the same column does not already exist in the list. If the column is already in the list, puts a value indirection to point to the occurrence in the column list, except if the column occurrence we are looking at is in the column list, in which case nothing is done. */ void opt_find_all_cols( - /*==============*/ ibool copy_val, /*!< in: if TRUE, new found columns are added as columns to copy */ dict_index_t *index, /*!< in: index to use */ diff --git a/storage/innobase/include/pars0opt.ic b/storage/innobase/include/pars0opt.ic index 57405ef6cdf3..be1278c987e4 100644 --- a/storage/innobase/include/pars0opt.ic +++ b/storage/innobase/include/pars0opt.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/pars0opt.ic +/** @file include/pars0opt.ic Simple SQL optimizer Created 12/21/1997 Heikki Tuuri diff --git a/storage/innobase/include/pars0pars.h b/storage/innobase/include/pars0pars.h index 8d99999fb6e6..4f7d4ce922ed 100644 --- a/storage/innobase/include/pars0pars.h +++ b/storage/innobase/include/pars0pars.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/pars0pars.h +/** @file include/pars0pars.h SQL parser Created 11/19/1996 Heikki Tuuri @@ -98,94 +97,68 @@ void pars_init(); /** Clean up the internal parser */ void pars_close(); -/*************************************************************/ /** - Parses an SQL string returning the query graph. +/** Parses an SQL string returning the query graph. @return own: the query graph */ -que_t *pars_sql( - /*=====*/ - pars_info_t *info, /*!< in: extra information, or NULL */ - const char *str); /*!< in: SQL string */ -/*************************************************************/ /** - Retrieves characters to the lexical analyzer. +que_t *pars_sql(pars_info_t *info, /*!< in: extra information, or NULL */ + const char *str); /*!< in: SQL string */ +/** Retrieves characters to the lexical analyzer. @return number of characters copied or 0 on EOF */ int pars_get_lex_chars( - /*===============*/ char *buf, /*!< in/out: buffer where to copy */ size_t max_size); /*!< in: maximum number of characters which fit in the buffer */ -/*************************************************************/ /** - Called by yyparse on error. */ -void yyerror( - /*====*/ - const char *s); /*!< in: error message string */ -/*********************************************************************/ /** - Parses a variable declaration. +/** Called by yyparse on error. */ +void yyerror(const char *s); /*!< in: error message string */ +/** Parses a variable declaration. @return own: symbol table node of type SYM_VAR */ sym_node_t *pars_variable_declaration( - /*======================*/ sym_node_t *node, /*!< in: symbol table node allocated for the id of the variable */ pars_res_word_t *type); /*!< in: pointer to a type token */ -/*********************************************************************/ /** - Parses a function expression. +/** Parses a function expression. @return own: function node in a query tree */ func_node_t *pars_func( - /*======*/ que_node_t *res_word, /*!< in: function name reserved word */ que_node_t *arg); /*!< in: first argument in the argument list */ /************************************************************************* Rebind a LIKE search string. NOTE: We ignore any '%' characters embedded within the search string. @return own: function node in a query tree */ -int pars_like_rebind( - /*=============*/ - sym_node_t *node, /* in: The search string node.*/ - const byte *ptr, /* in: literal to (re) bind */ - ulint len); /* in: length of literal to (re) bind*/ -/*********************************************************************/ /** - Parses an operator expression. +int pars_like_rebind(sym_node_t *node, /* in: The search string node.*/ + const byte *ptr, /* in: literal to (re) bind */ + ulint len); /* in: length of literal to (re) bind*/ +/** Parses an operator expression. @return own: function node in a query tree */ func_node_t *pars_op( - /*====*/ int func, /*!< in: operator token code */ que_node_t *arg1, /*!< in: first argument */ que_node_t *arg2); /*!< in: second argument or NULL for an unary operator */ -/*********************************************************************/ /** - Parses an ORDER BY clause. Order by a single column only is supported. +/** Parses an ORDER BY clause. Order by a single column only is supported. @return own: order-by node in a query tree */ order_node_t *pars_order_by( - /*==========*/ sym_node_t *column, /*!< in: column name */ pars_res_word_t *asc); /*!< in: &pars_asc_token or pars_desc_token */ -/*********************************************************************/ /** - Parses a select list; creates a query graph node for the whole SELECT +/** Parses a select list; creates a query graph node for the whole SELECT statement. @return own: select node in a query tree */ sel_node_t *pars_select_list( - /*=============*/ que_node_t *select_list, /*!< in: select list */ sym_node_t *into_list); /*!< in: variables list or NULL */ -/*********************************************************************/ /** - Parses a cursor declaration. +/** Parses a cursor declaration. @return sym_node */ que_node_t *pars_cursor_declaration( - /*====================*/ sym_node_t *sym_node, /*!< in: cursor id node in the symbol table */ sel_node_t *select_node); /*!< in: select node */ -/*********************************************************************/ /** - Parses a function declaration. +/** Parses a function declaration. @return sym_node */ que_node_t *pars_function_declaration( - /*======================*/ sym_node_t *sym_node); /*!< in: function id node in the symbol table */ -/*********************************************************************/ /** - Parses a select statement. +/** Parses a select statement. @return own: select node in a query tree */ sel_node_t *pars_select_statement( - /*==================*/ sel_node_t *select_node, /*!< in: select node already containing the select list */ sym_node_t *table_list, /*!< in: table list */ @@ -194,138 +167,102 @@ sel_node_t *pars_select_statement( pars_res_word_t *consistent_read, /*!< in: NULL or &pars_consistent_token */ order_node_t *order_by); /*!< in: NULL or an order-by node */ -/*********************************************************************/ /** - Parses a column assignment in an update. +/** Parses a column assignment in an update. @return column assignment node */ col_assign_node_t *pars_column_assignment( - /*===================*/ sym_node_t *column, /*!< in: column to assign */ que_node_t *exp); /*!< in: value to assign */ -/*********************************************************************/ /** - Parses a delete or update statement start. +/** Parses a delete or update statement start. @return own: update node in a query tree */ upd_node_t *pars_update_statement_start( - /*========================*/ ibool is_delete, /*!< in: TRUE if delete */ sym_node_t *table_sym, /*!< in: table name node */ col_assign_node_t *col_assign_list); /*!< in: column assignment list, NULL if delete */ -/*********************************************************************/ /** - Parses an update or delete statement. +/** Parses an update or delete statement. @return own: update node in a query tree */ upd_node_t *pars_update_statement( - /*==================*/ upd_node_t *node, /*!< in: update node */ sym_node_t *cursor_sym, /*!< in: pointer to a cursor entry in the symbol table or NULL */ que_node_t *search_cond); /*!< in: search condition or NULL */ -/*********************************************************************/ /** - Parses an insert statement. +/** Parses an insert statement. @return own: update node in a query tree */ ins_node_t *pars_insert_statement( - /*==================*/ sym_node_t *table_sym, /*!< in: table name node */ que_node_t *values_list, /*!< in: value expression list or NULL */ sel_node_t *select); /*!< in: select condition or NULL */ -/*********************************************************************/ /** - Parses a procedure parameter declaration. +/** Parses a procedure parameter declaration. @return own: symbol table node of type SYM_VAR */ sym_node_t *pars_parameter_declaration( - /*=======================*/ sym_node_t *node, /*!< in: symbol table node allocated for the id of the parameter */ ulint param_type, /*!< in: PARS_INPUT or PARS_OUTPUT */ pars_res_word_t *type); /*!< in: pointer to a type token */ -/*********************************************************************/ /** - Parses an elsif element. +/** Parses an elsif element. @return elsif node */ elsif_node_t *pars_elsif_element( - /*===============*/ que_node_t *cond, /*!< in: if-condition */ que_node_t *stat_list); /*!< in: statement list */ -/*********************************************************************/ /** - Parses an if-statement. +/** Parses an if-statement. @return if-statement node */ if_node_t *pars_if_statement( - /*==============*/ que_node_t *cond, /*!< in: if-condition */ que_node_t *stat_list, /*!< in: statement list */ que_node_t *else_part); /*!< in: else-part statement list */ -/*********************************************************************/ /** - Parses a for-loop-statement. +/** Parses a for-loop-statement. @return for-statement node */ for_node_t *pars_for_statement( - /*===============*/ sym_node_t *loop_var, /*!< in: loop variable */ que_node_t *loop_start_limit, /*!< in: loop start expression */ que_node_t *loop_end_limit, /*!< in: loop end expression */ que_node_t *stat_list); /*!< in: statement list */ -/*********************************************************************/ /** - Parses a while-statement. +/** Parses a while-statement. @return while-statement node */ while_node_t *pars_while_statement( - /*=================*/ que_node_t *cond, /*!< in: while-condition */ que_node_t *stat_list); /*!< in: statement list */ -/*********************************************************************/ /** - Parses an exit statement. +/** Parses an exit statement. @return exit statement node */ exit_node_t *pars_exit_statement(void); -/*=====================*/ -/*********************************************************************/ /** - Parses a return-statement. +/** Parses a return-statement. @return return-statement node */ return_node_t *pars_return_statement(void); -/*=======================*/ -/*********************************************************************/ /** - Parses an assignment statement. +/** Parses an assignment statement. @return assignment statement node */ assign_node_t *pars_assignment_statement( - /*======================*/ sym_node_t *var, /*!< in: variable to assign */ que_node_t *val); /*!< in: value to assign */ -/*********************************************************************/ /** - Parses a fetch statement. into_list or user_func (but not both) must be +/** Parses a fetch statement. into_list or user_func (but not both) must be non-NULL. @return fetch statement node */ fetch_node_t *pars_fetch_statement( - /*=================*/ sym_node_t *cursor, /*!< in: cursor node */ sym_node_t *into_list, /*!< in: variables to set, or NULL */ sym_node_t *user_func); /*!< in: user function name, or NULL */ -/*********************************************************************/ /** - Parses an open or close cursor statement. +/** Parses an open or close cursor statement. @return fetch statement node */ -open_node_t *pars_open_statement( - /*================*/ - ulint type, /*!< in: ROW_SEL_OPEN_CURSOR - or ROW_SEL_CLOSE_CURSOR */ - sym_node_t *cursor); /*!< in: cursor node */ -/*********************************************************************/ /** - Parses a commit statement. +open_node_t *pars_open_statement(ulint type, /*!< in: ROW_SEL_OPEN_CURSOR + or ROW_SEL_CLOSE_CURSOR */ + sym_node_t *cursor); /*!< in: cursor node */ +/** Parses a commit statement. @return own: commit node struct */ commit_node_t *pars_commit_statement(void); -/*=======================*/ -/*********************************************************************/ /** - Parses a rollback statement. +/** Parses a rollback statement. @return own: rollback node struct */ roll_node_t *pars_rollback_statement(void); -/*=========================*/ -/*********************************************************************/ /** - Parses a column definition at a table creation. +/** Parses a column definition at a table creation. @return column sym table node */ -sym_node_t *pars_column_def( - /*============*/ - sym_node_t *sym_node, /*!< in: column node in the - symbol table */ - pars_res_word_t *type, /*!< in: data type */ - sym_node_t *len, /*!< in: length of column, or - NULL */ - void *is_unsigned, /*!< in: if not NULL, column - is of type UNSIGNED. */ - void *is_not_null); /*!< in: if not NULL, column - is of type NOT NULL. */ +sym_node_t *pars_column_def(sym_node_t *sym_node, /*!< in: column node in the + symbol table */ + pars_res_word_t *type, /*!< in: data type */ + sym_node_t *len, /*!< in: length of column, or + NULL */ + void *is_unsigned, /*!< in: if not NULL, column + is of type UNSIGNED. */ + void *is_not_null); /*!< in: if not NULL, column + is of type NOT NULL. */ /** Parses a table creation operation. @param[in] table_sym table name node in the symbol table @param[in] column_defs list of column names @@ -345,11 +282,9 @@ tab_node_t *pars_create_table(sym_node_t *table_sym, sym_node_t *column_defs, sym_node_t *compact, sym_node_t *block_size, void *not_fit_in_memory); -/*********************************************************************/ /** - Parses an index creation operation. +/** Parses an index creation operation. @return index create subgraph */ ind_node_t *pars_create_index( - /*==============*/ pars_res_word_t *unique_def, /*!< in: not NULL if a unique index */ pars_res_word_t *clustered_def, /*!< in: not NULL if a clustered index */ sym_node_t *index_sym, /*!< in: index name node in the symbol @@ -357,11 +292,9 @@ ind_node_t *pars_create_index( sym_node_t *table_sym, /*!< in: table name node in the symbol table */ sym_node_t *column_list); /*!< in: list of column names */ -/*********************************************************************/ /** - Parses a procedure definition. +/** Parses a procedure definition. @return query fork node */ que_fork_t *pars_procedure_definition( - /*======================*/ sym_node_t *sym_node, /*!< in: procedure id node in the symbol table */ sym_node_t *param_list, /*!< in: parameter declaration list */ @@ -381,58 +314,43 @@ que_thr_t *pars_complete_graph_for_exec(que_node_t *node, trx_t *trx, row_prebuilt_t *prebuilt) MY_ATTRIBUTE((warn_unused_result)); -/****************************************************************/ /** - Create parser info struct. +/** Create parser info struct. @return own: info struct */ pars_info_t *pars_info_create(void); -/*==================*/ - -/****************************************************************/ /** - Free info struct and everything it contains. */ -void pars_info_free( - /*===========*/ - pars_info_t *info); /*!< in, own: info struct */ - -/****************************************************************/ /** - Add bound literal. */ -void pars_info_add_literal( - /*==================*/ - pars_info_t *info, /*!< in: info struct */ - const char *name, /*!< in: name */ - const void *address, /*!< in: address */ - ulint length, /*!< in: length of data */ - ulint type, /*!< in: type, e.g. DATA_FIXBINARY */ - ulint prtype); /*!< in: precise type, e.g. - DATA_UNSIGNED */ - -/****************************************************************/ /** - Equivalent to pars_info_add_literal(info, name, str, strlen(str), + +/** Free info struct and everything it contains. */ +void pars_info_free(pars_info_t *info); /*!< in, own: info struct */ + +/** Add bound literal. */ +void pars_info_add_literal(pars_info_t *info, /*!< in: info struct */ + const char *name, /*!< in: name */ + const void *address, /*!< in: address */ + ulint length, /*!< in: length of data */ + ulint type, /*!< in: type, e.g. DATA_FIXBINARY */ + ulint prtype); /*!< in: precise type, e.g. + DATA_UNSIGNED */ + +/** Equivalent to pars_info_add_literal(info, name, str, strlen(str), DATA_VARCHAR, DATA_ENGLISH). */ -void pars_info_add_str_literal( - /*======================*/ - pars_info_t *info, /*!< in: info struct */ - const char *name, /*!< in: name */ - const char *str); /*!< in: string */ +void pars_info_add_str_literal(pars_info_t *info, /*!< in: info struct */ + const char *name, /*!< in: name */ + const char *str); /*!< in: string */ /******************************************************************** If the literal value already exists then it rebinds otherwise it creates a new entry.*/ -void pars_info_bind_literal( - /*===================*/ - pars_info_t *info, /* in: info struct */ - const char *name, /* in: name */ - const void *address, /* in: address */ - ulint length, /* in: length of data */ - ulint type, /* in: type, e.g. DATA_FIXBINARY */ - ulint prtype); /* in: precise type, e.g. */ +void pars_info_bind_literal(pars_info_t *info, /* in: info struct */ + const char *name, /* in: name */ + const void *address, /* in: address */ + ulint length, /* in: length of data */ + ulint type, /* in: type, e.g. DATA_FIXBINARY */ + ulint prtype); /* in: precise type, e.g. */ /******************************************************************** If the literal value already exists then it rebinds otherwise it creates a new entry.*/ -void pars_info_bind_varchar_literal( - /*===========================*/ - pars_info_t *info, /*!< in: info struct */ - const char *name, /*!< in: name */ - const byte *str, /*!< in: string */ - ulint str_len); /*!< in: string length */ +void pars_info_bind_varchar_literal(pars_info_t *info, /*!< in: info struct */ + const char *name, /*!< in: name */ + const byte *str, /*!< in: string */ + ulint str_len); /*!< in: string length */ /** Equivalent to: @@ -456,10 +374,8 @@ creates a new entry. void pars_info_bind_int8_literal(pars_info_t *info, const char *name, const ib_uint64_t *val); -/****************************************************************/ /** - Add user function. */ +/** Add user function. */ void pars_info_bind_function( - /*===================*/ pars_info_t *info, /*!< in: info struct */ const char *name, /*!< in: function name */ pars_user_func_cb_t func, /*!< in: function address */ @@ -473,8 +389,7 @@ void pars_info_bind_function( void pars_info_bind_id(pars_info_t *info, ibool copy_name, const char *name, const char *id); -/****************************************************************/ /** - Equivalent to: +/** Equivalent to: char buf[4]; mach_write_to_4(buf, val); @@ -482,14 +397,11 @@ void pars_info_bind_id(pars_info_t *info, ibool copy_name, const char *name, except that the buffer is dynamically allocated from the info struct's heap. */ -void pars_info_add_int4_literal( - /*=======================*/ - pars_info_t *info, /*!< in: info struct */ - const char *name, /*!< in: name */ - lint val); /*!< in: value */ +void pars_info_add_int4_literal(pars_info_t *info, /*!< in: info struct */ + const char *name, /*!< in: name */ + lint val); /*!< in: value */ -/****************************************************************/ /** - Equivalent to: +/** Equivalent to: char buf[8]; mach_write_to_8(buf, val); @@ -497,20 +409,15 @@ void pars_info_add_int4_literal( except that the buffer is dynamically allocated from the info struct's heap. */ -void pars_info_add_ull_literal( - /*======================*/ - pars_info_t *info, /*!< in: info struct */ - const char *name, /*!< in: name */ - ib_uint64_t val); /*!< in: value */ +void pars_info_add_ull_literal(pars_info_t *info, /*!< in: info struct */ + const char *name, /*!< in: name */ + ib_uint64_t val); /*!< in: value */ -/****************************************************************/ /** - If the literal value already exists then it rebinds otherwise it +/** If the literal value already exists then it rebinds otherwise it creates a new entry. */ -void pars_info_bind_ull_literal( - /*=======================*/ - pars_info_t *info, /*!< in: info struct */ - const char *name, /*!< in: name */ - const ib_uint64_t *val); /*!< in: value */ +void pars_info_bind_ull_literal(pars_info_t *info, /*!< in: info struct */ + const char *name, /*!< in: name */ + const ib_uint64_t *val); /*!< in: value */ /** Add bound id. @param[in] info info struct @@ -518,11 +425,9 @@ void pars_info_bind_ull_literal( @param[in] id id */ void pars_info_add_id(pars_info_t *info, const char *name, const char *id); -/****************************************************************/ /** - Get bound literal with the given name. +/** Get bound literal with the given name. @return bound literal, or NULL if not found */ pars_bound_lit_t *pars_info_get_bound_lit( - /*====================*/ pars_info_t *info, /*!< in: info struct */ const char *name); /*!< in: bound literal name to find */ @@ -532,10 +437,8 @@ pars_bound_lit_t *pars_info_get_bound_lit( @return bound id, or NULL if not found */ pars_bound_id_t *pars_info_get_bound_id(pars_info_t *info, const char *name); -/******************************************************************/ /** - Release any resources used by the lexer. */ +/** Release any resources used by the lexer. */ void pars_lexer_close(void); -/*==================*/ /** Extra information supplied for pars_sql(). */ struct pars_info_t { diff --git a/storage/innobase/include/pars0pars.ic b/storage/innobase/include/pars0pars.ic index dc0b845ac059..d18d21501655 100644 --- a/storage/innobase/include/pars0pars.ic +++ b/storage/innobase/include/pars0pars.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/pars0pars.ic +/** @file include/pars0pars.ic SQL parser Created 11/19/1996 Heikki Tuuri diff --git a/storage/innobase/include/pars0sym.h b/storage/innobase/include/pars0sym.h index 57f0c1811eef..92fbd6fe88f0 100644 --- a/storage/innobase/include/pars0sym.h +++ b/storage/innobase/include/pars0sym.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/pars0sym.h +/** @file include/pars0sym.h SQL parser symbol table Created 12/15/1997 Heikki Tuuri @@ -41,73 +40,51 @@ this program; if not, write to the Free Software Foundation, Inc., #include "univ.i" #include "usr0types.h" -/******************************************************************/ /** - Creates a symbol table for a single stored procedure or query. +/** Creates a symbol table for a single stored procedure or query. @return own: symbol table */ sym_tab_t *sym_tab_create( - /*===========*/ mem_heap_t *heap); /*!< in: memory heap where to create */ -/******************************************************************/ /** - Frees the memory allocated dynamically AFTER parsing phase for variables +/** Frees the memory allocated dynamically AFTER parsing phase for variables etc. in the symbol table. Does not free the mem heap where the table was originally created. Frees also SQL explicit cursor definitions. */ -void sym_tab_free_private( - /*=================*/ - sym_tab_t *sym_tab); /*!< in, own: symbol table */ -/******************************************************************/ /** - Adds an integer literal to a symbol table. +void sym_tab_free_private(sym_tab_t *sym_tab); /*!< in, own: symbol table */ +/** Adds an integer literal to a symbol table. @return symbol table node */ -sym_node_t *sym_tab_add_int_lit( - /*================*/ - sym_tab_t *sym_tab, /*!< in: symbol table */ - ulint val); /*!< in: integer value */ -/******************************************************************/ /** - Adds an string literal to a symbol table. +sym_node_t *sym_tab_add_int_lit(sym_tab_t *sym_tab, /*!< in: symbol table */ + ulint val); /*!< in: integer value */ +/** Adds an string literal to a symbol table. @return symbol table node */ sym_node_t *sym_tab_add_str_lit( - /*================*/ sym_tab_t *sym_tab, /*!< in: symbol table */ const byte *str, /*!< in: string with no quotes around it */ ulint len); /*!< in: string length */ -/******************************************************************/ /** - Add a bound literal to a symbol table. +/** Add a bound literal to a symbol table. @return symbol table node */ sym_node_t *sym_tab_add_bound_lit( - /*==================*/ sym_tab_t *sym_tab, /*!< in: symbol table */ const char *name, /*!< in: name of bound literal */ ulint *lit_type); /*!< out: type of literal (PARS_*_LIT) */ /********************************************************************** Rebind literal to a node in the symbol table. */ sym_node_t *sym_tab_rebind_lit( - /*===============*/ /* out: symbol table node */ sym_node_t *node, /* in: node that is bound to literal*/ const void *address, /* in: pointer to data */ ulint length); /* in: length of data */ -/******************************************************************/ /** - Adds an SQL null literal to a symbol table. +/** Adds an SQL null literal to a symbol table. @return symbol table node */ -sym_node_t *sym_tab_add_null_lit( - /*=================*/ - sym_tab_t *sym_tab); /*!< in: symbol table */ -/******************************************************************/ /** - Adds an identifier to a symbol table. +sym_node_t *sym_tab_add_null_lit(sym_tab_t *sym_tab); /*!< in: symbol table */ +/** Adds an identifier to a symbol table. @return symbol table node */ -sym_node_t *sym_tab_add_id( - /*===========*/ - sym_tab_t *sym_tab, /*!< in: symbol table */ - byte *name, /*!< in: identifier name */ - ulint len); /*!< in: identifier length */ +sym_node_t *sym_tab_add_id(sym_tab_t *sym_tab, /*!< in: symbol table */ + byte *name, /*!< in: identifier name */ + ulint len); /*!< in: identifier length */ -/******************************************************************/ /** - Add a bound identifier to a symbol table. +/** Add a bound identifier to a symbol table. @return symbol table node */ -sym_node_t *sym_tab_add_bound_id( - /*===========*/ - sym_tab_t *sym_tab, /*!< in: symbol table */ - const char *name); /*!< in: name of bound id */ +sym_node_t *sym_tab_add_bound_id(sym_tab_t *sym_tab, /*!< in: symbol table */ + const char *name); /*!< in: name of bound id */ /** Index of sym_node_t::field_nos corresponding to the clustered index */ #define SYM_CLUST_FIELD_NO 0 diff --git a/storage/innobase/include/pars0sym.ic b/storage/innobase/include/pars0sym.ic index a3b6bd341877..495b78aee335 100644 --- a/storage/innobase/include/pars0sym.ic +++ b/storage/innobase/include/pars0sym.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/pars0sym.ic +/** @file include/pars0sym.ic SQL parser symbol table Created 12/15/1997 Heikki Tuuri diff --git a/storage/innobase/include/pars0types.h b/storage/innobase/include/pars0types.h index 0486161d8057..28d99e077e4b 100644 --- a/storage/innobase/include/pars0types.h +++ b/storage/innobase/include/pars0types.h @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/pars0types.h +/** @file include/pars0types.h SQL parser global types Created 1/11/1998 Heikki Tuuri diff --git a/storage/innobase/include/que0que.h b/storage/innobase/include/que0que.h index 41947f505c3e..5a93d9b6d6c5 100644 --- a/storage/innobase/include/que0que.h +++ b/storage/innobase/include/que0que.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/que0que.h +/** @file include/que0que.h Query graph Created 5/27/1996 Heikki Tuuri @@ -48,29 +47,21 @@ this program; if not, write to the Free Software Foundation, Inc., /** Mutex protecting the query threads. */ extern ib_mutex_t que_thr_mutex; -/***********************************************************************/ /** - Creates a query graph fork node. +/** Creates a query graph fork node. @return own: fork node */ que_fork_t *que_fork_create( - /*============*/ que_t *graph, /*!< in: graph, if NULL then this fork node is assumed to be the graph root */ que_node_t *parent, /*!< in: parent node */ ulint fork_type, /*!< in: fork type */ mem_heap_t *heap); /*!< in: memory heap where created */ -/***********************************************************************/ /** - Gets the first thr in a fork. */ +/** Gets the first thr in a fork. */ UNIV_INLINE -que_thr_t *que_fork_get_first_thr( - /*===================*/ - que_fork_t *fork); /*!< in: query fork */ -/***********************************************************************/ /** - Gets the child node of the first thr in a fork. */ +que_thr_t *que_fork_get_first_thr(que_fork_t *fork); /*!< in: query fork */ +/** Gets the child node of the first thr in a fork. */ UNIV_INLINE -que_node_t *que_fork_get_child( - /*===============*/ - que_fork_t *fork); /*!< in: query fork */ +que_node_t *que_fork_get_child(que_fork_t *fork); /*!< in: query fork */ /** Sets the parent of a graph node. @param[in] node graph node @@ -85,117 +76,74 @@ void que_node_set_parent(que_node_t *node, que_node_t *parent); @return own: query thread node */ que_thr_t *que_thr_create(que_fork_t *parent, mem_heap_t *heap, row_prebuilt_t *prebuilt); -/**********************************************************************/ /** - Frees a query graph, but not the heap where it was created. Does not free +/** Frees a query graph, but not the heap where it was created. Does not free explicit cursor declarations, they are freed in que_graph_free. */ -void que_graph_free_recursive( - /*=====================*/ - que_node_t *node); /*!< in: query graph node */ -/**********************************************************************/ /** - Frees a query graph. */ +void que_graph_free_recursive(que_node_t *node); /*!< in: query graph node */ +/** Frees a query graph. */ void que_graph_free( - /*===========*/ que_t *graph); /*!< in: query graph; we assume that the memory heap where this graph was created is private to this graph: if not, then use que_graph_free_recursive and free the heap afterwards! */ -/**********************************************************************/ /** - Stops a query thread if graph or trx is in a state requiring it. The +/** Stops a query thread if graph or trx is in a state requiring it. The conditions are tested in the order (1) graph, (2) trx. The lock_sys_t::mutex has to be reserved. @return true if stopped */ -ibool que_thr_stop( - /*=========*/ - que_thr_t *thr); /*!< in: query thread */ -/**********************************************************************/ /** - Moves a thread from another state to the QUE_THR_RUNNING state. Increments +ibool que_thr_stop(que_thr_t *thr); /*!< in: query thread */ +/** Moves a thread from another state to the QUE_THR_RUNNING state. Increments the n_active_thrs counters of the query graph and transaction. */ void que_thr_move_to_run_state_for_mysql( - /*================================*/ que_thr_t *thr, /*!< in: an query thread */ trx_t *trx); /*!< in: transaction */ -/**********************************************************************/ /** - A patch for MySQL used to 'stop' a dummy query thread used in MySQL +/** A patch for MySQL used to 'stop' a dummy query thread used in MySQL select, when there is no error or lock wait. */ -void que_thr_stop_for_mysql_no_error( - /*============================*/ - que_thr_t *thr, /*!< in: query thread */ - trx_t *trx); /*!< in: transaction */ -/**********************************************************************/ /** - A patch for MySQL used to 'stop' a dummy query thread used in MySQL. The +void que_thr_stop_for_mysql_no_error(que_thr_t *thr, /*!< in: query thread */ + trx_t *trx); /*!< in: transaction */ +/** A patch for MySQL used to 'stop' a dummy query thread used in MySQL. The query thread is stopped and made inactive, except in the case where it was put to the lock wait state in lock0lock.cc, but the lock has already been granted or the transaction chosen as a victim in deadlock resolution. */ -void que_thr_stop_for_mysql( - /*===================*/ - que_thr_t *thr); /*!< in: query thread */ -/**********************************************************************/ /** - Run a query thread. Handles lock waits. */ -void que_run_threads( - /*============*/ - que_thr_t *thr); /*!< in: query thread */ -/**********************************************************************/ /** - Moves a suspended query thread to the QUE_THR_RUNNING state and release +void que_thr_stop_for_mysql(que_thr_t *thr); /*!< in: query thread */ +/** Run a query thread. Handles lock waits. */ +void que_run_threads(que_thr_t *thr); /*!< in: query thread */ +/** Moves a suspended query thread to the QUE_THR_RUNNING state and release a worker thread to execute it. This function should be used to end the wait state of a query thread waiting for a lock or a stored procedure completion. @return query thread instance of thread to wakeup or NULL */ -que_thr_t *que_thr_end_lock_wait( - /*==================*/ - trx_t *trx); /*!< in: transaction in the - QUE_THR_LOCK_WAIT state */ -/**********************************************************************/ /** - Starts execution of a command in a query fork. Picks a query thread which +que_thr_t *que_thr_end_lock_wait(trx_t *trx); /*!< in: transaction in the + QUE_THR_LOCK_WAIT state */ +/** Starts execution of a command in a query fork. Picks a query thread which is not in the QUE_THR_RUNNING state and moves it to that state. If none can be chosen, a situation which may arise in parallelized fetches, NULL is returned. @return a query thread of the graph moved to QUE_THR_RUNNING state, or NULL; the query thread should be executed by que_run_threads by the caller */ -que_thr_t *que_fork_start_command( - /*===================*/ - que_fork_t *fork); /*!< in: a query fork */ -/***********************************************************************/ /** - Gets the trx of a query thread. */ +que_thr_t *que_fork_start_command(que_fork_t *fork); /*!< in: a query fork */ +/** Gets the trx of a query thread. */ UNIV_INLINE -trx_t *thr_get_trx( - /*========*/ - que_thr_t *thr); /*!< in: query thread */ -/*******************************************************************/ /** - Determines if this thread is rolling back an incomplete transaction +trx_t *thr_get_trx(que_thr_t *thr); /*!< in: query thread */ +/** Determines if this thread is rolling back an incomplete transaction in crash recovery. @return true if thr is rolling back an incomplete transaction in crash recovery */ UNIV_INLINE -ibool thr_is_recv( - /*========*/ - const que_thr_t *thr); /*!< in: query thread */ -/***********************************************************************/ /** - Gets the type of a graph node. */ +ibool thr_is_recv(const que_thr_t *thr); /*!< in: query thread */ +/** Gets the type of a graph node. */ UNIV_INLINE -ulint que_node_get_type( - /*==============*/ - const que_node_t *node); /*!< in: graph node */ -/***********************************************************************/ /** - Gets pointer to the value data type field of a graph node. */ +ulint que_node_get_type(const que_node_t *node); /*!< in: graph node */ +/** Gets pointer to the value data type field of a graph node. */ UNIV_INLINE -dtype_t *que_node_get_data_type( - /*===================*/ - que_node_t *node); /*!< in: graph node */ -/***********************************************************************/ /** - Gets pointer to the value dfield of a graph node. */ +dtype_t *que_node_get_data_type(que_node_t *node); /*!< in: graph node */ +/** Gets pointer to the value dfield of a graph node. */ UNIV_INLINE -dfield_t *que_node_get_val( - /*=============*/ - que_node_t *node); /*!< in: graph node */ -/***********************************************************************/ /** - Gets the value buffer size of a graph node. +dfield_t *que_node_get_val(que_node_t *node); /*!< in: graph node */ +/** Gets the value buffer size of a graph node. @return val buffer size, not defined if val.data == NULL in node */ UNIV_INLINE -ulint que_node_get_val_buf_size( - /*======================*/ - que_node_t *node); /*!< in: graph node */ +ulint que_node_get_val_buf_size(que_node_t *node); /*!< in: graph node */ /** Sets the value buffer size of a graph node. @param[in] node graph node @@ -203,25 +151,17 @@ ulint que_node_get_val_buf_size( UNIV_INLINE void que_node_set_val_buf_size(que_node_t *node, ulint size); -/*********************************************************************/ /** - Gets the next list node in a list of query graph nodes. */ +/** Gets the next list node in a list of query graph nodes. */ UNIV_INLINE -que_node_t *que_node_get_next( - /*==============*/ - que_node_t *node); /*!< in: node in a list */ -/*********************************************************************/ /** - Gets the parent node of a query graph node. +que_node_t *que_node_get_next(que_node_t *node); /*!< in: node in a list */ +/** Gets the parent node of a query graph node. @return parent node or NULL */ UNIV_INLINE -que_node_t *que_node_get_parent( - /*================*/ - que_node_t *node); /*!< in: node */ -/****************************************************************/ /** - Get the first containing loop node (e.g. while_node_t or for_node_t) for the +que_node_t *que_node_get_parent(que_node_t *node); /*!< in: node */ +/** Get the first containing loop node (e.g. while_node_t or for_node_t) for the given node, or NULL if the node is not within a loop. @return containing loop node, or NULL. */ que_node_t *que_node_get_containing_loop_node( - /*==============================*/ que_node_t *node); /*!< in: node */ /** Catenates a query graph node to a list of them, possible empty list. @@ -235,69 +175,48 @@ que_node_t *que_node_list_add_last(que_node_t *node_list, que_node_t *node); Get the last node from the list.*/ UNIV_INLINE que_node_t *que_node_list_get_last( - /*===================*/ /* out: node last node from list.*/ que_node_t *node_list); /* in: node list, or NULL */ -/*********************************************************************/ /** - Gets a query graph node list length. +/** Gets a query graph node list length. @return length, for NULL list 0 */ UNIV_INLINE ulint que_node_list_get_len( - /*==================*/ que_node_t *node_list); /*!< in: node list, or NULL */ -/**********************************************************************/ /** - Checks if graph, trx, or session is in a state where the query thread should +/** Checks if graph, trx, or session is in a state where the query thread should be stopped. @return true if should be stopped; NOTE that if the peek is made without reserving the trx_t::mutex, then another peek with the mutex reserved is necessary before deciding the actual stopping */ UNIV_INLINE -ibool que_thr_peek_stop( - /*==============*/ - que_thr_t *thr); /*!< in: query thread */ -/***********************************************************************/ /** - Returns TRUE if the query graph is for a SELECT statement. +ibool que_thr_peek_stop(que_thr_t *thr); /*!< in: query thread */ +/** Returns TRUE if the query graph is for a SELECT statement. @return true if a select */ UNIV_INLINE -ibool que_graph_is_select( - /*================*/ - que_t *graph); /*!< in: graph */ -/**********************************************************************/ /** - Prints info of an SQL query graph node. */ -void que_node_print_info( - /*================*/ - que_node_t *node); /*!< in: query graph node */ -/*********************************************************************/ /** - Evaluate the given SQL +ibool que_graph_is_select(que_t *graph); /*!< in: graph */ +/** Prints info of an SQL query graph node. */ +void que_node_print_info(que_node_t *node); /*!< in: query graph node */ +/** Evaluate the given SQL @return error code or DB_SUCCESS */ -dberr_t que_eval_sql( - /*=========*/ - pars_info_t *info, /*!< in: info struct, or NULL */ - const char *sql, /*!< in: SQL string */ - ibool reserve_dict_mutex, - /*!< in: if TRUE, acquire/release - dict_sys->mutex around call to pars_sql. */ - trx_t *trx); /*!< in: trx */ - -/**********************************************************************/ /** - Round robin scheduler. +dberr_t que_eval_sql(pars_info_t *info, /*!< in: info struct, or NULL */ + const char *sql, /*!< in: SQL string */ + ibool reserve_dict_mutex, + /*!< in: if TRUE, acquire/release + dict_sys->mutex around call to pars_sql. */ + trx_t *trx); /*!< in: trx */ + +/** Round robin scheduler. @return a query thread of the graph moved to QUE_THR_RUNNING state, or NULL; the query thread should be executed by que_run_threads by the caller */ que_thr_t *que_fork_scheduler_round_robin( - /*===========================*/ que_fork_t *fork, /*!< in: a query fork */ que_thr_t *thr); /*!< in: current pos */ -/*********************************************************************/ /** - Initialise the query sub-system. */ +/** Initialise the query sub-system. */ void que_init(void); -/*==========*/ -/*********************************************************************/ /** - Close the query sub-system. */ +/** Close the query sub-system. */ void que_close(void); -/*===========*/ /** Query thread states */ enum que_thr_state_t { diff --git a/storage/innobase/include/que0que.ic b/storage/innobase/include/que0que.ic index 25b7ebefc680..d850bc17bf78 100644 --- a/storage/innobase/include/que0que.ic +++ b/storage/innobase/include/que0que.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/que0que.ic +/** @file include/que0que.ic Query graph Created 5/27/1996 Heikki Tuuri @@ -33,12 +32,9 @@ this program; if not, write to the Free Software Foundation, Inc., #include "usr0sess.h" -/***********************************************************************/ /** - Gets the trx of a query thread. */ +/** Gets the trx of a query thread. */ UNIV_INLINE -trx_t *thr_get_trx( - /*========*/ - que_thr_t *thr) /*!< in: query thread */ +trx_t *thr_get_trx(que_thr_t *thr) /*!< in: query thread */ { ut_ad(thr); @@ -46,36 +42,27 @@ trx_t *thr_get_trx( } #ifndef UNIV_HOTBACKUP -/*******************************************************************/ /** - Determines if this thread is rolling back an incomplete transaction +/** Determines if this thread is rolling back an incomplete transaction in crash recovery. @return true if thr is rolling back an incomplete transaction in crash recovery */ UNIV_INLINE -ibool thr_is_recv( - /*========*/ - const que_thr_t *thr) /*!< in: query thread */ +ibool thr_is_recv(const que_thr_t *thr) /*!< in: query thread */ { return (trx_is_recv(thr->graph->trx)); } #endif /* !UNIV_HOTBACKUP */ -/***********************************************************************/ /** - Gets the first thr in a fork. */ +/** Gets the first thr in a fork. */ UNIV_INLINE -que_thr_t *que_fork_get_first_thr( - /*===================*/ - que_fork_t *fork) /*!< in: query fork */ +que_thr_t *que_fork_get_first_thr(que_fork_t *fork) /*!< in: query fork */ { return (UT_LIST_GET_FIRST(fork->thrs)); } -/***********************************************************************/ /** - Gets the child node of the first thr in a fork. */ +/** Gets the child node of the first thr in a fork. */ UNIV_INLINE -que_node_t *que_fork_get_child( - /*===============*/ - que_fork_t *fork) /*!< in: query fork */ +que_node_t *que_fork_get_child(que_fork_t *fork) /*!< in: query fork */ { que_thr_t *thr; @@ -84,85 +71,65 @@ que_node_t *que_fork_get_child( return (thr->child); } -/***********************************************************************/ /** - Gets the type of a graph node. */ +/** Gets the type of a graph node. */ UNIV_INLINE -ulint que_node_get_type( - /*==============*/ - const que_node_t *node) /*!< in: graph node */ +ulint que_node_get_type(const que_node_t *node) /*!< in: graph node */ { return (reinterpret_cast(node)->type); } -/***********************************************************************/ /** - Gets pointer to the value dfield of a graph node. */ +/** Gets pointer to the value dfield of a graph node. */ UNIV_INLINE -dfield_t *que_node_get_val( - /*=============*/ - que_node_t *node) /*!< in: graph node */ +dfield_t *que_node_get_val(que_node_t *node) /*!< in: graph node */ { ut_ad(node); return (&(((que_common_t *)node)->val)); } -/***********************************************************************/ /** - Gets the value buffer size of a graph node. +/** Gets the value buffer size of a graph node. @return val buffer size, not defined if val.data == NULL in node */ UNIV_INLINE -ulint que_node_get_val_buf_size( - /*======================*/ - que_node_t *node) /*!< in: graph node */ +ulint que_node_get_val_buf_size(que_node_t *node) /*!< in: graph node */ { ut_ad(node); return (((que_common_t *)node)->val_buf_size); } -/***********************************************************************/ /** - Sets the value buffer size of a graph node. */ +/** Sets the value buffer size of a graph node. */ UNIV_INLINE -void que_node_set_val_buf_size( - /*======================*/ - que_node_t *node, /*!< in: graph node */ - ulint size) /*!< in: size */ +void que_node_set_val_buf_size(que_node_t *node, /*!< in: graph node */ + ulint size) /*!< in: size */ { ut_ad(node); ((que_common_t *)node)->val_buf_size = size; } -/***********************************************************************/ /** - Sets the parent of a graph node. */ +/** Sets the parent of a graph node. */ UNIV_INLINE -void que_node_set_parent( - /*================*/ - que_node_t *node, /*!< in: graph node */ - que_node_t *parent) /*!< in: parent */ +void que_node_set_parent(que_node_t *node, /*!< in: graph node */ + que_node_t *parent) /*!< in: parent */ { ut_ad(node); ((que_common_t *)node)->parent = parent; } -/***********************************************************************/ /** - Gets pointer to the value data type field of a graph node. */ +/** Gets pointer to the value data type field of a graph node. */ UNIV_INLINE -dtype_t *que_node_get_data_type( - /*===================*/ - que_node_t *node) /*!< in: graph node */ +dtype_t *que_node_get_data_type(que_node_t *node) /*!< in: graph node */ { ut_ad(node); return (dfield_get_type(&((que_common_t *)node)->val)); } -/*********************************************************************/ /** - Catenates a query graph node to a list of them, possible empty list. +/** Catenates a query graph node to a list of them, possible empty list. @return one-way list of nodes */ UNIV_INLINE que_node_t *que_node_list_add_last( - /*===================*/ que_node_t *node_list, /*!< in: node list, or NULL */ que_node_t *node) /*!< in: node */ { @@ -192,7 +159,6 @@ que_node_t *que_node_list_add_last( Removes a query graph node from the list.*/ UNIV_INLINE que_node_t *que_node_list_get_last( - /*===================*/ /* out: last node in list.*/ que_node_t *node_list) /* in: node list */ { @@ -209,23 +175,18 @@ que_node_t *que_node_list_get_last( return (node); } -/*********************************************************************/ /** - Gets the next list node in a list of query graph nodes. +/** Gets the next list node in a list of query graph nodes. @return next node in a list of nodes */ UNIV_INLINE -que_node_t *que_node_get_next( - /*==============*/ - que_node_t *node) /*!< in: node in a list */ +que_node_t *que_node_get_next(que_node_t *node) /*!< in: node in a list */ { return (((que_common_t *)node)->brother); } -/*********************************************************************/ /** - Gets a query graph node list length. +/** Gets a query graph node list length. @return length, for NULL list 0 */ UNIV_INLINE ulint que_node_list_get_len( - /*==================*/ que_node_t *node_list) /*!< in: node list, or NULL */ { const que_common_t *cnode; @@ -242,27 +203,21 @@ ulint que_node_list_get_len( return (len); } -/*********************************************************************/ /** - Gets the parent node of a query graph node. +/** Gets the parent node of a query graph node. @return parent node or NULL */ UNIV_INLINE -que_node_t *que_node_get_parent( - /*================*/ - que_node_t *node) /*!< in: node */ +que_node_t *que_node_get_parent(que_node_t *node) /*!< in: node */ { return (((que_common_t *)node)->parent); } -/**********************************************************************/ /** - Checks if graph, trx, or session is in a state where the query thread should +/** Checks if graph, trx, or session is in a state where the query thread should be stopped. @return true if should be stopped; NOTE that if the peek is made without reserving the trx mutex, then another peek with the mutex reserved is necessary before deciding the actual stopping */ UNIV_INLINE -ibool que_thr_peek_stop( - /*==============*/ - que_thr_t *thr) /*!< in: query thread */ +ibool que_thr_peek_stop(que_thr_t *thr) /*!< in: query thread */ { trx_t *trx; que_t *graph; @@ -280,13 +235,10 @@ ibool que_thr_peek_stop( return (FALSE); } -/***********************************************************************/ /** - Returns TRUE if the query graph is for a SELECT statement. +/** Returns TRUE if the query graph is for a SELECT statement. @return true if a select */ UNIV_INLINE -ibool que_graph_is_select( - /*================*/ - que_t *graph) /*!< in: graph */ +ibool que_graph_is_select(que_t *graph) /*!< in: graph */ { if (graph->fork_type == QUE_FORK_SELECT_SCROLL || graph->fork_type == QUE_FORK_SELECT_NON_SCROLL) { diff --git a/storage/innobase/include/que0types.h b/storage/innobase/include/que0types.h index 26cdee14cdb7..c25c3ff209a7 100644 --- a/storage/innobase/include/que0types.h +++ b/storage/innobase/include/que0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/que0types.h +/** @file include/que0types.h Query graph global types Created 5/27/1996 Heikki Tuuri diff --git a/storage/innobase/include/read0read.h b/storage/innobase/include/read0read.h index c1f5e4f37564..eab38c4df5b9 100644 --- a/storage/innobase/include/read0read.h +++ b/storage/innobase/include/read0read.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/read0read.h +/** @file include/read0read.h Cursor read Created 2/16/1997 Heikki Tuuri diff --git a/storage/innobase/include/read0types.h b/storage/innobase/include/read0types.h index fa30a9d16d52..abf2bbcc554f 100644 --- a/storage/innobase/include/read0types.h +++ b/storage/innobase/include/read0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/read0types.h +/** @file include/read0types.h Cursor read Created 2/16/1997 Heikki Tuuri diff --git a/storage/innobase/include/rem0cmp.h b/storage/innobase/include/rem0cmp.h index 61b57bd76dc7..049f671c2c26 100644 --- a/storage/innobase/include/rem0cmp.h +++ b/storage/innobase/include/rem0cmp.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/*******************************************************************/ /** - @file include/rem0cmp.h +/** @file include/rem0cmp.h Comparison services for records Created 7/1/1994 Heikki Tuuri @@ -45,14 +44,11 @@ namespace dd { class Spatial_reference_system; } -/*************************************************************/ /** - Returns TRUE if two columns are equal for comparison purposes. +/** Returns TRUE if two columns are equal for comparison purposes. @return true if the columns are considered equal in comparisons */ -ibool cmp_cols_are_equal( - /*===============*/ - const dict_col_t *col1, /*!< in: column 1 */ - const dict_col_t *col2, /*!< in: column 2 */ - ibool check_charsets); +ibool cmp_cols_are_equal(const dict_col_t *col1, /*!< in: column 1 */ + const dict_col_t *col2, /*!< in: column 2 */ + ibool check_charsets); /*!< in: whether to check charsets */ /** Compare two data fields. @param[in] mtype main type @@ -89,10 +85,9 @@ int cmp_dfield_dfield(const dfield_t *dfield1, const dfield_t *dfield2, @param[in] mode compare mode @param[in] srs Spatial reference system of R-tree @retval negative if dtuple is less than rec */ -int cmp_dtuple_rec_with_gis( - /*====================*/ - const dtuple_t *dtuple, const rec_t *rec, const ulint *offsets, - page_cur_mode_t mode, const dd::Spatial_reference_system *srs); +int cmp_dtuple_rec_with_gis(const dtuple_t *dtuple, const rec_t *rec, + const ulint *offsets, page_cur_mode_t mode, + const dd::Spatial_reference_system *srs); /** Compare a GIS data tuple to a physical record in rtree non-leaf node. We need to check the page number field, since we don't store pk field in @@ -169,7 +164,6 @@ none of which are stored externally. @retval negative if rec1 (including non-ordering columns) is less than rec2 @retval 0 if rec1 is a duplicate of rec2 */ int cmp_rec_rec_simple( - /*===============*/ const rec_t *rec1, /*!< in: physical record */ const rec_t *rec2, /*!< in: physical record */ const ulint *offsets1, /*!< in: rec_get_offsets(rec1, ...) */ diff --git a/storage/innobase/include/rem0cmp.ic b/storage/innobase/include/rem0cmp.ic index efec078404ba..40ef4f671b33 100644 --- a/storage/innobase/include/rem0cmp.ic +++ b/storage/innobase/include/rem0cmp.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/*******************************************************************/ /** - @file include/rem0cmp.ic +/** @file include/rem0cmp.ic Comparison services for records Created 7/1/1994 Heikki Tuuri diff --git a/storage/innobase/include/rem0rec.h b/storage/innobase/include/rem0rec.h index 7eb1f7a75b8f..2195b7485a2e 100644 --- a/storage/innobase/include/rem0rec.h +++ b/storage/innobase/include/rem0rec.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -26,8 +26,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "my_compiler.h" -/********************************************************************/ /** - @file include/rem0rec.h +/** @file include/rem0rec.h Record manager Created 5/30/1994 Heikki Tuuri @@ -47,35 +46,27 @@ this program; if not, write to the Free Software Foundation, Inc., #include "trx0types.h" #include "univ.i" -/******************************************************/ /** - The following function is used to get the pointer of the next chained record +/** The following function is used to get the pointer of the next chained record on the same page. @return pointer to the next chained record, or NULL if none */ UNIV_INLINE const rec_t *rec_get_next_ptr_const( - /*===================*/ const rec_t *rec, /*!< in: physical record */ ulint comp) /*!< in: nonzero=compact page format */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************/ /** - The following function is used to get the pointer of the next chained record +/** The following function is used to get the pointer of the next chained record on the same page. @return pointer to the next chained record, or NULL if none */ UNIV_INLINE -rec_t *rec_get_next_ptr( - /*=============*/ - rec_t *rec, /*!< in: physical record */ - ulint comp) /*!< in: nonzero=compact page format */ +rec_t *rec_get_next_ptr(rec_t *rec, /*!< in: physical record */ + ulint comp) /*!< in: nonzero=compact page format */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************/ /** - The following function is used to get the offset of the +/** The following function is used to get the offset of the next chained record on the same page. @return the page offset of the next chained record, or 0 if none */ UNIV_INLINE -ulint rec_get_next_offs( - /*==============*/ - const rec_t *rec, /*!< in: physical record */ - ulint comp) /*!< in: nonzero=compact page format */ +ulint rec_get_next_offs(const rec_t *rec, /*!< in: physical record */ + ulint comp) /*!< in: nonzero=compact page format */ MY_ATTRIBUTE((warn_unused_result)); /** The following function is used to set the next record offset field of an @@ -90,13 +81,11 @@ new-style record. */ UNIV_INLINE void rec_set_next_offs_new(rec_t *rec, ulint next); -/******************************************************/ /** - The following function is used to get the number of records owned by the +/** The following function is used to get the number of records owned by the previous directory record. @return number of owned records */ UNIV_INLINE ulint rec_get_n_owned_old( - /*================*/ const rec_t *rec) /*!< in: old-style physical record */ MY_ATTRIBUTE((warn_unused_result)); @@ -106,13 +95,11 @@ ulint rec_get_n_owned_old( UNIV_INLINE void rec_set_n_owned_old(rec_t *rec, ulint n_owned); -/******************************************************/ /** - The following function is used to get the number of records owned by the +/** The following function is used to get the number of records owned by the previous directory record. @return number of owned records */ UNIV_INLINE ulint rec_get_n_owned_new( - /*================*/ const rec_t *rec) /*!< in: new-style physical record */ MY_ATTRIBUTE((warn_unused_result)); @@ -123,15 +110,12 @@ ulint rec_get_n_owned_new( UNIV_INLINE void rec_set_n_owned_new(rec_t *rec, page_zip_des_t *page_zip, ulint n_owned); -/******************************************************/ /** - The following function is used to retrieve the info bits of +/** The following function is used to retrieve the info bits of a record. @return info bits */ UNIV_INLINE -ulint rec_get_info_bits( - /*==============*/ - const rec_t *rec, /*!< in: physical record */ - ulint comp) /*!< in: nonzero=compact page format */ +ulint rec_get_info_bits(const rec_t *rec, /*!< in: physical record */ + ulint comp) /*!< in: nonzero=compact page format */ MY_ATTRIBUTE((warn_unused_result)); /** The following function is used to set the info bits of a record. @@ -152,13 +136,11 @@ void rec_set_info_bits_new(rec_t *rec, ulint bits); UNIV_INLINE void rec_set_status(rec_t *rec, ulint bits); -/******************************************************/ /** - The following function is used to retrieve the info and status +/** The following function is used to retrieve the info and status bits of a record. (Only compact records have status bits.) @return info bits */ UNIV_INLINE ulint rec_get_info_and_status_bits( - /*=========================*/ const rec_t *rec, /*!< in: physical record */ ulint comp) /*!< in: nonzero=compact page format */ MY_ATTRIBUTE((warn_unused_result)); @@ -170,14 +152,11 @@ ulint rec_get_info_and_status_bits( UNIV_INLINE void rec_set_info_and_status_bits(rec_t *rec, ulint bits); -/******************************************************/ /** - The following function tells if record is delete marked. +/** The following function tells if record is delete marked. @return nonzero if delete marked */ UNIV_INLINE -ulint rec_get_deleted_flag( - /*=================*/ - const rec_t *rec, /*!< in: physical record */ - ulint comp) /*!< in: nonzero=compact page format */ +ulint rec_get_deleted_flag(const rec_t *rec, /*!< in: physical record */ + ulint comp) /*!< in: nonzero=compact page format */ MY_ATTRIBUTE((warn_unused_result)); /** The following function is used to set the deleted bit. @@ -193,13 +172,10 @@ void rec_set_deleted_flag_old(rec_t *rec, ulint flag); UNIV_INLINE void rec_set_deleted_flag_new(rec_t *rec, page_zip_des_t *page_zip, ulint flag); -/******************************************************/ /** - The following function tells if a new-style record is a node pointer. +/** The following function tells if a new-style record is a node pointer. @return true if node pointer */ UNIV_INLINE -ibool rec_get_node_ptr_flag( - /*==================*/ - const rec_t *rec) /*!< in: physical record */ +ibool rec_get_node_ptr_flag(const rec_t *rec) /*!< in: physical record */ MY_ATTRIBUTE((warn_unused_result)); /** The following function is used to get the order number of an old-style @@ -230,14 +206,11 @@ record. UNIV_INLINE void rec_set_heap_no_new(rec_t *rec, ulint heap_no); -/******************************************************/ /** - The following function is used to test whether the data offsets +/** The following function is used to test whether the data offsets in the record are stored in one-byte or two-byte format. @return true if 1-byte form */ UNIV_INLINE -ibool rec_get_1byte_offs_flag( - /*====================*/ - const rec_t *rec) /*!< in: physical record */ +ibool rec_get_1byte_offs_flag(const rec_t *rec) /*!< in: physical record */ MY_ATTRIBUTE((warn_unused_result)); /** The following function is used to set the 1-byte offsets flag. @@ -246,48 +219,37 @@ ibool rec_get_1byte_offs_flag( UNIV_INLINE void rec_set_1byte_offs_flag(rec_t *rec, ibool flag); -/******************************************************/ /** - Returns the offset of nth field end if the record is stored in the 1-byte +/** Returns the offset of nth field end if the record is stored in the 1-byte offsets form. If the field is SQL null, the flag is ORed in the returned value. @return offset of the start of the field, SQL null flag ORed */ UNIV_INLINE -ulint rec_1_get_field_end_info( - /*=====================*/ - const rec_t *rec, /*!< in: record */ - ulint n) /*!< in: field index */ +ulint rec_1_get_field_end_info(const rec_t *rec, /*!< in: record */ + ulint n) /*!< in: field index */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************/ /** - Returns the offset of nth field end if the record is stored in the 2-byte +/** Returns the offset of nth field end if the record is stored in the 2-byte offsets form. If the field is SQL null, the flag is ORed in the returned value. @return offset of the start of the field, SQL null flag and extern storage flag ORed */ UNIV_INLINE -ulint rec_2_get_field_end_info( - /*=====================*/ - const rec_t *rec, /*!< in: record */ - ulint n) /*!< in: field index */ +ulint rec_2_get_field_end_info(const rec_t *rec, /*!< in: record */ + ulint n) /*!< in: field index */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************/ /** - Returns nonzero if the field is stored off-page. +/** Returns nonzero if the field is stored off-page. @retval 0 if the field is stored in-page @retval REC_2BYTE_EXTERN_MASK if the field is stored externally */ UNIV_INLINE -ulint rec_2_is_field_extern( - /*==================*/ - const rec_t *rec, /*!< in: record */ - ulint n) /*!< in: field index */ +ulint rec_2_is_field_extern(const rec_t *rec, /*!< in: record */ + ulint n) /*!< in: field index */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************/ /** - Determine how many of the first n columns in a compact +/** Determine how many of the first n columns in a compact physical record are stored externally. @return number of externally stored columns */ ulint rec_get_n_extern_new( - /*=================*/ const rec_t *rec, /*!< in: compact physical record */ const dict_index_t *index, /*!< in: record descriptor */ ulint n) /*!< in: number of columns to scan */ @@ -301,28 +263,23 @@ ulint rec_get_n_extern_new( rec_get_offsets_func(rec, index, offsets, n, heap) #endif /* UNIV_DEBUG */ -/************************************************************/ /** - The following function is used to get the offset to the nth +/** The following function is used to get the offset to the nth data field in an old-style record. @return offset to the field */ ulint rec_get_nth_field_offs_old( - /*=======================*/ const rec_t *rec, /*!< in: record */ ulint n, /*!< in: index of the field */ ulint *len); /*!< out: length of the field; UNIV_SQL_NULL if SQL null */ #define rec_get_nth_field_old(rec, n, len) \ ((rec) + rec_get_nth_field_offs_old(rec, n, len)) -/************************************************************/ /** - Gets the physical size of an old-style field. +/** Gets the physical size of an old-style field. Also an SQL null may have a field of size > 0, if the data type is of a fixed size. @return field size in bytes */ UNIV_INLINE -ulint rec_get_nth_field_size( - /*===================*/ - const rec_t *rec, /*!< in: record */ - ulint n) /*!< in: index of the field */ +ulint rec_get_nth_field_size(const rec_t *rec, /*!< in: record */ + ulint n) /*!< in: index of the field */ MY_ATTRIBUTE((warn_unused_result)); /** The following function is used to get an offset to the nth data field in a @@ -336,39 +293,31 @@ ulint rec_get_nth_field_offs(const ulint *offsets, ulint n, ulint *len); #define rec_get_nth_field(rec, offsets, n, len) \ ((rec) + rec_get_nth_field_offs(offsets, n, len)) -/******************************************************/ /** - Determine if the offsets are for a record in the new +/** Determine if the offsets are for a record in the new compact format. @return nonzero if compact format */ UNIV_INLINE ulint rec_offs_comp( - /*==========*/ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************/ /** - Determine if the offsets are for a record containing +/** Determine if the offsets are for a record containing externally stored columns. @return nonzero if externally stored */ UNIV_INLINE ulint rec_offs_any_extern( - /*================*/ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************/ /** - Determine if the offsets are for a record containing null BLOB pointers. +/** Determine if the offsets are for a record containing null BLOB pointers. @return first field containing a null BLOB pointer, or NULL if none found */ UNIV_INLINE const byte *rec_offs_any_null_extern( - /*=====================*/ const rec_t *rec, /*!< in: record */ const ulint *offsets) /*!< in: rec_get_offsets(rec) */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************/ /** - Returns nonzero if the extern bit is set in nth field of rec. +/** Returns nonzero if the extern bit is set in nth field of rec. @return nonzero if externally stored */ UNIV_INLINE ulint rec_offs_nth_extern( - /*================*/ const ulint *offsets, /*!< in: array returned by rec_get_offsets() */ ulint n) /*!< in: nth field */ MY_ATTRIBUTE((warn_unused_result)); @@ -377,31 +326,25 @@ ulint rec_offs_nth_extern( @param[in] offsets array returned by rec_get_offsets() @param[in] n nth field */ void rec_offs_make_nth_extern(ulint *offsets, const ulint n); -/******************************************************/ /** - Returns nonzero if the SQL NULL bit is set in nth field of rec. +/** Returns nonzero if the SQL NULL bit is set in nth field of rec. @return nonzero if SQL NULL */ UNIV_INLINE ulint rec_offs_nth_sql_null( - /*==================*/ const ulint *offsets, /*!< in: array returned by rec_get_offsets() */ ulint n) /*!< in: nth field */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************/ /** - Gets the physical size of a field. +/** Gets the physical size of a field. @return length of field */ UNIV_INLINE ulint rec_offs_nth_size( - /*==============*/ const ulint *offsets, /*!< in: array returned by rec_get_offsets() */ ulint n) /*!< in: nth field */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************/ /** - Returns the number of extern bits set in a record. +/** Returns the number of extern bits set in a record. @return number of externally stored fields */ UNIV_INLINE ulint rec_offs_n_extern( - /*==============*/ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ MY_ATTRIBUTE((warn_unused_result)); @@ -422,64 +365,51 @@ UNIV_INLINE void rec_set_nth_field(rec_t *rec, const ulint *offsets, ulint n, const void *data, ulint len); -/**********************************************************/ /** - The following function returns the data size of an old-style physical +/** The following function returns the data size of an old-style physical record, that is the sum of field lengths. SQL null fields are counted as length 0 fields. The value returned by the function is the distance from record origin to record end in bytes. @return size */ UNIV_INLINE -ulint rec_get_data_size_old( - /*==================*/ - const rec_t *rec) /*!< in: physical record */ +ulint rec_get_data_size_old(const rec_t *rec) /*!< in: physical record */ MY_ATTRIBUTE((warn_unused_result)); #define rec_offs_init(offsets) \ rec_offs_set_n_alloc(offsets, (sizeof offsets) / sizeof *offsets) -/**********************************************************/ /** - The following function returns the data size of a physical +/** The following function returns the data size of a physical record, that is the sum of field lengths. SQL null fields are counted as length 0 fields. The value returned by the function is the distance from record origin to record end in bytes. @return size */ UNIV_INLINE ulint rec_offs_data_size( - /*===============*/ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ MY_ATTRIBUTE((warn_unused_result)); -/**********************************************************/ /** - Returns the total size of record minus data size of record. +/** Returns the total size of record minus data size of record. The value returned by the function is the distance from record start to record origin in bytes. @return size */ UNIV_INLINE ulint rec_offs_extra_size( - /*================*/ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ MY_ATTRIBUTE((warn_unused_result)); -/**********************************************************/ /** - Returns the total size of a physical record. +/** Returns the total size of a physical record. @return size */ UNIV_INLINE ulint rec_offs_size( - /*==========*/ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ MY_ATTRIBUTE((warn_unused_result)); #ifdef UNIV_DEBUG -/**********************************************************/ /** - Returns a pointer to the start of the record. +/** Returns a pointer to the start of the record. @return pointer to start */ UNIV_INLINE byte *rec_get_start( - /*==========*/ const rec_t *rec, /*!< in: pointer to record */ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ MY_ATTRIBUTE((warn_unused_result)); -/**********************************************************/ /** - Returns a pointer to the end of the record. +/** Returns a pointer to the end of the record. @return pointer to end */ UNIV_INLINE byte *rec_get_end( - /*========*/ const rec_t *rec, /*!< in: pointer to record */ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ MY_ATTRIBUTE((warn_unused_result)); @@ -497,11 +427,9 @@ UNIV_INLINE rec_t *rec_copy(void *buf, const rec_t *rec, const ulint *offsets); #ifndef UNIV_HOTBACKUP -/**********************************************************/ /** - Determines the size of a data tuple prefix in a temporary file. +/** Determines the size of a data tuple prefix in a temporary file. @return total size */ ulint rec_get_converted_size_temp( - /*========================*/ const dict_index_t *index, /*!< in: record descriptor */ const dfield_t *fields, /*!< in: array of data fields */ ulint n_fields, /*!< in: number of data fields */ @@ -510,21 +438,17 @@ ulint rec_get_converted_size_temp( ulint *extra) /*!< out: extra size */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************/ /** - Determine the offset to each field in temporary file. +/** Determine the offset to each field in temporary file. @see rec_convert_dtuple_to_temp() */ void rec_init_offsets_temp( - /*==================*/ const rec_t *rec, /*!< in: temporary file record */ const dict_index_t *index, /*!< in: record descriptor */ ulint *offsets); /*!< in/out: array of offsets; in: n=rec_offs_n_fields(offsets) */ -/*********************************************************/ /** - Builds a temporary file record out of a data tuple. +/** Builds a temporary file record out of a data tuple. @see rec_init_offsets_temp() */ void rec_convert_dtuple_to_temp( - /*=======================*/ rec_t *rec, /*!< out: record */ const dict_index_t *index, /*!< in: record descriptor */ const dfield_t *fields, /*!< in: array of data fields */ @@ -532,12 +456,10 @@ void rec_convert_dtuple_to_temp( const dtuple_t *v_entry); /*!< in: dtuple contains virtual column data */ -/**************************************************************/ /** - Copies the first n fields of a physical record to a new physical record in +/** Copies the first n fields of a physical record to a new physical record in a buffer. @return own: copied record */ rec_t *rec_copy_prefix_to_buf( - /*===================*/ const rec_t *rec, /*!< in: physical record */ const dict_index_t *index, /*!< in: record descriptor */ ulint n_fields, /*!< in: number of fields @@ -557,12 +479,10 @@ UNIV_INLINE ulint rec_fold(const rec_t *rec, const ulint *offsets, ulint n_fields, ulint n_bytes, ulint fold) MY_ATTRIBUTE((warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ -/*********************************************************/ /** - Builds a physical record out of a data tuple and +/** Builds a physical record out of a data tuple and stores it into the given buffer. @return pointer to the origin of physical record */ rec_t *rec_convert_dtuple_to_rec( - /*======================*/ byte *buf, /*!< in: start address of the physical record */ const dict_index_t *index, /*!< in: record descriptor */ @@ -570,32 +490,26 @@ rec_t *rec_convert_dtuple_to_rec( ulint n_ext) /*!< in: number of externally stored columns */ MY_ATTRIBUTE((warn_unused_result)); -/**********************************************************/ /** - Returns the extra size of an old-style physical record if we know its +/** Returns the extra size of an old-style physical record if we know its data size and number of fields. @return extra size */ UNIV_INLINE ulint rec_get_converted_extra_size( - /*=========================*/ ulint data_size, /*!< in: data size */ ulint n_fields, /*!< in: number of fields */ ulint n_ext) /*!< in: number of externally stored columns */ MY_ATTRIBUTE((const)); -/**********************************************************/ /** - Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT. +/** Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT. @return total size */ ulint rec_get_converted_size_comp_prefix( - /*===============================*/ const dict_index_t *index, /*!< in: record descriptor */ const dfield_t *fields, /*!< in: array of data fields */ ulint n_fields, /*!< in: number of data fields */ ulint *extra) /*!< out: extra size */ MY_ATTRIBUTE((warn_unused_result)); -/**********************************************************/ /** - Determines the size of a data tuple in ROW_FORMAT=COMPACT. +/** Determines the size of a data tuple in ROW_FORMAT=COMPACT. @return total size */ ulint rec_get_converted_size_comp( - /*========================*/ const dict_index_t *index, /*!< in: record descriptor; dict_table_is_comp() is assumed to hold, even if @@ -604,23 +518,19 @@ ulint rec_get_converted_size_comp( const dfield_t *fields, /*!< in: array of data fields */ ulint n_fields, /*!< in: number of data fields */ ulint *extra); /*!< out: extra size */ -/**********************************************************/ /** - The following function returns the size of a data tuple when converted to +/** The following function returns the size of a data tuple when converted to a physical record. @return size */ UNIV_INLINE ulint rec_get_converted_size( - /*===================*/ dict_index_t *index, /*!< in: record descriptor */ const dtuple_t *dtuple, /*!< in: data tuple */ ulint n_ext) /*!< in: number of externally stored columns */ MY_ATTRIBUTE((warn_unused_result)); #ifndef UNIV_HOTBACKUP -/**************************************************************/ /** - Copies the first n fields of a physical record to a data tuple. +/** Copies the first n fields of a physical record to a data tuple. The fields are copied to the memory heap. */ void rec_copy_prefix_to_dtuple( - /*======================*/ dtuple_t *tuple, /*!< out: data tuple */ const rec_t *rec, /*!< in: physical record */ const dict_index_t *index, /*!< in: record descriptor */ @@ -628,41 +538,29 @@ void rec_copy_prefix_to_dtuple( to copy */ mem_heap_t *heap); /*!< in: memory heap */ #endif /* !UNIV_HOTBACKUP */ -/***************************************************************/ /** - Validates the consistency of a physical record. +/** Validates the consistency of a physical record. @return true if ok */ ibool rec_validate( - /*=========*/ const rec_t *rec, /*!< in: physical record */ const ulint *offsets); /*!< in: array returned by rec_get_offsets() */ -/***************************************************************/ /** - Prints an old-style physical record. */ -void rec_print_old( - /*==========*/ - FILE *file, /*!< in: file where to print */ - const rec_t *rec); /*!< in: physical record */ +/** Prints an old-style physical record. */ +void rec_print_old(FILE *file, /*!< in: file where to print */ + const rec_t *rec); /*!< in: physical record */ #ifndef UNIV_HOTBACKUP -/***************************************************************/ /** - Prints a spatial index record. */ +/** Prints a spatial index record. */ void rec_print_mbr_rec( - /*==========*/ FILE *file, /*!< in: file where to print */ const rec_t *rec, /*!< in: physical record */ const ulint *offsets); /*!< in: array returned by rec_get_offsets() */ -/***************************************************************/ /** - Prints a physical record. */ +/** Prints a physical record. */ void rec_print_new( - /*==========*/ FILE *file, /*!< in: file where to print */ const rec_t *rec, /*!< in: physical record */ const ulint *offsets); /*!< in: array returned by rec_get_offsets() */ -/***************************************************************/ /** - Prints a physical record. */ -void rec_print( - /*======*/ - FILE *file, /*!< in: file where to print */ - const rec_t *rec, /*!< in: physical record */ - const dict_index_t *index); /*!< in: record descriptor */ +/** Prints a physical record. */ +void rec_print(FILE *file, /*!< in: file where to print */ + const rec_t *rec, /*!< in: physical record */ + const dict_index_t *index); /*!< in: record descriptor */ /** Pretty-print a record. @param[in,out] o output stream @@ -753,13 +651,10 @@ class rec_printer : public std::ostringstream { }; #endif /* UNIV_DEBUG */ -/************************************************************/ /** - Reads the DB_TRX_ID of a clustered index record. +/** Reads the DB_TRX_ID of a clustered index record. @return the value of DB_TRX_ID */ -trx_id_t rec_get_trx_id( - /*===========*/ - const rec_t *rec, /*!< in: record */ - const dict_index_t *index) /*!< in: clustered index */ +trx_id_t rec_get_trx_id(const rec_t *rec, /*!< in: record */ + const dict_index_t *index) /*!< in: clustered index */ MY_ATTRIBUTE((warn_unused_result)); #endif /* UNIV_HOTBACKUP */ diff --git a/storage/innobase/include/rem0rec.ic b/storage/innobase/include/rem0rec.ic index 9facf84e4350..94b9f5b4e5c8 100644 --- a/storage/innobase/include/rem0rec.ic +++ b/storage/innobase/include/rem0rec.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file include/rem0rec.ic +/** @file include/rem0rec.ic Record manager Created 5/30/1994 Heikki Tuuri @@ -82,26 +81,18 @@ most significant bytes and bits are written below less significant. 4 bits info bits */ -/***********************************************************/ /** - Sets the value of the ith field SQL null bit of an old-style record. */ -void rec_set_nth_field_null_bit( - /*=======================*/ - rec_t *rec, /*!< in: record */ - ulint i, /*!< in: ith field */ - ibool val); /*!< in: value to set */ -/***********************************************************/ /** - Sets an old-style record field to SQL null. +/** Sets the value of the ith field SQL null bit of an old-style record. */ +void rec_set_nth_field_null_bit(rec_t *rec, /*!< in: record */ + ulint i, /*!< in: ith field */ + ibool val); /*!< in: value to set */ +/** Sets an old-style record field to SQL null. The physical size of the field is not changed. */ -void rec_set_nth_field_sql_null( - /*=======================*/ - rec_t *rec, /*!< in: record */ - ulint n); /*!< in: index of the field */ +void rec_set_nth_field_sql_null(rec_t *rec, /*!< in: record */ + ulint n); /*!< in: index of the field */ -/******************************************************/ /** - Sets a bit field within 1 byte. */ +/** Sets a bit field within 1 byte. */ UNIV_INLINE void rec_set_bit_field_1( - /*================*/ rec_t *rec, /*!< in: pointer to record origin */ ulint val, /*!< in: value to set */ ulint offs, /*!< in: offset from the origin down */ @@ -119,11 +110,9 @@ void rec_set_bit_field_1( (mach_read_from_1(rec - offs) & ~mask) | (val << shift)); } -/******************************************************/ /** - Sets a bit field within 2 bytes. */ +/** Sets a bit field within 2 bytes. */ UNIV_INLINE void rec_set_bit_field_2( - /*================*/ rec_t *rec, /*!< in: pointer to record origin */ ulint val, /*!< in: value to set */ ulint offs, /*!< in: offset from the origin down */ @@ -143,13 +132,11 @@ void rec_set_bit_field_2( (mach_read_from_2(rec - offs) & ~mask) | (val << shift)); } -/******************************************************/ /** - The following function is used to get the pointer of the next chained record +/** The following function is used to get the pointer of the next chained record on the same page. @return pointer to the next chained record, or NULL if none */ UNIV_INLINE const rec_t *rec_get_next_ptr_const( - /*===================*/ const rec_t *rec, /*!< in: physical record */ ulint comp) /*!< in: nonzero=compact page format */ { @@ -197,28 +184,22 @@ const rec_t *rec_get_next_ptr_const( } } -/******************************************************/ /** - The following function is used to get the pointer of the next chained record +/** The following function is used to get the pointer of the next chained record on the same page. @return pointer to the next chained record, or NULL if none */ UNIV_INLINE -rec_t *rec_get_next_ptr( - /*=============*/ - rec_t *rec, /*!< in: physical record */ - ulint comp) /*!< in: nonzero=compact page format */ +rec_t *rec_get_next_ptr(rec_t *rec, /*!< in: physical record */ + ulint comp) /*!< in: nonzero=compact page format */ { return (const_cast(rec_get_next_ptr_const(rec, comp))); } -/******************************************************/ /** - The following function is used to get the offset of the next chained record +/** The following function is used to get the offset of the next chained record on the same page. @return the page offset of the next chained record, or 0 if none */ UNIV_INLINE -ulint rec_get_next_offs( - /*==============*/ - const rec_t *rec, /*!< in: physical record */ - ulint comp) /*!< in: nonzero=compact page format */ +ulint rec_get_next_offs(const rec_t *rec, /*!< in: physical record */ + ulint comp) /*!< in: nonzero=compact page format */ { ulint field_value; #if REC_NEXT_MASK != 0xFFFFUL @@ -267,14 +248,11 @@ ulint rec_get_next_offs( } } -/******************************************************/ /** - The following function is used to set the next record offset field +/** The following function is used to set the next record offset field of an old-style record. */ UNIV_INLINE -void rec_set_next_offs_old( - /*==================*/ - rec_t *rec, /*!< in: old-style physical record */ - ulint next) /*!< in: offset of the next record */ +void rec_set_next_offs_old(rec_t *rec, /*!< in: old-style physical record */ + ulint next) /*!< in: offset of the next record */ { ut_ad(rec); ut_ad(UNIV_PAGE_SIZE > next); @@ -288,14 +266,11 @@ void rec_set_next_offs_old( mach_write_to_2(rec - REC_NEXT, next); } -/******************************************************/ /** - The following function is used to set the next record offset field +/** The following function is used to set the next record offset field of a new-style record. */ UNIV_INLINE -void rec_set_next_offs_new( - /*==================*/ - rec_t *rec, /*!< in/out: new-style physical record */ - ulint next) /*!< in: offset of the next record */ +void rec_set_next_offs_new(rec_t *rec, /*!< in/out: new-style physical record */ + ulint next) /*!< in: offset of the next record */ { ulint field_value; @@ -317,14 +292,11 @@ void rec_set_next_offs_new( mach_write_to_2(rec - REC_NEXT, field_value); } -/******************************************************/ /** - The following function is used to set the number of fields +/** The following function is used to set the number of fields in an old-style record. */ UNIV_INLINE -void rec_set_n_fields_old( - /*=================*/ - rec_t *rec, /*!< in: physical record */ - ulint n_fields) /*!< in: the number of fields */ +void rec_set_n_fields_old(rec_t *rec, /*!< in: physical record */ + ulint n_fields) /*!< in: the number of fields */ { ut_ad(rec); ut_ad(n_fields <= REC_MAX_N_FIELDS); @@ -334,49 +306,40 @@ void rec_set_n_fields_old( REC_OLD_N_FIELDS_SHIFT); } -/******************************************************/ /** - The following function is used to get the number of records owned by the +/** The following function is used to get the number of records owned by the previous directory record. @return number of owned records */ UNIV_INLINE ulint rec_get_n_owned_old( - /*================*/ const rec_t *rec) /*!< in: old-style physical record */ { return (rec_get_bit_field_1(rec, REC_OLD_N_OWNED, REC_N_OWNED_MASK, REC_N_OWNED_SHIFT)); } -/******************************************************/ /** - The following function is used to set the number of owned records. */ +/** The following function is used to set the number of owned records. */ UNIV_INLINE -void rec_set_n_owned_old( - /*================*/ - rec_t *rec, /*!< in: old-style physical record */ - ulint n_owned) /*!< in: the number of owned */ +void rec_set_n_owned_old(rec_t *rec, /*!< in: old-style physical record */ + ulint n_owned) /*!< in: the number of owned */ { rec_set_bit_field_1(rec, n_owned, REC_OLD_N_OWNED, REC_N_OWNED_MASK, REC_N_OWNED_SHIFT); } -/******************************************************/ /** - The following function is used to get the number of records owned by the +/** The following function is used to get the number of records owned by the previous directory record. @return number of owned records */ UNIV_INLINE ulint rec_get_n_owned_new( - /*================*/ const rec_t *rec) /*!< in: new-style physical record */ { return (rec_get_bit_field_1(rec, REC_NEW_N_OWNED, REC_N_OWNED_MASK, REC_N_OWNED_SHIFT)); } -/******************************************************/ /** - The following function is used to set the number of owned records. */ +/** The following function is used to set the number of owned records. */ UNIV_INLINE void rec_set_n_owned_new( - /*================*/ rec_t *rec, /*!< in/out: new-style physical record */ page_zip_des_t *page_zip, /*!< in/out: compressed page, or NULL */ ulint n_owned) /*!< in: the number of owned */ @@ -397,14 +360,11 @@ inline bool rec_info_bits_valid(ulint bits) { } #endif /* UNIV_DEBUG */ -/******************************************************/ /** - The following function is used to retrieve the info bits of a record. +/** The following function is used to retrieve the info bits of a record. @return info bits */ UNIV_INLINE -ulint rec_get_info_bits( - /*==============*/ - const rec_t *rec, /*!< in: physical record */ - ulint comp) /*!< in: nonzero=compact page format */ +ulint rec_get_info_bits(const rec_t *rec, /*!< in: physical record */ + ulint comp) /*!< in: nonzero=compact page format */ { const ulint val = rec_get_bit_field_1(rec, comp ? REC_NEW_INFO_BITS : REC_OLD_INFO_BITS, @@ -413,50 +373,40 @@ ulint rec_get_info_bits( return (val); } -/******************************************************/ /** - The following function is used to set the info bits of a record. */ +/** The following function is used to set the info bits of a record. */ UNIV_INLINE -void rec_set_info_bits_old( - /*==================*/ - rec_t *rec, /*!< in: old-style physical record */ - ulint bits) /*!< in: info bits */ +void rec_set_info_bits_old(rec_t *rec, /*!< in: old-style physical record */ + ulint bits) /*!< in: info bits */ { ut_ad(rec_info_bits_valid(bits)); rec_set_bit_field_1(rec, bits, REC_OLD_INFO_BITS, REC_INFO_BITS_MASK, REC_INFO_BITS_SHIFT); } -/******************************************************/ /** - The following function is used to set the info bits of a record. */ +/** The following function is used to set the info bits of a record. */ UNIV_INLINE -void rec_set_info_bits_new( - /*==================*/ - rec_t *rec, /*!< in/out: new-style physical record */ - ulint bits) /*!< in: info bits */ +void rec_set_info_bits_new(rec_t *rec, /*!< in/out: new-style physical record */ + ulint bits) /*!< in: info bits */ { ut_ad(rec_info_bits_valid(bits)); rec_set_bit_field_1(rec, bits, REC_NEW_INFO_BITS, REC_INFO_BITS_MASK, REC_INFO_BITS_SHIFT); } -/******************************************************/ /** - The following function is used to set the status bits of a new-style record. */ +/** The following function is used to set the status bits of a new-style record. + */ UNIV_INLINE -void rec_set_status( - /*===========*/ - rec_t *rec, /*!< in/out: physical record */ - ulint bits) /*!< in: info bits */ +void rec_set_status(rec_t *rec, /*!< in/out: physical record */ + ulint bits) /*!< in: info bits */ { rec_set_bit_field_1(rec, bits, REC_NEW_STATUS, REC_NEW_STATUS_MASK, REC_NEW_STATUS_SHIFT); } -/******************************************************/ /** - The following function is used to retrieve the info and status +/** The following function is used to retrieve the info and status bits of a record. (Only compact records have status bits.) @return info bits */ UNIV_INLINE ulint rec_get_info_and_status_bits( - /*=========================*/ const rec_t *rec, /*!< in: physical record */ ulint comp) /*!< in: nonzero=compact page format */ { @@ -473,14 +423,11 @@ ulint rec_get_info_and_status_bits( } return (bits); } -/******************************************************/ /** - The following function is used to set the info and status +/** The following function is used to set the info and status bits of a record. (Only compact records have status bits.) */ UNIV_INLINE -void rec_set_info_and_status_bits( - /*=========================*/ - rec_t *rec, /*!< in/out: physical record */ - ulint bits) /*!< in: info bits */ +void rec_set_info_and_status_bits(rec_t *rec, /*!< in/out: physical record */ + ulint bits) /*!< in: info bits */ { #if (REC_NEW_STATUS_MASK >> REC_NEW_STATUS_SHIFT) & \ (REC_INFO_BITS_MASK >> REC_INFO_BITS_SHIFT) @@ -490,14 +437,11 @@ void rec_set_info_and_status_bits( rec_set_info_bits_new(rec, bits & ~REC_NEW_STATUS_MASK); } -/******************************************************/ /** - The following function tells if record is delete marked. +/** The following function tells if record is delete marked. @return nonzero if delete marked */ UNIV_INLINE -ulint rec_get_deleted_flag( - /*=================*/ - const rec_t *rec, /*!< in: physical record */ - ulint comp) /*!< in: nonzero=compact page format */ +ulint rec_get_deleted_flag(const rec_t *rec, /*!< in: physical record */ + ulint comp) /*!< in: nonzero=compact page format */ { if (comp) { return (rec_get_bit_field_1(rec, REC_NEW_INFO_BITS, REC_INFO_DELETED_FLAG, @@ -508,13 +452,10 @@ ulint rec_get_deleted_flag( } } -/******************************************************/ /** - The following function is used to set the deleted bit. */ +/** The following function is used to set the deleted bit. */ UNIV_INLINE -void rec_set_deleted_flag_old( - /*=====================*/ - rec_t *rec, /*!< in: old-style physical record */ - ulint flag) /*!< in: nonzero if delete marked */ +void rec_set_deleted_flag_old(rec_t *rec, /*!< in: old-style physical record */ + ulint flag) /*!< in: nonzero if delete marked */ { ulint val; @@ -529,11 +470,9 @@ void rec_set_deleted_flag_old( rec_set_info_bits_old(rec, val); } -/******************************************************/ /** - The following function is used to set the deleted bit. */ +/** The following function is used to set the deleted bit. */ UNIV_INLINE void rec_set_deleted_flag_new( - /*=====================*/ rec_t *rec, /*!< in/out: new-style physical record */ page_zip_des_t *page_zip, /*!< in/out: compressed page, or NULL */ ulint flag) /*!< in: nonzero if delete marked */ @@ -555,76 +494,58 @@ void rec_set_deleted_flag_new( } } -/******************************************************/ /** - The following function tells if a new-style record is a node pointer. +/** The following function tells if a new-style record is a node pointer. @return true if node pointer */ UNIV_INLINE -ibool rec_get_node_ptr_flag( - /*==================*/ - const rec_t *rec) /*!< in: physical record */ +ibool rec_get_node_ptr_flag(const rec_t *rec) /*!< in: physical record */ { return (REC_STATUS_NODE_PTR == rec_get_status(rec)); } -/******************************************************/ /** - The following function is used to get the order number +/** The following function is used to get the order number of an old-style record in the heap of the index page. @return heap order number */ UNIV_INLINE -ulint rec_get_heap_no_old( - /*================*/ - const rec_t *rec) /*!< in: physical record */ +ulint rec_get_heap_no_old(const rec_t *rec) /*!< in: physical record */ { return (rec_get_bit_field_2(rec, REC_OLD_HEAP_NO, REC_HEAP_NO_MASK, REC_HEAP_NO_SHIFT)); } -/******************************************************/ /** - The following function is used to set the heap number +/** The following function is used to set the heap number field in an old-style record. */ UNIV_INLINE -void rec_set_heap_no_old( - /*================*/ - rec_t *rec, /*!< in: physical record */ - ulint heap_no) /*!< in: the heap number */ +void rec_set_heap_no_old(rec_t *rec, /*!< in: physical record */ + ulint heap_no) /*!< in: the heap number */ { rec_set_bit_field_2(rec, heap_no, REC_OLD_HEAP_NO, REC_HEAP_NO_MASK, REC_HEAP_NO_SHIFT); } -/******************************************************/ /** - The following function is used to get the order number +/** The following function is used to get the order number of a new-style record in the heap of the index page. @return heap order number */ UNIV_INLINE -ulint rec_get_heap_no_new( - /*================*/ - const rec_t *rec) /*!< in: physical record */ +ulint rec_get_heap_no_new(const rec_t *rec) /*!< in: physical record */ { return (rec_get_bit_field_2(rec, REC_NEW_HEAP_NO, REC_HEAP_NO_MASK, REC_HEAP_NO_SHIFT)); } -/******************************************************/ /** - The following function is used to set the heap number +/** The following function is used to set the heap number field in a new-style record. */ UNIV_INLINE -void rec_set_heap_no_new( - /*================*/ - rec_t *rec, /*!< in/out: physical record */ - ulint heap_no) /*!< in: the heap number */ +void rec_set_heap_no_new(rec_t *rec, /*!< in/out: physical record */ + ulint heap_no) /*!< in: the heap number */ { rec_set_bit_field_2(rec, heap_no, REC_NEW_HEAP_NO, REC_HEAP_NO_MASK, REC_HEAP_NO_SHIFT); } -/******************************************************/ /** - The following function is used to set the 1-byte offsets flag. */ +/** The following function is used to set the 1-byte offsets flag. */ UNIV_INLINE -void rec_set_1byte_offs_flag( - /*====================*/ - rec_t *rec, /*!< in: physical record */ - ibool flag) /*!< in: TRUE if 1byte form */ +void rec_set_1byte_offs_flag(rec_t *rec, /*!< in: physical record */ + ibool flag) /*!< in: TRUE if 1byte form */ { #if TRUE != 1 #error "TRUE != 1" @@ -635,26 +556,21 @@ void rec_set_1byte_offs_flag( REC_OLD_SHORT_SHIFT); } -/******************************************************/ /** - Returns nonzero if the field is stored off-page. +/** Returns nonzero if the field is stored off-page. @retval 0 if the field is stored in-page @retval REC_2BYTE_EXTERN_MASK if the field is stored externally */ UNIV_INLINE -ulint rec_2_is_field_extern( - /*==================*/ - const rec_t *rec, /*!< in: record */ - ulint n) /*!< in: field index */ +ulint rec_2_is_field_extern(const rec_t *rec, /*!< in: record */ + ulint n) /*!< in: field index */ { return (rec_2_get_field_end_info(rec, n) & REC_2BYTE_EXTERN_MASK); } -/************************************************************/ /** - The following function is used to get an offset to the nth +/** The following function is used to get an offset to the nth data field in a record. @return offset from the origin of rec */ UNIV_INLINE ulint rec_get_nth_field_offs( - /*===================*/ const ulint *offsets, /*!< in: array returned by rec_get_offsets() */ ulint n, /*!< in: index of the field */ ulint *len) /*!< out: length of the field; UNIV_SQL_NULL @@ -684,38 +600,32 @@ ulint rec_get_nth_field_offs( return (offs); } -/******************************************************/ /** - Determine if the offsets are for a record in the new +/** Determine if the offsets are for a record in the new compact format. @return nonzero if compact format */ UNIV_INLINE ulint rec_offs_comp( - /*==========*/ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ { ut_ad(rec_offs_validate(NULL, NULL, offsets)); return (*rec_offs_base(offsets) & REC_OFFS_COMPACT); } -/******************************************************/ /** - Determine if the offsets are for a record containing +/** Determine if the offsets are for a record containing externally stored columns. @return nonzero if externally stored */ UNIV_INLINE ulint rec_offs_any_extern( - /*================*/ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ { ut_ad(rec_offs_validate(NULL, NULL, offsets)); return (*rec_offs_base(offsets) & REC_OFFS_EXTERNAL); } -/******************************************************/ /** - Determine if the offsets are for a record containing null BLOB pointers. +/** Determine if the offsets are for a record containing null BLOB pointers. @return first field containing a null BLOB pointer, or NULL if none found */ UNIV_INLINE const byte *rec_offs_any_null_extern( - /*=====================*/ const rec_t *rec, /*!< in: record */ const ulint *offsets) /*!< in: rec_get_offsets(rec) */ { @@ -742,12 +652,10 @@ const byte *rec_offs_any_null_extern( return (NULL); } -/******************************************************/ /** - Returns nonzero if the extern bit is set in nth field of rec. +/** Returns nonzero if the extern bit is set in nth field of rec. @return nonzero if externally stored */ UNIV_INLINE ulint rec_offs_nth_extern( - /*================*/ const ulint *offsets, /*!< in: array returned by rec_get_offsets() */ ulint n) /*!< in: nth field */ { @@ -756,12 +664,10 @@ ulint rec_offs_nth_extern( return (rec_offs_base(offsets)[1 + n] & REC_OFFS_EXTERNAL); } -/******************************************************/ /** - Returns nonzero if the SQL NULL bit is set in nth field of rec. +/** Returns nonzero if the SQL NULL bit is set in nth field of rec. @return nonzero if SQL NULL */ UNIV_INLINE ulint rec_offs_nth_sql_null( - /*==================*/ const ulint *offsets, /*!< in: array returned by rec_get_offsets() */ ulint n) /*!< in: nth field */ { @@ -770,12 +676,10 @@ ulint rec_offs_nth_sql_null( return (rec_offs_base(offsets)[1 + n] & REC_OFFS_SQL_NULL); } -/******************************************************/ /** - Gets the physical size of a field. +/** Gets the physical size of a field. @return length of field */ UNIV_INLINE ulint rec_offs_nth_size( - /*==============*/ const ulint *offsets, /*!< in: array returned by rec_get_offsets() */ ulint n) /*!< in: nth field */ { @@ -788,12 +692,10 @@ ulint rec_offs_nth_size( REC_OFFS_MASK); } -/******************************************************/ /** - Returns the number of extern bits set in a record. +/** Returns the number of extern bits set in a record. @return number of externally stored fields */ UNIV_INLINE ulint rec_offs_n_extern( - /*==============*/ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ { ulint n = 0; @@ -811,18 +713,15 @@ ulint rec_offs_n_extern( return (n); } -/******************************************************/ /** - Returns the offset of n - 1th field end if the record is stored in the 1-byte - offsets form. If the field is SQL null, the flag is ORed in the returned +/** Returns the offset of n - 1th field end if the record is stored in the + 1-byte offsets form. If the field is SQL null, the flag is ORed in the returned value. This function and the 2-byte counterpart are defined here because the C-compiler was not able to sum negative and positive constant offsets, and warned of constant arithmetic overflow within the compiler. @return offset of the start of the PREVIOUS field, SQL null flag ORed */ UNIV_INLINE -ulint rec_1_get_prev_field_end_info( - /*==========================*/ - const rec_t *rec, /*!< in: record */ - ulint n) /*!< in: field index */ +ulint rec_1_get_prev_field_end_info(const rec_t *rec, /*!< in: record */ + ulint n) /*!< in: field index */ { ut_ad(rec_get_1byte_offs_flag(rec)); ut_ad(n <= rec_get_n_fields_old(rec)); @@ -830,16 +729,13 @@ ulint rec_1_get_prev_field_end_info( return (mach_read_from_1(rec - (REC_N_OLD_EXTRA_BYTES + n))); } -/******************************************************/ /** - Returns the offset of n - 1th field end if the record is stored in the 2-byte - offsets form. If the field is SQL null, the flag is ORed in the returned +/** Returns the offset of n - 1th field end if the record is stored in the + 2-byte offsets form. If the field is SQL null, the flag is ORed in the returned value. @return offset of the start of the PREVIOUS field, SQL null flag ORed */ UNIV_INLINE -ulint rec_2_get_prev_field_end_info( - /*==========================*/ - const rec_t *rec, /*!< in: record */ - ulint n) /*!< in: field index */ +ulint rec_2_get_prev_field_end_info(const rec_t *rec, /*!< in: record */ + ulint n) /*!< in: field index */ { ut_ad(!rec_get_1byte_offs_flag(rec)); ut_ad(n <= rec_get_n_fields_old(rec)); @@ -847,15 +743,12 @@ ulint rec_2_get_prev_field_end_info( return (mach_read_from_2(rec - (REC_N_OLD_EXTRA_BYTES + 2 * n))); } -/******************************************************/ /** - Sets the field end info for the nth field if the record is stored in the +/** Sets the field end info for the nth field if the record is stored in the 1-byte format. */ UNIV_INLINE -void rec_1_set_field_end_info( - /*=====================*/ - rec_t *rec, /*!< in: record */ - ulint n, /*!< in: field index */ - ulint info) /*!< in: value to set */ +void rec_1_set_field_end_info(rec_t *rec, /*!< in: record */ + ulint n, /*!< in: field index */ + ulint info) /*!< in: value to set */ { ut_ad(rec_get_1byte_offs_flag(rec)); ut_ad(n < rec_get_n_fields_old(rec)); @@ -863,15 +756,12 @@ void rec_1_set_field_end_info( mach_write_to_1(rec - (REC_N_OLD_EXTRA_BYTES + n + 1), info); } -/******************************************************/ /** - Sets the field end info for the nth field if the record is stored in the +/** Sets the field end info for the nth field if the record is stored in the 2-byte format. */ UNIV_INLINE -void rec_2_set_field_end_info( - /*=====================*/ - rec_t *rec, /*!< in: record */ - ulint n, /*!< in: field index */ - ulint info) /*!< in: value to set */ +void rec_2_set_field_end_info(rec_t *rec, /*!< in: record */ + ulint n, /*!< in: field index */ + ulint info) /*!< in: value to set */ { ut_ad(!rec_get_1byte_offs_flag(rec)); ut_ad(n < rec_get_n_fields_old(rec)); @@ -879,15 +769,12 @@ void rec_2_set_field_end_info( mach_write_to_2(rec - (REC_N_OLD_EXTRA_BYTES + 2 * n + 2), info); } -/******************************************************/ /** - Returns the offset of nth field start if the record is stored in the 1-byte +/** Returns the offset of nth field start if the record is stored in the 1-byte offsets form. @return offset of the start of the field */ UNIV_INLINE -ulint rec_1_get_field_start_offs( - /*=======================*/ - const rec_t *rec, /*!< in: record */ - ulint n) /*!< in: field index */ +ulint rec_1_get_field_start_offs(const rec_t *rec, /*!< in: record */ + ulint n) /*!< in: field index */ { ut_ad(rec_get_1byte_offs_flag(rec)); ut_ad(n <= rec_get_n_fields_old(rec)); @@ -899,15 +786,12 @@ ulint rec_1_get_field_start_offs( return (rec_1_get_prev_field_end_info(rec, n) & ~REC_1BYTE_SQL_NULL_MASK); } -/******************************************************/ /** - Returns the offset of nth field start if the record is stored in the 2-byte +/** Returns the offset of nth field start if the record is stored in the 2-byte offsets form. @return offset of the start of the field */ UNIV_INLINE -ulint rec_2_get_field_start_offs( - /*=======================*/ - const rec_t *rec, /*!< in: record */ - ulint n) /*!< in: field index */ +ulint rec_2_get_field_start_offs(const rec_t *rec, /*!< in: record */ + ulint n) /*!< in: field index */ { ut_ad(!rec_get_1byte_offs_flag(rec)); ut_ad(n <= rec_get_n_fields_old(rec)); @@ -920,17 +804,14 @@ ulint rec_2_get_field_start_offs( ~(REC_2BYTE_SQL_NULL_MASK | REC_2BYTE_EXTERN_MASK)); } -/******************************************************/ /** - The following function is used to read the offset of the start of a data field - in the record. The start of an SQL null field is the end offset of the +/** The following function is used to read the offset of the start of a data + field in the record. The start of an SQL null field is the end offset of the previous non-null field, or 0, if none exists. If n is the number of the last field + 1, then the end offset of the last field is returned. @return offset of the start of the field */ UNIV_INLINE -ulint rec_get_field_start_offs( - /*=====================*/ - const rec_t *rec, /*!< in: record */ - ulint n) /*!< in: field index */ +ulint rec_get_field_start_offs(const rec_t *rec, /*!< in: record */ + ulint n) /*!< in: field index */ { ut_ad(rec); ut_ad(n <= rec_get_n_fields_old(rec)); @@ -946,16 +827,13 @@ ulint rec_get_field_start_offs( return (rec_2_get_field_start_offs(rec, n)); } -/************************************************************/ /** - Gets the physical size of an old-style field. +/** Gets the physical size of an old-style field. Also an SQL null may have a field of size > 0, if the data type is of a fixed size. @return field size in bytes */ UNIV_INLINE -ulint rec_get_nth_field_size( - /*===================*/ - const rec_t *rec, /*!< in: record */ - ulint n) /*!< in: index of the field */ +ulint rec_get_nth_field_size(const rec_t *rec, /*!< in: record */ + ulint n) /*!< in: index of the field */ { ulint os; ulint next_os; @@ -968,15 +846,13 @@ ulint rec_get_nth_field_size( return (next_os - os); } -/***********************************************************/ /** - This is used to modify the value of an already existing field in a record. +/** This is used to modify the value of an already existing field in a record. The previous value must have exactly the same size as the new value. If len is UNIV_SQL_NULL then the field is treated as an SQL null. For records in ROW_FORMAT=COMPACT (new-style records), len must not be UNIV_SQL_NULL unless the field already is SQL null. */ UNIV_INLINE void rec_set_nth_field( - /*==============*/ rec_t *rec, /*!< in: record */ const ulint *offsets, /*!< in: array returned by rec_get_offsets() */ ulint n, /*!< in: index number of the field */ @@ -1011,31 +887,26 @@ void rec_set_nth_field( ut_memcpy(data2, data, len); } -/**********************************************************/ /** - The following function returns the data size of an old-style physical +/** The following function returns the data size of an old-style physical record, that is the sum of field lengths. SQL null fields are counted as length 0 fields. The value returned by the function is the distance from record origin to record end in bytes. @return size */ UNIV_INLINE -ulint rec_get_data_size_old( - /*==================*/ - const rec_t *rec) /*!< in: physical record */ +ulint rec_get_data_size_old(const rec_t *rec) /*!< in: physical record */ { ut_ad(rec); return (rec_get_field_start_offs(rec, rec_get_n_fields_old(rec))); } -/**********************************************************/ /** - The following function returns the data size of a physical +/** The following function returns the data size of a physical record, that is the sum of field lengths. SQL null fields are counted as length 0 fields. The value returned by the function is the distance from record origin to record end in bytes. @return size */ UNIV_INLINE ulint rec_offs_data_size( - /*===============*/ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ { ulint size; @@ -1046,14 +917,12 @@ ulint rec_offs_data_size( return (size); } -/**********************************************************/ /** - Returns the total size of record minus data size of record. The value +/** Returns the total size of record minus data size of record. The value returned by the function is the distance from record start to record origin in bytes. @return size */ UNIV_INLINE ulint rec_offs_extra_size( - /*================*/ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ { ulint size; @@ -1063,24 +932,20 @@ ulint rec_offs_extra_size( return (size); } -/**********************************************************/ /** - Returns the total size of a physical record. +/** Returns the total size of a physical record. @return size */ UNIV_INLINE ulint rec_offs_size( - /*==========*/ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ { return (rec_offs_data_size(offsets) + rec_offs_extra_size(offsets)); } #ifdef UNIV_DEBUG -/**********************************************************/ /** - Returns a pointer to the end of the record. +/** Returns a pointer to the end of the record. @return pointer to end */ UNIV_INLINE byte *rec_get_end( - /*========*/ const rec_t *rec, /*!< in: pointer to record */ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ { @@ -1088,12 +953,10 @@ byte *rec_get_end( return (const_cast(rec + rec_offs_data_size(offsets))); } -/**********************************************************/ /** - Returns a pointer to the start of the record. +/** Returns a pointer to the start of the record. @return pointer to start */ UNIV_INLINE byte *rec_get_start( - /*==========*/ const rec_t *rec, /*!< in: pointer to record */ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ { @@ -1125,13 +988,11 @@ rec_t *rec_copy(void *buf, const rec_t *rec, const ulint *offsets) { return ((byte *)buf + extra_len); } -/**********************************************************/ /** - Returns the extra size of an old-style physical record if we know its +/** Returns the extra size of an old-style physical record if we know its data size and number of fields. @return extra size */ UNIV_INLINE ulint rec_get_converted_extra_size( - /*=========================*/ ulint data_size, /*!< in: data size */ ulint n_fields, /*!< in: number of fields */ ulint n_ext) /*!< in: number of externally stored columns */ @@ -1143,13 +1004,11 @@ ulint rec_get_converted_extra_size( return (REC_N_OLD_EXTRA_BYTES + 2 * n_fields); } -/**********************************************************/ /** - The following function returns the size of a data tuple when converted to +/** The following function returns the size of a data tuple when converted to a physical record. @return size */ UNIV_INLINE ulint rec_get_converted_size( - /*===================*/ dict_index_t *index, /*!< in: record descriptor */ const dtuple_t *dtuple, /*!< in: data tuple */ ulint n_ext) /*!< in: number of externally stored columns */ diff --git a/storage/innobase/include/rem0types.h b/storage/innobase/include/rem0types.h index 4598007840bf..ebef23485c3d 100644 --- a/storage/innobase/include/rem0types.h +++ b/storage/innobase/include/rem0types.h @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file include/rem0types.h +/** @file include/rem0types.h Record manager global types Created 5/30/1994 Heikki Tuuri diff --git a/storage/innobase/include/row0ext.h b/storage/innobase/include/row0ext.h index 2c10d22cfccb..20400c98d5d2 100644 --- a/storage/innobase/include/row0ext.h +++ b/storage/innobase/include/row0ext.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0ext.h +/** @file include/row0ext.h Caching of externally stored column prefixes Created September 2006 Marko Makela diff --git a/storage/innobase/include/row0ext.ic b/storage/innobase/include/row0ext.ic index 1bc2388d647a..b75c34e4dca1 100644 --- a/storage/innobase/include/row0ext.ic +++ b/storage/innobase/include/row0ext.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0ext.ic +/** @file include/row0ext.ic Caching of externally stored column prefixes Created September 2006 Marko Makela @@ -34,13 +33,11 @@ this program; if not, write to the Free Software Foundation, Inc., #include "btr0types.h" #include "rem0types.h" -/********************************************************************/ /** - Looks up a column prefix of an externally stored column. +/** Looks up a column prefix of an externally stored column. @return column prefix, or NULL if the column is not stored externally, or pointer to field_ref_zero if the BLOB pointer is unset */ UNIV_INLINE const byte *row_ext_lookup_ith( - /*===============*/ const row_ext_t *ext, /*!< in/out: column prefix cache */ ulint i, /*!< in: index of ext->ext[] */ ulint *len) /*!< out: length of prefix, in bytes, @@ -63,20 +60,17 @@ const byte *row_ext_lookup_ith( } } -/********************************************************************/ /** - Looks up a column prefix of an externally stored column. +/** Looks up a column prefix of an externally stored column. @return column prefix, or NULL if the column is not stored externally, or pointer to field_ref_zero if the BLOB pointer is unset */ UNIV_INLINE -const byte *row_ext_lookup( - /*===========*/ - const row_ext_t *ext, /*!< in: column prefix cache */ - ulint col, /*!< in: column number in the InnoDB - table object, as reported by - dict_col_get_no(); NOT relative to the - records in the clustered index */ - ulint *len) /*!< out: length of prefix, in bytes, - at most ext->max_len */ +const byte *row_ext_lookup(const row_ext_t *ext, /*!< in: column prefix cache */ + ulint col, /*!< in: column number in the InnoDB + table object, as reported by + dict_col_get_no(); NOT relative to the + records in the clustered index */ + ulint *len) /*!< out: length of prefix, in bytes, + at most ext->max_len */ { ulint i; diff --git a/storage/innobase/include/row0ftsort.h b/storage/innobase/include/row0ftsort.h index da7b5a2b8d0d..b64c2b406744 100644 --- a/storage/innobase/include/row0ftsort.h +++ b/storage/innobase/include/row0ftsort.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2010, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2010, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0ftsort.h +/** @file include/row0ftsort.h Create Full Text Index with (parallel) merge sort Created 10/13/2010 Jimmy Yang @@ -166,8 +165,7 @@ typedef struct fts_psort_insert fts_psort_insert_t; #define DEBUG_FTS_SORT_PRINT(str) #endif /* FTSORT_PRINT */ -/*************************************************************/ /** - Create a temporary "fts sort index" used to merge sort the +/** Create a temporary "fts sort index" used to merge sort the tokenized doc string. The index has three "fields": 1) Tokenized word, @@ -176,7 +174,6 @@ typedef struct fts_psort_insert fts_psort_insert_t; @return dict_index_t structure for the fts sort index */ dict_index_t *row_merge_create_fts_sort_index( - /*============================*/ dict_index_t *index, /*!< in: Original FTS index based on which this sort index is created */ @@ -187,11 +184,9 @@ dict_index_t *row_merge_create_fts_sort_index( instead of 8 bytes integer to store Doc ID during sort */ -/********************************************************************/ /** - Initialize FTS parallel sort structures. +/** Initialize FTS parallel sort structures. @return true if all successful */ ibool row_fts_psort_info_init( - /*====================*/ trx_t *trx, /*!< in: transaction */ row_merge_dup_t *dup, /*!< in,own: descriptor of FTS index being created */ @@ -208,40 +203,29 @@ ibool row_fts_psort_info_init( instantiated */ fts_psort_t **merge); /*!< out: parallel merge info to be instantiated */ -/********************************************************************/ /** - Clean up and deallocate FTS parallel sort structures, and close +/** Clean up and deallocate FTS parallel sort structures, and close temparary merge sort files */ void row_fts_psort_info_destroy( - /*=======================*/ fts_psort_t *psort_info, /*!< parallel sort info */ fts_psort_t *merge_info); /*!< parallel merge info */ -/********************************************************************/ /** - Free up merge buffers when merge sort is done */ +/** Free up merge buffers when merge sort is done */ void row_fts_free_pll_merge_buf( - /*=======================*/ fts_psort_t *psort_info); /*!< in: parallel sort info */ -/*********************************************************************/ /** - Start the parallel tokenization and parallel merge sort */ +/** Start the parallel tokenization and parallel merge sort */ void row_fts_start_psort( - /*================*/ fts_psort_t *psort_info); /*!< in: parallel sort info */ -/*********************************************************************/ /** - Kick off the parallel merge and insert thread */ +/** Kick off the parallel merge and insert thread */ void row_fts_start_parallel_merge( - /*=========================*/ fts_psort_t *merge_info); /*!< in: parallel sort info */ -/********************************************************************/ /** - Propagate a newly added record up one level in the selection tree +/** Propagate a newly added record up one level in the selection tree @return parent where this value propagated to */ -int row_merge_fts_sel_propagate( - /*========================*/ - int propogated, /*online_log); } -/******************************************************/ /** - Try to log an operation to a secondary index that is +/** Try to log an operation to a secondary index that is (or was) being created. @retval true if the operation was logged or can be ignored @retval false if online index creation is not taking place */ UNIV_INLINE bool row_log_online_op_try( - /*==================*/ dict_index_t *index, /*!< in/out: index, S or X latched */ const dtuple_t *tuple, /*!< in: index tuple */ trx_id_t trx_id) /*!< in: transaction ID for insert, diff --git a/storage/innobase/include/row0merge.h b/storage/innobase/include/row0merge.h index af6ee472b642..71a396b8d362 100644 --- a/storage/innobase/include/row0merge.h +++ b/storage/innobase/include/row0merge.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0merge.h +/** @file include/row0merge.h Index build routines using a merge sort Created 13/06/2005 Jan Lindstrom @@ -135,27 +134,20 @@ struct row_merge_dup_t { ulint n_dup; /*!< number of duplicates */ }; -/*************************************************************/ /** - Report a duplicate key. */ +/** Report a duplicate key. */ void row_merge_dup_report( - /*=================*/ row_merge_dup_t *dup, /*!< in/out: for reporting duplicates */ const dfield_t *entry); /*!< in: duplicate index entry */ -/*********************************************************************/ /** - Sets an exclusive lock on a table, for the duration of creating indexes. +/** Sets an exclusive lock on a table, for the duration of creating indexes. @return error code or DB_SUCCESS */ -dberr_t row_merge_lock_table( - /*=================*/ - trx_t *trx, /*!< in/out: transaction */ - dict_table_t *table, /*!< in: table to lock */ - enum lock_mode mode) /*!< in: LOCK_X or LOCK_S */ +dberr_t row_merge_lock_table(trx_t *trx, /*!< in/out: transaction */ + dict_table_t *table, /*!< in: table to lock */ + enum lock_mode mode) /*!< in: LOCK_X or LOCK_S */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Drop those indexes which were created before an error occurred. +/** Drop those indexes which were created before an error occurred. The data dictionary must have been locked exclusively by the caller, because the transaction will not be committed. */ void row_merge_drop_indexes( - /*===================*/ trx_t *trx, /*!< in/out: transaction */ dict_table_t *table, /*!< in/out: table containing the indexes */ ibool locked); /*!< in: TRUE=table locked, @@ -168,29 +160,21 @@ UNIV_PFS_IO defined, register the file descriptor with Performance Schema. int row_merge_file_create_low(const char *path) MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Destroy a merge file. And de-register the file from Performance Schema +/** Destroy a merge file. And de-register the file from Performance Schema if UNIV_PFS_IO is defined. */ -void row_merge_file_destroy_low( - /*=======================*/ - int fd); /*!< in: merge file descriptor */ +void row_merge_file_destroy_low(int fd); /*!< in: merge file descriptor */ -/*********************************************************************/ /** - Provide a new pathname for a table that is being renamed if it belongs to +/** Provide a new pathname for a table that is being renamed if it belongs to a file-per-table tablespace. The caller is responsible for freeing the memory allocated for the return value. @return new pathname of tablespace file, or NULL if space = 0 */ -char *row_make_new_pathname( - /*==================*/ - dict_table_t *table, /*!< in: table to be renamed */ - const char *new_name); /*!< in: new name */ -/*********************************************************************/ /** - Rename the tables in the data dictionary. The data dictionary must +char *row_make_new_pathname(dict_table_t *table, /*!< in: table to be renamed */ + const char *new_name); /*!< in: new name */ +/** Rename the tables in the data dictionary. The data dictionary must have been locked exclusively by the caller, because the transaction will not be committed. @return error code or DB_SUCCESS */ dberr_t row_merge_rename_tables_dict( - /*=========================*/ dict_table_t *old_table, /*!< in/out: old table, renamed to tmp_name */ dict_table_t *new_table, /*!< in/out: new table, renamed to @@ -210,14 +194,12 @@ dict_index_t *row_merge_create_index(trx_t *trx, dict_table_t *table, const index_def_t *index_def, const dict_add_v_col_t *add_v); -/*********************************************************************/ /** - Drop a table. The caller must have ensured that the background stats +/** Drop a table. The caller must have ensured that the background stats thread is not processing the table. This can be done by calling dict_stats_wait_bg_to_stop_using_table() after locking the dictionary and before calling this function. @return DB_SUCCESS or error code */ dberr_t row_merge_drop_table( - /*=================*/ trx_t *trx, /*!< in: transaction */ dict_table_t *table); /*!< in: table instance to drop */ @@ -264,27 +246,20 @@ dberr_t row_merge_build_indexes( void row_merge_buf_write(const row_merge_buf_t *buf, const merge_file_t *of, row_merge_block_t *block); -/********************************************************************/ /** - Sort a buffer. */ +/** Sort a buffer. */ void row_merge_buf_sort( - /*===============*/ row_merge_buf_t *buf, /*!< in/out: sort buffer */ row_merge_dup_t *dup); /*!< in/out: reporter of duplicates (NULL if non-unique index) */ -/********************************************************************/ /** - Write a merge block to the file system. +/** Write a merge block to the file system. @return true if request was successful, false if fail */ -ibool row_merge_write( - /*============*/ - int fd, /*!< in: file descriptor */ - ulint offset, /*!< in: offset where to write, - in number of row_merge_block_t elements */ - const void *buf); /*!< in: data */ -/********************************************************************/ /** - Empty a sort buffer. +ibool row_merge_write(int fd, /*!< in: file descriptor */ + ulint offset, /*!< in: offset where to write, + in number of row_merge_block_t elements */ + const void *buf); /*!< in: data */ +/** Empty a sort buffer. @return sort buffer */ row_merge_buf_t *row_merge_buf_empty( - /*================*/ row_merge_buf_t *buf) /*!< in,own: sort buffer */ MY_ATTRIBUTE((warn_unused_result)); @@ -308,38 +283,27 @@ dberr_t row_merge_sort(trx_t *trx, const row_merge_dup_t *dup, merge_file_t *file, row_merge_block_t *block, int *tmpfd, ut_stage_alter_t *stage = NULL); -/*********************************************************************/ /** - Allocate a sort buffer. +/** Allocate a sort buffer. @return own: sort buffer */ row_merge_buf_t *row_merge_buf_create( - /*=================*/ dict_index_t *index) /*!< in: secondary index */ MY_ATTRIBUTE((warn_unused_result, malloc)); -/*********************************************************************/ /** - Deallocate a sort buffer. */ +/** Deallocate a sort buffer. */ void row_merge_buf_free( - /*===============*/ row_merge_buf_t *buf); /*!< in,own: sort buffer to be freed */ -/*********************************************************************/ /** - Destroy a merge file. */ +/** Destroy a merge file. */ void row_merge_file_destroy( - /*===================*/ merge_file_t *merge_file); /*!< in/out: merge file structure */ -/********************************************************************/ /** - Read a merge block from the file system. +/** Read a merge block from the file system. @return true if request was successful, false if fail */ -ibool row_merge_read( - /*===========*/ - int fd, /*!< in: file descriptor */ - ulint offset, /*!< in: offset where to read - in number of row_merge_block_t - elements */ - row_merge_block_t *buf); /*!< out: data */ -/********************************************************************/ /** - Read a merge record. +ibool row_merge_read(int fd, /*!< in: file descriptor */ + ulint offset, /*!< in: offset where to read + in number of row_merge_block_t + elements */ + row_merge_block_t *buf); /*!< out: data */ +/** Read a merge record. @return pointer to next record, or NULL on I/O error or end of list */ const byte *row_merge_read_rec( - /*===============*/ row_merge_block_t *block, /*!< in/out: file buffer */ mrec_buf_t *buf, /*!< in/out: secondary buffer */ const byte *b, /*!< in: pointer to record */ diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h index 777ec62058f7..aa2612387446 100644 --- a/storage/innobase/include/row0mysql.h +++ b/storage/innobase/include/row0mysql.h @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0mysql.h +/** @file include/row0mysql.h Interface between Innobase row operations and MySQL. Contains also create table and other data dictionary operations. @@ -54,37 +53,29 @@ extern ibool row_rollback_on_timeout; struct row_prebuilt_t; -/*******************************************************************/ /** - Frees the blob heap in prebuilt when no longer needed. */ +/** Frees the blob heap in prebuilt when no longer needed. */ void row_mysql_prebuilt_free_blob_heap( - /*==============================*/ row_prebuilt_t *prebuilt); /*!< in: prebuilt struct of a ha_innobase:: table handle */ -/*******************************************************************/ /** - Stores a >= 5.0.3 format true VARCHAR length to dest, in the MySQL row +/** Stores a >= 5.0.3 format true VARCHAR length to dest, in the MySQL row format. @return pointer to the data, we skip the 1 or 2 bytes at the start that are used to store the len */ byte *row_mysql_store_true_var_len( - /*=========================*/ byte *dest, /*!< in: where to store */ ulint len, /*!< in: length, must fit in two bytes */ ulint lenlen); /*!< in: storage length of len: either 1 or 2 bytes */ -/*******************************************************************/ /** - Reads a >= 5.0.3 format true VARCHAR length, in the MySQL row format, and +/** Reads a >= 5.0.3 format true VARCHAR length, in the MySQL row format, and returns a pointer to the data. @return pointer to the data, we skip the 1 or 2 bytes at the start that are used to store the len */ const byte *row_mysql_read_true_varchar( - /*========================*/ ulint *len, /*!< out: variable-length field length */ const byte *field, /*!< in: field in the MySQL format */ ulint lenlen); /*!< in: storage length of len: either 1 or 2 bytes */ -/*******************************************************************/ /** - Stores a reference to a BLOB in the MySQL format. */ +/** Stores a reference to a BLOB in the MySQL format. */ void row_mysql_store_blob_ref( - /*=====================*/ byte *dest, /*!< in: where to store */ ulint col_len, /*!< in: dest buffer size: determines into how many bytes the BLOB length is stored, @@ -96,20 +87,16 @@ void row_mysql_store_blob_ref( is SQL NULL this should be 0; remember also to set the NULL bit in the MySQL record header! */ -/*******************************************************************/ /** - Reads a reference to a BLOB in the MySQL format. +/** Reads a reference to a BLOB in the MySQL format. @return pointer to BLOB data */ const byte *row_mysql_read_blob_ref( - /*====================*/ ulint *len, /*!< out: BLOB length */ const byte *ref, /*!< in: BLOB reference in the MySQL format */ ulint col_len); /*!< in: BLOB reference length (not BLOB length) */ -/*******************************************************************/ /** - Converts InnoDB geometry data format to MySQL data format. */ +/** Converts InnoDB geometry data format to MySQL data format. */ void row_mysql_store_geometry( - /*=====================*/ byte *dest, /*!< in/out: where to store */ ulint dest_len, /*!< in: dest buffer size: determines into how many bytes the geometry length is stored, @@ -121,22 +108,17 @@ void row_mysql_store_geometry( is SQL NULL this should be 0; remember also to set the NULL bit in the MySQL record header! */ -/**************************************************************/ /** - Pad a column with spaces. */ -void row_mysql_pad_col( - /*==============*/ - ulint mbminlen, /*!< in: minimum size of a character, - in bytes */ - byte *pad, /*!< out: padded buffer */ - ulint len); /*!< in: number of bytes to pad */ - -/**************************************************************/ /** - Stores a non-SQL-NULL field given in the MySQL format in the InnoDB format. +/** Pad a column with spaces. */ +void row_mysql_pad_col(ulint mbminlen, /*!< in: minimum size of a character, + in bytes */ + byte *pad, /*!< out: padded buffer */ + ulint len); /*!< in: number of bytes to pad */ + +/** Stores a non-SQL-NULL field given in the MySQL format in the InnoDB format. The counterpart of this function is row_sel_field_store_in_mysql_format() in row0sel.cc. @return up to which byte we used buf in the conversion */ byte *row_mysql_store_col_in_innobase_format( - /*===================================*/ dfield_t *dfield, /*!< in/out: dfield where dtype information must be already set when this function is called! */ @@ -165,49 +147,39 @@ byte *row_mysql_store_col_in_innobase_format( payload data; if the column is a true VARCHAR then this is irrelevant */ ulint comp); /*!< in: nonzero=compact format */ -/****************************************************************/ /** - Handles user errors and lock waits detected by the database engine. +/** Handles user errors and lock waits detected by the database engine. @return true if it was a lock wait and we should continue running the query thread */ bool row_mysql_handle_errors( - /*====================*/ dberr_t *new_err, /*!< out: possible new error encountered in rollback, or the old error which was during the function entry */ trx_t *trx, /*!< in: transaction */ que_thr_t *thr, /*!< in: query thread, or NULL */ trx_savept_t *savept); /*!< in: savepoint, or NULL */ -/********************************************************************/ /** - Create a prebuilt struct for a MySQL table handle. +/** Create a prebuilt struct for a MySQL table handle. @return own: a prebuilt struct */ row_prebuilt_t *row_create_prebuilt( - /*================*/ dict_table_t *table, /*!< in: Innobase table handle */ ulint mysql_row_len); /*!< in: length in bytes of a row in the MySQL format */ -/********************************************************************/ /** - Free a prebuilt struct for a MySQL table handle. */ +/** Free a prebuilt struct for a MySQL table handle. */ void row_prebuilt_free( - /*==============*/ row_prebuilt_t *prebuilt, /*!< in, own: prebuilt struct */ ibool dict_locked); /*!< in: TRUE=data dictionary locked */ -/*********************************************************************/ /** - Updates the transaction pointers in query graphs stored in the prebuilt +/** Updates the transaction pointers in query graphs stored in the prebuilt struct. */ void row_update_prebuilt_trx( - /*====================*/ row_prebuilt_t *prebuilt, /*!< in/out: prebuilt struct in MySQL handle */ trx_t *trx); /*!< in: transaction handle */ -/*********************************************************************/ /** - Sets an AUTO_INC type lock on the table mentioned in prebuilt. The +/** Sets an AUTO_INC type lock on the table mentioned in prebuilt. The AUTO_INC lock gives exclusive access to the auto-inc counter of the table. The lock is reserved only for the duration of an SQL statement. It is not compatible with another AUTO_INC or exclusive lock on the table. @return error code or DB_SUCCESS */ dberr_t row_lock_table_autoinc_for_mysql( - /*=============================*/ row_prebuilt_t *prebuilt) /*!< in: prebuilt struct in the MySQL table handle */ MY_ATTRIBUTE((warn_unused_result)); @@ -223,27 +195,21 @@ dberr_t row_lock_table(row_prebuilt_t *prebuilt); dberr_t row_insert_for_mysql(const byte *mysql_rec, row_prebuilt_t *prebuilt) MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Builds a dummy query graph used in selects. */ +/** Builds a dummy query graph used in selects. */ void row_prebuild_sel_graph( - /*===================*/ row_prebuilt_t *prebuilt); /*!< in: prebuilt struct in MySQL handle */ -/*********************************************************************/ /** - Gets pointer to a prebuilt update vector used in updates. If the update +/** Gets pointer to a prebuilt update vector used in updates. If the update graph has not yet been built in the prebuilt struct, then this function first builds it. @return prebuilt update vector */ upd_t *row_get_prebuilt_update_vector( - /*===========================*/ row_prebuilt_t *prebuilt); /*!< in: prebuilt struct in MySQL handle */ -/*********************************************************************/ /** - Checks if a table is such that we automatically created a clustered +/** Checks if a table is such that we automatically created a clustered index on it (on row id). @return true if the clustered index was generated automatically */ ibool row_table_got_default_clust_index( - /*==============================*/ const dict_table_t *table); /*!< in: table */ /** Does an update or delete of a row for MySQL. @@ -273,65 +239,48 @@ the latest clustered index record lock we set. void row_unlock_for_mysql(row_prebuilt_t *prebuilt, ibool has_latches_on_recs); #endif /* !UNIV_HOTBACKUP */ -/*********************************************************************/ /** - Checks if a table name contains the string "/#sql" which denotes temporary +/** Checks if a table name contains the string "/#sql" which denotes temporary tables in MySQL. @return true if temporary table */ -bool row_is_mysql_tmp_table_name( - /*========================*/ - const char *name) MY_ATTRIBUTE((warn_unused_result)); +bool row_is_mysql_tmp_table_name(const char *name) + MY_ATTRIBUTE((warn_unused_result)); /*!< in: table name in the form 'database/tablename' */ #ifndef UNIV_HOTBACKUP -/*********************************************************************/ /** - Creates an query graph node of 'update' type to be used in the MySQL +/** Creates an query graph node of 'update' type to be used in the MySQL interface. @return own: update node */ upd_node_t *row_create_update_node_for_mysql( - /*=============================*/ dict_table_t *table, /*!< in: table to update */ mem_heap_t *heap); /*!< in: mem heap from which allocated */ -/**********************************************************************/ /** - Does a cascaded delete or set null in a foreign key operation. +/** Does a cascaded delete or set null in a foreign key operation. @return error code or DB_SUCCESS */ dberr_t row_update_cascade_for_mysql( - /*=========================*/ que_thr_t *thr, /*!< in: query thread */ upd_node_t *node, /*!< in: update node used in the cascade or set null operation */ dict_table_t *table) /*!< in: table where we do the operation */ MY_ATTRIBUTE((nonnull, warn_unused_result)); -/*********************************************************************/ /** - Locks the data dictionary exclusively for performing a table create or other +/** Locks the data dictionary exclusively for performing a table create or other data dictionary modification operation. */ -void row_mysql_lock_data_dictionary_func( - /*================================*/ - trx_t *trx, /*!< in/out: transaction */ - const char *file, /*!< in: file name */ - ulint line); /*!< in: line number */ +void row_mysql_lock_data_dictionary_func(trx_t *trx, /*!< in/out: transaction */ + const char *file, /*!< in: file name */ + ulint line); /*!< in: line number */ #define row_mysql_lock_data_dictionary(trx) \ row_mysql_lock_data_dictionary_func(trx, __FILE__, __LINE__) -/*********************************************************************/ /** - Unlocks the data dictionary exclusive lock. */ -void row_mysql_unlock_data_dictionary( - /*=============================*/ - trx_t *trx); /*!< in/out: transaction */ -/*********************************************************************/ /** - Locks the data dictionary in shared mode from modifications, for performing +/** Unlocks the data dictionary exclusive lock. */ +void row_mysql_unlock_data_dictionary(trx_t *trx); /*!< in/out: transaction */ +/** Locks the data dictionary in shared mode from modifications, for performing foreign key check, rollback, or other operation invisible to MySQL. */ void row_mysql_freeze_data_dictionary_func( - /*==================================*/ trx_t *trx, /*!< in/out: transaction */ const char *file, /*!< in: file name */ ulint line); /*!< in: line number */ #define row_mysql_freeze_data_dictionary(trx) \ row_mysql_freeze_data_dictionary_func(trx, __FILE__, __LINE__) -/*********************************************************************/ /** - Unlocks the data dictionary shared lock. */ -void row_mysql_unfreeze_data_dictionary( - /*===============================*/ - trx_t *trx); /*!< in/out: transaction */ +/** Unlocks the data dictionary shared lock. */ +void row_mysql_unfreeze_data_dictionary(trx_t *trx); /*!< in/out: transaction */ /** Creates a table for MySQL. On success the in-memory table could be kept in non-LRU list while on failure the 'table' object will be freed. @param[in] table table definition(will be freed, or on @@ -342,13 +291,11 @@ kept in non-LRU list while on failure the 'table' object will be freed. dberr_t row_create_table_for_mysql(dict_table_t *table, const char *compression, trx_t *trx) MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Does an index creation operation for MySQL. TODO: currently failure +/** Does an index creation operation for MySQL. TODO: currently failure to create an index results in dropping the whole table! This is no problem currently as all indexes must be created at the same time as the table. @return error number or DB_SUCCESS */ dberr_t row_create_index_for_mysql( - /*=======================*/ dict_index_t *index, /*!< in, own: index definition (will be freed) */ trx_t *trx, /*!< in: transaction handle */ @@ -360,8 +307,7 @@ dberr_t row_create_index_for_mysql( large. */ dict_table_t *handler) /* ! in/out: table handler. */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Scans a table create SQL string and adds to the data dictionary +/** Scans a table create SQL string and adds to the data dictionary the foreign key constraints declared in the string. This function should be called after the indexes for a table have been created. Each foreign key constraint must be accompanied with indexes in @@ -388,25 +334,19 @@ dberr_t row_table_add_foreign_constraints(trx_t *trx, const char *sql_string, const dd::Table *dd_table) MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - The master thread in srv0srv.cc calls this regularly to drop tables which +/** The master thread in srv0srv.cc calls this regularly to drop tables which we must drop in background after queries to them have ended. Such lazy dropping of tables is needed in ALTER TABLE on Unix. @return how many tables dropped + remaining tables in list */ ulint row_drop_tables_for_mysql_in_background(void); -/*=========================================*/ -/*********************************************************************/ /** - Get the background drop list length. NOTE: the caller must own the kernel +/** Get the background drop list length. NOTE: the caller must own the kernel mutex! @return how many tables in list */ ulint row_get_background_drop_list_len_low(void); -/*======================================*/ -/*********************************************************************/ /** - Sets an exclusive lock on a table. +/** Sets an exclusive lock on a table. @return error code or DB_SUCCESS */ dberr_t row_mysql_lock_table( - /*=================*/ trx_t *trx, /*!< in/out: transaction */ dict_table_t *table, /*!< in: table to lock */ enum lock_mode mode, /*!< in: LOCK_X or LOCK_S */ @@ -450,22 +390,18 @@ inline dberr_t row_drop_table_for_mysql(const char *name, trx_t *trx, name, trx, drop_db ? SQLCOM_DROP_DB : SQLCOM_DROP_TABLE, true, NULL)); } -/*********************************************************************/ /** - Discards the tablespace of a table which stored in an .ibd file. Discarding +/** Discards the tablespace of a table which stored in an .ibd file. Discarding means that this function deletes the .ibd file and assigns a new table id for the table. Also the flag table->ibd_file_missing is set TRUE. @return error code or DB_SUCCESS */ dberr_t row_discard_tablespace_for_mysql( - /*=============================*/ const char *name, /*!< in: table name */ trx_t *trx) /*!< in: transaction handle */ MY_ATTRIBUTE((warn_unused_result)); -/*****************************************************************/ /** - Imports a tablespace. The space id in the .ibd file must match the space id +/** Imports a tablespace. The space id in the .ibd file must match the space id of the table in the data dictionary. @return error code or DB_SUCCESS */ dberr_t row_import_tablespace_for_mysql( - /*============================*/ dict_table_t *table, /*!< in/out: table */ row_prebuilt_t *prebuilt) /*!< in: prebuilt struct in MySQL */ MY_ATTRIBUTE((warn_unused_result)); @@ -488,14 +424,12 @@ dberr_t row_rename_table_for_mysql(const char *old_name, const char *new_name, const dd::Table *dd_table, trx_t *trx, bool log) MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Scans an index for either COOUNT(*) or CHECK TABLE. +/** Scans an index for either COOUNT(*) or CHECK TABLE. If CHECK TABLE; Checks that the index contains entries in an ascending order, unique constraint is not broken, and calculates the number of index entries in the read view of the current transaction. @return DB_SUCCESS or other error */ dberr_t row_scan_index_for_mysql( - /*=====================*/ row_prebuilt_t *prebuilt, /*!< in: prebuilt struct in MySQL handle */ const dict_index_t *index, /*!< in: index */ @@ -505,15 +439,11 @@ dberr_t row_scan_index_for_mysql( ulint *n_rows) /*!< out: number of entries seen in the consistent read */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Initialize this module */ +/** Initialize this module */ void row_mysql_init(void); -/*================*/ -/*********************************************************************/ /** - Close this module */ +/** Close this module */ void row_mysql_close(void); -/*=================*/ /* A struct describing a place for an individual column in the MySQL row format which is presented to the table handler in ha_innobase. diff --git a/storage/innobase/include/row0mysql.ic b/storage/innobase/include/row0mysql.ic index 2b1dc2f193e1..64b746e7ce98 100644 --- a/storage/innobase/include/row0mysql.ic +++ b/storage/innobase/include/row0mysql.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2001, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2001, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0mysql.ic +/** @file include/row0mysql.ic MySQL interface for Innobase Created 1/23/2001 Heikki Tuuri diff --git a/storage/innobase/include/row0purge.h b/storage/innobase/include/row0purge.h index cfda3a934cb3..354d680ad140 100644 --- a/storage/innobase/include/row0purge.h +++ b/storage/innobase/include/row0purge.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -26,8 +26,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "my_compiler.h" -/**************************************************/ /** - @file include/row0purge.h +/** @file include/row0purge.h Purge obsolete records Created 3/14/1997 Heikki Tuuri @@ -53,8 +52,7 @@ this program; if not, write to the Free Software Foundation, Inc., purge_node_t *row_purge_node_create(que_thr_t *parent, mem_heap_t *heap) MY_ATTRIBUTE((warn_unused_result)); -/***********************************************************/ /** - Determines if it is possible to remove a secondary index entry. +/** Determines if it is possible to remove a secondary index entry. Removal is possible if the secondary index entry does not refer to any not delete marked version of a clustered index record where DB_TRX_ID is newer than the purge view. @@ -68,19 +66,15 @@ purge_node_t *row_purge_node_create(que_thr_t *parent, mem_heap_t *heap) secondary index entry after purge has removed it and released the leaf page latch. @return true if the secondary index record can be purged */ -bool row_purge_poss_sec( - /*===============*/ - purge_node_t *node, /*!< in/out: row purge node */ - dict_index_t *index, /*!< in: secondary index */ - const dtuple_t *entry) /*!< in: secondary index entry */ +bool row_purge_poss_sec(purge_node_t *node, /*!< in/out: row purge node */ + dict_index_t *index, /*!< in: secondary index */ + const dtuple_t *entry) /*!< in: secondary index entry */ MY_ATTRIBUTE((warn_unused_result)); /*************************************************************** Does the purge operation for a single undo log record. This is a high-level function used in an SQL execution graph. @return query thread to run next or NULL */ -que_thr_t *row_purge_step( - /*===========*/ - que_thr_t *thr) /*!< in: query thread */ +que_thr_t *row_purge_step(que_thr_t *thr) /*!< in: query thread */ MY_ATTRIBUTE((warn_unused_result)); /* Purge node structure */ @@ -170,13 +164,12 @@ struct purge_node_t { trx_rseg_t *rseg; #ifdef UNIV_DEBUG - /***********************************************************/ /** - Validate the persisent cursor. The purge node has two references - to the clustered index record - one via the ref member, and the - other via the persistent cursor. These two references must match - each other if the found_clust flag is set. - @return true if the persistent cursor is consistent with - the ref member.*/ + /** Validate the persisent cursor. The purge node has two references + to the clustered index record - one via the ref member, and the + other via the persistent cursor. These two references must match + each other if the found_clust flag is set. + @return true if the persistent cursor is consistent with + the ref member.*/ bool validate_pcur(); #endif }; diff --git a/storage/innobase/include/row0purge.ic b/storage/innobase/include/row0purge.ic index d45f8a136e17..b08bcc13ad9e 100644 --- a/storage/innobase/include/row0purge.ic +++ b/storage/innobase/include/row0purge.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0purge.ic +/** @file include/row0purge.ic Purge obsolete records Created 3/14/1997 Heikki Tuuri diff --git a/storage/innobase/include/row0quiesce.h b/storage/innobase/include/row0quiesce.h index 2407373f160d..e72b4e8cea6d 100644 --- a/storage/innobase/include/row0quiesce.h +++ b/storage/innobase/include/row0quiesce.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2012, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0quiesce.h +/** @file include/row0quiesce.h Header file for tablespace quiesce functions. @@ -45,27 +44,20 @@ struct trx_t; /** The v2 .cfg has space flags written */ #define IB_EXPORT_CFG_VERSION_V2 0x2UL -/*********************************************************************/ /** - Quiesce the tablespace that the table resides in. */ -void row_quiesce_table_start( - /*====================*/ - dict_table_t *table, /*!< in: quiesce this table */ - trx_t *trx); /*!< in/out: transaction/session */ +/** Quiesce the tablespace that the table resides in. */ +void row_quiesce_table_start(dict_table_t *table, /*!< in: quiesce this table */ + trx_t *trx); /*!< in/out: transaction/session */ -/*********************************************************************/ /** - Set a table's quiesce state. +/** Set a table's quiesce state. @return DB_SUCCESS or errro code. */ dberr_t row_quiesce_set_state( - /*==================*/ dict_table_t *table, /*!< in: quiesce this table */ ib_quiesce_t state, /*!< in: quiesce state to set */ trx_t *trx) /*!< in/out: transaction */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Cleanup after table quiesce. */ +/** Cleanup after table quiesce. */ void row_quiesce_table_complete( - /*=======================*/ dict_table_t *table, /*!< in: quiesce this table */ trx_t *trx); /*!< in/out: transaction/session */ diff --git a/storage/innobase/include/row0quiesce.ic b/storage/innobase/include/row0quiesce.ic index 1f58dcd18316..46fe76acfba9 100644 --- a/storage/innobase/include/row0quiesce.ic +++ b/storage/innobase/include/row0quiesce.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2012, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2012, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0quiesce.ic +/** @file include/row0quiesce.ic Quiesce a tablespace. diff --git a/storage/innobase/include/row0row.h b/storage/innobase/include/row0row.h index be6dde7853d4..0c1b0e340ea7 100644 --- a/storage/innobase/include/row0row.h +++ b/storage/innobase/include/row0row.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0row.h +/** @file include/row0row.h General row routines Created 4/20/1996 Heikki Tuuri @@ -44,32 +43,26 @@ this program; if not, write to the Free Software Foundation, Inc., #include "trx0types.h" #include "univ.i" -/*********************************************************************/ /** - Gets the offset of the DB_TRX_ID field, in bytes relative to the origin of +/** Gets the offset of the DB_TRX_ID field, in bytes relative to the origin of a clustered index record. @return offset of DATA_TRX_ID */ UNIV_INLINE ulint row_get_trx_id_offset( - /*==================*/ const dict_index_t *index, /*!< in: clustered index */ const ulint *offsets) /*!< in: record offsets */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Reads the trx id field from a clustered index record. +/** Reads the trx id field from a clustered index record. @return value of the field */ UNIV_INLINE trx_id_t row_get_rec_trx_id( - /*===============*/ const rec_t *rec, /*!< in: record */ const dict_index_t *index, /*!< in: clustered index */ const ulint *offsets) /*!< in: rec_get_offsets(rec, index) */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Reads the roll pointer field from a clustered index record. +/** Reads the roll pointer field from a clustered index record. @return value of the field */ UNIV_INLINE roll_ptr_t row_get_rec_roll_ptr( - /*=================*/ const rec_t *rec, /*!< in: record */ const dict_index_t *index, /*!< in: clustered index */ const ulint *offsets) /*!< in: rec_get_offsets(rec, index) */ @@ -80,14 +73,12 @@ roll_ptr_t row_get_rec_roll_ptr( #define ROW_BUILD_FOR_PURGE 1 /*!< build row for purge. */ #define ROW_BUILD_FOR_UNDO 2 /*!< build row for undo. */ #define ROW_BUILD_FOR_INSERT 3 /*!< build row for insert. */ -/*****************************************************************/ /** - When an insert or purge to a table is performed, this function builds +/** When an insert or purge to a table is performed, this function builds the entry to be inserted into or purged from an index on the table. @return index entry which should be inserted or purged @retval NULL if the externally stored columns in the clustered index record are unavailable and ext != NULL, or row is missing some needed columns. */ dtuple_t *row_build_index_entry_low( - /*======================*/ const dtuple_t *row, /*!< in: row which should be inserted or purged */ const row_ext_t *ext, /*!< in: externally stored column @@ -100,15 +91,13 @@ dtuple_t *row_build_index_entry_low( ROW_BUILD_FOR_PURGE or ROW_BUILD_FOR_UNDO */ MY_ATTRIBUTE((warn_unused_result)); -/*****************************************************************/ /** - When an insert or purge to a table is performed, this function builds +/** When an insert or purge to a table is performed, this function builds the entry to be inserted into or purged from an index on the table. @return index entry which should be inserted or purged, or NULL if the externally stored columns in the clustered index record are unavailable and ext != NULL */ UNIV_INLINE dtuple_t *row_build_index_entry( - /*==================*/ const dtuple_t *row, /*!< in: row which should be inserted or purged */ const row_ext_t *ext, /*!< in: externally stored column @@ -118,51 +107,48 @@ dtuple_t *row_build_index_entry( the memory for the index entry is allocated */ MY_ATTRIBUTE((warn_unused_result)); -/*******************************************************************/ /** - An inverse function to row_build_index_entry. Builds a row from a +/** An inverse function to row_build_index_entry. Builds a row from a record in a clustered index. @return own: row built; see the NOTE below! */ -dtuple_t *row_build( - /*======*/ - ulint type, /*!< in: ROW_COPY_POINTERS or - ROW_COPY_DATA; the latter - copies also the data fields to - heap while the first only - places pointers to data fields - on the index page, and thus is - more efficient */ - const dict_index_t *index, /*!< in: clustered index */ - const rec_t *rec, /*!< in: record in the clustered - index; NOTE: in the case - ROW_COPY_POINTERS the data - fields in the row will point - directly into this record, - therefore, the buffer page of - this record must be at least - s-latched and the latch held - as long as the row dtuple is used! */ - const ulint *offsets, /*!< in: rec_get_offsets(rec,index) - or NULL, in which case this function - will invoke rec_get_offsets() */ - const dict_table_t *col_table, - /*!< in: table, to check which - externally stored columns - occur in the ordering columns - of an index, or NULL if - index->table should be - consulted instead; the user - columns in this table should be - the same columns as in index->table */ - const dtuple_t *add_cols, - /*!< in: default values of - added columns, or NULL */ - const ulint *col_map, /*!< in: mapping of old column - numbers to new ones, or NULL */ - row_ext_t **ext, /*!< out, own: cache of - externally stored column - prefixes, or NULL */ - mem_heap_t *heap); /*!< in: memory heap from which - the memory needed is allocated */ +dtuple_t *row_build(ulint type, /*!< in: ROW_COPY_POINTERS or + ROW_COPY_DATA; the latter + copies also the data fields to + heap while the first only + places pointers to data fields + on the index page, and thus is + more efficient */ + const dict_index_t *index, /*!< in: clustered index */ + const rec_t *rec, /*!< in: record in the clustered + index; NOTE: in the case + ROW_COPY_POINTERS the data + fields in the row will point + directly into this record, + therefore, the buffer page of + this record must be at least + s-latched and the latch held + as long as the row dtuple is used! */ + const ulint *offsets, /*!< in: rec_get_offsets(rec,index) + or NULL, in which case this function + will invoke rec_get_offsets() */ + const dict_table_t *col_table, + /*!< in: table, to check which + externally stored columns + occur in the ordering columns + of an index, or NULL if + index->table should be + consulted instead; the user + columns in this table should be + the same columns as in index->table */ + const dtuple_t *add_cols, + /*!< in: default values of + added columns, or NULL */ + const ulint *col_map, /*!< in: mapping of old column + numbers to new ones, or NULL */ + row_ext_t **ext, /*!< out, own: cache of + externally stored column + prefixes, or NULL */ + mem_heap_t *heap); /*!< in: memory heap from which + the memory needed is allocated */ /** An inverse function to row_build_index_entry. Builds a row from a record in a clustered index, with possible indexing on ongoing @@ -195,12 +181,10 @@ dtuple_t *row_build_w_add_vcol(ulint type, const dict_index_t *index, const ulint *col_map, row_ext_t **ext, mem_heap_t *heap); -/*******************************************************************/ /** - Converts an index record to a typed data tuple. +/** Converts an index record to a typed data tuple. @return index entry built; does not set info_bits, and the data fields in the entry will point directly to rec */ dtuple_t *row_rec_to_index_entry_low( - /*=======================*/ const rec_t *rec, /*!< in: record in the index */ const dict_index_t *index, /*!< in: index */ const ulint *offsets, /*!< in: rec_get_offsets(rec, index) */ @@ -209,12 +193,10 @@ dtuple_t *row_rec_to_index_entry_low( mem_heap_t *heap) /*!< in: memory heap from which the memory needed is allocated */ MY_ATTRIBUTE((warn_unused_result)); -/*******************************************************************/ /** - Converts an index record to a typed data tuple. NOTE that externally +/** Converts an index record to a typed data tuple. NOTE that externally stored (often big) fields are NOT copied to heap. @return own: index entry built */ dtuple_t *row_rec_to_index_entry( - /*===================*/ const rec_t *rec, /*!< in: record in the index */ const dict_index_t *index, /*!< in: index */ const ulint *offsets, /*!< in/out: rec_get_offsets(rec) */ @@ -223,12 +205,10 @@ dtuple_t *row_rec_to_index_entry( mem_heap_t *heap) /*!< in: memory heap from which the memory needed is allocated */ MY_ATTRIBUTE((warn_unused_result)); -/*******************************************************************/ /** - Builds from a secondary index record a row reference with which we can +/** Builds from a secondary index record a row reference with which we can search the clustered index record. @return own: row reference built; see the NOTE below! */ dtuple_t *row_build_row_ref( - /*==============*/ ulint type, /*!< in: ROW_COPY_DATA, or ROW_COPY_POINTERS: the former copies also the data fields to heap, whereas the latter only places pointers @@ -244,11 +224,9 @@ dtuple_t *row_build_row_ref( mem_heap_t *heap) /*!< in: memory heap from which the memory needed is allocated */ MY_ATTRIBUTE((warn_unused_result)); -/*******************************************************************/ /** - Builds from a secondary index record a row reference with which we can +/** Builds from a secondary index record a row reference with which we can search the clustered index record. */ void row_build_row_ref_in_tuple( - /*=======================*/ dtuple_t *ref, /*!< in/out: row reference built; see the NOTE below! */ const rec_t *rec, /*!< in: record in the index; @@ -276,12 +254,10 @@ UNIV_INLINE void row_build_row_ref_fast(dtuple_t *ref, const ulint *map, const rec_t *rec, const ulint *offsets); -/***************************************************************/ /** - Searches the clustered index record for a row, if we have the row +/** Searches the clustered index record for a row, if we have the row reference. @return true if found */ ibool row_search_on_row_ref( - /*==================*/ btr_pcur_t *pcur, /*!< out: persistent cursor, which must be closed by the caller */ ulint mode, /*!< in: BTR_MODIFY_LEAF, ... */ @@ -289,12 +265,10 @@ ibool row_search_on_row_ref( const dtuple_t *ref, /*!< in: row reference */ mtr_t *mtr) /*!< in/out: mtr */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Fetches the clustered index record for a secondary index record. The latches +/** Fetches the clustered index record for a secondary index record. The latches on the secondary index record are preserved. @return record or NULL, if no record found */ rec_t *row_get_clust_rec( - /*==============*/ ulint mode, /*!< in: BTR_MODIFY_LEAF, ... */ const rec_t *rec, /*!< in: record in a secondary index */ dict_index_t *index, /*!< in: secondary index */ @@ -341,11 +315,9 @@ enum row_search_result { row_purge_poss_sec() failed */ }; -/***************************************************************/ /** - Searches an index record. +/** Searches an index record. @return whether the record was found or buffered */ enum row_search_result row_search_index_entry( - /*===================*/ dict_index_t *index, /*!< in: index */ const dtuple_t *entry, /*!< in: index entry */ ulint mode, /*!< in: BTR_MODIFY_LEAF, ... */ @@ -362,23 +334,20 @@ enum row_search_result row_search_index_entry( (2) the clustered index record -> (3) rollback segment data for the clustered index record. */ -/*******************************************************************/ /** - Formats the raw data in "data" (in InnoDB on-disk format) using +/** Formats the raw data in "data" (in InnoDB on-disk format) using "dict_field" and writes the result to "buf". Not more than "buf_size" bytes are written to "buf". The result is always NUL-terminated (provided buf_size is positive) and the number of bytes that were written to "buf" is returned (including the terminating NUL). @return number of bytes that were written */ -ulint row_raw_format( - /*===========*/ - const char *data, /*!< in: raw data */ - ulint data_len, /*!< in: raw data length - in bytes */ - const dict_field_t *dict_field, /*!< in: index field */ - char *buf, /*!< out: output buffer */ - ulint buf_size) /*!< in: output buffer size - in bytes */ +ulint row_raw_format(const char *data, /*!< in: raw data */ + ulint data_len, /*!< in: raw data length + in bytes */ + const dict_field_t *dict_field, /*!< in: index field */ + char *buf, /*!< out: output buffer */ + ulint buf_size) /*!< in: output buffer size + in bytes */ MY_ATTRIBUTE((warn_unused_result)); #include "row0row.ic" diff --git a/storage/innobase/include/row0row.ic b/storage/innobase/include/row0row.ic index d1dae9b84f40..ac83498740dc 100644 --- a/storage/innobase/include/row0row.ic +++ b/storage/innobase/include/row0row.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0row.ic +/** @file include/row0row.ic General row routines Created 4/20/1996 Heikki Tuuri @@ -35,13 +34,11 @@ this program; if not, write to the Free Software Foundation, Inc., #include "rem0rec.h" #include "trx0undo.h" -/*********************************************************************/ /** - Gets the offset of the DB_TRX_ID field, in bytes relative to the origin of +/** Gets the offset of the DB_TRX_ID field, in bytes relative to the origin of a clustered index record. @return offset of DATA_TRX_ID */ UNIV_INLINE ulint row_get_trx_id_offset( - /*==================*/ const dict_index_t *index, /*!< in: clustered index */ const ulint *offsets) /*!< in: record offsets */ { @@ -61,12 +58,10 @@ ulint row_get_trx_id_offset( return (offset); } -/*********************************************************************/ /** - Reads the trx id field from a clustered index record. +/** Reads the trx id field from a clustered index record. @return value of the field */ UNIV_INLINE trx_id_t row_get_rec_trx_id( - /*===============*/ const rec_t *rec, /*!< in: record */ const dict_index_t *index, /*!< in: clustered index */ const ulint *offsets) /*!< in: rec_get_offsets(rec, index) */ @@ -85,12 +80,10 @@ trx_id_t row_get_rec_trx_id( return (trx_read_trx_id(rec + offset)); } -/*********************************************************************/ /** - Reads the roll pointer field from a clustered index record. +/** Reads the roll pointer field from a clustered index record. @return value of the field */ UNIV_INLINE roll_ptr_t row_get_rec_roll_ptr( - /*=================*/ const rec_t *rec, /*!< in: record */ const dict_index_t *index, /*!< in: clustered index */ const ulint *offsets) /*!< in: rec_get_offsets(rec, index) */ @@ -109,15 +102,13 @@ roll_ptr_t row_get_rec_roll_ptr( return (trx_read_roll_ptr(rec + offset + DATA_TRX_ID_LEN)); } -/*****************************************************************/ /** - When an insert or purge to a table is performed, this function builds +/** When an insert or purge to a table is performed, this function builds the entry to be inserted into or purged from an index on the table. @return index entry which should be inserted or purged, or NULL if the externally stored columns in the clustered index record are unavailable and ext != NULL */ UNIV_INLINE dtuple_t *row_build_index_entry( - /*==================*/ const dtuple_t *row, /*!< in: row which should be inserted or purged */ const row_ext_t *ext, /*!< in: externally stored column @@ -135,12 +126,10 @@ dtuple_t *row_build_index_entry( return (entry); } -/*******************************************************************/ /** - Builds from a secondary index record a row reference with which we can +/** Builds from a secondary index record a row reference with which we can search the clustered index record. */ UNIV_INLINE void row_build_row_ref_fast( - /*===================*/ dtuple_t *ref, /*!< in/out: typed data tuple where the reference is built */ const ulint *map, /*!< in: array of field numbers in rec diff --git a/storage/innobase/include/row0sel.h b/storage/innobase/include/row0sel.h index 0ae168b0c854..7fd024ae8e2d 100644 --- a/storage/innobase/include/row0sel.h +++ b/storage/innobase/include/row0sel.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -26,8 +26,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "my_compiler.h" -/**************************************************/ /** - @file include/row0sel.h +/** @file include/row0sel.h Select Created 12/19/1997 Heikki Tuuri @@ -48,23 +47,16 @@ this program; if not, write to the Free Software Foundation, Inc., #include "trx0types.h" #include "univ.i" -/*********************************************************************/ /** - Creates a select node struct. +/** Creates a select node struct. @return own: select node struct */ sel_node_t *sel_node_create( - /*============*/ mem_heap_t *heap); /*!< in: memory heap where created */ -/*********************************************************************/ /** - Frees the memory private to a select node when a query graph is freed, +/** Frees the memory private to a select node when a query graph is freed, does not free the heap where the node was originally created. */ -void sel_node_free_private( - /*==================*/ - sel_node_t *node); /*!< in: select node struct */ -/*********************************************************************/ /** - Frees a prefetch buffer for a column, including the dynamically allocated +void sel_node_free_private(sel_node_t *node); /*!< in: select node struct */ +/** Frees a prefetch buffer for a column, including the dynamically allocated memory for data stored there. */ void sel_col_prefetch_buf_free( - /*======================*/ sel_buf_t *prefetch_buf); /*!< in, own: prefetch buffer */ /** Gets the plan node for the nth table in a join. @@ -74,26 +66,17 @@ void sel_col_prefetch_buf_free( UNIV_INLINE plan_t *sel_node_get_nth_plan(sel_node_t *node, ulint i); -/**********************************************************************/ /** - Performs a select step. This is a high-level function used in SQL execution +/** Performs a select step. This is a high-level function used in SQL execution graphs. @return query thread to run next or NULL */ -que_thr_t *row_sel_step( - /*=========*/ - que_thr_t *thr); /*!< in: query thread */ -/**********************************************************************/ /** - Performs an execution step of an open or close cursor statement node. +que_thr_t *row_sel_step(que_thr_t *thr); /*!< in: query thread */ +/** Performs an execution step of an open or close cursor statement node. @return query thread to run next or NULL */ UNIV_INLINE -que_thr_t *open_step( - /*======*/ - que_thr_t *thr); /*!< in: query thread */ -/**********************************************************************/ /** - Performs a fetch for a cursor. +que_thr_t *open_step(que_thr_t *thr); /*!< in: query thread */ +/** Performs a fetch for a cursor. @return query thread to run next or NULL */ -que_thr_t *fetch_step( - /*=======*/ - que_thr_t *thr); /*!< in: query thread */ +que_thr_t *fetch_step(que_thr_t *thr); /*!< in: query thread */ /** Copy used fields from cached row. Copy cache record field by field, don't touch fields that @@ -104,14 +87,12 @@ are not covered by current key. void row_sel_copy_cached_fields_for_mysql(byte *buf, const byte *cached_rec, row_prebuilt_t *prebuilt); -/****************************************************************/ /** - Converts a key value stored in MySQL format to an Innobase dtuple. The last +/** Converts a key value stored in MySQL format to an Innobase dtuple. The last field of the key value may be just a prefix of a fixed length field: hence the parameter key_len. But currently we do not allow search keys where the last field is only a prefix of the full key field len and print a warning if such appears. */ void row_sel_convert_mysql_key_to_innobase( - /*==================================*/ dtuple_t *tuple, /*!< in/out: tuple where to build; NOTE: we assume that the type info in the tuple is already according @@ -200,11 +181,9 @@ dberr_t row_search_mvcc(byte *buf, page_cur_mode_t mode, row_prebuilt_t *prebuilt, ulint match_mode, ulint direction) MY_ATTRIBUTE((warn_unused_result)); -/********************************************************************/ /** - Count rows in a R-Tree leaf level. +/** Count rows in a R-Tree leaf level. @return DB_SUCCESS if successful */ dberr_t row_count_rtree_recs( - /*=================*/ row_prebuilt_t *prebuilt, /*!< in: prebuilt struct for the table handle; this contains the info of search_tuple, index; if search @@ -215,11 +194,9 @@ dberr_t row_count_rtree_recs( ulint *n_rows); /*!< out: number of entries seen in the consistent read */ -/*******************************************************************/ /** - Read the max AUTOINC value from an index. +/** Read the max AUTOINC value from an index. @return DB_SUCCESS if all OK else error code */ dberr_t row_search_max_autoinc( - /*===================*/ dict_index_t *index, /*!< in: index to search */ const char *col_name, /*!< in: autoinc column name */ ib_uint64_t *value) /*!< out: AUTOINC value read */ diff --git a/storage/innobase/include/row0sel.ic b/storage/innobase/include/row0sel.ic index 8fd734020b80..f69fec871621 100644 --- a/storage/innobase/include/row0sel.ic +++ b/storage/innobase/include/row0sel.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0sel.ic +/** @file include/row0sel.ic Select Created 12/19/1997 Heikki Tuuri @@ -33,39 +32,31 @@ this program; if not, write to the Free Software Foundation, Inc., #include "que0que.h" -/*********************************************************************/ /** - Gets the plan node for the nth table in a join. +/** Gets the plan node for the nth table in a join. @return plan node */ UNIV_INLINE -plan_t *sel_node_get_nth_plan( - /*==================*/ - sel_node_t *node, /*!< in: select node */ - ulint i) /*!< in: get ith plan node */ +plan_t *sel_node_get_nth_plan(sel_node_t *node, /*!< in: select node */ + ulint i) /*!< in: get ith plan node */ { ut_ad(i < node->n_tables); return (node->plans + i); } -/*********************************************************************/ /** - Resets the cursor defined by sel_node to the SEL_NODE_OPEN state, which means - that it will start fetching from the start of the result set again, regardless - of where it was before, and it will set intention locks on the tables. */ +/** Resets the cursor defined by sel_node to the SEL_NODE_OPEN state, which + means that it will start fetching from the start of the result set again, + regardless of where it was before, and it will set intention locks on the + tables. */ UNIV_INLINE -void sel_node_reset_cursor( - /*==================*/ - sel_node_t *node) /*!< in: select node */ +void sel_node_reset_cursor(sel_node_t *node) /*!< in: select node */ { node->state = SEL_NODE_OPEN; } -/**********************************************************************/ /** - Performs an execution step of an open or close cursor statement node. +/** Performs an execution step of an open or close cursor statement node. @return query thread to run next or NULL */ UNIV_INLINE -que_thr_t *open_step( - /*======*/ - que_thr_t *thr) /*!< in: query thread */ +que_thr_t *open_step(que_thr_t *thr) /*!< in: query thread */ { sel_node_t *sel_node; open_node_t *node; diff --git a/storage/innobase/include/row0types.h b/storage/innobase/include/row0types.h index 7b4a8e87ebff..78d88ff85828 100644 --- a/storage/innobase/include/row0types.h +++ b/storage/innobase/include/row0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0types.h +/** @file include/row0types.h Row operation global types Created 12/27/1996 Heikki Tuuri diff --git a/storage/innobase/include/row0uins.h b/storage/innobase/include/row0uins.h index dc9b412ab967..445bb5393a1f 100644 --- a/storage/innobase/include/row0uins.h +++ b/storage/innobase/include/row0uins.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -26,8 +26,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "my_compiler.h" -/**************************************************/ /** - @file include/row0uins.h +/** @file include/row0uins.h Fresh insert undo Created 2/25/1997 Heikki Tuuri @@ -44,17 +43,14 @@ this program; if not, write to the Free Software Foundation, Inc., #include "trx0types.h" #include "univ.i" -/***********************************************************/ /** - Undoes a fresh insert of a row to a table. A fresh insert means that +/** Undoes a fresh insert of a row to a table. A fresh insert means that the same clustered index unique key did not have any record, even delete marked, at the time of the insert. InnoDB is eager in a rollback: if it figures out that an index record will be removed in the purge anyway, it will remove it in the rollback. @return DB_SUCCESS */ -dberr_t row_undo_ins( - /*=========*/ - undo_node_t *node, /*!< in: row undo node */ - que_thr_t *thr) /*!< in: query thread */ +dberr_t row_undo_ins(undo_node_t *node, /*!< in: row undo node */ + que_thr_t *thr) /*!< in: query thread */ MY_ATTRIBUTE((warn_unused_result)); #include "row0uins.ic" diff --git a/storage/innobase/include/row0uins.ic b/storage/innobase/include/row0uins.ic index 4f4b33ef3db7..3cd6640f5b9f 100644 --- a/storage/innobase/include/row0uins.ic +++ b/storage/innobase/include/row0uins.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0uins.ic +/** @file include/row0uins.ic Fresh insert undo Created 2/25/1997 Heikki Tuuri diff --git a/storage/innobase/include/row0umod.h b/storage/innobase/include/row0umod.h index 9938c8c8e6cf..6a707a0ad1e9 100644 --- a/storage/innobase/include/row0umod.h +++ b/storage/innobase/include/row0umod.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0umod.h +/** @file include/row0umod.h Undo modify of a row Created 2/27/1997 Heikki Tuuri @@ -42,13 +41,10 @@ this program; if not, write to the Free Software Foundation, Inc., #include "trx0types.h" #include "univ.i" -/***********************************************************/ /** - Undoes a modify operation on a row of a table. +/** Undoes a modify operation on a row of a table. @return DB_SUCCESS or error code */ -dberr_t row_undo_mod( - /*=========*/ - undo_node_t *node, /*!< in: row undo node */ - que_thr_t *thr) /*!< in: query thread */ +dberr_t row_undo_mod(undo_node_t *node, /*!< in: row undo node */ + que_thr_t *thr) /*!< in: query thread */ MY_ATTRIBUTE((warn_unused_result)); #include "row0umod.ic" diff --git a/storage/innobase/include/row0umod.ic b/storage/innobase/include/row0umod.ic index f7e85efaa81c..80084928896d 100644 --- a/storage/innobase/include/row0umod.ic +++ b/storage/innobase/include/row0umod.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0umod.ic +/** @file include/row0umod.ic Undo modify of a row Created 2/27/1997 Heikki Tuuri diff --git a/storage/innobase/include/row0undo.h b/storage/innobase/include/row0undo.h index 3fe56326f1ad..a36f46ba7f25 100644 --- a/storage/innobase/include/row0undo.h +++ b/storage/innobase/include/row0undo.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0undo.h +/** @file include/row0undo.h Row undo Created 1/8/1997 Heikki Tuuri @@ -44,32 +43,25 @@ this program; if not, write to the Free Software Foundation, Inc., #include "trx0types.h" #include "univ.i" -/********************************************************************/ /** - Creates a row undo node to a query graph. +/** Creates a row undo node to a query graph. @return own: undo node */ undo_node_t *row_undo_node_create( - /*=================*/ trx_t *trx, /*!< in: transaction */ que_thr_t *parent, /*!< in: parent node, i.e., a thr node */ mem_heap_t *heap); /*!< in: memory heap where created */ -/***********************************************************/ /** - Looks for the clustered index record when node has the row reference. +/** Looks for the clustered index record when node has the row reference. The pcur in node is used in the search. If found, stores the row to node, and stores the position of pcur, and detaches it. The pcur must be closed by the caller in any case. @return true if found; NOTE the node->pcur must be closed by the caller, regardless of the return value */ bool row_undo_search_clust_to_pcur( - /*==========================*/ undo_node_t *node) /*!< in/out: row undo node */ MY_ATTRIBUTE((warn_unused_result)); -/***********************************************************/ /** - Undoes a row operation in a table. This is a high-level function used +/** Undoes a row operation in a table. This is a high-level function used in SQL execution graphs. @return query thread to run next or NULL */ -que_thr_t *row_undo_step( - /*==========*/ - que_thr_t *thr); /*!< in: query thread */ +que_thr_t *row_undo_step(que_thr_t *thr); /*!< in: query thread */ /* A single query thread will try to perform the undo for all successive versions of a clustered index record, if the transaction has modified it diff --git a/storage/innobase/include/row0undo.ic b/storage/innobase/include/row0undo.ic index 6d3b793b9d1f..c17ab5fcd735 100644 --- a/storage/innobase/include/row0undo.ic +++ b/storage/innobase/include/row0undo.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0undo.ic +/** @file include/row0undo.ic Row undo Created 1/8/1997 Heikki Tuuri diff --git a/storage/innobase/include/row0upd.h b/storage/innobase/include/row0upd.h index 3c96fb444f00..d32540eab38f 100644 --- a/storage/innobase/include/row0upd.h +++ b/storage/innobase/include/row0upd.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0upd.h +/** @file include/row0upd.h Update of a row Created 12/27/1996 Heikki Tuuri @@ -57,14 +56,11 @@ this program; if not, write to the Free Software Foundation, Inc., UNIV_INLINE upd_t *upd_create(ulint n, mem_heap_t *heap); -/*********************************************************************/ /** - Returns the number of fields in the update vector == number of columns +/** Returns the number of fields in the update vector == number of columns to be updated by an update vector. @return number of fields */ UNIV_INLINE -ulint upd_get_n_fields( - /*=============*/ - const upd_t *update); /*!< in: update vector */ +ulint upd_get_n_fields(const upd_t *update); /*!< in: update vector */ #ifdef UNIV_DEBUG /** Returns the nth field of an update vector. @@ -92,22 +88,18 @@ void upd_field_set_field_no(upd_field_t *upd_field, ulint field_no, UNIV_INLINE void upd_field_set_v_field_no(upd_field_t *upd_field, ulint field_no, dict_index_t *index); -/*********************************************************************/ /** - Returns a field of an update vector by field_no. +/** Returns a field of an update vector by field_no. @return update vector field, or NULL */ UNIV_INLINE const upd_field_t *upd_get_field_by_field_no( - /*======================*/ const upd_t *update, /*!< in: update vector */ ulint no, /*!< in: field_no */ bool is_virtual) /*!< in: if it is a virtual column */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************/ /** - Writes into the redo log the values of trx id and roll ptr and enough info +/** Writes into the redo log the values of trx id and roll ptr and enough info to determine their positions within a clustered index record. @return new pointer to mlog */ byte *row_upd_write_sys_vals_to_log( - /*==========================*/ dict_index_t *index, /*!< in: clustered index */ trx_id_t trx_id, /*!< in: transaction id */ roll_ptr_t roll_ptr, /*!< in: roll ptr of the undo log record */ @@ -130,10 +122,8 @@ void row_upd_rec_sys_fields(rec_t *rec, page_zip_des_t *page_zip, const dict_index_t *index, const ulint *offsets, const trx_t *trx, roll_ptr_t roll_ptr); -/*********************************************************************/ /** - Sets the trx id or roll ptr field of a clustered index entry. */ +/** Sets the trx id or roll ptr field of a clustered index entry. */ void row_upd_index_entry_sys_field( - /*==========================*/ dtuple_t *entry, /*!< in/out: index entry, where the memory buffers for sys fields are already allocated: the function just copies the new values to @@ -141,60 +131,49 @@ void row_upd_index_entry_sys_field( dict_index_t *index, /*!< in: clustered index */ ulint type, /*!< in: DATA_TRX_ID or DATA_ROLL_PTR */ ib_uint64_t val); /*!< in: value to write */ -/*********************************************************************/ /** - Creates an update node for a query graph. +/** Creates an update node for a query graph. @return own: update node */ upd_node_t *upd_node_create( - /*============*/ mem_heap_t *heap); /*!< in: mem heap where created */ -/***********************************************************/ /** - Writes to the redo log the new values of the fields occurring in the index. */ +/** Writes to the redo log the new values of the fields occurring in the index. + */ void row_upd_index_write_log( - /*====================*/ const upd_t *update, /*!< in: update vector */ byte *log_ptr, /*!< in: pointer to mlog buffer: must contain at least MLOG_BUF_MARGIN bytes of free space; the buffer is closed within this function */ mtr_t *mtr); /*!< in: mtr into whose log to write */ -/***********************************************************/ /** - Returns TRUE if row update changes size of some field in index or if some +/** Returns TRUE if row update changes size of some field in index or if some field to be updated is stored externally in rec or update. @return true if the update changes the size of some field in index or the field is external in rec or update */ ibool row_upd_changes_field_size_or_external( - /*===================================*/ dict_index_t *index, /*!< in: index */ const ulint *offsets, /*!< in: rec_get_offsets(rec, index) */ const upd_t *update); /*!< in: update vector */ -/***********************************************************/ /** - Returns true if row update contains disowned external fields. +/** Returns true if row update contains disowned external fields. @return true if the update contains disowned external fields. */ bool row_upd_changes_disowned_external( - /*==============================*/ const upd_t *update) /*!< in: update vector */ MY_ATTRIBUTE((warn_unused_result)); -/***********************************************************/ /** - Replaces the new column values stored in the update vector to the +/** Replaces the new column values stored in the update vector to the record given. No field size changes are allowed. This function is usually invoked on a clustered index. The only use case for a secondary index is row_ins_sec_index_entry_by_modify() or its counterpart in ibuf_insert_to_index_page(). */ void row_upd_rec_in_place( - /*=================*/ rec_t *rec, /*!< in/out: record where replaced */ dict_index_t *index, /*!< in: the index the record belongs to */ const ulint *offsets, /*!< in: array returned by rec_get_offsets() */ const upd_t *update, /*!< in: update vector */ page_zip_des_t *page_zip); /*!< in: compressed page with enough space available, or NULL */ -/***************************************************************/ /** - Builds an update vector from those fields which in a secondary index entry +/** Builds an update vector from those fields which in a secondary index entry differ from a record that has the equal ordering fields. NOTE: we compare the fields as binary strings! @return own: update vector of differing fields */ upd_t *row_upd_build_sec_rec_difference_binary( - /*====================================*/ const rec_t *rec, /*!< in: secondary index record */ dict_index_t *index, /*!< in: index */ const ulint *offsets, /*!< in: rec_get_offsets(rec, index) */ @@ -223,11 +202,9 @@ upd_t *row_upd_build_difference_binary(dict_index_t *index, trx_t *trx, mem_heap_t *heap, TABLE *mysql_table) MY_ATTRIBUTE((warn_unused_result)); -/***********************************************************/ /** - Replaces the new column values stored in the update vector to the index entry - given. */ +/** Replaces the new column values stored in the update vector to the index + entry given. */ void row_upd_index_replace_new_col_vals_index_pos( - /*=========================================*/ dtuple_t *entry, /*!< in/out: index entry where replaced; the clustered index record must be covered by a lock or a page latch to @@ -243,11 +220,9 @@ void row_upd_index_replace_new_col_vals_index_pos( does not work for non-clustered indexes. */ mem_heap_t *heap); /*!< in: memory heap for allocating and copying the new values */ -/***********************************************************/ /** - Replaces the new column values stored in the update vector to the index entry - given. */ +/** Replaces the new column values stored in the update vector to the index + entry given. */ void row_upd_index_replace_new_col_vals( - /*===============================*/ dtuple_t *entry, /*!< in/out: index entry where replaced; the clustered index record must be covered by a lock or a page latch to @@ -259,10 +234,8 @@ void row_upd_index_replace_new_col_vals( an upd_field is the clustered index position */ mem_heap_t *heap); /*!< in: memory heap for allocating and copying the new values */ -/***********************************************************/ /** - Replaces the new column values stored in the update vector. */ +/** Replaces the new column values stored in the update vector. */ void row_upd_replace( - /*============*/ trx_t *trx, /*!< in: current transaction. */ dtuple_t *row, /*!< in/out: row where replaced, indexed by col_no; @@ -287,15 +260,13 @@ void row_upd_replace_vcol(dtuple_t *row, const dict_table_t *table, const upd_t *update, bool upd_new, dtuple_t *undo_row, const byte *ptr); -/***********************************************************/ /** - Checks if an update vector changes an ordering field of an index record. +/** Checks if an update vector changes an ordering field of an index record. This function is fast if the update vector is short or the number of ordering fields in the index is small. Otherwise, this can be quadratic. NOTE: we compare the fields as binary strings! @return true if update vector changes an ordering field in the index record */ ibool row_upd_changes_ord_field_binary_func( - /*==================================*/ dict_index_t *index, /*!< in: index of the record */ const upd_t *update, /*!< in: update vector for the row; NOTE: the field numbers in this MUST be clustered index @@ -318,32 +289,25 @@ ibool row_upd_changes_ord_field_binary_func( #else /* UNIV_DEBUG */ #define row_upd_changes_ord_field_binary(index, update, thr, row, ext) \ row_upd_changes_ord_field_binary_func(index, update, row, ext, 0) -#endif /* UNIV_DEBUG */ -/***********************************************************/ /** - Checks if an FTS indexed column is affected by an UPDATE. +#endif /* UNIV_DEBUG */ +/** Checks if an FTS indexed column is affected by an UPDATE. @return offset within fts_t::indexes if FTS indexed column updated else ULINT_UNDEFINED */ ulint row_upd_changes_fts_column( - /*=======================*/ dict_table_t *table, /*!< in: table */ upd_field_t *upd_field); /*!< in: field to check */ -/***********************************************************/ /** - Checks if an FTS Doc ID column is affected by an UPDATE. +/** Checks if an FTS Doc ID column is affected by an UPDATE. @return whether Doc ID column is affected */ -bool row_upd_changes_doc_id( - /*===================*/ - dict_table_t *table, /*!< in: table */ - upd_field_t *upd_field) /*!< in: field to check */ +bool row_upd_changes_doc_id(dict_table_t *table, /*!< in: table */ + upd_field_t *upd_field) /*!< in: field to check */ MY_ATTRIBUTE((warn_unused_result)); -/***********************************************************/ /** - Checks if an update vector changes an ordering field of an index record. +/** Checks if an update vector changes an ordering field of an index record. This function is fast if the update vector is short or the number of ordering fields in the index is small. Otherwise, this can be quadratic. NOTE: we compare the fields as binary strings! @return true if update vector may change an ordering field in an index record */ ibool row_upd_changes_some_index_ord_field_binary( - /*========================================*/ const dict_table_t *table, /*!< in: table */ const upd_t *update); /*!< in: update vector for the row */ /** Stores to the heap the row on which the node->pcur is positioned. @@ -353,39 +317,29 @@ ibool row_upd_changes_some_index_ord_field_binary( user thread invokes dml */ void row_upd_store_row(trx_t *trx, upd_node_t *node, THD *thd, TABLE *mysql_table); -/***********************************************************/ /** - Updates a row in a table. This is a high-level function used +/** Updates a row in a table. This is a high-level function used in SQL execution graphs. @return query thread to run next or NULL */ -que_thr_t *row_upd_step( - /*=========*/ - que_thr_t *thr); /*!< in: query thread */ -/*********************************************************************/ /** - Parses the log data of system field values. +que_thr_t *row_upd_step(que_thr_t *thr); /*!< in: query thread */ +/** Parses the log data of system field values. @return log data end or NULL */ -byte *row_upd_parse_sys_vals( - /*===================*/ - const byte *ptr, /*!< in: buffer */ - const byte *end_ptr, /*!< in: buffer end */ - ulint *pos, /*!< out: TRX_ID position in record */ - trx_id_t *trx_id, /*!< out: trx id */ - roll_ptr_t *roll_ptr); /*!< out: roll ptr */ -/*********************************************************************/ /** - Updates the trx id and roll ptr field in a clustered index record in database - recovery. */ +byte *row_upd_parse_sys_vals(const byte *ptr, /*!< in: buffer */ + const byte *end_ptr, /*!< in: buffer end */ + ulint *pos, /*!< out: TRX_ID position in record */ + trx_id_t *trx_id, /*!< out: trx id */ + roll_ptr_t *roll_ptr); /*!< out: roll ptr */ +/** Updates the trx id and roll ptr field in a clustered index record in + database recovery. */ void row_upd_rec_sys_fields_in_recovery( - /*===============================*/ rec_t *rec, /*!< in/out: record */ page_zip_des_t *page_zip, /*!< in/out: compressed page, or NULL */ const ulint *offsets, /*!< in: array returned by rec_get_offsets() */ ulint pos, /*!< in: TRX_ID position in rec */ trx_id_t trx_id, /*!< in: transaction id */ roll_ptr_t roll_ptr); /*!< in: roll ptr of the undo log record */ -/*********************************************************************/ /** - Parses the log data written by row_upd_index_write_log. +/** Parses the log data written by row_upd_index_write_log. @return log data end or NULL */ byte *row_upd_index_parse( - /*================*/ const byte *ptr, /*!< in: buffer */ const byte *end_ptr, /*!< in: buffer end */ mem_heap_t *heap, /*!< in: memory heap where update vector is diff --git a/storage/innobase/include/row0upd.ic b/storage/innobase/include/row0upd.ic index e6df61a278d0..9cfdc79b4932 100644 --- a/storage/innobase/include/row0upd.ic +++ b/storage/innobase/include/row0upd.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0upd.ic +/** @file include/row0upd.ic Update of a row Created 12/27/1996 Heikki Tuuri @@ -40,14 +39,11 @@ this program; if not, write to the Free Software Foundation, Inc., #endif /* !UNIV_HOTBACKUP */ #include "page0zip.h" -/*********************************************************************/ /** - Creates an update vector object. +/** Creates an update vector object. @return own: update vector object */ UNIV_INLINE -upd_t *upd_create( - /*=======*/ - ulint n, /*!< in: number of fields */ - mem_heap_t *heap) /*!< in: heap from which memory allocated */ +upd_t *upd_create(ulint n, /*!< in: number of fields */ + mem_heap_t *heap) /*!< in: heap from which memory allocated */ { upd_t *update; @@ -61,14 +57,11 @@ upd_t *upd_create( return (update); } -/*********************************************************************/ /** - Returns the number of fields in the update vector == number of columns +/** Returns the number of fields in the update vector == number of columns to be updated by an update vector. @return number of fields */ UNIV_INLINE -ulint upd_get_n_fields( - /*=============*/ - const upd_t *update) /*!< in: update vector */ +ulint upd_get_n_fields(const upd_t *update) /*!< in: update vector */ { ut_ad(update); @@ -76,12 +69,10 @@ ulint upd_get_n_fields( } #ifdef UNIV_DEBUG -/*********************************************************************/ /** - Returns the nth field of an update vector. +/** Returns the nth field of an update vector. @return update vector field */ UNIV_INLINE upd_field_t *upd_get_nth_field( - /*==============*/ const upd_t *update, /*!< in: update vector */ ulint n) /*!< in: field position in update vector */ { @@ -92,11 +83,9 @@ upd_field_t *upd_get_nth_field( } #endif /* UNIV_DEBUG */ -/*********************************************************************/ /** - Sets an index field number to be updated by an update vector field. */ +/** Sets an index field number to be updated by an update vector field. */ UNIV_INLINE void upd_field_set_field_no( - /*===================*/ upd_field_t *upd_field, /*!< in: update vector field */ ulint field_no, /*!< in: field number in a clustered index */ @@ -138,12 +127,10 @@ void upd_field_set_v_field_no(upd_field_t *upd_field, ulint field_no, ->m_col.copy_type(dfield_get_type(&upd_field->new_val)); } -/*********************************************************************/ /** - Returns a field of an update vector by field_no. +/** Returns a field of an update vector by field_no. @return update vector field, or NULL */ UNIV_INLINE const upd_field_t *upd_get_field_by_field_no( - /*======================*/ const upd_t *update, /*!< in: update vector */ ulint no, /*!< in: field_no */ bool is_virtual) /*!< in: if it is virtual column */ @@ -166,12 +153,10 @@ const upd_field_t *upd_get_field_by_field_no( } #ifndef UNIV_HOTBACKUP -/*********************************************************************/ /** - Updates the trx id and roll ptr field in a clustered index record when +/** Updates the trx id and roll ptr field in a clustered index record when a row is updated or marked deleted. */ UNIV_INLINE void row_upd_rec_sys_fields( - /*===================*/ rec_t *rec, /*!< in/out: record */ page_zip_des_t *page_zip, /*!< in/out: compressed page whose uncompressed part will be updated, or NULL */ diff --git a/storage/innobase/include/row0vers.h b/storage/innobase/include/row0vers.h index 3cfa53d2ec93..9e157683312e 100644 --- a/storage/innobase/include/row0vers.h +++ b/storage/innobase/include/row0vers.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0vers.h +/** @file include/row0vers.h Row versions Created 2/6/1997 Heikki Tuuri @@ -46,20 +45,17 @@ this program; if not, write to the Free Software Foundation, Inc., // Forward declaration class ReadView; -/*****************************************************************/ /** - Finds out if an active transaction has inserted or modified a secondary +/** Finds out if an active transaction has inserted or modified a secondary index record. @return 0 if committed, else the active transaction id; NOTE that this function can return false positives but never false negatives. The caller must confirm all positive results by calling trx_is_active() while holding lock_sys->mutex. */ trx_t *row_vers_impl_x_locked( - /*===================*/ const rec_t *rec, /*!< in: record in a secondary index */ dict_index_t *index, /*!< in: the secondary index */ const ulint *offsets); /*!< in: rec_get_offsets(rec, index) */ -/*****************************************************************/ /** - Finds out if we must preserve a delete marked earlier version of a clustered +/** Finds out if we must preserve a delete marked earlier version of a clustered index record, because it is >= the purge view. @param[in] trx_id transaction id in the version @param[in] name table name @@ -67,19 +63,16 @@ trx_t *row_vers_impl_x_locked( clustered index record; it will also hold the latch on purge_view @return true if earlier version should be preserved */ -ibool row_vers_must_preserve_del_marked( - /*==============================*/ - trx_id_t trx_id, const table_name_t &name, mtr_t *mtr); +ibool row_vers_must_preserve_del_marked(trx_id_t trx_id, + const table_name_t &name, mtr_t *mtr); -/*****************************************************************/ /** - Finds out if a version of the record, where the version >= the current +/** Finds out if a version of the record, where the version >= the current purge view, should have ientry as its secondary index entry. We check if there is any not delete marked version of the record where the trx id >= purge view, and the secondary index entry == ientry; exactly in this case we return TRUE. @return true if earlier version should have */ ibool row_vers_old_has_index_entry( - /*=========================*/ ibool also_curr, /*!< in: TRUE if also rec is included in the versions to search; otherwise only versions prior to it are searched */ @@ -92,13 +85,11 @@ ibool row_vers_old_has_index_entry( roll_ptr_t roll_ptr, /*!< in: roll_ptr for the purge record */ trx_id_t trx_id); /*!< in: transaction ID on the purging record */ -/*****************************************************************/ /** - Constructs the version of a clustered index record which a consistent +/** Constructs the version of a clustered index record which a consistent read should see. We assume that the trx id stored in rec is such that the consistent read should not see rec in its present version. @return DB_SUCCESS or DB_MISSING_HISTORY */ dberr_t row_vers_build_for_consistent_read( - /*===============================*/ const rec_t *rec, /*!< in: record in a clustered index; the caller must have a latch on the page; this latch locks the top of the stack of versions @@ -121,11 +112,9 @@ dberr_t row_vers_build_for_consistent_read( it was freshly inserted afterwards */ const dtuple_t **vrow); /*!< out: reports virtual column info if any */ -/*****************************************************************/ /** - Constructs the last committed version of a clustered index record, +/** Constructs the last committed version of a clustered index record, which should be seen by a semi-consistent read. */ void row_vers_build_for_semi_consistent_read( - /*====================================*/ const rec_t *rec, /*!< in: record in a clustered index; the caller must have a latch on the page; this latch locks the top of the stack of versions diff --git a/storage/innobase/include/row0vers.ic b/storage/innobase/include/row0vers.ic index a76ea316a320..542012003607 100644 --- a/storage/innobase/include/row0vers.ic +++ b/storage/innobase/include/row0vers.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/row0vers.ic +/** @file include/row0vers.ic Row versions Created 2/6/1997 Heikki Tuuri diff --git a/storage/innobase/include/sess0sess.h b/storage/innobase/include/sess0sess.h index ec4de652f1d6..437c19dc4c6c 100644 --- a/storage/innobase/include/sess0sess.h +++ b/storage/innobase/include/sess0sess.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2013, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/sess0sess.h +/** @file include/sess0sess.h InnoDB session state tracker. Multi file, shared, system tablespace implementation. diff --git a/storage/innobase/include/srv0conc.h b/storage/innobase/include/srv0conc.h index 159672efe259..7bbecb11b3cf 100644 --- a/storage/innobase/include/srv0conc.h +++ b/storage/innobase/include/srv0conc.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -37,8 +37,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/srv0conc.h +/** @file include/srv0conc.h InnoDB concurrency manager header file @@ -61,36 +60,27 @@ we could get a deadlock. Value of 0 will disable the concurrency check. */ extern ulong srv_thread_concurrency; struct row_prebuilt_t; -/*********************************************************************/ /** - Puts an OS thread to wait if there are too many concurrent threads +/** Puts an OS thread to wait if there are too many concurrent threads (>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. @param[in,out] prebuilt row prebuilt handler */ void srv_conc_enter_innodb(row_prebuilt_t *prebuilt); -/*********************************************************************/ /** - This lets a thread enter InnoDB regardless of the number of threads inside +/** This lets a thread enter InnoDB regardless of the number of threads inside InnoDB. This must be called when a thread ends a lock wait. */ void srv_conc_force_enter_innodb( - /*========================*/ trx_t *trx); /*!< in: transaction object associated with the thread */ -/*********************************************************************/ /** - This must be called when a thread exits InnoDB in a lock wait or at the +/** This must be called when a thread exits InnoDB in a lock wait or at the end of an SQL statement. */ void srv_conc_force_exit_innodb( - /*=======================*/ trx_t *trx); /*!< in: transaction object associated with the thread */ -/*********************************************************************/ /** - Get the count of threads waiting inside InnoDB. */ +/** Get the count of threads waiting inside InnoDB. */ ulint srv_conc_get_waiting_threads(void); -/*==============================*/ -/*********************************************************************/ /** - Get the count of threads active inside InnoDB. */ +/** Get the count of threads active inside InnoDB. */ ulint srv_conc_get_active_threads(void); -/*==============================*/ #endif /* srv_conc_h */ diff --git a/storage/innobase/include/srv0mon.h b/storage/innobase/include/srv0mon.h index 6012574c6ff6..636fd5e6be01 100644 --- a/storage/innobase/include/srv0mon.h +++ b/storage/innobase/include/srv0mon.h @@ -1,6 +1,6 @@ /*********************************************************************** -Copyright (c) 2010, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2010, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify @@ -25,8 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ***********************************************************************/ -/**************************************************/ /** - @file include/srv0mon.h +/** @file include/srv0mon.h Server monitor counter related defines Created 12/15/2009 Jimmy Yang @@ -769,81 +768,61 @@ compensated by mon_last_value if accumulated value is required. */ MONITOR_FIELD(monitor, mon_start_value) + \ MONITOR_FIELD(monitor, mon_last_value))) -/****************************************************************/ /** - Get monitor's monitor_info_t by its monitor id (index into the +/** Get monitor's monitor_info_t by its monitor id (index into the innodb_counter_info array @return Point to corresponding monitor_info_t, or NULL if no such monitor */ monitor_info_t *srv_mon_get_info( - /*=============*/ monitor_id_t monitor_id); /*!< id index into the innodb_counter_info array */ -/****************************************************************/ /** - Get monitor's name by its monitor id (index into the +/** Get monitor's name by its monitor id (index into the innodb_counter_info array @return corresponding monitor name, or NULL if no such monitor */ const char *srv_mon_get_name( - /*=============*/ monitor_id_t monitor_id); /*!< id index into the innodb_counter_info array */ -/****************************************************************/ /** - Turn on/off/reset monitor counters in a module. If module_value +/** Turn on/off/reset monitor counters in a module. If module_value is NUM_MONITOR then turn on all monitor counters. */ void srv_mon_set_module_control( - /*=======================*/ monitor_id_t module_id, /*!< in: Module ID as in monitor_counter_id. If it is set to NUM_MONITOR, this means we shall turn on all the counters */ mon_option_t set_option); /*!< in: Turn on/off reset the counter */ -/****************************************************************/ /** - This function consolidates some existing server counters used +/** This function consolidates some existing server counters used by "system status variables". These existing system variables do not have mechanism to start/stop and reset the counters, so we simulate these controls by remembering the corresponding counter values when the corresponding monitors are turned on/off/reset, and do appropriate mathematics to deduct the actual value. */ void srv_mon_process_existing_counter( - /*=============================*/ monitor_id_t monitor_id, /*!< in: the monitor's ID as in monitor_counter_id */ mon_option_t set_option); /*!< in: Turn on/off reset the counter */ -/*************************************************************/ /** - This function is used to calculate the maximum counter value +/** This function is used to calculate the maximum counter value since the start of monitor counter @return max counter value since start. */ UNIV_INLINE mon_type_t srv_mon_calc_max_since_start( - /*=========================*/ monitor_id_t monitor); /*!< in: monitor id */ -/*************************************************************/ /** - This function is used to calculate the minimum counter value +/** This function is used to calculate the minimum counter value since the start of monitor counter @return min counter value since start. */ UNIV_INLINE mon_type_t srv_mon_calc_min_since_start( - /*=========================*/ monitor_id_t monitor); /*!< in: monitor id*/ -/*************************************************************/ /** - Reset a monitor, create a new base line with the current monitor +/** Reset a monitor, create a new base line with the current monitor value. This baseline is recorded by MONITOR_VALUE_RESET(monitor) */ -void srv_mon_reset( - /*==========*/ - monitor_id_t monitor); /*!< in: monitor id*/ -/*************************************************************/ /** - This function resets all values of a monitor counter */ +void srv_mon_reset(monitor_id_t monitor); /*!< in: monitor id*/ +/** This function resets all values of a monitor counter */ UNIV_INLINE -void srv_mon_reset_all( - /*==============*/ - monitor_id_t monitor); /*!< in: monitor id*/ -/*************************************************************/ /** - Turn on monitor counters that are marked as default ON. */ +void srv_mon_reset_all(monitor_id_t monitor); /*!< in: monitor id*/ +/** Turn on monitor counters that are marked as default ON. */ void srv_mon_default_on(void); -/*====================*/ #include "srv0mon.ic" #else /* !UNIV_HOTBACKUP */ diff --git a/storage/innobase/include/srv0mon.ic b/storage/innobase/include/srv0mon.ic index fc4506409a0a..324889253d48 100644 --- a/storage/innobase/include/srv0mon.ic +++ b/storage/innobase/include/srv0mon.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2010, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2010, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,20 +24,17 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/*******************************************************************/ /** - @file include/srv0mon.ic +/** @file include/srv0mon.ic Server monitoring system Created 1/20/2010 Jimmy Yang ************************************************************************/ -/*************************************************************/ /** - This function is used to calculate the maximum counter value +/** This function is used to calculate the maximum counter value since the start of monitor counter @return max counter value since start. */ UNIV_INLINE mon_type_t srv_mon_calc_max_since_start( - /*=========================*/ monitor_id_t monitor) /*!< in: monitor id */ { if (MONITOR_MAX_VALUE_START(monitor) == MAX_RESERVED) { @@ -60,13 +57,11 @@ mon_type_t srv_mon_calc_max_since_start( return (MONITOR_MAX_VALUE_START(monitor)); } -/*************************************************************/ /** - This function is used to calculate the minimum counter value +/** This function is used to calculate the minimum counter value since the start of monitor counter @return min counter value since start. */ UNIV_INLINE mon_type_t srv_mon_calc_min_since_start( - /*=========================*/ monitor_id_t monitor) /*!< in: monitor id */ { if (MONITOR_MIN_VALUE_START(monitor) == MIN_RESERVED) { @@ -89,12 +84,9 @@ mon_type_t srv_mon_calc_min_since_start( return (MONITOR_MIN_VALUE_START(monitor)); } -/*************************************************************/ /** - This function resets all values of a monitor counter */ +/** This function resets all values of a monitor counter */ UNIV_INLINE -void srv_mon_reset_all( - /*==============*/ - monitor_id_t monitor) /*!< in: monitor id */ +void srv_mon_reset_all(monitor_id_t monitor) /*!< in: monitor id */ { /* Do not reset all counter values if monitor is still on. */ if (MONITOR_IS_ON(monitor)) { diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index 81370f1b9755..aa242bd560af 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2008, 2009, Google Inc. Copyright (c) 2009, Percona Inc. @@ -39,8 +39,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/srv0srv.h +/** @file include/srv0srv.h The server main program Created 10/10/1995 Heikki Tuuri @@ -646,58 +645,42 @@ enum srv_thread_type { number must be biggest) */ }; -/*********************************************************************/ /** - Boots Innobase server. */ +/** Boots Innobase server. */ void srv_boot(void); -/*==========*/ -/*********************************************************************/ /** - Frees the data structures created in srv_init(). */ +/** Frees the data structures created in srv_init(). */ void srv_free(void); -/*==========*/ -/*********************************************************************/ /** - Sets the info describing an i/o thread current state. */ +/** Sets the info describing an i/o thread current state. */ void srv_set_io_thread_op_info( - /*======================*/ ulint i, /*!< in: the 'segment' of the i/o thread */ const char *str); /*!< in: constant char string describing the state */ -/*********************************************************************/ /** - Resets the info describing an i/o thread current state. */ +/** Resets the info describing an i/o thread current state. */ void srv_reset_io_thread_op_info(); -/*=========================*/ -/*******************************************************************/ /** - Tells the purge thread that there has been activity in the database +/** Tells the purge thread that there has been activity in the database and wakes up the purge thread if it is suspended (not sleeping). Note that there is a small chance that the purge thread stays suspended (we do not protect our operation with the srv_sys_t:mutex, for performance reasons). */ void srv_wake_purge_thread_if_not_active(void); -/*=====================================*/ -/*******************************************************************/ /** - Tells the Innobase server that there has been activity in the database +/** Tells the Innobase server that there has been activity in the database and wakes up the master thread if it is suspended (not sleeping). Used in the MySQL interface. Note that there is a small chance that the master thread stays suspended (we do not protect our operation with the kernel mutex, for performace reasons). */ void srv_active_wake_master_thread_low(void); -/*===================================*/ #define srv_active_wake_master_thread() \ do { \ if (!srv_read_only_mode) { \ srv_active_wake_master_thread_low(); \ } \ } while (0) -/*******************************************************************/ /** - Wakes up the master thread if it is suspended or being suspended. */ +/** Wakes up the master thread if it is suspended or being suspended. */ void srv_wake_master_thread(void); #ifndef UNIV_HOTBACKUP -/*========================*/ -/******************************************************************/ /** - Outputs to a file the output of the InnoDB Monitor. +/** Outputs to a file the output of the InnoDB Monitor. @return false if not all information printed due to failure to obtain necessary mutex */ ibool srv_printf_innodb_monitor( - /*======================*/ FILE *file, /*!< in: output stream */ ibool nowait, /*!< in: whether to wait for the lock_sys_t::mutex */ @@ -706,33 +689,21 @@ ibool srv_printf_innodb_monitor( ulint *trx_end); /*!< out: file position of the end of the list of active transactions */ -/******************************************************************/ /** - Function to pass InnoDB status variables to MySQL */ +/** Function to pass InnoDB status variables to MySQL */ void srv_export_innodb_status(void); -/*==========================*/ -/*******************************************************************/ /** - Get current server activity count. We don't hold srv_sys::mutex while +/** Get current server activity count. We don't hold srv_sys::mutex while reading this value as it is only used in heuristics. @return activity count. */ ulint srv_get_activity_count(void); -/*========================*/ -/*******************************************************************/ /** - Check if there has been any activity. +/** Check if there has been any activity. @return false if no change in activity counter. */ -ibool srv_check_activity( - /*===============*/ - ulint old_activity_count); /*!< old activity count */ -/******************************************************************/ /** - Increment the server activity counter. */ +ibool srv_check_activity(ulint old_activity_count); /*!< old activity count */ +/** Increment the server activity counter. */ void srv_inc_activity_count(void); -/*=========================*/ -/**********************************************************************/ /** - Enqueues a task to server task queue and releases a worker thread, if there +/** Enqueues a task to server task queue and releases a worker thread, if there is a suspended one. */ -void srv_que_task_enqueue_low( - /*=====================*/ - que_thr_t *thr); /*!< in: query thread */ +void srv_que_task_enqueue_low(que_thr_t *thr); /*!< in: query thread */ /** A thread which prints the info output by various InnoDB monitors. */ void srv_monitor_thread(); @@ -750,21 +721,16 @@ void srv_purge_coordinator_thread(); /** Worker thread that reads tasks from the work queue and executes them. */ void srv_worker_thread(); -/**********************************************************************/ /** - Get count of tasks in the queue. +/** Get count of tasks in the queue. @return number of tasks in queue */ ulint srv_get_task_queue_length(void); -/*===========================*/ -/*********************************************************************/ /** - Releases threads of the type given from suspension in the thread table. +/** Releases threads of the type given from suspension in the thread table. NOTE! The server mutex has to be reserved by the caller! @return number of threads released: this may be less than n if not enough threads were suspended at the moment */ -ulint srv_release_threads( - /*================*/ - enum srv_thread_type type, /*!< in: thread type */ - ulint n); /*!< in: number of threads to release */ +ulint srv_release_threads(enum srv_thread_type type, /*!< in: thread type */ + ulint n); /*!< in: number of threads to release */ /** Check whether any background thread (except the master thread) is active. Send the threads wakeup signal. @@ -787,10 +753,8 @@ The first phase of server shutdown must have already been executed @retval false if no thread is active */ bool srv_master_thread_active(); -/**********************************************************************/ /** - Wakeup the purge threads. */ +/** Wakeup the purge threads. */ void srv_purge_wakeup(void); -/*==================*/ /** Check if the purge threads are active, both coordinator and worker threads @return true if any thread is active, false if no thread is active */ diff --git a/storage/innobase/include/srv0srv.ic b/storage/innobase/include/srv0srv.ic index 3ef8df1bc538..d22d9a7ad5b0 100644 --- a/storage/innobase/include/srv0srv.ic +++ b/storage/innobase/include/srv0srv.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/srv0srv.ic +/** @file include/srv0srv.ic Server main program Created 10/4/1995 Heikki Tuuri diff --git a/storage/innobase/include/srv0start.h b/storage/innobase/include/srv0start.h index 33962184c211..82ef14b13f9a 100644 --- a/storage/innobase/include/srv0start.h +++ b/storage/innobase/include/srv0start.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/srv0start.h +/** @file include/srv0start.h Starts the Innobase database server Created 10/10/1995 Heikki Tuuri @@ -62,24 +61,18 @@ struct dict_table_t; only one buffer pool instance is used. */ #define BUF_POOL_SIZE_THRESHOLD (1024 * 1024 * 1024) -/*********************************************************************/ /** - Parse temporary tablespace configuration. +/** Parse temporary tablespace configuration. @return true if ok, false on parse error */ bool srv_parse_temp_data_file_paths_and_sizes( - /*=====================================*/ char *str); /*!< in/out: the data file path string */ -/*********************************************************************/ /** - Frees the memory allocated by srv_parse_data_file_paths_and_sizes() +/** Frees the memory allocated by srv_parse_data_file_paths_and_sizes() and srv_parse_log_group_home_dirs(). */ void srv_free_paths_and_sizes(void); -/*==========================*/ -/*********************************************************************/ /** - Adds a slash or a backslash to the end of a string if it is missing +/** Adds a slash or a backslash to the end of a string if it is missing and the string is not empty. @return string which has the separator if the string is not empty */ char *srv_add_path_separator_if_needed( - /*=============================*/ char *str); /*!< in: null-terminated character string */ #ifndef UNIV_HOTBACKUP @@ -119,17 +112,14 @@ void srv_shutdown(); purge threads early to apply purge. */ void srv_start_purge_threads(); -/*************************************************************/ /** - Copy the file path component of the physical file to parameter. It will +/** Copy the file path component of the physical file to parameter. It will copy up to and including the terminating path separator. @return number of bytes copied or ULINT_UNDEFINED if destination buffer is smaller than the path to be copied. */ -ulint srv_path_copy( - /*==========*/ - char *dest, /*!< out: destination buffer */ - ulint dest_len, /*!< in: max bytes to copy */ - const char *basedir, /*!< in: base directory */ - const char *table_name) /*!< in: source table name */ +ulint srv_path_copy(char *dest, /*!< out: destination buffer */ + ulint dest_len, /*!< in: max bytes to copy */ + const char *basedir, /*!< in: base directory */ + const char *table_name) /*!< in: source table name */ MY_ATTRIBUTE((warn_unused_result)); /** Get the encryption-data filename from the table name for a diff --git a/storage/innobase/include/sync0arr.h b/storage/innobase/include/sync0arr.h index 4ce96edd32a9..070d07e6586d 100644 --- a/storage/innobase/include/sync0arr.h +++ b/storage/innobase/include/sync0arr.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/sync0arr.h +/** @file include/sync0arr.h The wait array used in synchronization primitives Created 9/5/1995 Heikki Tuuri @@ -59,8 +58,7 @@ sync_array_t *sync_array_get_and_reserve_cell(void *object, ulint type, const char *file, ulint line, sync_cell_t **cell); -/******************************************************************/ /** - Reserves a wait array cell for waiting for an object. +/** Reserves a wait array cell for waiting for an object. The event of the cell is reset to nonsignalled state. */ sync_cell_t *sync_array_reserve_cell( sync_array_t *arr, /*!< in: wait array */ @@ -69,51 +67,43 @@ sync_cell_t *sync_array_reserve_cell( const char *file, /*!< in: file where requested */ ulint line); /*!< in: line where requested */ -/******************************************************************/ /** - This function should be called when a thread starts to wait on +/** This function should be called when a thread starts to wait on a wait array cell. In the debug version this function checks if the wait for a semaphore will result in a deadlock, in which case prints info and asserts. */ void sync_array_wait_event(sync_array_t *arr, /*!< in: wait array */ sync_cell_t *&cell); /*!< in: the reserved cell */ -/******************************************************************/ /** - Frees the cell. NOTE! sync_array_wait_event frees the cell +/** Frees the cell. NOTE! sync_array_wait_event frees the cell automatically! */ void sync_array_free_cell(sync_array_t *arr, /*!< in: wait array */ sync_cell_t *&cell); /*!< in: the reserved cell */ -/**********************************************************************/ /** - Note that one of the wait objects was signalled. */ +/** Note that one of the wait objects was signalled. */ void sync_array_object_signalled(); -/**********************************************************************/ /** - If the wakeup algorithm does not work perfectly at semaphore relases, +/** If the wakeup algorithm does not work perfectly at semaphore relases, this function will do the waking (see the comment in mutex_exit). This function should be called about every 1 second in the server. */ void sync_arr_wake_threads_if_sema_free(); -/**********************************************************************/ /** - Prints warnings of long semaphore waits to stderr. +/** Prints warnings of long semaphore waits to stderr. @return true if fatal semaphore wait threshold was exceeded */ ibool sync_array_print_long_waits( os_thread_id_t *waiter, /*!< out: longest waiting thread */ const void **sema); /*!< out: longest-waited-for semaphore */ -/**********************************************************************/ /** - Prints info of the wait array. */ +/** Prints info of the wait array. */ void sync_array_print(FILE *file); /*!< in: file where to print */ -/**********************************************************************/ /** - Create the primary system wait array(s), they are protected by an OS mutex */ +/** Create the primary system wait array(s), they are protected by an OS mutex + */ void sync_array_init(ulint n_threads); /*!< in: Number of slots to create */ -/**********************************************************************/ /** - Close sync array wait sub-system. */ +/** Close sync array wait sub-system. */ void sync_array_close(); -/**********************************************************************/ /** - Get an instance of the sync wait array. */ +/** Get an instance of the sync wait array. */ UNIV_INLINE sync_array_t *sync_array_get(); diff --git a/storage/innobase/include/sync0arr.ic b/storage/innobase/include/sync0arr.ic index 81400ac815eb..4b5834e7f662 100644 --- a/storage/innobase/include/sync0arr.ic +++ b/storage/innobase/include/sync0arr.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/sync0arr.ic +/** @file include/sync0arr.ic The wait array for synchronization primitives Inline code @@ -38,14 +37,11 @@ extern sync_array_t **sync_wait_array; #include "ut0counter.h" -/**********************************************************************/ /** - Get an instance of the sync wait array. +/** Get an instance of the sync wait array. @return an instance of the sync wait array. */ UNIV_INLINE -sync_array_t *sync_array_get() -/*============*/ -{ +sync_array_t *sync_array_get() { if (sync_array_size <= 1) { return (sync_wait_array[0]); } @@ -54,8 +50,7 @@ sync_array_t *sync_array_get() sync_wait_array[default_indexer_t<>::get_rnd_index() % sync_array_size]); } -/******************************************************************/ /** - Get an instance of the sync wait array and reserve a wait array cell +/** Get an instance of the sync wait array and reserve a wait array cell in the instance for waiting for an object. The event of the cell is reset to nonsignalled state. If reserving cell of the instance fails, try to get another new @@ -63,7 +58,6 @@ sync_array_t *sync_array_get() @return the sync array reserved, never NULL. */ UNIV_INLINE sync_array_t *sync_array_get_and_reserve_cell( - /*============================*/ void *object, /*!< in: pointer to the object to wait for */ ulint type, /*!< in: lock request type */ const char *file, /*!< in: file where requested */ diff --git a/storage/innobase/include/sync0debug.h b/storage/innobase/include/sync0debug.h index b3dd1ff69afb..b2c3d6a1bd8b 100644 --- a/storage/innobase/include/sync0debug.h +++ b/storage/innobase/include/sync0debug.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2013, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2018, Oracle and/or its affiliates. All Rights Reserved. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -30,8 +30,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/sync0debug.h +/** @file include/sync0debug.h Debug checks for latches, header file Created 2012-08-21 Sunny Bains diff --git a/storage/innobase/include/sync0policy.h b/storage/innobase/include/sync0policy.h index c8fbb57dccc1..77ebba2040d6 100644 --- a/storage/innobase/include/sync0policy.h +++ b/storage/innobase/include/sync0policy.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2013, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/sync0policy.h +/** @file include/sync0policy.h Policies for mutexes. Created 2012-08-21 Sunny Bains. diff --git a/storage/innobase/include/sync0policy.ic b/storage/innobase/include/sync0policy.ic index 9c5422bc8fad..834179c79a3f 100644 --- a/storage/innobase/include/sync0policy.ic +++ b/storage/innobase/include/sync0policy.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2013, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/sync0policy.ic +/** @file include/sync0policy.ic Policy for mutexes. Created 2012-08-21 Sunny Bains. diff --git a/storage/innobase/include/sync0rw.h b/storage/innobase/include/sync0rw.h index f202695ad4b9..5f49368ee8ef 100644 --- a/storage/innobase/include/sync0rw.h +++ b/storage/innobase/include/sync0rw.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -31,8 +31,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/sync0rw.h +/** @file include/sync0rw.h The read-write lock (for threads, not for database transactions) Created 9/11/1995 Heikki Tuuri @@ -162,8 +161,7 @@ extern rw_lock_stats_t rw_lock_stats; #ifndef UNIV_LIBRARY #ifndef UNIV_HOTBACKUP #ifndef UNIV_PFS_RWLOCK -/******************************************************************/ /** - Creates, or rather, initializes an rw-lock object in a specified memory +/** Creates, or rather, initializes an rw-lock object in a specified memory location (which must be appropriately aligned). The rw-lock is initialized to the non-locked state. Explicit freeing of the rw-lock with rw_lock_free is necessary only if the memory block containing it is freed. @@ -176,8 +174,7 @@ extern rw_lock_stats_t rw_lock_stats; #define rw_lock_create(K, L, level) rw_lock_create_func((L), __FILE__, __LINE__) #endif /* UNIV_DEBUG */ -/**************************************************************/ /** - NOTE! The following macros should be used in rw locking and +/** NOTE! The following macros should be used in rw locking and unlocking, not the corresponding function. */ #define rw_lock_s_lock(M) rw_lock_s_lock_func((M), 0, __FILE__, __LINE__) @@ -314,13 +311,11 @@ unlocking, not the corresponding function. */ #define rw_lock_s_unlock(L) rw_lock_s_unlock_gen(L, 0) #define rw_lock_x_unlock(L) rw_lock_x_unlock_gen(L, 0) -/******************************************************************/ /** - Creates, or rather, initializes an rw-lock object in a specified memory +/** Creates, or rather, initializes an rw-lock object in a specified memory location (which must be appropriately aligned). The rw-lock is initialized to the non-locked state. Explicit freeing of the rw-lock with rw_lock_free is necessary only if the memory block containing it is freed. */ void rw_lock_create_func( - /*================*/ rw_lock_t *lock, /*!< in: pointer to memory */ #ifdef UNIV_DEBUG latch_level_t level, /*!< in: level */ @@ -328,22 +323,16 @@ void rw_lock_create_func( #endif /* UNIV_DEBUG */ const char *cfile_name, /*!< in: file name where created */ ulint cline); /*!< in: file line where created */ -/******************************************************************/ /** - Calling this function is obligatory only if the memory buffer containing +/** Calling this function is obligatory only if the memory buffer containing the rw-lock is freed. Removes an rw-lock object from the global list. The rw-lock is checked to be in the non-locked state. */ -void rw_lock_free_func( - /*==============*/ - rw_lock_t *lock); /*!< in/out: rw-lock */ +void rw_lock_free_func(rw_lock_t *lock); /*!< in/out: rw-lock */ #ifdef UNIV_DEBUG -/******************************************************************/ /** - Checks that the rw-lock has been initialized and that there are no +/** Checks that the rw-lock has been initialized and that there are no simultaneous shared and exclusive locks. @return true */ -bool rw_lock_validate( - /*=============*/ - const rw_lock_t *lock); /*!< in: rw-lock */ -#endif /* UNIV_DEBUG */ +bool rw_lock_validate(const rw_lock_t *lock); /*!< in: rw-lock */ +#endif /* UNIV_DEBUG */ /** Low-level function which tries to lock an rw-lock in s-mode. Performs no spinning. @@ -393,8 +382,7 @@ void rw_lock_s_unlock_func( #endif /* UNIV_DEBUG */ rw_lock_t *lock); -/******************************************************************/ /** - NOTE! Use the corresponding macro, not directly this function! Lock an +/** NOTE! Use the corresponding macro, not directly this function! Lock an rw-lock in exclusive mode for the current thread. If the rw-lock is locked in shared or exclusive mode, or there is an exclusive lock request waiting, the function spins a preset time (controlled by srv_n_spin_wait_rounds), @@ -403,24 +391,20 @@ void rw_lock_s_unlock_func( != 0, only a single x-lock may be taken on the lock. NOTE: If the same thread has an s-lock, locking does not succeed! */ void rw_lock_x_lock_func( - /*================*/ rw_lock_t *lock, /*!< in: pointer to rw-lock */ ulint pass, /*!< in: pass value; != 0, if the lock will be passed to another thread to unlock */ const char *file_name, /*!< in: file name where lock requested */ ulint line); /*!< in: line where requested */ -/******************************************************************/ /** - Low-level function for acquiring an sx lock. +/** Low-level function for acquiring an sx lock. @return false if did not succeed, true if success. */ ibool rw_lock_sx_lock_low( - /*================*/ rw_lock_t *lock, /*!< in: pointer to rw-lock */ ulint pass, /*!< in: pass value; != 0, if the lock will be passed to another thread to unlock */ const char *file_name, /*!< in: file name where lock requested */ ulint line); /*!< in: line where requested */ -/******************************************************************/ /** - NOTE! Use the corresponding macro, not directly this function! Lock an +/** NOTE! Use the corresponding macro, not directly this function! Lock an rw-lock in SX mode for the current thread. If the rw-lock is locked in exclusive mode, or there is an exclusive lock request waiting, the function spins a preset time (controlled by SYNC_SPIN_ROUNDS), waiting @@ -429,7 +413,6 @@ ibool rw_lock_sx_lock_low( only a single sx-lock may be taken on the lock. NOTE: If the same thread has an s-lock, locking does not succeed! */ void rw_lock_sx_lock_func( - /*=================*/ rw_lock_t *lock, /*!< in: pointer to rw-lock */ ulint pass, /*!< in: pass value; != 0, if the lock will be passed to another thread to unlock */ @@ -458,8 +441,7 @@ void rw_lock_sx_unlock_func( #endif /* UNIV_DEBUG */ rw_lock_t *lock); -/******************************************************************/ /** - This function is used in the insert buffer to move the ownership of an +/** This function is used in the insert buffer to move the ownership of an x-latch on a buffer frame to the current thread. The x-latch was set by the buffer read operation and it protected the buffer frame while the read was done. The ownership is moved because we want that the current @@ -467,48 +449,32 @@ void rw_lock_sx_unlock_func( This, in turn, is needed to pass the debug checks of index page operations. */ void rw_lock_x_lock_move_ownership( - /*==========================*/ rw_lock_t *lock); /*!< in: lock which was x-locked in the buffer read */ #endif /* !UNIV_HOTBACKUP */ -/******************************************************************/ /** - Returns the value of writer_count for the lock. Does not reserve the lock +/** Returns the value of writer_count for the lock. Does not reserve the lock mutex, so the caller must be sure it is not changed during the call. @return value of writer_count */ UNIV_INLINE -ulint rw_lock_get_x_lock_count( - /*=====================*/ - const rw_lock_t *lock); /*!< in: rw-lock */ -/******************************************************************/ /** - Returns the number of sx-lock for the lock. Does not reserve the lock +ulint rw_lock_get_x_lock_count(const rw_lock_t *lock); /*!< in: rw-lock */ +/** Returns the number of sx-lock for the lock. Does not reserve the lock mutex, so the caller must be sure it is not changed during the call. @return value of writer_count */ UNIV_INLINE -ulint rw_lock_get_sx_lock_count( - /*======================*/ - const rw_lock_t *lock); /*!< in: rw-lock */ -/********************************************************************/ /** - Check if there are threads waiting for the rw-lock. +ulint rw_lock_get_sx_lock_count(const rw_lock_t *lock); /*!< in: rw-lock */ +/** Check if there are threads waiting for the rw-lock. @return 1 if waiters, 0 otherwise */ UNIV_INLINE -ulint rw_lock_get_waiters( - /*================*/ - const rw_lock_t *lock); /*!< in: rw-lock */ -/******************************************************************/ /** - Returns the write-status of the lock - this function made more sense +ulint rw_lock_get_waiters(const rw_lock_t *lock); /*!< in: rw-lock */ +/** Returns the write-status of the lock - this function made more sense with the old rw_lock implementation. @return RW_LOCK_NOT_LOCKED, RW_LOCK_X, RW_LOCK_X_WAIT, RW_LOCK_SX */ UNIV_INLINE -ulint rw_lock_get_writer( - /*===============*/ - const rw_lock_t *lock); /*!< in: rw-lock */ -/******************************************************************/ /** - Returns the number of readers (s-locks). +ulint rw_lock_get_writer(const rw_lock_t *lock); /*!< in: rw-lock */ +/** Returns the number of readers (s-locks). @return number of readers */ UNIV_INLINE -ulint rw_lock_get_reader_count( - /*=====================*/ - const rw_lock_t *lock); /*!< in: rw-lock */ +ulint rw_lock_get_reader_count(const rw_lock_t *lock); /*!< in: rw-lock */ /** Decrements lock_word the specified amount if it is greater than 0. This is used by both s_lock and x_lock operations. @@ -540,51 +506,37 @@ void rw_lock_set_writer_id_and_recursion_flag(rw_lock_t *lock, bool recursive); #ifndef UNIV_HOTBACKUP #ifdef UNIV_DEBUG -/******************************************************************/ /** - Checks if the thread has locked the rw-lock in the specified mode, with +/** Checks if the thread has locked the rw-lock in the specified mode, with the pass value == 0. */ -ibool rw_lock_own( - /*========*/ - rw_lock_t *lock, /*!< in: rw-lock */ - ulint lock_type) /*!< in: lock type: RW_LOCK_S, - RW_LOCK_X */ +ibool rw_lock_own(rw_lock_t *lock, /*!< in: rw-lock */ + ulint lock_type) /*!< in: lock type: RW_LOCK_S, + RW_LOCK_X */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************************/ /** - Checks if the thread has locked the rw-lock in the specified mode, with +/** Checks if the thread has locked the rw-lock in the specified mode, with the pass value == 0. */ bool rw_lock_own_flagged( - /*================*/ const rw_lock_t *lock, /*!< in: rw-lock */ rw_lock_flags_t flags) /*!< in: specify lock types with OR of the rw_lock_flag_t values */ MY_ATTRIBUTE((warn_unused_result)); #endif /* UNIV_DEBUG */ #endif /* !UNIV_HOTBACKUP */ -/******************************************************************/ /** - Checks if somebody has locked the rw-lock in the specified mode. +/** Checks if somebody has locked the rw-lock in the specified mode. @return true if locked */ -bool rw_lock_is_locked( - /*==============*/ - rw_lock_t *lock, /*!< in: rw-lock */ - ulint lock_type); /*!< in: lock type: RW_LOCK_S, - RW_LOCK_X or RW_LOCK_SX */ +bool rw_lock_is_locked(rw_lock_t *lock, /*!< in: rw-lock */ + ulint lock_type); /*!< in: lock type: RW_LOCK_S, + RW_LOCK_X or RW_LOCK_SX */ #ifdef UNIV_DEBUG -/***************************************************************/ /** - Prints debug info of currently locked rw-locks. */ -void rw_lock_list_print_info( - /*====================*/ - FILE *file); /*!< in: file where to print */ +/** Prints debug info of currently locked rw-locks. */ +void rw_lock_list_print_info(FILE *file); /*!< in: file where to print */ /*#####################################################################*/ -/*********************************************************************/ /** - Prints info of a debug struct. */ -void rw_lock_debug_print( - /*================*/ - FILE *f, /*!< in: output stream */ - const rw_lock_debug_t *info); /*!< in: debug struct */ -#endif /* UNIV_DEBUG */ +/** Prints info of a debug struct. */ +void rw_lock_debug_print(FILE *f, /*!< in: output stream */ + const rw_lock_debug_t *info); /*!< in: debug struct */ +#endif /* UNIV_DEBUG */ #endif /* !UNIV_LIBRARY */ @@ -889,15 +841,12 @@ void pfs_rw_lock_sx_unlock_func( #endif /* UNIV_DEBUG */ rw_lock_t *lock); -/******************************************************************/ /** - Performance schema instrumented wrap function for rw_lock_free_func() +/** Performance schema instrumented wrap function for rw_lock_free_func() NOTE! Please use the corresponding macro rw_lock_free(), not directly this function! */ UNIV_INLINE -void pfs_rw_lock_free_func( - /*==================*/ - rw_lock_t *lock); /*!< in: rw-lock */ -#endif /* UNIV_PFS_RWLOCK */ +void pfs_rw_lock_free_func(rw_lock_t *lock); /*!< in: rw-lock */ +#endif /* UNIV_PFS_RWLOCK */ #include "sync0rw.ic" diff --git a/storage/innobase/include/sync0rw.ic b/storage/innobase/include/sync0rw.ic index 79dd10734b09..c4604ba0f849 100644 --- a/storage/innobase/include/sync0rw.ic +++ b/storage/innobase/include/sync0rw.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -31,8 +31,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/sync0rw.ic +/** @file include/sync0rw.ic The read-write lock (for threads) Created 9/11/1995 Heikki Tuuri @@ -40,56 +39,43 @@ this program; if not, write to the Free Software Foundation, Inc., #include "os0event.h" -/******************************************************************/ /** - Lock an rw-lock in shared mode for the current thread. If the rw-lock is +/** Lock an rw-lock in shared mode for the current thread. If the rw-lock is locked in exclusive mode, or there is an exclusive lock request waiting, the function spins a preset time (controlled by srv_n_spin_wait_rounds), waiting for the lock before suspending the thread. */ void rw_lock_s_lock_spin( - /*================*/ rw_lock_t *lock, /*!< in: pointer to rw-lock */ ulint pass, /*!< in: pass value; != 0, if the lock will be passed to another thread to unlock */ const char *file_name, /*!< in: file name where lock requested */ ulint line); /*!< in: line where requested */ #ifdef UNIV_DEBUG -/******************************************************************/ /** - Inserts the debug information for an rw-lock. */ +/** Inserts the debug information for an rw-lock. */ void rw_lock_add_debug_info( - /*===================*/ rw_lock_t *lock, /*!< in: rw-lock */ ulint pass, /*!< in: pass value */ ulint lock_type, /*!< in: lock type */ const char *file_name, /*!< in: file where requested */ ulint line); /*!< in: line where requested */ -/******************************************************************/ /** - Removes a debug information struct for an rw-lock. */ -void rw_lock_remove_debug_info( - /*======================*/ - rw_lock_t *lock, /*!< in: rw-lock */ - ulint pass, /*!< in: pass value */ - ulint lock_type); /*!< in: lock type */ -#endif /* UNIV_DEBUG */ - -/********************************************************************/ /** - Check if there are threads waiting for the rw-lock. +/** Removes a debug information struct for an rw-lock. */ +void rw_lock_remove_debug_info(rw_lock_t *lock, /*!< in: rw-lock */ + ulint pass, /*!< in: pass value */ + ulint lock_type); /*!< in: lock type */ +#endif /* UNIV_DEBUG */ + +/** Check if there are threads waiting for the rw-lock. @return 1 if waiters, 0 otherwise */ UNIV_INLINE -ulint rw_lock_get_waiters( - /*================*/ - const rw_lock_t *lock) /*!< in: rw-lock */ +ulint rw_lock_get_waiters(const rw_lock_t *lock) /*!< in: rw-lock */ { return (lock->waiters); } -/********************************************************************/ /** - Sets lock->waiters to 1. It is not an error if lock->waiters is already +/** Sets lock->waiters to 1. It is not an error if lock->waiters is already 1. On platforms where ATOMIC builtins are used this function enforces a memory barrier. */ UNIV_INLINE -void rw_lock_set_waiter_flag( - /*====================*/ - rw_lock_t *lock) /*!< in/out: rw-lock */ +void rw_lock_set_waiter_flag(rw_lock_t *lock) /*!< in/out: rw-lock */ { #ifdef INNODB_RW_LOCKS_USE_ATOMICS (void)os_compare_and_swap_ulint(&lock->waiters, 0, 1); @@ -99,14 +85,11 @@ void rw_lock_set_waiter_flag( #endif /* INNODB_RW_LOCKS_USE_ATOMICS */ } -/********************************************************************/ /** - Resets lock->waiters to 0. It is not an error if lock->waiters is already +/** Resets lock->waiters to 0. It is not an error if lock->waiters is already 0. On platforms where ATOMIC builtins are used this function enforces a memory barrier. */ UNIV_INLINE -void rw_lock_reset_waiter_flag( - /*======================*/ - rw_lock_t *lock) /*!< in/out: rw-lock */ +void rw_lock_reset_waiter_flag(rw_lock_t *lock) /*!< in/out: rw-lock */ { #ifdef INNODB_RW_LOCKS_USE_ATOMICS (void)os_compare_and_swap_ulint(&lock->waiters, 1, 0); @@ -116,14 +99,11 @@ void rw_lock_reset_waiter_flag( #endif /* INNODB_RW_LOCKS_USE_ATOMICS */ } -/******************************************************************/ /** - Returns the write-status of the lock - this function made more sense +/** Returns the write-status of the lock - this function made more sense with the old rw_lock implementation. @return RW_LOCK_NOT_LOCKED, RW_LOCK_X, RW_LOCK_X_WAIT, RW_LOCK_SX */ UNIV_INLINE -ulint rw_lock_get_writer( - /*===============*/ - const rw_lock_t *lock) /*!< in: rw-lock */ +ulint rw_lock_get_writer(const rw_lock_t *lock) /*!< in: rw-lock */ { lint lock_word = lock->lock_word; @@ -147,13 +127,10 @@ ulint rw_lock_get_writer( } } -/******************************************************************/ /** - Returns the number of readers (s-locks). +/** Returns the number of readers (s-locks). @return number of readers */ UNIV_INLINE -ulint rw_lock_get_reader_count( - /*=====================*/ - const rw_lock_t *lock) /*!< in: rw-lock */ +ulint rw_lock_get_reader_count(const rw_lock_t *lock) /*!< in: rw-lock */ { lint lock_word = lock->lock_word; ut_ad(lock_word <= X_LOCK_DECR); @@ -183,21 +160,14 @@ ulint rw_lock_get_reader_count( #ifndef INNODB_RW_LOCKS_USE_ATOMICS UNIV_INLINE -ib_mutex_t *rw_lock_get_mutex( - /*==============*/ - rw_lock_t *lock) { - return (&(lock->mutex)); -} +ib_mutex_t *rw_lock_get_mutex(rw_lock_t *lock) { return (&(lock->mutex)); } #endif /* INNODB_RW_LOCKS_USE_ATOMICS */ -/******************************************************************/ /** - Returns the value of writer_count for the lock. Does not reserve the lock +/** Returns the value of writer_count for the lock. Does not reserve the lock mutex, so the caller must be sure it is not changed during the call. @return value of writer_count */ UNIV_INLINE -ulint rw_lock_get_x_lock_count( - /*=====================*/ - const rw_lock_t *lock) /*!< in: rw-lock */ +ulint rw_lock_get_x_lock_count(const rw_lock_t *lock) /*!< in: rw-lock */ { lint lock_copy = lock->lock_word; ut_ad(lock_copy <= X_LOCK_DECR); @@ -221,14 +191,11 @@ ulint rw_lock_get_x_lock_count( } } -/******************************************************************/ /** - Returns the number of sx-lock for the lock. Does not reserve the lock +/** Returns the number of sx-lock for the lock. Does not reserve the lock mutex, so the caller must be sure it is not changed during the call. @return value of sx-lock count */ UNIV_INLINE -ulint rw_lock_get_sx_lock_count( - /*======================*/ - const rw_lock_t *lock) /*!< in: rw-lock */ +ulint rw_lock_get_sx_lock_count(const rw_lock_t *lock) /*!< in: rw-lock */ { #ifdef UNIV_DEBUG lint lock_copy = lock->lock_word; @@ -249,19 +216,16 @@ ulint rw_lock_get_sx_lock_count( #endif /* UNIV_DEBUG */ } -/******************************************************************/ /** - Two different implementations for decrementing the lock_word of a rw_lock: +/** Two different implementations for decrementing the lock_word of a rw_lock: one for systems supporting atomic operations, one for others. This does does not support recusive x-locks: they should be handled by the caller and need not be atomic since they are performed by the current lock holder. Returns true if the decrement was made, false if not. @return true if decr occurs */ ALWAYS_INLINE -bool rw_lock_lock_word_decr( - /*===================*/ - rw_lock_t *lock, /*!< in/out: rw-lock */ - ulint amount, /*!< in: amount to decrement */ - lint threshold) /*!< in: threshold of judgement */ +bool rw_lock_lock_word_decr(rw_lock_t *lock, /*!< in/out: rw-lock */ + ulint amount, /*!< in: amount to decrement */ + lint threshold) /*!< in: threshold of judgement */ { #ifdef INNODB_RW_LOCKS_USE_ATOMICS lint local_lock_word; @@ -288,14 +252,11 @@ bool rw_lock_lock_word_decr( #endif /* INNODB_RW_LOCKS_USE_ATOMICS */ } -/******************************************************************/ /** - Increments lock_word the specified amount and returns new value. +/** Increments lock_word the specified amount and returns new value. @return lock->lock_word after increment */ UNIV_INLINE -lint rw_lock_lock_word_incr( - /*===================*/ - rw_lock_t *lock, /*!< in/out: rw-lock */ - ulint amount) /*!< in: amount of increment */ +lint rw_lock_lock_word_incr(rw_lock_t *lock, /*!< in/out: rw-lock */ + ulint amount) /*!< in: amount of increment */ { #ifdef INNODB_RW_LOCKS_USE_ATOMICS return (os_atomic_increment_lint(&lock->lock_word, amount)); @@ -313,8 +274,7 @@ lint rw_lock_lock_word_incr( #endif /* INNODB_RW_LOCKS_USE_ATOMICS */ } -/******************************************************************/ /** - This function sets the lock->writer_thread and lock->recursive fields. +/** This function sets the lock->writer_thread and lock->recursive fields. For platforms where we are using atomic builtins instead of lock->mutex it sets the lock->writer_thread field using atomics to ensure memory ordering. Note that it is assumed that the caller of this function @@ -324,7 +284,6 @@ lint rw_lock_lock_word_incr( lock->recursive flag is set. */ UNIV_INLINE void rw_lock_set_writer_id_and_recursion_flag( - /*=====================================*/ rw_lock_t *lock, /*!< in/out: lock to work on */ bool recursive) /*!< in: true if recursion allowed */ @@ -357,13 +316,11 @@ void rw_lock_set_writer_id_and_recursion_flag( #endif /* INNODB_RW_LOCKS_USE_ATOMICS */ } -/******************************************************************/ /** - Low-level function which tries to lock an rw-lock in s-mode. Performs no +/** Low-level function which tries to lock an rw-lock in s-mode. Performs no spinning. @return TRUE if success */ ALWAYS_INLINE ibool rw_lock_s_lock_low( - /*===============*/ rw_lock_t *lock, /*!< in: pointer to rw-lock */ ulint pass MY_ATTRIBUTE((unused)), /*!< in: pass value; != 0, if the lock will be @@ -386,15 +343,13 @@ ibool rw_lock_s_lock_low( return (TRUE); /* locking succeeded */ } -/******************************************************************/ /** - NOTE! Use the corresponding macro, not directly this function! Lock an +/** NOTE! Use the corresponding macro, not directly this function! Lock an rw-lock in shared mode for the current thread. If the rw-lock is locked in exclusive mode, or there is an exclusive lock request waiting, the function spins a preset time (controlled by srv_n_spin_wait_rounds), waiting for the lock, before suspending the thread. */ UNIV_INLINE void rw_lock_s_lock_func( - /*================*/ rw_lock_t *lock, /*!< in: pointer to rw-lock */ ulint pass, /*!< in: pass value; != 0, if the lock will be passed to another thread to unlock */ @@ -422,14 +377,12 @@ void rw_lock_s_lock_func( } } -/******************************************************************/ /** - NOTE! Use the corresponding macro, not directly this function! Lock an +/** NOTE! Use the corresponding macro, not directly this function! Lock an rw-lock in exclusive mode for the current thread if the lock can be obtained immediately. @return true if success */ UNIV_INLINE ibool rw_lock_x_lock_func_nowait( - /*=======================*/ rw_lock_t *lock, /*!< in: pointer to rw-lock */ const char *file_name, /*!< in: file name where lock requested */ ulint line) /*!< in: line where requested */ @@ -486,11 +439,9 @@ ibool rw_lock_x_lock_func_nowait( return (TRUE); } -/******************************************************************/ /** - Releases a shared mode lock. */ +/** Releases a shared mode lock. */ UNIV_INLINE void rw_lock_s_unlock_func( -/*==================*/ #ifdef UNIV_DEBUG ulint pass, /*!< in: pass value; != 0, if the lock may have been passed to another thread to unlock */ @@ -516,11 +467,9 @@ void rw_lock_s_unlock_func( ut_ad(rw_lock_validate(lock)); } -/******************************************************************/ /** - Releases an exclusive mode lock. */ +/** Releases an exclusive mode lock. */ UNIV_INLINE void rw_lock_x_unlock_func( -/*==================*/ #ifdef UNIV_DEBUG ulint pass, /*!< in: pass value; != 0, if the lock may have been passed to another thread to unlock */ @@ -573,11 +522,9 @@ void rw_lock_x_unlock_func( ut_ad(rw_lock_validate(lock)); } -/******************************************************************/ /** - Releases a sx mode lock. */ +/** Releases a sx mode lock. */ UNIV_INLINE void rw_lock_sx_unlock_func( -/*===================*/ #ifdef UNIV_DEBUG ulint pass, /*!< in: pass value; != 0, if the lock may have been passed to another thread to unlock */ @@ -622,13 +569,11 @@ void rw_lock_sx_unlock_func( #ifdef UNIV_PFS_RWLOCK -/******************************************************************/ /** - Performance schema instrumented wrap function for rw_lock_create_func(). +/** Performance schema instrumented wrap function for rw_lock_create_func(). NOTE! Please use the corresponding macro rw_lock_create(), not directly this function! */ UNIV_INLINE void pfs_rw_lock_create_func( - /*====================*/ mysql_pfs_key_t key, /*!< in: key registered with performance schema */ rw_lock_t *lock, /*!< in/out: pointer to memory */ @@ -651,13 +596,11 @@ void pfs_rw_lock_create_func( #endif /* UNIV_DEBUG */ cfile_name, cline); } -/******************************************************************/ /** - Performance schema instrumented wrap function for rw_lock_x_lock_func() +/** Performance schema instrumented wrap function for rw_lock_x_lock_func() NOTE! Please use the corresponding macro rw_lock_x_lock(), not directly this function! */ UNIV_INLINE void pfs_rw_lock_x_lock_func( - /*====================*/ rw_lock_t *lock, /*!< in: pointer to rw-lock */ ulint pass, /*!< in: pass value; != 0, if the lock will be passed to another thread to unlock */ @@ -684,15 +627,13 @@ void pfs_rw_lock_x_lock_func( rw_lock_x_lock_func(lock, pass, file_name, line); } } -/******************************************************************/ /** - Performance schema instrumented wrap function for +/** Performance schema instrumented wrap function for rw_lock_x_lock_func_nowait() NOTE! Please use the corresponding macro rw_lock_x_lock_func(), not directly this function! @return true if success */ UNIV_INLINE ibool pfs_rw_lock_x_lock_func_nowait( - /*===========================*/ rw_lock_t *lock, /*!< in: pointer to rw-lock */ const char *file_name, /*!< in: file name where lock requested */ @@ -722,14 +663,11 @@ ibool pfs_rw_lock_x_lock_func_nowait( return (ret); } -/******************************************************************/ /** - Performance schema instrumented wrap function for rw_lock_free_func() +/** Performance schema instrumented wrap function for rw_lock_free_func() NOTE! Please use the corresponding macro rw_lock_free(), not directly this function! */ UNIV_INLINE -void pfs_rw_lock_free_func( - /*==================*/ - rw_lock_t *lock) /*!< in: pointer to rw-lock */ +void pfs_rw_lock_free_func(rw_lock_t *lock) /*!< in: pointer to rw-lock */ { if (lock->pfs_psi != NULL) { PSI_RWLOCK_CALL(destroy_rwlock)(lock->pfs_psi); @@ -738,13 +676,11 @@ void pfs_rw_lock_free_func( rw_lock_free_func(lock); } -/******************************************************************/ /** - Performance schema instrumented wrap function for rw_lock_s_lock_func() +/** Performance schema instrumented wrap function for rw_lock_s_lock_func() NOTE! Please use the corresponding macro rw_lock_s_lock(), not directly this function! */ ALWAYS_INLINE void pfs_rw_lock_s_lock_func( - /*====================*/ rw_lock_t *lock, /*!< in: pointer to rw-lock */ ulint pass, /*!< in: pass value; != 0, if the lock will be passed to another @@ -771,13 +707,11 @@ void pfs_rw_lock_s_lock_func( rw_lock_s_lock_func(lock, pass, file_name, line); } } -/******************************************************************/ /** - Performance schema instrumented wrap function for rw_lock_sx_lock_func() +/** Performance schema instrumented wrap function for rw_lock_sx_lock_func() NOTE! Please use the corresponding macro rw_lock_sx_lock(), not directly this function! */ UNIV_INLINE void pfs_rw_lock_sx_lock_func( - /*====================*/ rw_lock_t *lock, /*!< in: pointer to rw-lock */ ulint pass, /*!< in: pass value; != 0, if the lock will be passed to another @@ -804,14 +738,12 @@ void pfs_rw_lock_sx_lock_func( rw_lock_sx_lock_func(lock, pass, file_name, line); } } -/******************************************************************/ /** - Performance schema instrumented wrap function for rw_lock_s_lock_func() +/** Performance schema instrumented wrap function for rw_lock_s_lock_func() NOTE! Please use the corresponding macro rw_lock_s_lock(), not directly this function! @return true if success */ UNIV_INLINE ibool pfs_rw_lock_s_lock_low( - /*===================*/ rw_lock_t *lock, /*!< in: pointer to rw-lock */ ulint pass, /*!< in: pass value; != 0, if the lock will be passed to another @@ -841,14 +773,12 @@ ibool pfs_rw_lock_s_lock_low( return (ret); } -/******************************************************************/ /** - Performance schema instrumented wrap function for rw_lock_sx_lock_nowait() +/** Performance schema instrumented wrap function for rw_lock_sx_lock_nowait() NOTE! Please use the corresponding macro, not directly this function! @return true if success */ UNIV_INLINE ibool pfs_rw_lock_sx_lock_low( - /*====================*/ rw_lock_t *lock, /*!< in: pointer to rw-lock */ ulint pass, /*!< in: pass value; != 0, if the lock will be passed to another @@ -879,13 +809,11 @@ ibool pfs_rw_lock_sx_lock_low( return (ret); } -/******************************************************************/ /** - Performance schema instrumented wrap function for rw_lock_x_unlock_func() +/** Performance schema instrumented wrap function for rw_lock_x_unlock_func() NOTE! Please use the corresponding macro rw_lock_x_unlock(), not directly this function! */ UNIV_INLINE void pfs_rw_lock_x_unlock_func( -/*======================*/ #ifdef UNIV_DEBUG ulint pass, /*!< in: pass value; != 0, if the lock may have been passed to another @@ -905,13 +833,11 @@ void pfs_rw_lock_x_unlock_func( lock); } -/******************************************************************/ /** - Performance schema instrumented wrap function for rw_lock_sx_unlock_func() +/** Performance schema instrumented wrap function for rw_lock_sx_unlock_func() NOTE! Please use the corresponding macro rw_lock_sx_unlock(), not directly this function! */ UNIV_INLINE void pfs_rw_lock_sx_unlock_func( -/*======================*/ #ifdef UNIV_DEBUG ulint pass, /*!< in: pass value; != 0, if the lock may have been passed to another @@ -931,13 +857,11 @@ void pfs_rw_lock_sx_unlock_func( lock); } -/******************************************************************/ /** - Performance schema instrumented wrap function for rw_lock_s_unlock_func() +/** Performance schema instrumented wrap function for rw_lock_s_unlock_func() NOTE! Please use the corresponding macro pfs_rw_lock_s_unlock(), not directly this function! */ ALWAYS_INLINE void pfs_rw_lock_s_unlock_func( -/*======================*/ #ifdef UNIV_DEBUG ulint pass, /*!< in: pass value; != 0, if the lock may have been passed to another diff --git a/storage/innobase/include/sync0sync.h b/storage/innobase/include/sync0sync.h index 30e7fca089d7..78bc48805979 100644 --- a/storage/innobase/include/sync0sync.h +++ b/storage/innobase/include/sync0sync.h @@ -32,8 +32,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/sync0sync.h +/** @file include/sync0sync.h Mutex, the basic synchronization primitive Created 9/5/1995 Heikki Tuuri diff --git a/storage/innobase/include/sync0types.h b/storage/innobase/include/sync0types.h index 6effdc84b841..8aca5c4950c4 100644 --- a/storage/innobase/include/sync0types.h +++ b/storage/innobase/include/sync0types.h @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/sync0types.h +/** @file include/sync0types.h Global types for sync Created 9/5/1995 Heikki Tuuri diff --git a/storage/innobase/include/trx0i_s.h b/storage/innobase/include/trx0i_s.h index 92f14df20315..f67b34924d74 100644 --- a/storage/innobase/include/trx0i_s.h +++ b/storage/innobase/include/trx0i_s.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/trx0i_s.h +/** @file include/trx0i_s.h INFORMATION SCHEMA innodb_trx, innodb_locks and innodb_lock_waits tables cache structures and public functions. @@ -167,87 +166,56 @@ INFORMATION SCHEMA tables is fetched and later retrieved by the C++ code in handler/i_s.cc. */ extern trx_i_s_cache_t *trx_i_s_cache; -/*******************************************************************/ /** - Initialize INFORMATION SCHEMA trx related cache. */ -void trx_i_s_cache_init( - /*===============*/ - trx_i_s_cache_t *cache); /*!< out: cache to init */ -/*******************************************************************/ /** - Free the INFORMATION SCHEMA trx related cache. */ -void trx_i_s_cache_free( - /*===============*/ - trx_i_s_cache_t *cache); /*!< in/out: cache to free */ - -/*******************************************************************/ /** - Issue a shared/read lock on the tables cache. */ -void trx_i_s_cache_start_read( - /*=====================*/ - trx_i_s_cache_t *cache); /*!< in: cache */ - -/*******************************************************************/ /** - Release a shared/read lock on the tables cache. */ -void trx_i_s_cache_end_read( - /*===================*/ - trx_i_s_cache_t *cache); /*!< in: cache */ - -/*******************************************************************/ /** - Issue an exclusive/write lock on the tables cache. */ -void trx_i_s_cache_start_write( - /*======================*/ - trx_i_s_cache_t *cache); /*!< in: cache */ - -/*******************************************************************/ /** - Release an exclusive/write lock on the tables cache. */ -void trx_i_s_cache_end_write( - /*====================*/ - trx_i_s_cache_t *cache); /*!< in: cache */ - -/*******************************************************************/ /** - Retrieves the number of used rows in the cache for a given +/** Initialize INFORMATION SCHEMA trx related cache. */ +void trx_i_s_cache_init(trx_i_s_cache_t *cache); /*!< out: cache to init */ +/** Free the INFORMATION SCHEMA trx related cache. */ +void trx_i_s_cache_free(trx_i_s_cache_t *cache); /*!< in/out: cache to free */ + +/** Issue a shared/read lock on the tables cache. */ +void trx_i_s_cache_start_read(trx_i_s_cache_t *cache); /*!< in: cache */ + +/** Release a shared/read lock on the tables cache. */ +void trx_i_s_cache_end_read(trx_i_s_cache_t *cache); /*!< in: cache */ + +/** Issue an exclusive/write lock on the tables cache. */ +void trx_i_s_cache_start_write(trx_i_s_cache_t *cache); /*!< in: cache */ + +/** Release an exclusive/write lock on the tables cache. */ +void trx_i_s_cache_end_write(trx_i_s_cache_t *cache); /*!< in: cache */ + +/** Retrieves the number of used rows in the cache for a given INFORMATION SCHEMA table. @return number of rows */ -ulint trx_i_s_cache_get_rows_used( - /*========================*/ - trx_i_s_cache_t *cache, /*!< in: cache */ - enum i_s_table table); /*!< in: which table */ +ulint trx_i_s_cache_get_rows_used(trx_i_s_cache_t *cache, /*!< in: cache */ + enum i_s_table table); /*!< in: which table */ -/*******************************************************************/ /** - Retrieves the nth row in the cache for a given INFORMATION SCHEMA +/** Retrieves the nth row in the cache for a given INFORMATION SCHEMA table. @return row */ -void *trx_i_s_cache_get_nth_row( - /*======================*/ - trx_i_s_cache_t *cache, /*!< in: cache */ - enum i_s_table table, /*!< in: which table */ - ulint n); /*!< in: row number */ - -/*******************************************************************/ /** - Update the transactions cache if it has not been read for some time. +void *trx_i_s_cache_get_nth_row(trx_i_s_cache_t *cache, /*!< in: cache */ + enum i_s_table table, /*!< in: which table */ + ulint n); /*!< in: row number */ + +/** Update the transactions cache if it has not been read for some time. @return 0 - fetched, 1 - not */ int trx_i_s_possibly_fetch_data_into_cache( - /*===================================*/ trx_i_s_cache_t *cache); /*!< in/out: cache */ -/*******************************************************************/ /** - Returns TRUE if the data in the cache is truncated due to the memory +/** Returns TRUE if the data in the cache is truncated due to the memory limit posed by TRX_I_S_MEM_LIMIT. @return true if truncated */ -ibool trx_i_s_cache_is_truncated( - /*=======================*/ - trx_i_s_cache_t *cache); /*!< in: cache */ +ibool trx_i_s_cache_is_truncated(trx_i_s_cache_t *cache); /*!< in: cache */ /** The maximum length of a resulting lock_id_size in trx_i_s_create_lock_id(), not including the terminating NUL. ":%lu:%lu:%lu" -> 63 chars */ #define TRX_I_S_LOCK_ID_MAX_LEN (TRX_ID_MAX_LEN + 63) -/*******************************************************************/ /** - Crafts a lock id string from a i_s_locks_row_t object. Returns its +/** Crafts a lock id string from a i_s_locks_row_t object. Returns its second argument. This function aborts if there is not enough space in lock_id. Be sure to provide at least TRX_I_S_LOCK_ID_MAX_LEN + 1 if you want to be 100% sure that it will not abort. @return resulting lock id */ char *trx_i_s_create_lock_id( - /*===================*/ const i_s_locks_row_t *row, /*!< in: innodb_locks row */ char *lock_id, /*!< out: resulting lock_id */ ulint lock_id_size); /*!< in: size of the lock id diff --git a/storage/innobase/include/trx0purge.h b/storage/innobase/include/trx0purge.h index 9c72a0c3b83c..9500504fd4a8 100644 --- a/storage/innobase/include/trx0purge.h +++ b/storage/innobase/include/trx0purge.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/trx0purge.h +/** @file include/trx0purge.h Purge old versions Created 3/26/1996 Heikki Tuuri @@ -50,31 +49,24 @@ this program; if not, write to the Free Software Foundation, Inc., /** The global data structure coordinating a purge */ extern trx_purge_t *purge_sys; -/********************************************************************/ /** - Calculates the file address of an undo log header when we have the file +/** Calculates the file address of an undo log header when we have the file address of its history list node. @return file address of the log */ UNIV_INLINE fil_addr_t trx_purge_get_log_from_hist( - /*========================*/ fil_addr_t node_addr); /*!< in: file address of the history list node of the log */ -/********************************************************************/ /** - Creates the global purge system control structure and inits the history +/** Creates the global purge system control structure and inits the history mutex. */ void trx_purge_sys_create( - /*=================*/ ulint n_purge_threads, /*!< in: number of purge threads */ purge_pq_t *purge_queue); /*!< in/own: UNDO log min binary heap*/ -/********************************************************************/ /** - Frees the global purge system control structure. */ +/** Frees the global purge system control structure. */ void trx_purge_sys_close(void); -/*======================*/ /************************************************************************ Adds the update undo log as the first log in the history list. Removes the update undo log segment from the rseg slot if it is too big for reuse. */ void trx_purge_add_update_undo_to_history( - /*=================================*/ trx_t *trx, /*!< in: transaction */ trx_undo_ptr_t *undo_ptr, /*!< in: update undo log. */ page_t *undo_page, /*!< in: update undo log header page, @@ -84,24 +76,17 @@ void trx_purge_add_update_undo_to_history( len else skip updating it. */ ulint n_added_logs, /*!< in: number of logs added */ mtr_t *mtr); /*!< in: mtr */ -/*******************************************************************/ /** - This function runs a purge batch. +/** This function runs a purge batch. @return number of undo log pages handled in the batch */ -ulint trx_purge( - /*======*/ - ulint n_purge_threads, /*!< in: number of purge tasks to - submit to task queue. */ - ulint limit, /*!< in: the maximum number of - records to purge in one batch */ - bool truncate); /*!< in: truncate history if true */ -/*******************************************************************/ /** - Stop purge and wait for it to stop, move to PURGE_STATE_STOP. */ +ulint trx_purge(ulint n_purge_threads, /*!< in: number of purge tasks to + submit to task queue. */ + ulint limit, /*!< in: the maximum number of + records to purge in one batch */ + bool truncate); /*!< in: truncate history if true */ +/** Stop purge and wait for it to stop, move to PURGE_STATE_STOP. */ void trx_purge_stop(void); -/*================*/ -/*******************************************************************/ /** - Resume purge, move to PURGE_STATE_RUN. */ +/** Resume purge, move to PURGE_STATE_RUN. */ void trx_purge_run(void); -/*================*/ /** Purge states */ enum purge_state_t { @@ -112,11 +97,9 @@ enum purge_state_t { PURGE_STATE_DISABLED /*!< Purge was never started */ }; -/*******************************************************************/ /** - Get the purge state. +/** Get the purge state. @return purge state. */ purge_state_t trx_purge_state(void); -/*=================*/ // Forward declaration struct TrxUndoRsegsIterator; diff --git a/storage/innobase/include/trx0purge.ic b/storage/innobase/include/trx0purge.ic index c47414016e21..bd115fe2e7bd 100644 --- a/storage/innobase/include/trx0purge.ic +++ b/storage/innobase/include/trx0purge.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/trx0purge.ic +/** @file include/trx0purge.ic Purge old versions Created 3/26/1996 Heikki Tuuri @@ -33,13 +32,11 @@ this program; if not, write to the Free Software Foundation, Inc., #include "trx0undo.h" -/********************************************************************/ /** - Calculates the file address of an undo log header when we have the file +/** Calculates the file address of an undo log header when we have the file address of its history list node. @return file address of the log */ UNIV_INLINE fil_addr_t trx_purge_get_log_from_hist( - /*========================*/ fil_addr_t node_addr) /*!< in: file address of the history list node of the log */ { @@ -48,13 +45,10 @@ fil_addr_t trx_purge_get_log_from_hist( return (node_addr); } -/********************************************************************/ /** - address of its history list node. +/** address of its history list node. @return true if purge_sys_t::limit <= purge_sys_t::iter */ UNIV_INLINE -bool trx_purge_check_limit(void) -/*=======================*/ -{ +bool trx_purge_check_limit(void) { /* limit is used to track till what point purge element has been processed and so limit <= iter. undo_no ordering is enforced only within the same rollback segment. diff --git a/storage/innobase/include/trx0rec.h b/storage/innobase/include/trx0rec.h index 526b03c97f23..61ab576582a5 100644 --- a/storage/innobase/include/trx0rec.h +++ b/storage/innobase/include/trx0rec.h @@ -26,8 +26,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "my_compiler.h" -/**************************************************/ /** - @file include/trx0rec.h +/** @file include/trx0rec.h Transaction undo log record Created 3/26/1996 Heikki Tuuri @@ -57,45 +56,34 @@ UNIV_INLINE trx_undo_rec_t *trx_undo_rec_copy(const trx_undo_rec_t *undo_rec, mem_heap_t *heap); -/**********************************************************************/ /** - Reads the undo log record type. +/** Reads the undo log record type. @return record type */ UNIV_INLINE ulint trx_undo_rec_get_type( - /*==================*/ const trx_undo_rec_t *undo_rec); /*!< in: undo log record */ -/**********************************************************************/ /** - Reads from an undo log record the record compiler info. +/** Reads from an undo log record the record compiler info. @return compiler info */ UNIV_INLINE ulint trx_undo_rec_get_cmpl_info( - /*=======================*/ const trx_undo_rec_t *undo_rec); /*!< in: undo log record */ -/**********************************************************************/ /** - Returns TRUE if an undo log record contains an extern storage field. +/** Returns TRUE if an undo log record contains an extern storage field. @return true if extern */ UNIV_INLINE ibool trx_undo_rec_get_extern_storage( - /*============================*/ const trx_undo_rec_t *undo_rec); /*!< in: undo log record */ -/**********************************************************************/ /** - Reads the undo log record number. +/** Reads the undo log record number. @return undo no */ UNIV_INLINE undo_no_t trx_undo_rec_get_undo_no( - /*=====================*/ const trx_undo_rec_t *undo_rec); /*!< in: undo log record */ -/**********************************************************************/ /** - Returns the start of the undo record data area. */ +/** Returns the start of the undo record data area. */ #define trx_undo_rec_get_ptr(undo_rec, undo_no) \ ((undo_rec) + trx_undo_rec_get_offset(undo_no)) -/**********************************************************************/ /** - Reads from an undo log record the general parameters. +/** Reads from an undo log record the general parameters. @return remaining part of undo log record after reading these values */ byte *trx_undo_rec_get_pars( - /*==================*/ trx_undo_rec_t *undo_rec, /*!< in: undo log record */ ulint *type, /*!< out: undo record type: TRX_UNDO_INSERT_REC, ... */ @@ -112,11 +100,9 @@ byte *trx_undo_rec_get_pars( table_id_t trx_undo_rec_get_table_id(const trx_undo_rec_t *undo_rec) MY_ATTRIBUTE((warn_unused_result)); -/*******************************************************************/ /** - Builds a row reference from an undo log record. +/** Builds a row reference from an undo log record. @return pointer to remaining part of undo record */ byte *trx_undo_rec_get_row_ref( - /*=====================*/ byte *ptr, /*!< in: remaining part of a copy of an undo log record, at the start of the row reference; NOTE that this copy of the undo log record must @@ -127,24 +113,20 @@ byte *trx_undo_rec_get_row_ref( dtuple_t **ref, /*!< out, own: row reference */ mem_heap_t *heap); /*!< in: memory heap from which the memory needed is allocated */ -/**********************************************************************/ /** - Reads from an undo log update record the system field values of the old +/** Reads from an undo log update record the system field values of the old version. @return remaining part of undo log record after reading these values */ byte *trx_undo_update_rec_get_sys_cols( - /*=============================*/ const byte *ptr, /*!< in: remaining part of undo log record after reading general parameters */ trx_id_t *trx_id, /*!< out: trx id */ roll_ptr_t *roll_ptr, /*!< out: roll ptr */ ulint *info_bits); /*!< out: info bits state */ -/*******************************************************************/ /** - Builds an update vector based on a remaining part of an undo log record. +/** Builds an update vector based on a remaining part of an undo log record. @return remaining part of the record, NULL if an error detected, which means that the record is corrupted */ byte *trx_undo_update_rec_get_update( - /*===========================*/ const byte *ptr, /*!< in: remaining part in update undo log record, after reading the row reference NOTE that this copy of the undo log record must @@ -164,13 +146,11 @@ byte *trx_undo_update_rec_get_update( mem_heap_t *heap, /*!< in: memory heap from which the memory needed is allocated */ upd_t **upd); /*!< out, own: update vector */ -/*******************************************************************/ /** - Builds a partial row from an update undo log record, for purge. +/** Builds a partial row from an update undo log record, for purge. It contains the columns which occur as ordering in any index of the table. Any missing columns are indicated by col->mtype == DATA_MISSING. @return pointer to remaining part of undo record */ byte *trx_undo_rec_get_partial_row( - /*=========================*/ const byte *ptr, /*!< in: remaining part in update undo log record of a suitable type, at the start of the stored index columns; @@ -186,14 +166,12 @@ byte *trx_undo_rec_get_partial_row( mem_heap_t *heap) /*!< in: memory heap from which the memory needed is allocated */ MY_ATTRIBUTE((warn_unused_result)); -/***********************************************************************/ /** - Writes information to an undo log about an insert, update, or a delete marking - of a clustered index record. This information is used in a rollback of the - transaction and in consistent reads that must look to the history of this +/** Writes information to an undo log about an insert, update, or a delete + marking of a clustered index record. This information is used in a rollback of + the transaction and in consistent reads that must look to the history of this transaction. @return DB_SUCCESS or error code */ dberr_t trx_undo_report_row_operation( - /*==========================*/ ulint flags, /*!< in: if BTR_NO_UNDO_LOG_FLAG bit is set, does nothing */ ulint op_type, /*!< in: TRX_UNDO_INSERT_OP or @@ -259,23 +237,17 @@ bool trx_undo_prev_version_build(const rec_t *index_rec, mtr_t *index_mtr, const dtuple_t **vrow, ulint v_status); #endif /* !UNIV_HOTBACKUP */ -/***********************************************************/ /** - Parses a redo log record of adding an undo log record. +/** Parses a redo log record of adding an undo log record. @return end of log record or NULL */ -byte *trx_undo_parse_add_undo_rec( - /*========================*/ - byte *ptr, /*!< in: buffer */ - byte *end_ptr, /*!< in: buffer end */ - page_t *page); /*!< in: page or NULL */ -/***********************************************************/ /** - Parses a redo log record of erasing of an undo page end. +byte *trx_undo_parse_add_undo_rec(byte *ptr, /*!< in: buffer */ + byte *end_ptr, /*!< in: buffer end */ + page_t *page); /*!< in: page or NULL */ +/** Parses a redo log record of erasing of an undo page end. @return end of log record or NULL */ -byte *trx_undo_parse_erase_page_end( - /*==========================*/ - byte *ptr, /*!< in: buffer */ - byte *end_ptr, /*!< in: buffer end */ - page_t *page, /*!< in: page or NULL */ - mtr_t *mtr); /*!< in: mtr or NULL */ +byte *trx_undo_parse_erase_page_end(byte *ptr, /*!< in: buffer */ + byte *end_ptr, /*!< in: buffer end */ + page_t *page, /*!< in: page or NULL */ + mtr_t *mtr); /*!< in: mtr or NULL */ /** Read from an undo log record a non-virtual column value. @param[in,out] ptr pointer to remaining part of the undo record diff --git a/storage/innobase/include/trx0rec.ic b/storage/innobase/include/trx0rec.ic index 82dab2736f1f..049a8240487b 100644 --- a/storage/innobase/include/trx0rec.ic +++ b/storage/innobase/include/trx0rec.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,42 +24,35 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/trx0rec.ic +/** @file include/trx0rec.ic Transaction undo log record Created 3/26/1996 Heikki Tuuri *******************************************************/ #ifndef UNIV_HOTBACKUP -/**********************************************************************/ /** - Reads from an undo log record the record type. +/** Reads from an undo log record the record type. @return record type */ UNIV_INLINE ulint trx_undo_rec_get_type( - /*==================*/ const trx_undo_rec_t *undo_rec) /*!< in: undo log record */ { return (mach_read_from_1(undo_rec + 2) & (TRX_UNDO_CMPL_INFO_MULT - 1)); } -/**********************************************************************/ /** - Reads from an undo log record the record compiler info. +/** Reads from an undo log record the record compiler info. @return compiler info */ UNIV_INLINE ulint trx_undo_rec_get_cmpl_info( - /*=======================*/ const trx_undo_rec_t *undo_rec) /*!< in: undo log record */ { return (mach_read_from_1(undo_rec + 2) / TRX_UNDO_CMPL_INFO_MULT); } -/**********************************************************************/ /** - Returns TRUE if an undo log record contains an extern storage field. +/** Returns TRUE if an undo log record contains an extern storage field. @return true if extern */ UNIV_INLINE ibool trx_undo_rec_get_extern_storage( - /*============================*/ const trx_undo_rec_t *undo_rec) /*!< in: undo log record */ { if (mach_read_from_1(undo_rec + 2) & TRX_UNDO_UPD_EXTERN) { @@ -69,12 +62,10 @@ ibool trx_undo_rec_get_extern_storage( return (FALSE); } -/**********************************************************************/ /** - Reads the undo log record number. +/** Reads the undo log record number. @return undo no */ UNIV_INLINE undo_no_t trx_undo_rec_get_undo_no( - /*=====================*/ const trx_undo_rec_t *undo_rec) /*!< in: undo log record */ { const byte *ptr; @@ -84,12 +75,10 @@ undo_no_t trx_undo_rec_get_undo_no( return (mach_u64_read_much_compressed(ptr)); } -/***********************************************************************/ /** - Copies the undo record to the heap. +/** Copies the undo record to the heap. @return own: copy of undo log record */ UNIV_INLINE trx_undo_rec_t *trx_undo_rec_copy( - /*==============*/ const trx_undo_rec_t *undo_rec, /*!< in: undo log record */ mem_heap_t *heap) /*!< in: heap where copied */ { diff --git a/storage/innobase/include/trx0roll.h b/storage/innobase/include/trx0roll.h index 1fd047c4fe3f..8a4e8bb75256 100644 --- a/storage/innobase/include/trx0roll.h +++ b/storage/innobase/include/trx0roll.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/trx0roll.h +/** @file include/trx0roll.h Transaction rollback Created 3/26/1996 Heikki Tuuri @@ -46,39 +45,29 @@ this program; if not, write to the Free Software Foundation, Inc., extern bool trx_rollback_or_clean_is_active; -/*******************************************************************/ /** - Determines if this transaction is rolling back an incomplete transaction +/** Determines if this transaction is rolling back an incomplete transaction in crash recovery. @return true if trx is an incomplete transaction that is being rolled back in crash recovery */ -ibool trx_is_recv( - /*========*/ - const trx_t *trx); /*!< in: transaction */ -/*******************************************************************/ /** - Returns a transaction savepoint taken at this point in time. +ibool trx_is_recv(const trx_t *trx); /*!< in: transaction */ +/** Returns a transaction savepoint taken at this point in time. @return savepoint */ -trx_savept_t trx_savept_take( - /*============*/ - trx_t *trx); /*!< in: transaction */ +trx_savept_t trx_savept_take(trx_t *trx); /*!< in: transaction */ -/********************************************************************/ /** - Get next undo log record from redo and noredo rollback segments. +/** Get next undo log record from redo and noredo rollback segments. @return undo log record copied to heap, NULL if none left, or if the undo number of the top record would be less than the limit */ trx_undo_rec_t *trx_roll_pop_top_rec_of_trx( - /*========================*/ trx_t *trx, /*!< in: transaction */ undo_no_t limit, /*!< in: least undo number we need */ roll_ptr_t *roll_ptr, /*!< out: roll pointer to undo record */ mem_heap_t *heap); /*!< in: memory heap where copied */ -/*******************************************************************/ /** - Rollback or clean up any incomplete transactions which were +/** Rollback or clean up any incomplete transactions which were encountered in crash recovery. If the transaction already was committed, then we clean up a possible insert undo log. If the transaction was not yet committed, then we roll it back. */ void trx_rollback_or_clean_recovered( - /*============================*/ ibool all); /*!< in: FALSE=roll back dictionary transactions; TRUE=roll back all non-PREPARED transactions */ @@ -89,41 +78,28 @@ transaction was not yet committed, then we roll it back. Note: this is done in a background thread. */ void trx_recovery_rollback_thread(); -/*********************************************************************/ /** - Creates a rollback command node struct. +/** Creates a rollback command node struct. @return own: rollback node struct */ roll_node_t *roll_node_create( - /*=============*/ mem_heap_t *heap); /*!< in: mem heap where created */ -/***********************************************************/ /** - Performs an execution step for a rollback command node in a query graph. +/** Performs an execution step for a rollback command node in a query graph. @return query thread to run next, or NULL */ -que_thr_t *trx_rollback_step( - /*==============*/ - que_thr_t *thr); /*!< in: query thread */ -/*******************************************************************/ /** - Rollback a transaction used in MySQL. +que_thr_t *trx_rollback_step(que_thr_t *thr); /*!< in: query thread */ +/** Rollback a transaction used in MySQL. @return error code or DB_SUCCESS */ -dberr_t trx_rollback_for_mysql( - /*===================*/ - trx_t *trx); /*!< in/out: transaction */ -/*******************************************************************/ /** - Rollback the latest SQL statement for MySQL. +dberr_t trx_rollback_for_mysql(trx_t *trx); /*!< in/out: transaction */ +/** Rollback the latest SQL statement for MySQL. @return error code or DB_SUCCESS */ dberr_t trx_rollback_last_sql_stat_for_mysql( - /*=================================*/ trx_t *trx); /*!< in/out: transaction */ -/*******************************************************************/ /** - Rollback a transaction to a given savepoint or do a complete rollback. +/** Rollback a transaction to a given savepoint or do a complete rollback. @return error code or DB_SUCCESS */ dberr_t trx_rollback_to_savepoint( - /*======================*/ trx_t *trx, /*!< in: transaction handle */ trx_savept_t *savept); /*!< in: pointer to savepoint undo number, if partial rollback requested, or NULL for complete rollback */ -/*******************************************************************/ /** - Rolls back a transaction back to a named savepoint. Modifications after the +/** Rolls back a transaction back to a named savepoint. Modifications after the savepoint are undone but InnoDB does NOT release the corresponding locks which are stored in memory. If a lock is 'implicit', that is, a new inserted row holds a lock where the lock information is carried by the trx id stored in @@ -132,7 +108,6 @@ dberr_t trx_rollback_to_savepoint( @return if no savepoint of the name found then DB_NO_SAVEPOINT, otherwise DB_SUCCESS */ dberr_t trx_rollback_to_savepoint_for_mysql( - /*================================*/ trx_t *trx, /*!< in: transaction handle */ const char *savepoint_name, /*!< in: savepoint name */ int64_t *mysql_binlog_cache_pos) /*!< out: the MySQL binlog cache @@ -142,34 +117,28 @@ dberr_t trx_rollback_to_savepoint_for_mysql( binlog entries of the queries executed after the savepoint */ MY_ATTRIBUTE((warn_unused_result)); -/*******************************************************************/ /** - Creates a named savepoint. If the transaction is not yet started, starts it. +/** Creates a named savepoint. If the transaction is not yet started, starts it. If there is already a savepoint of the same name, this call erases that old savepoint and replaces it with a new. Savepoints are deleted in a transaction commit or rollback. @return always DB_SUCCESS */ dberr_t trx_savepoint_for_mysql( - /*====================*/ trx_t *trx, /*!< in: transaction handle */ const char *savepoint_name, /*!< in: savepoint name */ int64_t binlog_cache_pos); /*!< in: MySQL binlog cache position corresponding to this connection at the time of the savepoint */ -/*******************************************************************/ /** - Releases a named savepoint. Savepoints which +/** Releases a named savepoint. Savepoints which were set after this savepoint are deleted. @return if no savepoint of the name found then DB_NO_SAVEPOINT, otherwise DB_SUCCESS */ dberr_t trx_release_savepoint_for_mysql( - /*============================*/ trx_t *trx, /*!< in: transaction handle */ const char *savepoint_name) /*!< in: savepoint name */ MY_ATTRIBUTE((warn_unused_result)); -/*******************************************************************/ /** - Frees savepoint structs starting from savep. */ +/** Frees savepoint structs starting from savep. */ void trx_roll_savepoints_free( - /*=====================*/ trx_t *trx, /*!< in: transaction handle */ trx_named_savept_t *savep); /*!< in: free all savepoints > this one; if this is NULL, free all savepoints diff --git a/storage/innobase/include/trx0roll.ic b/storage/innobase/include/trx0roll.ic index 5ae8909f5a75..854bda45d21a 100644 --- a/storage/innobase/include/trx0roll.ic +++ b/storage/innobase/include/trx0roll.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,21 +24,18 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/trx0roll.ic +/** @file include/trx0roll.ic Transaction rollback Created 3/26/1996 Heikki Tuuri *******************************************************/ #ifdef UNIV_DEBUG -/*******************************************************************/ /** - Check if undo numbering is maintained while processing undo records +/** Check if undo numbering is maintained while processing undo records for rollback. @return true if undo numbering is maintained. */ UNIV_INLINE bool trx_roll_check_undo_rec_ordering( - /*=============================*/ undo_no_t curr_undo_rec_no, /*!< in: record number of undo record to process. */ space_id_t curr_undo_space_id, /*!< in: space-id of rollback diff --git a/storage/innobase/include/trx0rseg.h b/storage/innobase/include/trx0rseg.h index ebfe19c386d5..231c329ed39e 100644 --- a/storage/innobase/include/trx0rseg.h +++ b/storage/innobase/include/trx0rseg.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/trx0rseg.h +/** @file include/trx0rseg.h Rollback segment Created 3/26/1996 Heikki Tuuri diff --git a/storage/innobase/include/trx0rseg.ic b/storage/innobase/include/trx0rseg.ic index 0937a3fbe7d5..3ae1a460a0a9 100644 --- a/storage/innobase/include/trx0rseg.ic +++ b/storage/innobase/include/trx0rseg.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/trx0rseg.ic +/** @file include/trx0rseg.ic Rollback segment Created 3/26/1996 Heikki Tuuri @@ -78,12 +77,10 @@ trx_rsegf_t *trx_rsegf_get_new(space_id_t space, page_no_t page_no, return (header); } -/***************************************************************/ /** - Gets the file page number of the nth undo log slot. +/** Gets the file page number of the nth undo log slot. @return page number of the undo log segment */ UNIV_INLINE page_no_t trx_rsegf_get_nth_undo( - /*===================*/ trx_rsegf_t *rsegf, /*!< in: rollback segment header */ ulint n, /*!< in: index of slot */ mtr_t *mtr) /*!< in: mtr */ @@ -94,11 +91,9 @@ page_no_t trx_rsegf_get_nth_undo( MLOG_4BYTES, mtr)); } -/***************************************************************/ /** - Sets the file page number of the nth undo log slot. */ +/** Sets the file page number of the nth undo log slot. */ UNIV_INLINE void trx_rsegf_set_nth_undo( - /*===================*/ trx_rsegf_t *rsegf, /*!< in: rollback segment header */ ulint n, /*!< in: index of slot */ page_no_t page_no, /*!< in: page number of the undo log segment */ @@ -110,12 +105,10 @@ void trx_rsegf_set_nth_undo( page_no, MLOG_4BYTES, mtr); } -/****************************************************************/ /** - Looks for a free slot for an undo log segment. +/** Looks for a free slot for an undo log segment. @return slot index or ULINT_UNDEFINED if not found */ UNIV_INLINE ulint trx_rsegf_undo_find_free( - /*=====================*/ trx_rsegf_t *rsegf, /*!< in: rollback segment header */ mtr_t *mtr) /*!< in: mtr */ { diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index bd68828cb803..2910adefc1f3 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/trx0sys.h +/** @file include/trx0sys.h Transaction system Created 3/26/1996 Heikki Tuuri @@ -66,20 +65,14 @@ extern trx_sys_t *trx_sys; UNIV_INLINE bool trx_sys_hdr_page(const page_id_t &page_id); -/*****************************************************************/ /** - Creates and initializes the central memory structures for the transaction +/** Creates and initializes the central memory structures for the transaction system. This is called when the database is started. @return min binary heap of rsegs to purge */ purge_pq_t *trx_sys_init_at_db_start(void); -/*==========================*/ -/*****************************************************************/ /** - Creates the trx_sys instance and initializes purge_queue and mutex. */ +/** Creates the trx_sys instance and initializes purge_queue and mutex. */ void trx_sys_create(void); -/*================*/ -/*****************************************************************/ /** - Creates and initializes the transaction system at the database creation. */ +/** Creates and initializes the transaction system at the database creation. */ void trx_sys_create_sys_pages(void); -/*==========================*/ /** Find the page number in the TRX_SYS page for a given slot/rseg_id @param[in] rseg_id slot number in the TRX_SYS page rseg array @@ -91,13 +84,10 @@ page_no_t trx_sysf_rseg_find_page_no(ulint rseg_id); @return slot index or ULINT_UNDEFINED if not found */ ulint trx_sysf_rseg_find_free(mtr_t *mtr); -/**********************************************************************/ /** - Gets a pointer to the transaction system file copy and x-locks its page. +/** Gets a pointer to the transaction system file copy and x-locks its page. @return pointer to system file copy, page x-locked */ UNIV_INLINE -trx_sysf_t *trx_sysf_get( - /*=========*/ - mtr_t *mtr); /*!< in: mtr */ +trx_sysf_t *trx_sysf_get(mtr_t *mtr); /*!< in: mtr */ /** Gets the space of the nth rollback segment slot in the trx system file copy. @@ -139,19 +129,15 @@ UNIV_INLINE void trx_sysf_rseg_set_page_no(trx_sysf_t *sys_header, ulint i, page_no_t page_no, mtr_t *mtr); -/*****************************************************************/ /** - Allocates a new transaction id. +/** Allocates a new transaction id. @return new, allocated trx id */ UNIV_INLINE trx_id_t trx_sys_get_new_trx_id(); -/*===================*/ -/*****************************************************************/ /** - Determines the maximum transaction id. +/** Determines the maximum transaction id. @return maximum currently allocated trx id; will be stale after the next call to trx_sys_get_new_trx_id() */ UNIV_INLINE trx_id_t trx_sys_get_max_trx_id(void); -/*========================*/ #ifdef UNIV_DEBUG /* Flag to control TRX_RSEG_N_SLOTS behavior debugging. */ @@ -167,32 +153,25 @@ UNIV_INLINE void trx_write_trx_id(byte *ptr, trx_id_t id); #ifndef UNIV_HOTBACKUP -/*****************************************************************/ /** - Reads a trx id from an index page. In case that the id size changes in +/** Reads a trx id from an index page. In case that the id size changes in some future version, this function should be used instead of mach_read_... @return id */ UNIV_INLINE trx_id_t trx_read_trx_id( - /*============*/ const byte *ptr); /*!< in: pointer to memory from where to read */ -/****************************************************************/ /** - Looks for the trx instance with the given id in the rw trx_list. +/** Looks for the trx instance with the given id in the rw trx_list. @return the trx handle or NULL if not found */ UNIV_INLINE -trx_t *trx_get_rw_trx_by_id( - /*=================*/ - trx_id_t trx_id); /*!< in: trx id to search for */ -/****************************************************************/ /** - Returns the minimum trx id in rw trx list. This is the smallest id for which +trx_t *trx_get_rw_trx_by_id(trx_id_t trx_id); /*!< in: trx id to search for */ +/** Returns the minimum trx id in rw trx list. This is the smallest id for which the trx can possibly be active. (But, you must look at the trx->state to find out if the minimum trx id transaction itself is active, or already committed.) @return the minimum trx id, or trx_sys->max_trx_id if the trx list is empty */ UNIV_INLINE trx_id_t trx_rw_min_trx_id(void); -/*===================*/ /** Checks if a rw transaction with the given id is active. @param[in] trx_id trx id of the transaction @@ -213,36 +192,27 @@ UNIV_INLINE trx_t *trx_rw_is_active(trx_id_t trx_id, ibool *corrupt, bool do_ref_count); #if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG -/***********************************************************/ /** - Assert that a transaction has been recovered. +/** Assert that a transaction has been recovered. @return true */ UNIV_INLINE -ibool trx_assert_recovered( - /*=================*/ - trx_id_t trx_id) /*!< in: transaction identifier */ +ibool trx_assert_recovered(trx_id_t trx_id) /*!< in: transaction identifier */ MY_ATTRIBUTE((warn_unused_result)); #endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */ -/*****************************************************************/ /** - Updates the offset information about the end of the MySQL binlog entry +/** Updates the offset information about the end of the MySQL binlog entry which corresponds to the transaction just being committed. In a MySQL replication slave updates the latest master binlog position up to which replication has proceeded. */ void trx_sys_update_mysql_binlog_offset( - /*===============================*/ const char *file_name, /*!< in: MySQL log file name */ int64_t offset, /*!< in: position in that log file */ ulint field, /*!< in: offset of the MySQL log info field in the trx sys header */ mtr_t *mtr); /*!< in: mtr */ -/*****************************************************************/ /** - Prints to stderr the MySQL binlog offset info in the trx system header if +/** Prints to stderr the MySQL binlog offset info in the trx system header if the magic number shows it valid. */ void trx_sys_print_mysql_binlog_offset(void); -/*===================================*/ -/*****************************************************************/ /** - Shutdown/Close the transaction system. */ +/** Shutdown/Close the transaction system. */ void trx_sys_close(void); -/*===============*/ /** Determine if there are incomplete transactions in the system. @return whether incomplete transactions need rollback */ @@ -253,13 +223,10 @@ bool trx_sys_need_rollback(); Check if there are any active (non-prepared) transactions. @return total number of active transactions or 0 if none */ ulint trx_sys_any_active_transactions(void); -/*=================================*/ #else /* !UNIV_HOTBACKUP */ -/*****************************************************************/ /** - Prints to stderr the MySQL binlog info in the system header if the +/** Prints to stderr the MySQL binlog info in the system header if the magic number shows it valid. */ void trx_sys_print_mysql_binlog_offset_from_page( - /*========================================*/ const byte *page); /*!< in: buffer containing the trx system header page, i.e., page number TRX_SYS_PAGE_NO in the tablespace */ @@ -271,11 +238,9 @@ UNIV_INLINE void trx_sys_rw_trx_add(trx_t *trx); #ifdef UNIV_DEBUG -/*************************************************************/ /** - Validate the trx_sys_t::rw_trx_list. +/** Validate the trx_sys_t::rw_trx_list. @return true if the list is valid */ bool trx_sys_validate_trx_list(); -/*========================*/ #endif /* UNIV_DEBUG */ /** Initialize trx_sys_undo_spaces, called once during srv_start(). */ diff --git a/storage/innobase/include/trx0sys.ic b/storage/innobase/include/trx0sys.ic index 85af35d9afa6..b473e201bcc6 100644 --- a/storage/innobase/include/trx0sys.ic +++ b/storage/innobase/include/trx0sys.ic @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/trx0sys.ic +/** @file include/trx0sys.ic Transaction system Created 3/26/1996 Heikki Tuuri @@ -55,10 +54,8 @@ typedef byte trx_sysf_rseg_t; /* Size of a rollback segment specification slot */ #define TRX_SYS_RSEG_SLOT_SIZE 8 -/*****************************************************************/ /** - Writes the value of max_trx_id to the file based trx system header. */ +/** Writes the value of max_trx_id to the file based trx system header. */ void trx_sys_flush_max_trx_id(void); -/*==========================*/ /** Checks if a page address is the trx sys header page. @param[in] page_id page id @@ -69,13 +66,10 @@ bool trx_sys_hdr_page(const page_id_t &page_id) { page_id.page_no() == TRX_SYS_PAGE_NO); } -/**********************************************************************/ /** - Gets a pointer to the transaction system header and x-latches its page. +/** Gets a pointer to the transaction system header and x-latches its page. @return pointer to system header, page x-latched. */ UNIV_INLINE -trx_sysf_t *trx_sysf_get( - /*=========*/ - mtr_t *mtr) /*!< in: mtr */ +trx_sysf_t *trx_sysf_get(mtr_t *mtr) /*!< in: mtr */ { buf_block_t *block; trx_sysf_t *header; @@ -91,13 +85,11 @@ trx_sysf_t *trx_sysf_get( return (header); } -/*****************************************************************/ /** - Gets the space of the nth rollback segment slot in the trx system +/** Gets the space of the nth rollback segment slot in the trx system file copy. @return space id */ UNIV_INLINE space_id_t trx_sysf_rseg_get_space( - /*====================*/ trx_sysf_t *sys_header, /*!< in: trx sys header */ ulint slot, /*!< in: slot index == rseg id */ mtr_t *mtr) /*!< in: mtr */ @@ -110,13 +102,11 @@ space_id_t trx_sysf_rseg_get_space( MLOG_4BYTES, mtr)); } -/*****************************************************************/ /** - Gets the page number of the nth rollback segment slot in the trx system +/** Gets the page number of the nth rollback segment slot in the trx system header. @return page number, FIL_NULL if slot unused */ UNIV_INLINE page_no_t trx_sysf_rseg_get_page_no( - /*======================*/ trx_sysf_t *sys_header, /*!< in: trx system header */ ulint slot, /*!< in: slot index == rseg id */ mtr_t *mtr) /*!< in: mtr */ @@ -130,12 +120,10 @@ page_no_t trx_sysf_rseg_get_page_no( MLOG_4BYTES, mtr)); } -/*****************************************************************/ /** - Sets the space id of the nth rollback segment slot in the trx system +/** Sets the space id of the nth rollback segment slot in the trx system file copy. */ UNIV_INLINE void trx_sysf_rseg_set_space( - /*====================*/ trx_sysf_t *sys_header, /*!< in: trx sys file copy */ ulint slot, /*!< in: slot index == rseg id */ space_id_t space, /*!< in: space id */ @@ -149,12 +137,10 @@ void trx_sysf_rseg_set_space( space, MLOG_4BYTES, mtr); } -/*****************************************************************/ /** - Sets the page number of the nth rollback segment slot in the trx system +/** Sets the page number of the nth rollback segment slot in the trx system header. */ UNIV_INLINE void trx_sysf_rseg_set_page_no( - /*======================*/ trx_sysf_t *sys_header, /*!< in: trx sys header */ ulint slot, /*!< in: slot index == rseg id */ page_no_t page_no, /*!< in: page number, FIL_NULL if the @@ -170,15 +156,12 @@ void trx_sysf_rseg_set_page_no( } #endif /* !UNIV_HOTBACKUP */ -/*****************************************************************/ /** - Writes a trx id to an index page. In case that the id size changes in +/** Writes a trx id to an index page. In case that the id size changes in some future version, this function should be used instead of mach_write_... */ UNIV_INLINE -void trx_write_trx_id( - /*=============*/ - byte *ptr, /*!< in: pointer to memory where written */ - trx_id_t id) /*!< in: id */ +void trx_write_trx_id(byte *ptr, /*!< in: pointer to memory where written */ + trx_id_t id) /*!< in: id */ { #if DATA_TRX_ID_LEN != 6 #error "DATA_TRX_ID_LEN != 6" @@ -188,14 +171,12 @@ void trx_write_trx_id( } #ifndef UNIV_HOTBACKUP -/*****************************************************************/ /** - Reads a trx id from an index page. In case that the id size changes in +/** Reads a trx id from an index page. In case that the id size changes in some future version, this function should be used instead of mach_read_... @return id */ UNIV_INLINE trx_id_t trx_read_trx_id( - /*============*/ const byte *ptr) /*!< in: pointer to memory from where to read */ { #if DATA_TRX_ID_LEN != 6 @@ -204,16 +185,13 @@ trx_id_t trx_read_trx_id( return (mach_read_from_6(ptr)); } -/****************************************************************/ /** - Looks for the trx handle with the given id in rw_trx_list. +/** Looks for the trx handle with the given id in rw_trx_list. The caller must be holding trx_sys->mutex. @return the trx handle or NULL if not found; the pointer must not be dereferenced unless lock_sys->mutex was acquired before calling this function and is still being held */ UNIV_INLINE -trx_t *trx_get_rw_trx_by_id( - /*=================*/ - trx_id_t trx_id) /*!< in: trx id to search for */ +trx_t *trx_get_rw_trx_by_id(trx_id_t trx_id) /*!< in: trx id to search for */ { ut_ad(trx_id > 0); ut_ad(trx_sys_mutex_own()); @@ -229,16 +207,13 @@ trx_t *trx_get_rw_trx_by_id( return (it == trx_sys->rw_trx_set.end() ? NULL : it->m_trx); } -/****************************************************************/ /** - Returns the minimum trx id in trx list. This is the smallest id for which +/** Returns the minimum trx id in trx list. This is the smallest id for which the trx can possibly be active. (But, you must look at the trx->state to find out if the minimum trx id transaction itself is active, or already committed.). The caller must be holding the trx_sys_t::mutex in shared mode. @return the minimum trx id, or trx_sys->max_trx_id if the trx list is empty */ UNIV_INLINE -trx_id_t trx_rw_min_trx_id_low(void) -/*=======================*/ -{ +trx_id_t trx_rw_min_trx_id_low(void) { trx_id_t id; ut_ad(trx_sys_mutex_own()); @@ -256,13 +231,10 @@ trx_id_t trx_rw_min_trx_id_low(void) } #if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG -/***********************************************************/ /** - Assert that a transaction has been recovered. +/** Assert that a transaction has been recovered. @return true */ UNIV_INLINE -ibool trx_assert_recovered( - /*=================*/ - trx_id_t trx_id) /*!< in: transaction identifier */ +ibool trx_assert_recovered(trx_id_t trx_id) /*!< in: transaction identifier */ { const trx_t *trx; @@ -277,16 +249,13 @@ ibool trx_assert_recovered( } #endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */ -/****************************************************************/ /** - Returns the minimum trx id in rw trx list. This is the smallest id for which +/** Returns the minimum trx id in rw trx list. This is the smallest id for which the rw trx can possibly be active. (But, you must look at the trx->state to find out if the minimum trx id transaction itself is active, or already committed.) @return the minimum trx id, or trx_sys->max_trx_id if rw trx list is empty */ UNIV_INLINE -trx_id_t trx_rw_min_trx_id(void) -/*===================*/ -{ +trx_id_t trx_rw_min_trx_id(void) { trx_sys_mutex_enter(); trx_id_t id = trx_rw_min_trx_id_low(); @@ -296,13 +265,11 @@ trx_id_t trx_rw_min_trx_id(void) return (id); } -/****************************************************************/ /** - Checks if a rw transaction with the given id is active. If the caller is +/** Checks if a rw transaction with the given id is active. If the caller is not holding lock_sys->mutex, the transaction may already have been committed. @return transaction instance if active, or NULL */ UNIV_INLINE trx_t *trx_rw_is_active_low( - /*=================*/ trx_id_t trx_id, /*!< in: trx id of the transaction */ ibool *corrupt) /*!< in: NULL or pointer to a flag that will be set if corrupt */ @@ -332,19 +299,16 @@ trx_t *trx_rw_is_active_low( return (trx); } -/****************************************************************/ /** - Checks if a rw transaction with the given id is active. If the caller is +/** Checks if a rw transaction with the given id is active. If the caller is not holding lock_sys->mutex, the transaction may already have been committed. @return transaction instance if active, or NULL; */ UNIV_INLINE -trx_t *trx_rw_is_active( - /*=============*/ - trx_id_t trx_id, /*!< in: trx id of the transaction */ - ibool *corrupt, /*!< in: NULL or pointer to a flag - that will be set if corrupt */ - bool do_ref_count) /*!< in: if true then increment the - trx_t::n_ref_count */ +trx_t *trx_rw_is_active(trx_id_t trx_id, /*!< in: trx id of the transaction */ + ibool *corrupt, /*!< in: NULL or pointer to a flag + that will be set if corrupt */ + bool do_ref_count) /*!< in: if true then increment the + trx_t::n_ref_count */ { trx_t *trx; @@ -367,13 +331,10 @@ trx_t *trx_rw_is_active( return (trx); } -/*****************************************************************/ /** - Allocates a new transaction id. +/** Allocates a new transaction id. @return new, allocated trx id */ UNIV_INLINE -trx_id_t trx_sys_get_new_trx_id() -/*====================*/ -{ +trx_id_t trx_sys_get_new_trx_id() { ut_ad(trx_sys_mutex_own()); /* VERY important: after the database is started, max_trx_id value is @@ -390,14 +351,11 @@ trx_id_t trx_sys_get_new_trx_id() return (trx_sys->max_trx_id++); } -/*****************************************************************/ /** - Determines the maximum transaction id. +/** Determines the maximum transaction id. @return maximum currently allocated trx id; will be stale after the next call to trx_sys_get_new_trx_id() */ UNIV_INLINE -trx_id_t trx_sys_get_max_trx_id(void) -/*========================*/ -{ +trx_id_t trx_sys_get_max_trx_id(void) { ut_ad(!trx_sys_mutex_own()); #if UNIV_WORD_SIZE < DATA_TRX_ID_LEN diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index 8fa0368e03fb..9c2a0cc97889 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/trx0trx.h +/** @file include/trx0trx.h The transaction Created 3/26/1996 Heikki Tuuri @@ -74,36 +73,24 @@ extern sess_t *trx_dummy_sess; @param[in] observer flush observer */ void trx_set_flush_observer(trx_t *trx, FlushObserver *observer); -/******************************************************************/ /** - Set detailed error message for the transaction. */ -void trx_set_detailed_error( - /*===================*/ - trx_t *trx, /*!< in: transaction struct */ - const char *msg); /*!< in: detailed error message */ -/*************************************************************/ /** - Set detailed error message for the transaction from a file. Note that the +/** Set detailed error message for the transaction. */ +void trx_set_detailed_error(trx_t *trx, /*!< in: transaction struct */ + const char *msg); /*!< in: detailed error message */ +/** Set detailed error message for the transaction from a file. Note that the file is rewinded before reading from it. */ void trx_set_detailed_error_from_file( - /*=============================*/ trx_t *trx, /*!< in: transaction struct */ FILE *file); /*!< in: file to read message from */ -/****************************************************************/ /** - Retrieves the error_info field from a trx. +/** Retrieves the error_info field from a trx. @return the error info */ UNIV_INLINE -const dict_index_t *trx_get_error_info( - /*===============*/ - const trx_t *trx); /*!< in: trx object */ -/********************************************************************/ /** - Creates a transaction object for MySQL. +const dict_index_t *trx_get_error_info(const trx_t *trx); /*!< in: trx object */ +/** Creates a transaction object for MySQL. @return own: transaction object */ trx_t *trx_allocate_for_mysql(void); -/*========================*/ -/********************************************************************/ /** - Creates a transaction object for background operations by the master thread. +/** Creates a transaction object for background operations by the master thread. @return own: transaction object */ trx_t *trx_allocate_for_background(void); -/*=============================*/ /** Resurrect table locks for resurrected transactions. */ void trx_resurrect_locks(); @@ -116,11 +103,8 @@ void trx_free_resurrected(trx_t *trx); @param[in,out] trx transaction object to free */ void trx_free_for_background(trx_t *trx); -/********************************************************************/ /** - At shutdown, frees a transaction object that is in the PREPARED state. */ -void trx_free_prepared( - /*==============*/ - trx_t *trx); /*!< in, own: trx object */ +/** At shutdown, frees a transaction object that is in the PREPARED state. */ +void trx_free_prepared(trx_t *trx); /*!< in, own: trx object */ /** Free a transaction object for MySQL. @param[in,out] trx transaction */ @@ -134,33 +118,24 @@ void trx_disconnect_plain(trx_t *trx); @param[in,out] trx transaction */ void trx_disconnect_prepared(trx_t *trx); -/****************************************************************/ /** - Creates trx objects for transactions and initializes the trx list of +/** Creates trx objects for transactions and initializes the trx list of trx_sys at database start. Rollback segment and undo log lists must already exist when this function is called, because the lists of transactions to be rolled back or cleaned up are built based on the undo log lists. */ void trx_lists_init_at_db_start(void); -/*============================*/ -/*************************************************************/ /** - Starts the transaction if it is not yet started. */ +/** Starts the transaction if it is not yet started. */ void trx_start_if_not_started_xa_low( - /*============================*/ trx_t *trx, /*!< in/out: transaction */ bool read_write); /*!< in: true if read write transaction */ -/*************************************************************/ /** - Starts the transaction if it is not yet started. */ +/** Starts the transaction if it is not yet started. */ void trx_start_if_not_started_low( - /*=========================*/ trx_t *trx, /*!< in/out: transaction */ bool read_write); /*!< in: true if read write transaction */ -/*************************************************************/ /** - Starts a transaction for internal processing. */ -void trx_start_internal_low( - /*===================*/ - trx_t *trx); /*!< in/out: transaction */ +/** Starts a transaction for internal processing. */ +void trx_start_internal_low(trx_t *trx); /*!< in/out: transaction */ /** Starts a read-only transaction for internal processing. @param[in,out] trx transaction to be started */ @@ -205,32 +180,21 @@ void trx_start_internal_read_only_low(trx_t *trx); trx_start_if_not_started_xa_low((t), (rw)) #endif /* UNIV_DEBUG */ -/****************************************************************/ /** - Commits a transaction. */ -void trx_commit( - /*=======*/ - trx_t *trx); /*!< in/out: transaction */ +/** Commits a transaction. */ +void trx_commit(trx_t *trx); /*!< in/out: transaction */ -/****************************************************************/ /** - Commits a transaction and a mini-transaction. */ +/** Commits a transaction and a mini-transaction. */ void trx_commit_low( - /*===========*/ trx_t *trx, /*!< in/out: transaction */ mtr_t *mtr); /*!< in/out: mini-transaction (will be committed), or NULL if trx made no modifications */ -/****************************************************************/ /** - Cleans up a transaction at database startup. The cleanup is needed if +/** Cleans up a transaction at database startup. The cleanup is needed if the transaction already got to the middle of a commit when the database crashed, and we cannot roll it back. */ -void trx_cleanup_at_db_startup( - /*======================*/ - trx_t *trx); /*!< in: transaction */ -/**********************************************************************/ /** - Does the transaction commit for MySQL. +void trx_cleanup_at_db_startup(trx_t *trx); /*!< in: transaction */ +/** Does the transaction commit for MySQL. @return DB_SUCCESS or error number */ -dberr_t trx_commit_for_mysql( - /*=================*/ - trx_t *trx); /*!< in/out: transaction */ +dberr_t trx_commit_for_mysql(trx_t *trx); /*!< in/out: transaction */ /** Does the transaction prepare for MySQL. @@ -238,120 +202,82 @@ Does the transaction prepare for MySQL. dberr_t trx_prepare_for_mysql(trx_t *trx); -/**********************************************************************/ /** - This function is used to find number of prepared transactions and +/** This function is used to find number of prepared transactions and their transaction objects for a recovery. @return number of prepared transactions */ -int trx_recover_for_mysql( - /*==================*/ - XID *xid_list, /*!< in/out: prepared transactions */ - ulint len); /*!< in: number of slots in xid_list */ -/*******************************************************************/ /** - This function is used to find one X/Open XA distributed transaction +int trx_recover_for_mysql(XID *xid_list, /*!< in/out: prepared transactions */ + ulint len); /*!< in: number of slots in xid_list */ +/** This function is used to find one X/Open XA distributed transaction which is in the prepared state @return trx or NULL; on match, the trx->xid will be invalidated; note that the trx may have been committed, unless the caller is holding lock_sys->mutex */ trx_t *trx_get_trx_by_xid( - /*===============*/ const XID *xid); /*!< in: X/Open XA transaction identifier */ -/**********************************************************************/ /** - If required, flushes the log to disk if we called trx_commit_for_mysql() +/** If required, flushes the log to disk if we called trx_commit_for_mysql() with trx->flush_log_later == TRUE. */ -void trx_commit_complete_for_mysql( - /*==========================*/ - trx_t *trx); /*!< in/out: transaction */ -/**********************************************************************/ /** - Marks the latest SQL statement ended. */ -void trx_mark_sql_stat_end( - /*==================*/ - trx_t *trx); /*!< in: trx handle */ -/********************************************************************/ /** - Assigns a read view for a consistent read query. All the consistent reads +void trx_commit_complete_for_mysql(trx_t *trx); /*!< in/out: transaction */ +/** Marks the latest SQL statement ended. */ +void trx_mark_sql_stat_end(trx_t *trx); /*!< in: trx handle */ +/** Assigns a read view for a consistent read query. All the consistent reads within the same transaction will get the same read view, which is created when this function is first called for a new started transaction. */ -ReadView *trx_assign_read_view( - /*=================*/ - trx_t *trx); /*!< in: active transaction */ +ReadView *trx_assign_read_view(trx_t *trx); /*!< in: active transaction */ -/****************************************************************/ /** - @return the transaction's read view or NULL if one not assigned. */ +/** @return the transaction's read view or NULL if one not assigned. */ UNIV_INLINE -ReadView *trx_get_read_view( - /*==============*/ - trx_t *trx); +ReadView *trx_get_read_view(trx_t *trx); -/****************************************************************/ /** - @return the transaction's read view or NULL if one not assigned. */ +/** @return the transaction's read view or NULL if one not assigned. */ UNIV_INLINE -const ReadView *trx_get_read_view( - /*==============*/ - const trx_t *trx); - -/****************************************************************/ /** - Prepares a transaction for commit/rollback. */ -void trx_commit_or_rollback_prepare( - /*===========================*/ - trx_t *trx); /*!< in/out: transaction */ -/*********************************************************************/ /** - Creates a commit command node struct. +const ReadView *trx_get_read_view(const trx_t *trx); + +/** Prepares a transaction for commit/rollback. */ +void trx_commit_or_rollback_prepare(trx_t *trx); /*!< in/out: transaction */ +/** Creates a commit command node struct. @return own: commit node struct */ commit_node_t *trx_commit_node_create( - /*===================*/ mem_heap_t *heap); /*!< in: mem heap where created */ -/***********************************************************/ /** - Performs an execution step for a commit type node in a query graph. +/** Performs an execution step for a commit type node in a query graph. @return query thread to run next, or NULL */ -que_thr_t *trx_commit_step( - /*============*/ - que_thr_t *thr); /*!< in: query thread */ +que_thr_t *trx_commit_step(que_thr_t *thr); /*!< in: query thread */ -/**********************************************************************/ /** - Prints info about a transaction. +/** Prints info about a transaction. Caller must hold trx_sys->mutex. */ -void trx_print_low( - /*==========*/ - FILE *f, - /*!< in: output stream */ - const trx_t *trx, - /*!< in: transaction */ - ulint max_query_len, - /*!< in: max query length to print, - or 0 to use the default max length */ - ulint n_rec_locks, - /*!< in: lock_number_of_rows_locked(&trx->lock) */ - ulint n_trx_locks, - /*!< in: length of trx->lock.trx_locks */ - ulint heap_size); +void trx_print_low(FILE *f, + /*!< in: output stream */ + const trx_t *trx, + /*!< in: transaction */ + ulint max_query_len, + /*!< in: max query length to print, + or 0 to use the default max length */ + ulint n_rec_locks, + /*!< in: lock_number_of_rows_locked(&trx->lock) */ + ulint n_trx_locks, + /*!< in: length of trx->lock.trx_locks */ + ulint heap_size); /*!< in: mem_heap_get_size(trx->lock.lock_heap) */ -/**********************************************************************/ /** - Prints info about a transaction. +/** Prints info about a transaction. The caller must hold lock_sys->mutex and trx_sys->mutex. When possible, use trx_print() instead. */ void trx_print_latched( - /*==============*/ FILE *f, /*!< in: output stream */ const trx_t *trx, /*!< in: transaction */ ulint max_query_len); /*!< in: max query length to print, or 0 to use the default max length */ -/**********************************************************************/ /** - Prints info about a transaction. +/** Prints info about a transaction. Acquires and releases lock_sys->mutex and trx_sys->mutex. */ -void trx_print( - /*======*/ - FILE *f, /*!< in: output stream */ - const trx_t *trx, /*!< in: transaction */ - ulint max_query_len); /*!< in: max query length to print, - or 0 to use the default max length */ +void trx_print(FILE *f, /*!< in: output stream */ + const trx_t *trx, /*!< in: transaction */ + ulint max_query_len); /*!< in: max query length to print, + or 0 to use the default max length */ -/**********************************************************************/ /** - Determine if a transaction is a dictionary operation. +/** Determine if a transaction is a dictionary operation. @return dictionary operation mode */ UNIV_INLINE enum trx_dict_op_t trx_get_dict_operation( - /*===================*/ const trx_t *trx) /*!< in: transaction */ MY_ATTRIBUTE((warn_unused_result)); @@ -361,70 +287,51 @@ enum trx_dict_op_t trx_get_dict_operation( UNIV_INLINE void trx_set_dict_operation(trx_t *trx, enum trx_dict_op_t op); -/**********************************************************************/ /** - Determines if a transaction is in the given state. +/** Determines if a transaction is in the given state. The caller must hold trx_sys->mutex, or it must be the thread that is serving a running transaction. A running RW transaction must be in trx_sys->rw_trx_list. @return true if trx->state == state */ UNIV_INLINE -bool trx_state_eq( - /*=========*/ - const trx_t *trx, /*!< in: transaction */ - trx_state_t state) /*!< in: state */ +bool trx_state_eq(const trx_t *trx, /*!< in: transaction */ + trx_state_t state) /*!< in: state */ MY_ATTRIBUTE((warn_unused_result)); #ifdef UNIV_DEBUG -/**********************************************************************/ /** - Asserts that a transaction has been started. +/** Asserts that a transaction has been started. The caller must hold trx_sys->mutex. @return true if started */ -ibool trx_assert_started( - /*===============*/ - const trx_t *trx) /*!< in: transaction */ +ibool trx_assert_started(const trx_t *trx) /*!< in: transaction */ MY_ATTRIBUTE((warn_unused_result)); #endif /* UNIV_DEBUG */ -/**********************************************************************/ /** - Determines if the currently running transaction has been interrupted. +/** Determines if the currently running transaction has been interrupted. @return true if interrupted */ -ibool trx_is_interrupted( - /*===============*/ - const trx_t *trx); /*!< in: transaction */ -/**********************************************************************/ /** - Determines if the currently running transaction is in strict mode. +ibool trx_is_interrupted(const trx_t *trx); /*!< in: transaction */ +/** Determines if the currently running transaction is in strict mode. @return true if strict */ -ibool trx_is_strict( - /*==========*/ - trx_t *trx); /*!< in: transaction */ +ibool trx_is_strict(trx_t *trx); /*!< in: transaction */ -/*******************************************************************/ /** - Calculates the "weight" of a transaction. The weight of one transaction +/** Calculates the "weight" of a transaction. The weight of one transaction is estimated as the number of altered rows + the number of locked rows. @param t transaction @return transaction weight */ #define TRX_WEIGHT(t) ((t)->undo_no + UT_LIST_GET_LEN((t)->lock.trx_locks)) -/*******************************************************************/ /** - Compares the "weight" (or size) of two transactions. Transactions that +/** Compares the "weight" (or size) of two transactions. Transactions that have edited non-transactional tables are considered heavier than ones that have not. @return true if weight(a) >= weight(b) */ -bool trx_weight_ge( - /*==========*/ - const trx_t *a, /*!< in: the transaction to be compared */ - const trx_t *b); /*!< in: the transaction to be compared */ +bool trx_weight_ge(const trx_t *a, /*!< in: the transaction to be compared */ + const trx_t *b); /*!< in: the transaction to be compared */ /* Maximum length of a string that can be returned by trx_get_que_state_str(). */ #define TRX_QUE_STATE_STR_MAX_LEN 12 /* "ROLLING BACK" */ -/*******************************************************************/ /** - Retrieves transaction's que state in a human readable string. The string +/** Retrieves transaction's que state in a human readable string. The string should not be free()'d or modified. @return string in the data segment */ UNIV_INLINE -const char *trx_get_que_state_str( - /*==================*/ - const trx_t *trx); /*!< in: transaction */ +const char *trx_get_que_state_str(const trx_t *trx); /*!< in: transaction */ /** Retreieves the transaction ID. In a given point in time it is guaranteed that IDs of the running @@ -576,8 +483,7 @@ transaction pool. } while (0) #ifdef UNIV_DEBUG -/*******************************************************************/ /** - Assert that an autocommit non-locking select cannot be in the +/** Assert that an autocommit non-locking select cannot be in the rw_trx_list and that it is a read-only transaction. The tranasction must be in the mysql_trx_list. */ #define assert_trx_nonlocking_or_in_list(t) \ @@ -596,8 +502,7 @@ transaction pool. } \ } while (0) #else /* UNIV_DEBUG */ -/*******************************************************************/ /** - Assert that an autocommit non-locking slect cannot be in the +/** Assert that an autocommit non-locking slect cannot be in the rw_trx_list and that it is a read-only transaction. The tranasction must be in the mysql_trx_list. */ #define assert_trx_nonlocking_or_in_list(trx) ((void)0) @@ -606,8 +511,7 @@ transaction pool. typedef std::vector> lock_pool_t; -/*******************************************************************/ /** - Latching protocol for trx_lock_t::que_state. trx_lock_t::que_state +/** Latching protocol for trx_lock_t::que_state. trx_lock_t::que_state captures the state of the query thread during the execution of a query. This is different from a transaction state. The query state of a transaction can be updated asynchronously by other threads. The other threads can be diff --git a/storage/innobase/include/trx0trx.ic b/storage/innobase/include/trx0trx.ic index 95996256c469..be855448a1c8 100644 --- a/storage/innobase/include/trx0trx.ic +++ b/storage/innobase/include/trx0trx.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/trx0trx.ic +/** @file include/trx0trx.ic The transaction Created 3/26/1996 Heikki Tuuri @@ -33,17 +32,14 @@ this program; if not, write to the Free Software Foundation, Inc., #include "read0read.h" -/**********************************************************************/ /** - Determines if a transaction is in the given state. +/** Determines if a transaction is in the given state. The caller must hold trx_sys->mutex, or it must be the thread that is serving a running transaction. A running RW transaction must be in trx_sys->rw_trx_list. @return true if trx->state == state */ UNIV_INLINE -bool trx_state_eq( - /*=========*/ - const trx_t *trx, /*!< in: transaction */ - trx_state_t state) /*!< in: state */ +bool trx_state_eq(const trx_t *trx, /*!< in: transaction */ + trx_state_t state) /*!< in: state */ { #ifdef UNIV_DEBUG switch (trx->state) { @@ -78,25 +74,19 @@ bool trx_state_eq( return (trx->state == state); } -/****************************************************************/ /** - Retrieves the error_info field from a trx. +/** Retrieves the error_info field from a trx. @return the error info */ UNIV_INLINE -const dict_index_t *trx_get_error_info( - /*===============*/ - const trx_t *trx) /*!< in: trx object */ +const dict_index_t *trx_get_error_info(const trx_t *trx) /*!< in: trx object */ { return (trx->error_info); } -/*******************************************************************/ /** - Retrieves transaction's que state in a human readable string. The string +/** Retrieves transaction's que state in a human readable string. The string should not be free()'d or modified. @return string in the data segment */ UNIV_INLINE -const char *trx_get_que_state_str( - /*==================*/ - const trx_t *trx) /*!< in: transaction */ +const char *trx_get_que_state_str(const trx_t *trx) /*!< in: transaction */ { /* be sure to adjust TRX_QUE_STATE_STR_MAX_LEN if you change this */ switch (trx->lock.que_state) { @@ -147,12 +137,10 @@ trx_id_t trx_get_id_for_print(const trx_t *trx) { : reinterpret_cast(trx) | (max_trx_id + 1)); } -/**********************************************************************/ /** - Determine if a transaction is a dictionary operation. +/** Determine if a transaction is a dictionary operation. @return dictionary operation mode */ UNIV_INLINE enum trx_dict_op_t trx_get_dict_operation( - /*===================*/ const trx_t *trx) /*!< in: transaction */ { trx_dict_op_t op = static_cast(trx->dict_operation); @@ -168,14 +156,11 @@ enum trx_dict_op_t trx_get_dict_operation( #endif /* UNIV_DEBUG */ return (op); } -/**********************************************************************/ /** - Flag a transaction a dictionary operation. */ +/** Flag a transaction a dictionary operation. */ UNIV_INLINE -void trx_set_dict_operation( - /*===================*/ - trx_t *trx, /*!< in/out: transaction */ - enum trx_dict_op_t op) /*!< in: operation, not - TRX_DICT_OP_NONE */ +void trx_set_dict_operation(trx_t *trx, /*!< in/out: transaction */ + enum trx_dict_op_t op) /*!< in: operation, not + TRX_DICT_OP_NONE */ { #ifdef UNIV_DEBUG enum trx_dict_op_t old_op = trx_get_dict_operation(trx); @@ -203,44 +188,32 @@ ok: trx->dict_operation = op; } -/********************************************************************/ /** - Check if redo rseg is modified for insert/update. */ +/** Check if redo rseg is modified for insert/update. */ UNIV_INLINE -bool trx_is_redo_rseg_updated( - /*=====================*/ - const trx_t *trx) /*!< in: transaction */ +bool trx_is_redo_rseg_updated(const trx_t *trx) /*!< in: transaction */ { return (trx->rsegs.m_redo.insert_undo != 0 || trx->rsegs.m_redo.update_undo != 0); } -/********************************************************************/ /** - Check if noredo rseg is modified for insert/update. */ +/** Check if noredo rseg is modified for insert/update. */ UNIV_INLINE -bool trx_is_temp_rseg_updated( - /*=======================*/ - const trx_t *trx) /*!< in: transaction */ +bool trx_is_temp_rseg_updated(const trx_t *trx) /*!< in: transaction */ { return (trx->rsegs.m_noredo.insert_undo != 0 || trx->rsegs.m_noredo.update_undo != 0); } -/********************************************************************/ /** - Check if redo/noredo rseg is modified for insert/update. */ +/** Check if redo/noredo rseg is modified for insert/update. */ UNIV_INLINE -bool trx_is_rseg_updated( - /*================*/ - const trx_t *trx) /*!< in: transaction */ +bool trx_is_rseg_updated(const trx_t *trx) /*!< in: transaction */ { return (trx_is_redo_rseg_updated(trx) || trx_is_temp_rseg_updated(trx)); } -/********************************************************************/ /** - Check if redo/nonredo rseg is valid. */ +/** Check if redo/nonredo rseg is valid. */ UNIV_INLINE -bool trx_is_rseg_assigned( - /*=================*/ - const trx_t *trx) /*!< in: transaction */ +bool trx_is_rseg_assigned(const trx_t *trx) /*!< in: transaction */ { return (trx->rsegs.m_redo.rseg != NULL || trx->rsegs.m_noredo.rseg != NULL); } diff --git a/storage/innobase/include/trx0types.h b/storage/innobase/include/trx0types.h index a66c6c575738..d6352d3cc50c 100644 --- a/storage/innobase/include/trx0types.h +++ b/storage/innobase/include/trx0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/trx0types.h +/** @file include/trx0types.h Transaction system global type definitions Created 3/26/1996 Heikki Tuuri diff --git a/storage/innobase/include/trx0undo.h b/storage/innobase/include/trx0undo.h index 851338db0d90..3e5a6700fe36 100644 --- a/storage/innobase/include/trx0undo.h +++ b/storage/innobase/include/trx0undo.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/trx0undo.h +/** @file include/trx0undo.h Transaction undo log Created 3/26/1996 Heikki Tuuri @@ -43,19 +42,14 @@ this program; if not, write to the Free Software Foundation, Inc., #include "univ.i" #ifndef UNIV_HOTBACKUP -/***********************************************************************/ /** - Returns TRUE if the roll pointer is of the insert type. +/** Returns TRUE if the roll pointer is of the insert type. @return true if insert undo log */ UNIV_INLINE -ibool trx_undo_roll_ptr_is_insert( - /*========================*/ - roll_ptr_t roll_ptr); /*!< in: roll pointer */ -/***********************************************************************/ /** - Returns true if the record is of the insert type. +ibool trx_undo_roll_ptr_is_insert(roll_ptr_t roll_ptr); /*!< in: roll pointer */ +/** Returns true if the record is of the insert type. @return true if the record was freshly inserted (not updated). */ UNIV_INLINE bool trx_undo_trx_id_is_insert( - /*======================*/ const byte *trx_id) /*!< in: DB_TRX_ID, followed by DB_ROLL_PTR */ MY_ATTRIBUTE((warn_unused_result)); #endif /* !UNIV_HOTBACKUP */ @@ -68,14 +62,12 @@ mach_write_... UNIV_INLINE void trx_write_roll_ptr(byte *ptr, roll_ptr_t roll_ptr); -/*****************************************************************/ /** - Reads a roll ptr from an index page. In case that the roll ptr size +/** Reads a roll ptr from an index page. In case that the roll ptr size changes in some future version, this function should be used instead of mach_read_... @return roll ptr */ UNIV_INLINE roll_ptr_t trx_read_roll_ptr( - /*==============*/ const byte *ptr); /*!< in: pointer to memory from where to read */ #ifndef UNIV_HOTBACKUP @@ -137,21 +129,17 @@ UNIV_INLINE trx_undo_rec_t *trx_undo_page_get_first_rec(page_t *undo_page, page_no_t page_no, ulint offset); -/***********************************************************************/ /** - Gets the previous record in an undo log. +/** Gets the previous record in an undo log. @return undo log record, the page s-latched, NULL if none */ trx_undo_rec_t *trx_undo_get_prev_rec( - /*==================*/ trx_undo_rec_t *rec, /*!< in: undo record */ page_no_t page_no, /*!< in: undo log header page number */ ulint offset, /*!< in: undo log header offset on page */ bool shared, /*!< in: true=S-latch, false=X-latch */ mtr_t *mtr); /*!< in: mtr */ -/***********************************************************************/ /** - Gets the next record in an undo log. +/** Gets the next record in an undo log. @return undo log record, the page s-latched, NULL if none */ trx_undo_rec_t *trx_undo_get_next_rec( - /*==================*/ trx_undo_rec_t *rec, /*!< in: undo record */ page_no_t page_no, /*!< in: undo log header page number */ ulint offset, /*!< in: undo log header offset on page */ @@ -172,11 +160,9 @@ trx_undo_rec_t *trx_undo_get_first_rec(trx_id_t *modifier_trx_id, page_no_t page_no, ulint offset, ulint mode, mtr_t *mtr); -/********************************************************************/ /** - Tries to add a page to the undo log segment where the undo log is placed. +/** Tries to add a page to the undo log segment where the undo log is placed. @return X-latched block if success, else NULL */ buf_block_t *trx_undo_add_page( - /*==============*/ trx_t *trx, /*!< in: transaction */ trx_undo_t *undo, /*!< in: undo log memory object */ trx_undo_ptr_t *undo_ptr, /*!< in: assign undo log from @@ -186,11 +172,9 @@ buf_block_t *trx_undo_add_page( the caller must have reserved the rollback segment mutex */ MY_ATTRIBUTE((warn_unused_result)); -/********************************************************************/ /** - Frees the last undo log page. +/** Frees the last undo log page. The caller must hold the rollback segment mutex. */ void trx_undo_free_last_page_func( -/*==========================*/ #ifdef UNIV_DEBUG const trx_t *trx, /*!< in: transaction */ #endif /* UNIV_DEBUG */ @@ -206,11 +190,9 @@ void trx_undo_free_last_page_func( trx_undo_free_last_page_func(undo, mtr) #endif /* UNIV_DEBUG */ -/***********************************************************************/ /** - Truncates an undo log from the end. This function is used during a rollback +/** Truncates an undo log from the end. This function is used during a rollback to free space from an undo log. */ void trx_undo_truncate_end_func( -/*=======================*/ #ifdef UNIV_DEBUG const trx_t *trx, /*!< in: transaction whose undo log it is */ #endif /* UNIV_DEBUG */ @@ -235,33 +217,27 @@ freed, but emptied, if all the records there are below the limit. (everything below the limit will be truncated) */ void trx_undo_truncate_start(trx_rseg_t *rseg, page_no_t hdr_page_no, ulint hdr_offset, undo_no_t limit); -/********************************************************************/ /** - Initializes the undo log lists for a rollback segment memory copy. +/** Initializes the undo log lists for a rollback segment memory copy. This function is only called when the database is started or a new rollback segment created. @return the combined size of undo log segments in pages */ ulint trx_undo_lists_init( - /*================*/ trx_rseg_t *rseg); /*!< in: rollback segment memory object */ -/**********************************************************************/ /** - Assigns an undo log for a transaction. A new undo log is created or a cached +/** Assigns an undo log for a transaction. A new undo log is created or a cached undo log reused. @return DB_SUCCESS if undo log assign successful, possible error codes are: DB_TOO_MANY_CONCURRENT_TRXS DB_OUT_OF_FILE_SPACE DB_READ_ONLY DB_OUT_OF_MEMORY */ dberr_t trx_undo_assign_undo( - /*=================*/ trx_t *trx, /*!< in: transaction */ trx_undo_ptr_t *undo_ptr, /*!< in: assign undo log from referred rollback segment. */ ulint type) /*!< in: TRX_UNDO_INSERT or TRX_UNDO_UPDATE */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************************/ /** - Sets the state of the undo log segment at a transaction finish. +/** Sets the state of the undo log segment at a transaction finish. @return undo log segment header page, x-latched */ page_t *trx_undo_set_state_at_finish( - /*=========================*/ trx_undo_t *undo, /*!< in: undo log memory copy */ mtr_t *mtr); /*!< in: mtr */ @@ -274,12 +250,10 @@ page_t *trx_undo_set_state_at_finish( page_t *trx_undo_set_state_at_prepare(trx_t *trx, trx_undo_t *undo, bool rollback, mtr_t *mtr); -/**********************************************************************/ /** - Adds the update undo log header as the first in the history list, and +/** Adds the update undo log header as the first in the history list, and frees the memory object, or puts it to the list of cached update undo log segments. */ void trx_undo_update_cleanup( - /*====================*/ trx_t *trx, /*!< in: trx owning the update undo log */ trx_undo_ptr_t *undo_ptr, /*!< in: update undo log. */ @@ -298,11 +272,8 @@ the data can be discarded. @param[in] noredo whether the undo tablespace is redo logged */ void trx_undo_insert_cleanup(trx_undo_ptr_t *undo_ptr, bool noredo); -/********************************************************************/ /** - At shutdown, frees the undo logs of a PREPARED transaction. */ -void trx_undo_free_prepared( - /*===================*/ - trx_t *trx) /*!< in/out: PREPARED transaction */ +/** At shutdown, frees the undo logs of a PREPARED transaction. */ +void trx_undo_free_prepared(trx_t *trx) /*!< in/out: PREPARED transaction */ UNIV_COLD; /* Forward declaration. */ @@ -317,15 +288,12 @@ class Truncate; bool trx_undo_truncate_tablespace(undo::Truncate *undo_trunc); #endif /* !UNIV_HOTBACKUP */ -/***********************************************************/ /** - Parses the redo log entry of an undo log page initialization. +/** Parses the redo log entry of an undo log page initialization. @return end of log record or NULL */ -byte *trx_undo_parse_page_init( - /*=====================*/ - const byte *ptr, /*!< in: buffer */ - const byte *end_ptr, /*!< in: buffer end */ - page_t *page, /*!< in: page or NULL */ - mtr_t *mtr); /*!< in: mtr or NULL */ +byte *trx_undo_parse_page_init(const byte *ptr, /*!< in: buffer */ + const byte *end_ptr, /*!< in: buffer end */ + page_t *page, /*!< in: page or NULL */ + mtr_t *mtr); /*!< in: mtr or NULL */ /** Parse the redo log entry of an undo log page header create or reuse. @param[in] type MLOG_UNDO_HDR_CREATE or MLOG_UNDO_HDR_REUSE @param[in] ptr redo log record @@ -337,9 +305,7 @@ byte *trx_undo_parse_page_header(mlog_id_t type, const byte *ptr, const byte *end_ptr, page_t *page, mtr_t *mtr); /************************************************************************ Frees an undo log memory copy. */ -void trx_undo_mem_free( - /*==============*/ - trx_undo_t *undo); /* in: the undo object to be freed */ +void trx_undo_mem_free(trx_undo_t *undo); /* in: the undo object to be freed */ /* Types of an undo log segment */ #define TRX_UNDO_INSERT 1 /* contains undo entries for inserts */ diff --git a/storage/innobase/include/trx0undo.ic b/storage/innobase/include/trx0undo.ic index bda67f74d25e..08362f10418b 100644 --- a/storage/innobase/include/trx0undo.ic +++ b/storage/innobase/include/trx0undo.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/trx0undo.ic +/** @file include/trx0undo.ic Transaction undo log Created 3/26/1996 Heikki Tuuri @@ -61,10 +60,8 @@ inline roll_ptr_t trx_undo_build_roll_ptr(ibool is_insert, space_id_t space_id, return (roll_ptr); } -/***********************************************************************/ /** - Decodes a roll pointer. */ +/** Decodes a roll pointer. */ inline void trx_undo_decode_roll_ptr( - /*=====================*/ roll_ptr_t roll_ptr, /*!< in: roll pointer */ ibool *is_insert, /*!< out: TRUE if insert undo log */ ulint *rseg_id, /*!< out: rollback segment id */ @@ -88,13 +85,10 @@ inline void trx_undo_decode_roll_ptr( *is_insert = (ibool)roll_ptr; /* TRUE==1 */ } -/***********************************************************************/ /** - Returns TRUE if the roll pointer is of the insert type. +/** Returns TRUE if the roll pointer is of the insert type. @return true if insert undo log */ UNIV_INLINE -ibool trx_undo_roll_ptr_is_insert( - /*========================*/ - roll_ptr_t roll_ptr) /*!< in: roll pointer */ +ibool trx_undo_roll_ptr_is_insert(roll_ptr_t roll_ptr) /*!< in: roll pointer */ { #if DATA_ROLL_PTR_LEN != 7 #error "DATA_ROLL_PTR_LEN != 7" @@ -106,12 +100,10 @@ ibool trx_undo_roll_ptr_is_insert( return ((ibool)(roll_ptr >> 55)); } -/***********************************************************************/ /** - Returns true if the record is of the insert type. +/** Returns true if the record is of the insert type. @return true if the record was freshly inserted (not updated). */ UNIV_INLINE bool trx_undo_trx_id_is_insert( - /*======================*/ const byte *trx_id) /*!< in: DB_TRX_ID, followed by DB_ROLL_PTR */ { #if DATA_TRX_ID + 1 != DATA_ROLL_PTR @@ -121,16 +113,13 @@ bool trx_undo_trx_id_is_insert( } #endif /* !UNIV_HOTBACKUP */ -/*****************************************************************/ /** - Writes a roll ptr to an index page. In case that the size changes in +/** Writes a roll ptr to an index page. In case that the size changes in some future version, this function should be used instead of mach_write_... */ UNIV_INLINE -void trx_write_roll_ptr( - /*===============*/ - byte *ptr, /*!< in: pointer to memory where - written */ - roll_ptr_t roll_ptr) /*!< in: roll ptr */ +void trx_write_roll_ptr(byte *ptr, /*!< in: pointer to memory where + written */ + roll_ptr_t roll_ptr) /*!< in: roll ptr */ { #if DATA_ROLL_PTR_LEN != 7 #error "DATA_ROLL_PTR_LEN != 7" @@ -138,14 +127,12 @@ void trx_write_roll_ptr( mach_write_to_7(ptr, roll_ptr); } -/*****************************************************************/ /** - Reads a roll ptr from an index page. In case that the roll ptr size +/** Reads a roll ptr from an index page. In case that the roll ptr size changes in some future version, this function should be used instead of mach_read_... @return roll ptr */ UNIV_INLINE roll_ptr_t trx_read_roll_ptr( - /*==============*/ const byte *ptr) /*!< in: pointer to memory from where to read */ { #if DATA_ROLL_PTR_LEN != 7 @@ -184,13 +171,11 @@ page_t *trx_undo_page_get_s_latched(const page_id_t &page_id, return (buf_block_get_frame(block)); } -/******************************************************************/ /** - Returns the start offset of the undo log records of the specified undo +/** Returns the start offset of the undo log records of the specified undo log on the page. @return start offset */ UNIV_INLINE ulint trx_undo_page_get_start( - /*====================*/ page_t *undo_page, /*!< in: undo log page */ page_no_t page_no, /*!< in: undo log header page number */ ulint offset) /*!< in: undo log header offset on page */ @@ -206,13 +191,11 @@ ulint trx_undo_page_get_start( return (start); } -/******************************************************************/ /** - Returns the end offset of the undo log records of the specified undo +/** Returns the end offset of the undo log records of the specified undo log on the page. @return end offset */ UNIV_INLINE ulint trx_undo_page_get_end( - /*==================*/ page_t *undo_page, /*!< in: undo log page */ page_no_t page_no, /*!< in: undo log header page number */ ulint offset) /*!< in: undo log header offset on page */ @@ -236,13 +219,11 @@ ulint trx_undo_page_get_end( return (end); } -/******************************************************************/ /** - Returns the previous undo record on the page in the specified log, or +/** Returns the previous undo record on the page in the specified log, or NULL if none exists. @return pointer to record, NULL if none */ UNIV_INLINE trx_undo_rec_t *trx_undo_page_get_prev_rec( - /*=======================*/ trx_undo_rec_t *rec, /*!< in: undo log record */ page_no_t page_no, /*!< in: undo log header page number */ ulint offset) /*!< in: undo log header offset on page */ @@ -261,13 +242,11 @@ trx_undo_rec_t *trx_undo_page_get_prev_rec( return (undo_page + mach_read_from_2(rec - 2)); } -/******************************************************************/ /** - Returns the next undo log record on the page in the specified log, or +/** Returns the next undo log record on the page in the specified log, or NULL if none exists. @return pointer to record, NULL if none */ UNIV_INLINE trx_undo_rec_t *trx_undo_page_get_next_rec( - /*=======================*/ trx_undo_rec_t *rec, /*!< in: undo log record */ page_no_t page_no, /*!< in: undo log header page number */ ulint offset) /*!< in: undo log header offset on page */ @@ -289,13 +268,11 @@ trx_undo_rec_t *trx_undo_page_get_next_rec( return (undo_page + next); } -/******************************************************************/ /** - Returns the last undo record on the page in the specified undo log, or +/** Returns the last undo record on the page in the specified undo log, or NULL if none exists. @return pointer to record, NULL if none */ UNIV_INLINE trx_undo_rec_t *trx_undo_page_get_last_rec( - /*=======================*/ page_t *undo_page, /*!< in: undo log page */ page_no_t page_no, /*!< in: undo log header page number */ ulint offset) /*!< in: undo log header offset on page */ @@ -313,13 +290,11 @@ trx_undo_rec_t *trx_undo_page_get_last_rec( return (undo_page + mach_read_from_2(undo_page + end - 2)); } -/******************************************************************/ /** - Returns the first undo record on the page in the specified undo log, or +/** Returns the first undo record on the page in the specified undo log, or NULL if none exists. @return pointer to record, NULL if none */ UNIV_INLINE trx_undo_rec_t *trx_undo_page_get_first_rec( - /*========================*/ page_t *undo_page, /*!< in: undo log page */ page_no_t page_no, /*!< in: undo log header page number */ ulint offset) /*!< in: undo log header offset on page */ diff --git a/storage/innobase/include/usr0sess.h b/storage/innobase/include/usr0sess.h index 3ef02bf1c5b8..49ed984f2daf 100644 --- a/storage/innobase/include/usr0sess.h +++ b/storage/innobase/include/usr0sess.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/usr0sess.h +/** @file include/usr0sess.h Sessions Created 6/25/1996 Heikki Tuuri @@ -43,16 +42,11 @@ this program; if not, write to the Free Software Foundation, Inc., #include "usr0types.h" #include "ut0byte.h" -/*********************************************************************/ /** - Opens a session. +/** Opens a session. @return own: session object */ sess_t *sess_open(void); -/*============*/ -/*********************************************************************/ /** - Closes a session, freeing the memory occupied by it. */ -void sess_close( - /*=======*/ - sess_t *sess); /* in, own: session object */ +/** Closes a session, freeing the memory occupied by it. */ +void sess_close(sess_t *sess); /* in, own: session object */ /* The session handle. This data structure is only used by purge and is not really necessary. We should get rid of it. */ diff --git a/storage/innobase/include/usr0sess.ic b/storage/innobase/include/usr0sess.ic index 41a5ed019a3d..531dc121e2c2 100644 --- a/storage/innobase/include/usr0sess.ic +++ b/storage/innobase/include/usr0sess.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/usr0sess.ic +/** @file include/usr0sess.ic Sessions Created 6/25/1996 Heikki Tuuri diff --git a/storage/innobase/include/usr0types.h b/storage/innobase/include/usr0types.h index c6e8f990a3a7..2384a21b70a4 100644 --- a/storage/innobase/include/usr0types.h +++ b/storage/innobase/include/usr0types.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/usr0types.h +/** @file include/usr0types.h Users and sessions global types Created 6/25/1996 Heikki Tuuri diff --git a/storage/innobase/include/ut0byte.h b/storage/innobase/include/ut0byte.h index e09483d00ef2..0f6dfab33c10 100644 --- a/storage/innobase/include/ut0byte.h +++ b/storage/innobase/include/ut0byte.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/ut0byte.h +/** @file include/ut0byte.h Utilities for byte operations Created 1/20/1994 Heikki Tuuri @@ -36,14 +35,11 @@ this program; if not, write to the Free Software Foundation, Inc., #include "univ.i" -/*******************************************************/ /** - Creates a 64-bit integer out of two 32-bit integers. +/** Creates a 64-bit integer out of two 32-bit integers. @return created integer */ UNIV_INLINE -ib_uint64_t ut_ull_create( - /*==========*/ - ulint high, /*!< in: high-order 32 bits */ - ulint low) /*!< in: low-order 32 bits */ +ib_uint64_t ut_ull_create(ulint high, /*!< in: high-order 32 bits */ + ulint low) /*!< in: low-order 32 bits */ MY_ATTRIBUTE((const)); /** Rounds a 64-bit integer downward to a multiple of a power of 2. @@ -67,25 +63,19 @@ ib_uint64_t ut_uint64_align_up(ib_uint64_t n, ulint align_no); UNIV_INLINE void *ut_align(const void *ptr, ulint align_no); -/*********************************************************/ /** - The following function rounds down a pointer to the nearest +/** The following function rounds down a pointer to the nearest aligned address. @return aligned pointer */ UNIV_INLINE -void *ut_align_down( - /*==========*/ - const void *ptr, /*!< in: pointer */ - ulint align_no) /*!< in: align by this number */ +void *ut_align_down(const void *ptr, /*!< in: pointer */ + ulint align_no) /*!< in: align by this number */ MY_ATTRIBUTE((const)); -/*********************************************************/ /** - The following function computes the offset of a pointer from the nearest +/** The following function computes the offset of a pointer from the nearest aligned address. @return distance from aligned pointer */ UNIV_INLINE -ulint ut_align_offset( - /*============*/ - const void *ptr, /*!< in: pointer */ - ulint align_no) /*!< in: align by this number */ +ulint ut_align_offset(const void *ptr, /*!< in: pointer */ + ulint align_no) /*!< in: align by this number */ MY_ATTRIBUTE((const)); /** Gets the nth bit of a ulint. diff --git a/storage/innobase/include/ut0byte.ic b/storage/innobase/include/ut0byte.ic index 3c6225f9bb35..5042a82dd3c1 100644 --- a/storage/innobase/include/ut0byte.ic +++ b/storage/innobase/include/ut0byte.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,36 +24,29 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************************/ /** - @file include/ut0byte.ic +/** @file include/ut0byte.ic Utilities for byte operations Created 5/30/1994 Heikki Tuuri *******************************************************************/ -/*******************************************************/ /** - Creates a 64-bit integer out of two 32-bit integers. +/** Creates a 64-bit integer out of two 32-bit integers. @return created integer */ UNIV_INLINE -ib_uint64_t ut_ull_create( - /*==========*/ - ulint high, /*!< in: high-order 32 bits */ - ulint low) /*!< in: low-order 32 bits */ +ib_uint64_t ut_ull_create(ulint high, /*!< in: high-order 32 bits */ + ulint low) /*!< in: low-order 32 bits */ { ut_ad(high <= ULINT32_MASK); ut_ad(low <= ULINT32_MASK); return (((ib_uint64_t)high) << 32 | low); } -/********************************************************/ /** - Rounds a 64-bit integer downward to a multiple of a power of 2. +/** Rounds a 64-bit integer downward to a multiple of a power of 2. @return rounded value */ UNIV_INLINE -ib_uint64_t ut_uint64_align_down( - /*=================*/ - ib_uint64_t n, /*!< in: number to be rounded */ - ulint align_no) /*!< in: align by this number - which must be a power of 2 */ +ib_uint64_t ut_uint64_align_down(ib_uint64_t n, /*!< in: number to be rounded */ + ulint align_no) /*!< in: align by this number + which must be a power of 2 */ { ut_ad(align_no > 0); ut_ad(ut_is_2pow(align_no)); @@ -61,15 +54,12 @@ ib_uint64_t ut_uint64_align_down( return (n & ~((ib_uint64_t)align_no - 1)); } -/********************************************************/ /** - Rounds ib_uint64_t upward to a multiple of a power of 2. +/** Rounds ib_uint64_t upward to a multiple of a power of 2. @return rounded value */ UNIV_INLINE -ib_uint64_t ut_uint64_align_up( - /*===============*/ - ib_uint64_t n, /*!< in: number to be rounded */ - ulint align_no) /*!< in: align by this number - which must be a power of 2 */ +ib_uint64_t ut_uint64_align_up(ib_uint64_t n, /*!< in: number to be rounded */ + ulint align_no) /*!< in: align by this number + which must be a power of 2 */ { ib_uint64_t align_1 = (ib_uint64_t)align_no - 1; @@ -79,14 +69,11 @@ ib_uint64_t ut_uint64_align_up( return ((n + align_1) & ~align_1); } -/*********************************************************/ /** - The following function rounds up a pointer to the nearest aligned address. +/** The following function rounds up a pointer to the nearest aligned address. @return aligned pointer */ UNIV_INLINE -void *ut_align( - /*=====*/ - const void *ptr, /*!< in: pointer */ - ulint align_no) /*!< in: align by this number */ +void *ut_align(const void *ptr, /*!< in: pointer */ + ulint align_no) /*!< in: align by this number */ { ut_ad(align_no > 0); ut_ad(((align_no - 1) & align_no) == 0); @@ -97,15 +84,12 @@ void *ut_align( return ((void *)((((ulint)ptr) + align_no - 1) & ~(align_no - 1))); } -/*********************************************************/ /** - The following function rounds down a pointer to the nearest +/** The following function rounds down a pointer to the nearest aligned address. @return aligned pointer */ UNIV_INLINE -void *ut_align_down( - /*==========*/ - const void *ptr, /*!< in: pointer */ - ulint align_no) /*!< in: align by this number */ +void *ut_align_down(const void *ptr, /*!< in: pointer */ + ulint align_no) /*!< in: align by this number */ { ut_ad(align_no > 0); ut_ad(((align_no - 1) & align_no) == 0); @@ -116,15 +100,12 @@ void *ut_align_down( return ((void *)((((ulint)ptr)) & ~(align_no - 1))); } -/*********************************************************/ /** - The following function computes the offset of a pointer from the nearest +/** The following function computes the offset of a pointer from the nearest aligned address. @return distance from aligned pointer */ UNIV_INLINE -ulint ut_align_offset( - /*============*/ - const void *ptr, /*!< in: pointer */ - ulint align_no) /*!< in: align by this number */ +ulint ut_align_offset(const void *ptr, /*!< in: pointer */ + ulint align_no) /*!< in: align by this number */ { ut_ad(align_no > 0); ut_ad(((align_no - 1) & align_no) == 0); @@ -135,14 +116,11 @@ ulint ut_align_offset( return (((ulint)ptr) & (align_no - 1)); } -/*****************************************************************/ /** - Gets the nth bit of a ulint. +/** Gets the nth bit of a ulint. @return true if nth bit is 1; 0th bit is defined to be the least significant */ UNIV_INLINE -ibool ut_bit_get_nth( - /*===========*/ - ulint a, /*!< in: ulint */ - ulint n) /*!< in: nth bit requested */ +ibool ut_bit_get_nth(ulint a, /*!< in: ulint */ + ulint n) /*!< in: nth bit requested */ { ut_ad(n < 8 * sizeof(ulint)); #if TRUE != 1 @@ -151,15 +129,12 @@ ibool ut_bit_get_nth( return (1 & (a >> n)); } -/*****************************************************************/ /** - Sets the nth bit of a ulint. +/** Sets the nth bit of a ulint. @return the ulint with the bit set as requested */ UNIV_INLINE -ulint ut_bit_set_nth( - /*===========*/ - ulint a, /*!< in: ulint */ - ulint n, /*!< in: nth bit requested */ - ibool val) /*!< in: value for the bit to set */ +ulint ut_bit_set_nth(ulint a, /*!< in: ulint */ + ulint n, /*!< in: nth bit requested */ + ibool val) /*!< in: value for the bit to set */ { ut_ad(n < 8 * sizeof(ulint)); #if TRUE != 1 diff --git a/storage/innobase/include/ut0counter.h b/storage/innobase/include/ut0counter.h index 8863f826d463..daeb1c16cc29 100644 --- a/storage/innobase/include/ut0counter.h +++ b/storage/innobase/include/ut0counter.h @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/ut0counter.h +/** @file include/ut0counter.h Counter utility class diff --git a/storage/innobase/include/ut0crc32.h b/storage/innobase/include/ut0crc32.h index 519e0b235d0a..df791affe44b 100644 --- a/storage/innobase/include/ut0crc32.h +++ b/storage/innobase/include/ut0crc32.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/ut0crc32.h +/** @file include/ut0crc32.h CRC32 implementation Created Aug 10, 2011 Vasil Dimov @@ -36,14 +35,11 @@ this program; if not, write to the Free Software Foundation, Inc., #include "univ.i" -/********************************************************************/ /** - Initializes the data structures used by ut_crc32*(). Does not do any +/** Initializes the data structures used by ut_crc32*(). Does not do any allocations, would not hurt if called twice, but would be pointless. */ void ut_crc32_init(); -/*===========*/ -/********************************************************************/ /** - Calculates CRC32. +/** Calculates CRC32. @param ptr - data over which to calculate CRC32. @param len - data length in bytes. @return CRC32 (CRC-32C, using the GF(2) primitive polynomial 0x11EDC6F41, diff --git a/storage/innobase/include/ut0dbg.h b/storage/innobase/include/ut0dbg.h index 893a4128d074..6af486e940e1 100644 --- a/storage/innobase/include/ut0dbg.h +++ b/storage/innobase/include/ut0dbg.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/*****************************************************************/ /** - @file include/ut0dbg.h +/** @file include/ut0dbg.h Debug utilities for Innobase Created 1/30/1994 Heikki Tuuri @@ -38,10 +37,8 @@ this program; if not, write to the Free Software Foundation, Inc., #include "os0thread.h" -/*************************************************************/ /** - Report a failed assertion. */ +/** Report a failed assertion. */ void ut_dbg_assertion_failed( - /*====================*/ const char *expr, /*!< in: the failed assertion */ const char *file, /*!< in: source file containing the assertion */ ulint line) /*!< in: line number of the assertion */ diff --git a/storage/innobase/include/ut0list.h b/storage/innobase/include/ut0list.h index 72dfa29174c1..691b4cb7e0f9 100644 --- a/storage/innobase/include/ut0list.h +++ b/storage/innobase/include/ut0list.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,15 +24,13 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/*******************************************************************/ /** - @file include/ut0list.h +/** @file include/ut0list.h A double-linked list Created 4/26/2006 Osku Salerma ************************************************************************/ -/*******************************************************************/ /** - A double-linked list. This differs from the one in ut0lst.h in that in this +/** A double-linked list. This differs from the one in ut0lst.h in that in this one, each list node contains a pointer to the data, whereas the one in ut0lst.h uses a strategy where the list pointers are embedded in the data items themselves. @@ -59,56 +57,39 @@ this program; if not, write to the Free Software Foundation, Inc., struct ib_list_t; struct ib_list_node_t; -/****************************************************************/ /** - Create a new list using mem_alloc. Lists created with this function must be +/** Create a new list using mem_alloc. Lists created with this function must be freed with ib_list_free. @return list */ ib_list_t *ib_list_create(void); -/*=================*/ -/****************************************************************/ /** - Free a list. */ -void ib_list_free( - /*=========*/ - ib_list_t *list); /*!< in: list */ +/** Free a list. */ +void ib_list_free(ib_list_t *list); /*!< in: list */ -/****************************************************************/ /** - Add the data to the end of the list. +/** Add the data to the end of the list. @return new list node */ ib_list_node_t *ib_list_add_last( - /*=============*/ ib_list_t *list, /*!< in: list */ void *data, /*!< in: data */ mem_heap_t *heap); /*!< in: memory heap to use */ -/****************************************************************/ /** - Remove the node from the list. */ -void ib_list_remove( - /*===========*/ - ib_list_t *list, /*!< in: list */ - ib_list_node_t *node); /*!< in: node to remove */ +/** Remove the node from the list. */ +void ib_list_remove(ib_list_t *list, /*!< in: list */ + ib_list_node_t *node); /*!< in: node to remove */ -/****************************************************************/ /** - Get the first node in the list. +/** Get the first node in the list. @return first node, or NULL */ UNIV_INLINE -ib_list_node_t *ib_list_get_first( - /*==============*/ - ib_list_t *list); /*!< in: list */ +ib_list_node_t *ib_list_get_first(ib_list_t *list); /*!< in: list */ -/****************************************************************/ /** - Get the last node in the list. +/** Get the last node in the list. @return last node, or NULL */ UNIV_INLINE -ib_list_node_t *ib_list_get_last( - /*=============*/ - ib_list_t *list); /*!< in: list */ +ib_list_node_t *ib_list_get_last(ib_list_t *list); /*!< in: list */ /******************************************************************** Check if list is empty. */ UNIV_INLINE ibool ib_list_is_empty( - /*=============*/ /* out: TRUE if empty else */ const ib_list_t *list); /* in: list */ diff --git a/storage/innobase/include/ut0list.ic b/storage/innobase/include/ut0list.ic index b3e80e9f278b..9058c02e1185 100644 --- a/storage/innobase/include/ut0list.ic +++ b/storage/innobase/include/ut0list.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,31 +24,24 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/*******************************************************************/ /** - @file include/ut0list.ic +/** @file include/ut0list.ic A double-linked list Created 4/26/2006 Osku Salerma ************************************************************************/ -/****************************************************************/ /** - Get the first node in the list. +/** Get the first node in the list. @return first node, or NULL */ UNIV_INLINE -ib_list_node_t *ib_list_get_first( - /*==============*/ - ib_list_t *list) /*!< in: list */ +ib_list_node_t *ib_list_get_first(ib_list_t *list) /*!< in: list */ { return (list->first); } -/****************************************************************/ /** - Get the last node in the list. +/** Get the last node in the list. @return last node, or NULL */ UNIV_INLINE -ib_list_node_t *ib_list_get_last( - /*=============*/ - ib_list_t *list) /*!< in: list */ +ib_list_node_t *ib_list_get_last(ib_list_t *list) /*!< in: list */ { return (list->last); } @@ -57,7 +50,6 @@ ib_list_node_t *ib_list_get_last( Check if list is empty. */ UNIV_INLINE ibool ib_list_is_empty( - /*=============*/ /* out: TRUE if empty else FALSE */ const ib_list_t *list) /* in: list */ { diff --git a/storage/innobase/include/ut0lock_free_hash.h b/storage/innobase/include/ut0lock_free_hash.h index cfeaa14ad07d..df98df734295 100644 --- a/storage/innobase/include/ut0lock_free_hash.h +++ b/storage/innobase/include/ut0lock_free_hash.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2015, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2015, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/ut0lock_free_hash.h +/** @file include/ut0lock_free_hash.h Lock free hash implementation Created Mar 16, 2015 Vasil Dimov diff --git a/storage/innobase/include/ut0lst.h b/storage/innobase/include/ut0lst.h index 3831bbbf8123..cf5b465da033 100644 --- a/storage/innobase/include/ut0lst.h +++ b/storage/innobase/include/ut0lst.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/ut0lst.h +/** @file include/ut0lst.h List utilities Created 9/10/1995 Heikki Tuuri @@ -43,8 +42,7 @@ this program; if not, write to the Free Software Foundation, Inc., list node may belong to two or more lists, but is only on one list at a time. */ -/*******************************************************************/ /** - The two way list node. +/** The two way list node. @tparam Type the list node type name */ template struct ut_list_node { @@ -63,8 +61,7 @@ struct ut_list_node { /** Macro used for legacy reasons */ #define UT_LIST_NODE_T(t) ut_list_node -/*******************************************************************/ /** - The two-way list base node. The base node contains pointers to both ends +/** The two-way list base node. The base node contains pointers to both ends of the list and a count of nodes in the list (excluding the base node from the count). We also store a pointer to the member field so that it doesn't have to be specified when doing list operations. @@ -107,8 +104,7 @@ struct ut_list_base { #define UT_LIST_IS_INITIALISED(b) #endif /* UNIV_DEBUG */ -/*******************************************************************/ /** - Note: This is really the list constructor. We should be able to use +/** Note: This is really the list constructor. We should be able to use placement new here. Initializes the base node of a two-way list. @param b the list base node @@ -137,8 +133,7 @@ struct GenericGetNode { node_type Type::*m_node; }; -/*******************************************************************/ /** - Adds the node as the first element in a two-way linked list. +/** Adds the node as the first element in a two-way linked list. @param list the base node (not a pointer to it) @param elem the element to add */ template @@ -167,14 +162,12 @@ void ut_list_prepend(List &list, typename List::elem_type *elem) { ++list.count; } -/*******************************************************************/ /** - Adds the node as the first element in a two-way linked list. +/** Adds the node as the first element in a two-way linked list. @param LIST the base node (not a pointer to it) @param ELEM the element to add */ #define UT_LIST_ADD_FIRST(LIST, ELEM) ut_list_prepend(LIST, ELEM) -/*******************************************************************/ /** - Adds the node as the last element in a two-way linked list. +/** Adds the node as the last element in a two-way linked list. @param list list @param elem the element to add @param get_node to get the list node for that element */ @@ -205,8 +198,7 @@ void ut_list_append(List &list, typename List::elem_type *elem, ++list.count; } -/*******************************************************************/ /** - Adds the node as the last element in a two-way linked list. +/** Adds the node as the last element in a two-way linked list. @param list list @param elem the element to add */ template @@ -215,14 +207,12 @@ void ut_list_append(List &list, typename List::elem_type *elem) { GenericGetNode(list.node)); } -/*******************************************************************/ /** - Adds the node as the last element in a two-way linked list. +/** Adds the node as the last element in a two-way linked list. @param LIST list base node (not a pointer to it) @param ELEM the element to add */ #define UT_LIST_ADD_LAST(LIST, ELEM) ut_list_append(LIST, ELEM) -/*******************************************************************/ /** - Inserts a ELEM2 after ELEM1 in a list. +/** Inserts a ELEM2 after ELEM1 in a list. @param list the base node @param elem1 node after which ELEM2 is inserted @param elem2 node being inserted after ELEM1 */ @@ -253,16 +243,14 @@ void ut_list_insert(List &list, typename List::elem_type *elem1, ++list.count; } -/*******************************************************************/ /** - Inserts a ELEM2 after ELEM1 in a list. +/** Inserts a ELEM2 after ELEM1 in a list. @param LIST list base node (not a pointer to it) @param ELEM1 node after which ELEM2 is inserted @param ELEM2 node being inserted after ELEM1 */ #define UT_LIST_INSERT_AFTER(LIST, ELEM1, ELEM2) \ ut_list_insert(LIST, ELEM1, ELEM2) -/*******************************************************************/ /** - Removes a node from a two-way linked list. +/** Removes a node from a two-way linked list. @param list the base node (not a pointer to it) @param node member node within list element that is to be removed @param get_node functor to get the list node from elem */ @@ -294,8 +282,7 @@ void ut_list_remove(List &list, typename List::node_type &node, --list.count; } -/*******************************************************************/ /** - Removes a node from a two-way linked list. +/** Removes a node from a two-way linked list. @param list the base node (not a pointer to it) @param elem element to be removed from the list @param get_node functor to get the list node from elem */ @@ -305,8 +292,7 @@ void ut_list_remove(List &list, typename List::elem_type *elem, ut_list_remove(list, get_node(*elem), get_node); } -/*******************************************************************/ /** - Removes a node from a two-way linked list. +/** Removes a node from a two-way linked list. @param list the base node (not a pointer to it) @param elem element to be removed from the list */ template @@ -315,41 +301,35 @@ void ut_list_remove(List &list, typename List::elem_type *elem) { GenericGetNode(list.node)); } -/*******************************************************************/ /** - Removes a node from a two-way linked list. +/** Removes a node from a two-way linked list. @param LIST the base node (not a pointer to it) @param ELEM node to be removed from the list */ #define UT_LIST_REMOVE(LIST, ELEM) ut_list_remove(LIST, ELEM) -/********************************************************************/ /** - Gets the next node in a two-way list. +/** Gets the next node in a two-way list. @param NAME list name @param N pointer to a node @return the successor of N in NAME, or NULL */ #define UT_LIST_GET_NEXT(NAME, N) (((N)->NAME).next) -/********************************************************************/ /** - Gets the previous node in a two-way list. +/** Gets the previous node in a two-way list. @param NAME list name @param N pointer to a node @return the predecessor of N in NAME, or NULL */ #define UT_LIST_GET_PREV(NAME, N) (((N)->NAME).prev) -/********************************************************************/ /** - Alternative macro to get the number of nodes in a two-way list, i.e., +/** Alternative macro to get the number of nodes in a two-way list, i.e., its length. @param BASE the base node (not a pointer to it). @return the number of nodes in the list */ #define UT_LIST_GET_LEN(BASE) (BASE).count -/********************************************************************/ /** - Gets the first node in a two-way list. +/** Gets the first node in a two-way list. @param BASE the base node (not a pointer to it) @return first node, or NULL if the list is empty */ #define UT_LIST_GET_FIRST(BASE) (BASE).start -/********************************************************************/ /** - Gets the last node in a two-way list. +/** Gets the last node in a two-way list. @param BASE the base node (not a pointer to it) @return last node, or NULL if the list is empty */ #define UT_LIST_GET_LAST(BASE) (BASE).end @@ -358,8 +338,7 @@ struct NullValidate { void operator()(const void *elem) {} }; -/********************************************************************/ /** - Iterate over all the elements and call the functor for each element. +/** Iterate over all the elements and call the functor for each element. @param[in] list base node (not a pointer to it) @param[in,out] functor Functor that is called for each element in the list */ template @@ -390,8 +369,7 @@ void ut_list_reverse(List &list) { #define UT_LIST_REVERSE(LIST) ut_list_reverse(LIST) -/********************************************************************/ /** - Checks the consistency of a two-way list. +/** Checks the consistency of a two-way list. @param[in] list base node (not a pointer to it) @param[in,out] functor Functor that is called for each element in the list */ diff --git a/storage/innobase/include/ut0mem.h b/storage/innobase/include/ut0mem.h index 2e6c86ff30f9..773713a02e1c 100644 --- a/storage/innobase/include/ut0mem.h +++ b/storage/innobase/include/ut0mem.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/*******************************************************************/ /** - @file include/ut0mem.h +/** @file include/ut0mem.h Memory primitives Created 5/30/1994 Heikki Tuuri @@ -88,21 +87,17 @@ ulint ut_strlen(const char *str); UNIV_INLINE int ut_strcmp(const char *str1, const char *str2); -/**********************************************************************/ /** - Copies up to size - 1 characters from the NUL-terminated string src to +/** Copies up to size - 1 characters from the NUL-terminated string src to dst, NUL-terminating the result. Returns strlen(src), so truncation occurred if the return value >= size. @return strlen(src) */ -ulint ut_strlcpy( - /*=======*/ - char *dst, /*!< in: destination buffer */ - const char *src, /*!< in: source buffer */ - ulint size); /*!< in: size of destination buffer */ +ulint ut_strlcpy(char *dst, /*!< in: destination buffer */ + const char *src, /*!< in: source buffer */ + ulint size); /*!< in: size of destination buffer */ /******************************************************************** Concatenate 3 strings.*/ char *ut_str3cat( - /*=======*/ /* out, own: concatenated string, must be freed with ut_free() */ const char *s1, /* in: string 1 */ diff --git a/storage/innobase/include/ut0mem.ic b/storage/innobase/include/ut0mem.ic index 93b0b1f45262..6c29e01db70b 100644 --- a/storage/innobase/include/ut0mem.ic +++ b/storage/innobase/include/ut0mem.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2014, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/*******************************************************************/ /** - @file include/ut0mem.ic +/** @file include/ut0mem.ic Memory primitives Created 5/30/1994 Heikki Tuuri @@ -90,19 +89,16 @@ int ut_strcmp(const char *str1, const char *str2) { return (strcmp(str1, str2)); } -/**********************************************************************/ /** - Converts a raw binary data to a NUL-terminated hex string. The output is +/** Converts a raw binary data to a NUL-terminated hex string. The output is truncated if there is not enough space in "hex", make sure "hex_size" is at least (2 * raw_size + 1) if you do not want this to happen. Returns the actual number of characters written to "hex" (including the NUL). @return number of chars written */ UNIV_INLINE -ulint ut_raw_to_hex( - /*==========*/ - const void *raw, /*!< in: raw data */ - ulint raw_size, /*!< in: "raw" length in bytes */ - char *hex, /*!< out: hex string */ - ulint hex_size) /*!< in: "hex" size in bytes */ +ulint ut_raw_to_hex(const void *raw, /*!< in: raw data */ + ulint raw_size, /*!< in: "raw" length in bytes */ + char *hex, /*!< out: hex string */ + ulint hex_size) /*!< in: "hex" size in bytes */ { #ifdef WORDS_BIGENDIAN @@ -178,20 +174,17 @@ ulint ut_raw_to_hex( return (write_bytes); } -/*******************************************************************/ /** - Adds single quotes to the start and end of string and escapes any quotes +/** Adds single quotes to the start and end of string and escapes any quotes by doubling them. Returns the number of bytes that were written to "buf" (including the terminating NUL). If buf_size is too small then the trailing bytes from "str" are discarded. @return number of bytes that were written */ UNIV_INLINE -ulint ut_str_sql_format( - /*==============*/ - const char *str, /*!< in: string */ - ulint str_len, /*!< in: string length in bytes */ - char *buf, /*!< out: output buffer */ - ulint buf_size) /*!< in: output buffer size - in bytes */ +ulint ut_str_sql_format(const char *str, /*!< in: string */ + ulint str_len, /*!< in: string length in bytes */ + char *buf, /*!< out: output buffer */ + ulint buf_size) /*!< in: output buffer size + in bytes */ { ulint str_i; ulint buf_i; diff --git a/storage/innobase/include/ut0mutex.h b/storage/innobase/include/ut0mutex.h index 3a85638fc67c..befe31e79f50 100644 --- a/storage/innobase/include/ut0mutex.h +++ b/storage/innobase/include/ut0mutex.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2012, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2012, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/ut0mutex.h +/** @file include/ut0mutex.h Policy based mutexes. Created 2012-03-24 Sunny Bains. diff --git a/storage/innobase/include/ut0mutex.ic b/storage/innobase/include/ut0mutex.ic index 214a6617faf8..6b3ec99c6177 100644 --- a/storage/innobase/include/ut0mutex.ic +++ b/storage/innobase/include/ut0mutex.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2013, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2018, Oracle and/or its affiliates. All Rights Reserved. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -30,8 +30,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/ut0mutex.ic +/** @file include/ut0mutex.ic Mutex implementation include file Created 2012/08/21 Sunny Bains diff --git a/storage/innobase/include/ut0new.h b/storage/innobase/include/ut0new.h index d64df1b3fede..46d94c9d2359 100644 --- a/storage/innobase/include/ut0new.h +++ b/storage/innobase/include/ut0new.h @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/ut0new.h +/** @file include/ut0new.h Instrumented memory allocator. Created May 26, 2014 Vasil Dimov diff --git a/storage/innobase/include/ut0pool.h b/storage/innobase/include/ut0pool.h index 827f200dc85d..16fad021d16b 100644 --- a/storage/innobase/include/ut0pool.h +++ b/storage/innobase/include/ut0pool.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2013, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/ut0pool.h +/** @file include/ut0pool.h Object pool. Created 2012-Feb-26 Sunny Bains diff --git a/storage/innobase/include/ut0rbt.h b/storage/innobase/include/ut0rbt.h index 859fdbc8da11..f5bded2e78a6 100644 --- a/storage/innobase/include/ut0rbt.h +++ b/storage/innobase/include/ut0rbt.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -23,8 +23,7 @@ this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *****************************************************************************/ -/******************************************************************/ /** - @file include/ut0rbt.h +/** @file include/ut0rbt.h Various utilities Created 2007-03-20 Sunny Bains @@ -112,129 +111,87 @@ struct ib_rbt_bound_t { /* Compare a key with the node value (t is tree, k is key, n is node)*/ #define rbt_compare(t, k, n) (t->compare(k, n->value)) -/**********************************************************************/ /** - Free an instance of a red black tree */ -void rbt_free( - /*=====*/ - ib_rbt_t *tree); /*!< in: rb tree to free */ -/**********************************************************************/ /** - Create an instance of a red black tree +/** Free an instance of a red black tree */ +void rbt_free(ib_rbt_t *tree); /*!< in: rb tree to free */ +/** Create an instance of a red black tree @return rb tree instance */ -ib_rbt_t *rbt_create( - /*=======*/ - size_t sizeof_value, /*!< in: size in bytes */ - ib_rbt_compare compare); /*!< in: comparator */ -/**********************************************************************/ /** - Create an instance of a red black tree, whose comparison function takes +ib_rbt_t *rbt_create(size_t sizeof_value, /*!< in: size in bytes */ + ib_rbt_compare compare); /*!< in: comparator */ +/** Create an instance of a red black tree, whose comparison function takes an argument @return rb tree instance */ -ib_rbt_t *rbt_create_arg_cmp( - /*===============*/ - size_t sizeof_value, /*!< in: size in bytes */ - ib_rbt_arg_compare compare, /*!< in: comparator */ - void *cmp_arg); /*!< in: compare fn arg */ -/**********************************************************************/ /** - Delete a node from the red black tree, identified by key */ +ib_rbt_t *rbt_create_arg_cmp(size_t sizeof_value, /*!< in: size in bytes */ + ib_rbt_arg_compare compare, /*!< in: comparator */ + void *cmp_arg); /*!< in: compare fn arg */ +/** Delete a node from the red black tree, identified by key */ ibool rbt_delete( - /*=======*/ /* in: TRUE on success */ ib_rbt_t *tree, /* in: rb tree */ const void *key); /* in: key to delete */ -/**********************************************************************/ /** - Remove a node from the red black tree, NOTE: This function will not delete +/** Remove a node from the red black tree, NOTE: This function will not delete the node instance, THAT IS THE CALLERS RESPONSIBILITY. @return the deleted node with the const. */ ib_rbt_node_t *rbt_remove_node( - /*============*/ ib_rbt_t *tree, /*!< in: rb tree */ const ib_rbt_node_t *node); /*!< in: node to delete, this is a fudge and declared const because the caller has access only to const nodes.*/ -/**********************************************************************/ /** - Add data to the red black tree, identified by key (no dups yet!) +/** Add data to the red black tree, identified by key (no dups yet!) @return inserted node */ -const ib_rbt_node_t *rbt_insert( - /*=======*/ - ib_rbt_t *tree, /*!< in: rb tree */ - const void *key, /*!< in: key for ordering */ - const void *value); /*!< in: data that will be - copied to the node.*/ -/**********************************************************************/ /** - Add a new node to the tree, useful for data that is pre-sorted. +const ib_rbt_node_t *rbt_insert(ib_rbt_t *tree, /*!< in: rb tree */ + const void *key, /*!< in: key for ordering */ + const void *value); /*!< in: data that will be + copied to the node.*/ +/** Add a new node to the tree, useful for data that is pre-sorted. @return appended node */ const ib_rbt_node_t *rbt_add_node( - /*=========*/ ib_rbt_t *tree, /*!< in: rb tree */ ib_rbt_bound_t *parent, /*!< in: parent */ const void *value); /*!< in: this value is copied to the node */ -/**********************************************************************/ /** - Return the left most data node in the tree +/** Return the left most data node in the tree @return left most node */ -const ib_rbt_node_t *rbt_first( - /*======*/ - const ib_rbt_t *tree); /*!< in: rb tree */ -/**********************************************************************/ /** - Return the right most data node in the tree +const ib_rbt_node_t *rbt_first(const ib_rbt_t *tree); /*!< in: rb tree */ +/** Return the right most data node in the tree @return right most node */ -const ib_rbt_node_t *rbt_last( - /*=====*/ - const ib_rbt_t *tree); /*!< in: rb tree */ -/**********************************************************************/ /** - Return the next node from current. +const ib_rbt_node_t *rbt_last(const ib_rbt_t *tree); /*!< in: rb tree */ +/** Return the next node from current. @return successor node to current that is passed in. */ -const ib_rbt_node_t *rbt_next( - /*=====*/ - const ib_rbt_t *tree, /*!< in: rb tree */ - const ib_rbt_node_t * /* in: current node */ - current); -/**********************************************************************/ /** - Return the prev node from current. +const ib_rbt_node_t *rbt_next(const ib_rbt_t *tree, /*!< in: rb tree */ + const ib_rbt_node_t * /* in: current node */ + current); +/** Return the prev node from current. @return precedessor node to current that is passed in */ -const ib_rbt_node_t *rbt_prev( - /*=====*/ - const ib_rbt_t *tree, /*!< in: rb tree */ - const ib_rbt_node_t * /* in: current node */ - current); -/**********************************************************************/ /** - Search for the key, a node will be retuned in parent.last, whether it +const ib_rbt_node_t *rbt_prev(const ib_rbt_t *tree, /*!< in: rb tree */ + const ib_rbt_node_t * /* in: current node */ + current); +/** Search for the key, a node will be retuned in parent.last, whether it was found or not. If not found then parent.last will contain the parent node for the possibly new key otherwise the matching node. @return result of last comparison */ -int rbt_search( - /*=======*/ - const ib_rbt_t *tree, /*!< in: rb tree */ - ib_rbt_bound_t *parent, /*!< in: search bounds */ - const void *key); /*!< in: key to search */ -/**********************************************************************/ /** - Search for the key, a node will be retuned in parent.last, whether it +int rbt_search(const ib_rbt_t *tree, /*!< in: rb tree */ + ib_rbt_bound_t *parent, /*!< in: search bounds */ + const void *key); /*!< in: key to search */ +/** Search for the key, a node will be retuned in parent.last, whether it was found or not. If not found then parent.last will contain the parent node for the possibly new key otherwise the matching node. @return result of last comparison */ -int rbt_search_cmp( - /*===========*/ - const ib_rbt_t *tree, /*!< in: rb tree */ - ib_rbt_bound_t *parent, /*!< in: search bounds */ - const void *key, /*!< in: key to search */ - ib_rbt_compare compare, /*!< in: comparator */ - ib_rbt_arg_compare arg_compare); /*!< in: fn to compare items - with argument */ -/**********************************************************************/ /** - Merge the node from dst into src. Return the number of nodes merged. +int rbt_search_cmp(const ib_rbt_t *tree, /*!< in: rb tree */ + ib_rbt_bound_t *parent, /*!< in: search bounds */ + const void *key, /*!< in: key to search */ + ib_rbt_compare compare, /*!< in: comparator */ + ib_rbt_arg_compare arg_compare); /*!< in: fn to compare items + with argument */ +/** Merge the node from dst into src. Return the number of nodes merged. @return no. of recs merged */ -ulint rbt_merge_uniq( - /*===========*/ - ib_rbt_t *dst, /*!< in: dst rb tree */ - const ib_rbt_t *src); /*!< in: src rb tree */ +ulint rbt_merge_uniq(ib_rbt_t *dst, /*!< in: dst rb tree */ + const ib_rbt_t *src); /*!< in: src rb tree */ #if defined UNIV_DEBUG || defined IB_RBT_TESTING -/**********************************************************************/ /** - Verify the integrity of the RB tree. For debugging. 0 failure else height +/** Verify the integrity of the RB tree. For debugging. 0 failure else height of tree (in count of black nodes). @return true if OK false if tree invalid. */ -ibool rbt_validate( - /*=========*/ - const ib_rbt_t *tree); /*!< in: tree to validate */ -#endif /* UNIV_DEBUG || IB_RBT_TESTING */ +ibool rbt_validate(const ib_rbt_t *tree); /*!< in: tree to validate */ +#endif /* UNIV_DEBUG || IB_RBT_TESTING */ #endif /* INNOBASE_UT0RBT_H */ diff --git a/storage/innobase/include/ut0rnd.h b/storage/innobase/include/ut0rnd.h index 5e45222a7a1b..3075bd815fa5 100644 --- a/storage/innobase/include/ut0rnd.h +++ b/storage/innobase/include/ut0rnd.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -26,8 +26,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "my_compiler.h" -/******************************************************************/ /** - @file include/ut0rnd.h +/** @file include/ut0rnd.h Random numbers and hashing Created 1/20/1994 Heikki Tuuri @@ -43,22 +42,18 @@ this program; if not, write to the Free Software Foundation, Inc., in folding records */ #define UT_END_OF_FIELD 257 -/********************************************************/ /** - The following function generates a series of 'random' ulint integers. +/** The following function generates a series of 'random' ulint integers. @return the next 'random' number */ UNIV_INLINE ulint ut_rnd_gen_next_ulint( - /*==================*/ ulint rnd); /*!< in: the previous random number value */ -/*********************************************************/ /** - The following function generates 'random' ulint integers which +/** The following function generates 'random' ulint integers which enumerate the value space (let there be N of them) of ulint integers in a pseudo-random fashion. Note that the same integer is repeated always after N calls to the generator. @return the 'random' number */ UNIV_INLINE ulint ut_rnd_gen_ulint(void); -/*==================*/ /** Generates a random integer from a given interval. @param[in] low low limit; can generate also this value @@ -76,48 +71,33 @@ to work reliably. UNIV_INLINE ulint ut_hash_ulint(ulint key, ulint table_size); -/*************************************************************/ /** - Folds a 64-bit integer. +/** Folds a 64-bit integer. @return folded value */ UNIV_INLINE -ulint ut_fold_ull( - /*========*/ - ib_uint64_t d) /*!< in: 64-bit integer */ +ulint ut_fold_ull(ib_uint64_t d) /*!< in: 64-bit integer */ MY_ATTRIBUTE((const)); -/*************************************************************/ /** - Folds a character string ending in the null character. +/** Folds a character string ending in the null character. @return folded value */ UNIV_INLINE -ulint ut_fold_string( - /*===========*/ - const char *str) /*!< in: null-terminated string */ +ulint ut_fold_string(const char *str) /*!< in: null-terminated string */ MY_ATTRIBUTE((warn_unused_result)); -/***********************************************************/ /** - Looks for a prime number slightly greater than the given argument. +/** Looks for a prime number slightly greater than the given argument. The prime is chosen so that it is not near any power of 2. @return prime */ -ulint ut_find_prime( - /*==========*/ - ulint n) /*!< in: positive number > 100 */ +ulint ut_find_prime(ulint n) /*!< in: positive number > 100 */ MY_ATTRIBUTE((const)); -/*************************************************************/ /** - Folds a pair of ulints. +/** Folds a pair of ulints. @return folded value */ UNIV_INLINE -ulint ut_fold_ulint_pair( - /*===============*/ - ulint n1, /*!< in: ulint */ - ulint n2) /*!< in: ulint */ +ulint ut_fold_ulint_pair(ulint n1, /*!< in: ulint */ + ulint n2) /*!< in: ulint */ MY_ATTRIBUTE((const)); -/*************************************************************/ /** - Folds a binary string. +/** Folds a binary string. @return folded value */ UNIV_INLINE -ulint ut_fold_binary( - /*===========*/ - const byte *str, /*!< in: string of bytes */ - ulint len) /*!< in: length */ +ulint ut_fold_binary(const byte *str, /*!< in: string of bytes */ + ulint len) /*!< in: length */ MY_ATTRIBUTE((pure)); #include "ut0rnd.ic" diff --git a/storage/innobase/include/ut0rnd.ic b/storage/innobase/include/ut0rnd.ic index cc3e0da16c64..09a619ca9f73 100644 --- a/storage/innobase/include/ut0rnd.ic +++ b/storage/innobase/include/ut0rnd.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************************/ /** - @file include/ut0rnd.ic +/** @file include/ut0rnd.ic Random numbers and hashing Created 5/30/1994 Heikki Tuuri @@ -49,13 +48,11 @@ this program; if not, write to the Free Software Foundation, Inc., /** Seed value of ut_rnd_gen_ulint() */ extern thread_local ulint ut_rnd_ulint_counter; -/********************************************************/ /** - The following function generates a series of 'random' ulint integers. +/** The following function generates a series of 'random' ulint integers. This function is now based on thread local variables. @return the next 'random' number */ UNIV_INLINE ulint ut_rnd_gen_next_ulint( - /*==================*/ ulint rnd) /*!< in: the previous random number value */ { ulint n_bits; @@ -91,13 +88,11 @@ ulint ut_rnd_gen_ulint() { return (ut_rnd_gen_next_ulint(rnd)); } -/********************************************************/ /** - Generates a random integer from a given interval. +/** Generates a random integer from a given interval. This function is now based on thread local variables. @return the 'random' number */ UNIV_INLINE ulint ut_rnd_interval( - /*============*/ ulint low, /*!< in: low limit; can generate also this value */ ulint high) /*!< in: high limit; can generate also this value */ { @@ -114,16 +109,13 @@ ulint ut_rnd_interval( return (low + (rnd % (high - low))); } -/*******************************************************/ /** - The following function generates a hash value for a ulint integer +/** The following function generates a hash value for a ulint integer to a hash table of size table_size, which should be a prime or some random number for the hash table to work reliably. @return hash value */ UNIV_INLINE -ulint ut_hash_ulint( - /*==========*/ - ulint key, /*!< in: value to be hashed */ - ulint table_size) /*!< in: hash table size */ +ulint ut_hash_ulint(ulint key, /*!< in: value to be hashed */ + ulint table_size) /*!< in: hash table size */ { ut_ad(table_size); key = key ^ UT_HASH_RANDOM_MASK2; @@ -131,24 +123,18 @@ ulint ut_hash_ulint( return (key % table_size); } -/*************************************************************/ /** - Folds a 64-bit integer. +/** Folds a 64-bit integer. @return folded value */ UNIV_INLINE -ulint ut_fold_ull( - /*========*/ - ib_uint64_t d) /*!< in: 64-bit integer */ +ulint ut_fold_ull(ib_uint64_t d) /*!< in: 64-bit integer */ { return (ut_fold_ulint_pair((ulint)d & ULINT32_MASK, (ulint)(d >> 32))); } -/*************************************************************/ /** - Folds a character string ending in the null character. +/** Folds a character string ending in the null character. @return folded value */ UNIV_INLINE -ulint ut_fold_string( - /*===========*/ - const char *str) /*!< in: null-terminated string */ +ulint ut_fold_string(const char *str) /*!< in: null-terminated string */ { ulint fold = 0; @@ -162,28 +148,22 @@ ulint ut_fold_string( return (fold); } -/*************************************************************/ /** - Folds a pair of ulints. +/** Folds a pair of ulints. @return folded value */ UNIV_INLINE -ulint ut_fold_ulint_pair( - /*===============*/ - ulint n1, /*!< in: ulint */ - ulint n2) /*!< in: ulint */ +ulint ut_fold_ulint_pair(ulint n1, /*!< in: ulint */ + ulint n2) /*!< in: ulint */ { return ( ((((n1 ^ n2 ^ UT_HASH_RANDOM_MASK2) << 8) + n1) ^ UT_HASH_RANDOM_MASK) + n2); } -/*************************************************************/ /** - Folds a binary string. +/** Folds a binary string. @return folded value */ UNIV_INLINE -ulint ut_fold_binary( - /*===========*/ - const byte *str, /*!< in: string of bytes */ - ulint len) /*!< in: length */ +ulint ut_fold_binary(const byte *str, /*!< in: string of bytes */ + ulint len) /*!< in: length */ { ulint fold = 0; const byte *str_end = str + (len & 0xFFFFFFF8); diff --git a/storage/innobase/include/ut0sort.h b/storage/innobase/include/ut0sort.h index 3ec82690f53b..8b601b91ce61 100644 --- a/storage/innobase/include/ut0sort.h +++ b/storage/innobase/include/ut0sort.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2009, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/ut0sort.h +/** @file include/ut0sort.h Sort utility Created 11/9/1995 Heikki Tuuri @@ -43,8 +42,7 @@ the macro. The sort algorithm is mergesort which has logarithmic worst case. */ -/*******************************************************************/ /** - This macro expands to the body of a standard sort function. +/** This macro expands to the body of a standard sort function. The sort function uses mergesort and must be defined separately for each type of array. Also the comparison function has to be defined individually diff --git a/storage/innobase/include/ut0stage.h b/storage/innobase/include/ut0stage.h index 8472243eab7a..72faf6cd094f 100644 --- a/storage/innobase/include/ut0stage.h +++ b/storage/innobase/include/ut0stage.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2014, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2014, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file include/ut0stage.h +/** @file include/ut0stage.h Supplementary code to performance schema stage instrumentation. Created Nov 12, 2014 Vasil Dimov diff --git a/storage/innobase/include/ut0ut.h b/storage/innobase/include/ut0ut.h index 02a1056ac579..a4be20abf2c0 100644 --- a/storage/innobase/include/ut0ut.h +++ b/storage/innobase/include/ut0ut.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file include/ut0ut.h +/** @file include/ut0ut.h Various utilities Created 1/20/1994 Heikki Tuuri @@ -92,8 +91,7 @@ independent way by using YieldProcessor. */ #define UT_RESUME_PRIORITY_CPU() ((void)0) #endif -/*********************************************************************/ /** - Delays execution for at most max_wait_us microseconds or returns earlier +/** Delays execution for at most max_wait_us microseconds or returns earlier if cond becomes true. @param cond in: condition to wait for; evaluated every 2 ms @param max_wait_us in: maximum delay to wait, in microseconds */ @@ -141,14 +139,12 @@ UNIV_INLINE int ut_pair_cmp(ulint a_h, ulint a_l, ulint b_h, ulint b_l) MY_ATTRIBUTE((warn_unused_result)); -/*************************************************************/ /** - Calculates fast the remainder of n/m when m is a power of two. +/** Calculates fast the remainder of n/m when m is a power of two. @param n in: numerator @param m in: denominator, must be a power of two @return the remainder of n/m */ #define ut_2pow_remainder(n, m) ((n) & ((m)-1)) -/*************************************************************/ /** - Calculates the biggest multiple of m that is not bigger than n +/** Calculates the biggest multiple of m that is not bigger than n when m is a power of two. In other words, rounds n down to m * k. @param n in: number to round down @param m in: alignment, must be a power of two @@ -159,21 +155,17 @@ int ut_pair_cmp(ulint a_h, ulint a_l, ulint b_h, ulint b_l) @param m in: alignment, must be a power of two @return n rounded down to the biggest possible integer multiple of m */ #define ut_calc_align_down(n, m) ut_2pow_round(n, m) -/********************************************************/ /** - Calculates the smallest multiple of m that is not smaller than n +/** Calculates the smallest multiple of m that is not smaller than n when m is a power of two. In other words, rounds n up to m * k. @param n in: number to round up @param m in: alignment, must be a power of two @return n rounded up to the smallest possible integer multiple of m */ #define ut_calc_align(n, m) (((n) + ((m)-1)) & ~((m)-1)) -/*************************************************************/ /** - Calculates fast the 2-logarithm of a number, rounded upward to an +/** Calculates fast the 2-logarithm of a number, rounded upward to an integer. @return logarithm in the base 2, rounded upward */ UNIV_INLINE -ulint ut_2_log( - /*=====*/ - ulint n); /*!< in: number */ +ulint ut_2_log(ulint n); /*!< in: number */ /** Calculates 2 to power n. @param[in] n power of 2 @@ -181,12 +173,9 @@ ulint ut_2_log( UNIV_INLINE uint32_t ut_2_exp(uint32_t n); -/*************************************************************/ /** - Calculates fast the number rounded up to the nearest power of 2. +/** Calculates fast the number rounded up to the nearest power of 2. @return first power of 2 which is >= n */ -ulint ut_2_power_up( - /*==========*/ - ulint n) /*!< in: number != 0 */ +ulint ut_2_power_up(ulint n) /*!< in: number != 0 */ MY_ATTRIBUTE((const)); /** Determine how many bytes (groups of 8 bits) are needed to @@ -195,62 +184,46 @@ store the given number of bits. @return number of bytes (octets) needed to represent b */ #define UT_BITS_IN_BYTES(b) (((b) + 7) / 8) -/**********************************************************/ /** - Returns system time. We do not specify the format of the time returned: +/** Returns system time. We do not specify the format of the time returned: the only way to manipulate it is to use the function ut_difftime. @return system time */ ib_time_t ut_time(void); -/*=========*/ -/**********************************************************/ /** - Returns system time. +/** Returns system time. Upon successful completion, the value 0 is returned; otherwise the value -1 is returned and the global variable errno is set to indicate the error. @return 0 on success, -1 otherwise */ -int ut_usectime( - /*========*/ - ulint *sec, /*!< out: seconds since the Epoch */ - ulint *ms); /*!< out: microseconds since the Epoch+*sec */ +int ut_usectime(ulint *sec, /*!< out: seconds since the Epoch */ + ulint *ms); /*!< out: microseconds since the Epoch+*sec */ -/**********************************************************/ /** - Returns the number of microseconds since epoch. Similar to +/** Returns the number of microseconds since epoch. Similar to time(3), the return value is also stored in *tloc, provided that tloc is non-NULL. @return us since epoch */ -uintmax_t ut_time_us( - /*=======*/ - uintmax_t *tloc); /*!< out: us since epoch, if non-NULL */ -/**********************************************************/ /** - Returns the number of milliseconds since some epoch. The +uintmax_t ut_time_us(uintmax_t *tloc); /*!< out: us since epoch, if non-NULL */ +/** Returns the number of milliseconds since some epoch. The value may wrap around. It should only be used for heuristic purposes. @return ms since epoch */ ulint ut_time_ms(void); -/*============*/ #ifdef _WIN32 -/**********************************************************/ /** - Initialise highest available time resolution API on Windows +/** Initialise highest available time resolution API on Windows @return false if all OK else true */ bool ut_win_init_time(); #endif /* _WIN32 */ -/**********************************************************/ /** - Returns the number of milliseconds since some epoch. The +/** Returns the number of milliseconds since some epoch. The value may wrap around. It should only be used for heuristic purposes. @return ms since epoch */ ulint ut_time_ms(void); -/*============*/ -/**********************************************************/ /** - Returns the difference of two times in seconds. +/** Returns the difference of two times in seconds. @return time2 - time1 expressed in seconds */ -double ut_difftime( - /*========*/ - ib_time_t time2, /*!< in: time */ - ib_time_t time1); /*!< in: time */ +double ut_difftime(ib_time_t time2, /*!< in: time */ + ib_time_t time1); /*!< in: time */ /** Determines if a number is zero or a power of two. @param[in] n number @@ -265,12 +238,10 @@ struct ut_strcmp_functor { } }; -/*************************************************************/ /** - Runs an idle loop on CPU. The argument gives the desired delay +/** Runs an idle loop on CPU. The argument gives the desired delay in microseconds on 100 MHz Pentium + Visual C++. @return dummy value */ ulint ut_delay( - /*=====*/ ulint delay); /*!< in: delay in microseconds on 100 MHz Pentium */ /* Forward declaration of transaction handle */ @@ -286,16 +257,13 @@ as in SQL database_name.identifier. */ std::string ut_get_name(const trx_t *trx, const char *name); -/**********************************************************************/ /** - Outputs a fixed-length string, quoted as an SQL identifier. +/** Outputs a fixed-length string, quoted as an SQL identifier. If the string contains a slash '/', the string will be output as two identifiers separated by a period (.), as in SQL database_name.identifier. */ -void ut_print_name( - /*==========*/ - FILE *f, /*!< in: output stream */ - const trx_t *trx, /*!< in: transaction */ - const char *name); /*!< in: table name to print */ +void ut_print_name(FILE *f, /*!< in: output stream */ + const trx_t *trx, /*!< in: transaction */ + const char *name); /*!< in: table name to print */ /** Format a table name, quoted as an SQL identifier. If the name contains a slash '/', the result will contain two @@ -308,30 +276,23 @@ database_name.table_name. @return pointer to 'formatted' */ char *ut_format_name(const char *name, char *formatted, ulint formatted_size); -/**********************************************************************/ /** - Catenate files. */ -void ut_copy_file( - /*=========*/ - FILE *dest, /*!< in: output file */ - FILE *src); /*!< in: input file to be appended to output */ +/** Catenate files. */ +void ut_copy_file(FILE *dest, /*!< in: output file */ + FILE *src); /*!< in: input file to be appended to output */ #ifdef _WIN32 -/**********************************************************************/ /** - A substitute for vsnprintf(3), formatted output conversion into +/** A substitute for vsnprintf(3), formatted output conversion into a limited buffer. Note: this function DOES NOT return the number of characters that would have been printed if the buffer was unlimited because VC's _vsnprintf() returns -1 in this case and we would need to call _vscprintf() in addition to estimate that but we would need another copy of "ap" for that and VC does not provide va_copy(). */ -void ut_vsnprintf( - /*=========*/ - char *str, /*!< out: string */ - size_t size, /*!< in: str size */ - const char *fmt, /*!< in: format */ - va_list ap); /*!< in: format values */ +void ut_vsnprintf(char *str, /*!< out: string */ + size_t size, /*!< in: str size */ + const char *fmt, /*!< in: format */ + va_list ap); /*!< in: format values */ #else -/**********************************************************************/ /** - A wrapper for vsnprintf(3), formatted output conversion into +/** A wrapper for vsnprintf(3), formatted output conversion into a limited buffer. Note: this function DOES NOT return the number of characters that would have been printed if the buffer was unlimited because VC's _vsnprintf() returns -1 in this case and we would need to call @@ -340,13 +301,10 @@ void ut_vsnprintf( #define ut_vsnprintf(buf, size, fmt, ap) ((void)vsnprintf(buf, size, fmt, ap)) #endif /* _WIN32 */ -/*************************************************************/ /** - Convert an error number to a human readable text message. The +/** Convert an error number to a human readable text message. The returned string is static and should not be freed or modified. @return string, describing the error */ -const char *ut_strerr( - /*======*/ - dberr_t num); /*!< in: error number */ +const char *ut_strerr(dberr_t num); /*!< in: error number */ #ifdef UNIV_PFS_MEMORY diff --git a/storage/innobase/include/ut0ut.ic b/storage/innobase/include/ut0ut.ic index 5ce3ef2508c5..ff47d063471f 100644 --- a/storage/innobase/include/ut0ut.ic +++ b/storage/innobase/include/ut0ut.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************************/ /** - @file include/ut0ut.ic +/** @file include/ut0ut.ic Various utilities Created 5/30/1994 Heikki Tuuri @@ -59,14 +58,11 @@ void ut_pair_min(ulint *min_hi, ulint *min_lo, ulint a_hi, ulint a_lo, } #endif /* !UNIV_HOTBACKUP */ -/******************************************************/ /** - Compares two ulints. +/** Compares two ulints. @return 1 if a > b, 0 if a == b, -1 if a < b */ UNIV_INLINE -int ut_ulint_cmp( - /*=========*/ - ulint a, /*!< in: ulint */ - ulint b) /*!< in: ulint */ +int ut_ulint_cmp(ulint a, /*!< in: ulint */ + ulint b) /*!< in: ulint */ { if (a < b) { return (-1); @@ -97,14 +93,11 @@ int ut_pair_cmp(ulint a_h, ulint a_l, ulint b_h, ulint b_l) { return (ut_ulint_cmp(a_l, b_l)); } -/*************************************************************/ /** - Calculates fast the 2-logarithm of a number, rounded upward to an +/** Calculates fast the 2-logarithm of a number, rounded upward to an integer. @return logarithm in the base 2, rounded upward */ UNIV_INLINE -ulint ut_2_log( - /*=====*/ - ulint n) /*!< in: number != 0 */ +ulint ut_2_log(ulint n) /*!< in: number != 0 */ { ulint res; diff --git a/storage/innobase/include/ut0vec.h b/storage/innobase/include/ut0vec.h index 0497e710cc97..de0dbcea75b4 100644 --- a/storage/innobase/include/ut0vec.h +++ b/storage/innobase/include/ut0vec.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/*******************************************************************/ /** - @file include/ut0vec.h +/** @file include/ut0vec.h A vector of pointers to data items Created 4/6/2006 Osku Salerma @@ -73,7 +72,6 @@ freeing it when done with the vector. /******************************************************************** Create a new vector with the given initial size. */ ib_vector_t *ib_vector_create( - /*=============*/ /* out: vector */ ib_alloc_t *alloc, /* in: Allocator */ /* in: size of the data item */ @@ -83,16 +81,13 @@ ib_vector_t *ib_vector_create( Destroy the vector. Make sure the vector owns the allocator, e.g., the heap in the the heap allocator. */ UNIV_INLINE -void ib_vector_free( - /*===========*/ - ib_vector_t *vec); /* in/out: vector */ +void ib_vector_free(ib_vector_t *vec); /* in/out: vector */ /******************************************************************** Push a new element to the vector, increasing its size if necessary, if elem is not NULL then elem is copied to the vector.*/ UNIV_INLINE void *ib_vector_push( - /*===========*/ /* out: pointer the "new" element */ ib_vector_t *vec, /* in/out: vector */ const void *elem); /* in: data element */ @@ -101,7 +96,6 @@ void *ib_vector_push( Pop the last element from the vector.*/ UNIV_INLINE void *ib_vector_pop( - /*==========*/ /* out: pointer to the "new" element */ ib_vector_t *vec); /* in/out: vector */ @@ -116,14 +110,12 @@ void *ib_vector_remove(ib_vector_t *vec, const void *elem); Get the number of elements in the vector. */ UNIV_INLINE ulint ib_vector_size( - /*===========*/ /* out: number of elements in vector */ const ib_vector_t *vec); /* in: vector */ /******************************************************************** Increase the size of the vector. */ void ib_vector_resize( - /*=============*/ /* out: number of elements in vector */ ib_vector_t *vec); /* in/out: vector */ @@ -131,9 +123,7 @@ void ib_vector_resize( Test whether a vector is empty or not. @return true if empty */ UNIV_INLINE -ibool ib_vector_is_empty( - /*===============*/ - const ib_vector_t *vec); /*!< in: vector */ +ibool ib_vector_is_empty(const ib_vector_t *vec); /*!< in: vector */ /** Get the n'th element. @param[in] vec vector @@ -146,17 +136,12 @@ void *ib_vector_get(ib_vector_t *vec, ulint n); Const version of the get n'th element. @return n'th element */ UNIV_INLINE -const void *ib_vector_get_const( - /*================*/ - const ib_vector_t *vec, /* in: vector */ - ulint n); /* in: element index to get */ -/****************************************************************/ /** - Get last element. The vector must not be empty. +const void *ib_vector_get_const(const ib_vector_t *vec, /* in: vector */ + ulint n); /* in: element index to get */ +/** Get last element. The vector must not be empty. @return last element */ UNIV_INLINE -void *ib_vector_get_last( - /*===============*/ - ib_vector_t *vec); /*!< in: vector */ +void *ib_vector_get_last(ib_vector_t *vec); /*!< in: vector */ /** Set the n'th element. @param[in] vec vector @@ -168,15 +153,12 @@ void ib_vector_set(ib_vector_t *vec, ulint n, void *elem); /******************************************************************** Reset the vector size to 0 elements. */ UNIV_INLINE -void ib_vector_reset( - /*============*/ - ib_vector_t *vec); /* in/out: vector */ +void ib_vector_reset(ib_vector_t *vec); /* in/out: vector */ /******************************************************************** Get the last element of the vector. */ UNIV_INLINE void *ib_vector_last( - /*===========*/ /* out: pointer to last element */ ib_vector_t *vec); /* in/out: vector */ @@ -184,7 +166,6 @@ void *ib_vector_last( Get the last element of the vector. */ UNIV_INLINE const void *ib_vector_last_const( - /*=================*/ /* out: pointer to last element */ const ib_vector_t *vec); /* in: vector */ @@ -192,23 +173,19 @@ const void *ib_vector_last_const( Sort the vector elements. */ UNIV_INLINE void ib_vector_sort( - /*===========*/ ib_vector_t *vec, /* in/out: vector */ ib_compare_t compare); /* in: the comparator to use for sort */ /******************************************************************** The default ib_vector_t heap free. Does nothing. */ UNIV_INLINE -void ib_heap_free( - /*=========*/ - ib_alloc_t *allocator, /* in: allocator */ - void *ptr); /* in: size in bytes */ +void ib_heap_free(ib_alloc_t *allocator, /* in: allocator */ + void *ptr); /* in: size in bytes */ /******************************************************************** The default ib_vector_t heap malloc. Uses mem_heap_alloc(). */ UNIV_INLINE void *ib_heap_malloc( - /*===========*/ /* out: pointer to allocated memory */ ib_alloc_t *allocator, /* in: allocator */ ulint size); /* in: size in bytes */ @@ -219,7 +196,6 @@ we have to copy the elements from the old ptr to the new ptr. Uses mem_heap_alloc(). */ UNIV_INLINE void *ib_heap_resize( - /*===========*/ /* out: pointer to reallocated memory */ ib_alloc_t *allocator, /* in: allocator */ @@ -231,7 +207,6 @@ void *ib_heap_resize( Create a heap allocator that uses the passed in heap. */ UNIV_INLINE ib_alloc_t *ib_heap_allocator_create( - /*=====================*/ /* out: heap allocator instance */ mem_heap_t *heap); /* in: heap to use */ @@ -239,7 +214,6 @@ ib_alloc_t *ib_heap_allocator_create( Free a heap allocator. */ UNIV_INLINE void ib_heap_allocator_free( - /*===================*/ ib_alloc_t *ib_ut_alloc); /* in: alloc instace to free */ /* Allocator used by ib_vector_t. */ diff --git a/storage/innobase/include/ut0vec.ic b/storage/innobase/include/ut0vec.ic index 53fdece77db7..23e87126370d 100644 --- a/storage/innobase/include/ut0vec.ic +++ b/storage/innobase/include/ut0vec.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/*******************************************************************/ /** - @file include/ut0vec.ic +/** @file include/ut0vec.ic A vector of pointers to data items Created 4/6/2006 Osku Salerma @@ -38,10 +37,8 @@ this program; if not, write to the Free Software Foundation, Inc., /******************************************************************** The default ib_vector_t heap malloc. Uses mem_heap_alloc(). */ UNIV_INLINE -void *ib_heap_malloc( - /*===========*/ - ib_alloc_t *allocator, /* in: allocator */ - ulint size) /* in: size in bytes */ +void *ib_heap_malloc(ib_alloc_t *allocator, /* in: allocator */ + ulint size) /* in: size in bytes */ { mem_heap_t *heap = (mem_heap_t *)allocator->arg; @@ -51,10 +48,8 @@ void *ib_heap_malloc( /******************************************************************** The default ib_vector_t heap free. Does nothing. */ UNIV_INLINE -void ib_heap_free( - /*=========*/ - ib_alloc_t *allocator UNIV_UNUSED, /* in: allocator */ - void *ptr UNIV_UNUSED) /* in: size in bytes */ +void ib_heap_free(ib_alloc_t *allocator UNIV_UNUSED, /* in: allocator */ + void *ptr UNIV_UNUSED) /* in: size in bytes */ { /* We can't free individual elements. */ } @@ -65,12 +60,10 @@ we have to copy the elements from the old ptr to the new ptr. We always assume new_size >= old_size, so the buffer won't overflow. Uses mem_heap_alloc(). */ UNIV_INLINE -void *ib_heap_resize( - /*===========*/ - ib_alloc_t *allocator, /* in: allocator */ - void *old_ptr, /* in: pointer to memory */ - ulint old_size, /* in: old size in bytes */ - ulint new_size) /* in: new size in bytes */ +void *ib_heap_resize(ib_alloc_t *allocator, /* in: allocator */ + void *old_ptr, /* in: pointer to memory */ + ulint old_size, /* in: old size in bytes */ + ulint new_size) /* in: new size in bytes */ { void *new_ptr; mem_heap_t *heap = (mem_heap_t *)allocator->arg; @@ -85,9 +78,7 @@ void *ib_heap_resize( /******************************************************************** Create a heap allocator that uses the passed in heap. */ UNIV_INLINE -ib_alloc_t *ib_heap_allocator_create( - /*=====================*/ - mem_heap_t *heap) /* in: heap to use */ +ib_alloc_t *ib_heap_allocator_create(mem_heap_t *heap) /* in: heap to use */ { ib_alloc_t *heap_alloc; @@ -105,7 +96,6 @@ ib_alloc_t *ib_heap_allocator_create( Free a heap allocator. */ UNIV_INLINE void ib_heap_allocator_free( - /*===================*/ ib_alloc_t *ib_ut_alloc) /* in: alloc instace to free */ { mem_heap_free((mem_heap_t *)ib_ut_alloc->arg); @@ -115,20 +105,16 @@ void ib_heap_allocator_free( Get number of elements in vector. */ UNIV_INLINE ulint ib_vector_size( - /*===========*/ /* out: number of elements in vector*/ const ib_vector_t *vec) /* in: vector */ { return (vec->used); } -/****************************************************************/ /** - Get n'th element. */ +/** Get n'th element. */ UNIV_INLINE -void *ib_vector_get( - /*==========*/ - ib_vector_t *vec, /*!< in: vector */ - ulint n) /*!< in: element index to get */ +void *ib_vector_get(ib_vector_t *vec, /*!< in: vector */ + ulint n) /*!< in: element index to get */ { ut_a(n < vec->used); @@ -139,36 +125,28 @@ void *ib_vector_get( Const version of the get n'th element. @return n'th element */ UNIV_INLINE -const void *ib_vector_get_const( - /*================*/ - const ib_vector_t *vec, /* in: vector */ - ulint n) /* in: element index to get */ +const void *ib_vector_get_const(const ib_vector_t *vec, /* in: vector */ + ulint n) /* in: element index to get */ { ut_a(n < vec->used); return ((byte *)vec->data + IB_VEC_OFFSET(vec, n)); } -/****************************************************************/ /** - Get last element. The vector must not be empty. +/** Get last element. The vector must not be empty. @return last element */ UNIV_INLINE -void *ib_vector_get_last( - /*===============*/ - ib_vector_t *vec) /*!< in: vector */ +void *ib_vector_get_last(ib_vector_t *vec) /*!< in: vector */ { ut_a(vec->used > 0); return ((byte *)ib_vector_get(vec, vec->used - 1)); } -/****************************************************************/ /** - Set the n'th element. */ +/** Set the n'th element. */ UNIV_INLINE -void ib_vector_set( - /*==========*/ - ib_vector_t *vec, /*!< in/out: vector */ - ulint n, /*!< in: element index to set */ - void *elem) /*!< in: data element */ +void ib_vector_set(ib_vector_t *vec, /*!< in/out: vector */ + ulint n, /*!< in: element index to set */ + void *elem) /*!< in: data element */ { void *slot; @@ -182,7 +160,6 @@ void ib_vector_set( Reset the vector size to 0 elements. */ UNIV_INLINE void ib_vector_reset( - /*============*/ /* out: void */ ib_vector_t *vec) /* in: vector */ { @@ -193,7 +170,6 @@ void ib_vector_reset( Get the last element of the vector. */ UNIV_INLINE void *ib_vector_last( - /*===========*/ /* out: void */ ib_vector_t *vec) /* in: vector */ { @@ -206,7 +182,6 @@ void *ib_vector_last( Get the last element of the vector. */ UNIV_INLINE const void *ib_vector_last_const( - /*=================*/ /* out: void */ const ib_vector_t *vec) /* in: vector */ { @@ -215,12 +190,10 @@ const void *ib_vector_last_const( return (ib_vector_get_const(vec, ib_vector_size(vec) - 1)); } -/****************************************************************/ /** - Remove the last element from the vector. +/** Remove the last element from the vector. @return last vector element */ UNIV_INLINE void *ib_vector_pop( - /*==========*/ /* out: pointer to element */ ib_vector_t *vec) /* in: vector */ { @@ -239,7 +212,6 @@ Append an element to the vector, if elem != NULL then copy the data from elem.*/ UNIV_INLINE void *ib_vector_push( - /*===========*/ /* out: pointer to the "new" element */ ib_vector_t *vec, /* in: vector */ const void *elem) /* in: element to add (can be NULL) */ @@ -265,14 +237,11 @@ void *ib_vector_push( return (last); } -/*******************************************************************/ /** - Remove an element to the vector +/** Remove an element to the vector @return pointer to the "removed" element */ UNIV_INLINE -void *ib_vector_remove( - /*=============*/ - ib_vector_t *vec, /*!< in: vector */ - const void *elem) /*!< in: value to remove */ +void *ib_vector_remove(ib_vector_t *vec, /*!< in: vector */ + const void *elem) /*!< in: value to remove */ { void *current = NULL; void *next; @@ -301,7 +270,6 @@ void *ib_vector_remove( Sort the vector elements. */ UNIV_INLINE void ib_vector_sort( - /*===========*/ /* out: void */ ib_vector_t *vec, /* in: vector */ ib_compare_t compare) /* in: the comparator to use for sort */ @@ -313,9 +281,7 @@ void ib_vector_sort( Destroy the vector. Make sure the vector owns the allocator, e.g., the heap in the the heap allocator. */ UNIV_INLINE -void ib_vector_free( - /*===========*/ - ib_vector_t *vec) /* in, own: vector */ +void ib_vector_free(ib_vector_t *vec) /* in, own: vector */ { /* Currently we only support one type of allocator - heap, when the heap is freed all the elements are freed too. */ @@ -330,9 +296,7 @@ void ib_vector_free( Test whether a vector is empty or not. @return true if empty */ UNIV_INLINE -ibool ib_vector_is_empty( - /*===============*/ - const ib_vector_t *vec) /*!< in: vector */ +ibool ib_vector_is_empty(const ib_vector_t *vec) /*!< in: vector */ { return (ib_vector_size(vec) == 0); } diff --git a/storage/innobase/include/ut0wqueue.h b/storage/innobase/include/ut0wqueue.h index 10e1a75c80db..348934171d32 100644 --- a/storage/innobase/include/ut0wqueue.h +++ b/storage/innobase/include/ut0wqueue.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,15 +24,13 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/*******************************************************************/ /** - @file include/ut0wqueue.h +/** @file include/ut0wqueue.h A work queue Created 4/26/2006 Osku Salerma ************************************************************************/ -/*******************************************************************/ /** - A Work queue. Threads can add work items to the queue and other threads can +/** A Work queue. Threads can add work items to the queue and other threads can wait for work items to be available and take them off the queue for processing. ************************************************************************/ @@ -48,31 +46,22 @@ this program; if not, write to the Free Software Foundation, Inc., struct ib_list_t; struct ib_wqueue_t; -/****************************************************************/ /** - Create a new work queue. +/** Create a new work queue. @return work queue */ ib_wqueue_t *ib_wqueue_create(); -/*===============*/ - -/****************************************************************/ /** - Free a work queue. */ -void ib_wqueue_free( - /*===========*/ - ib_wqueue_t *wq); /*!< in: work queue */ - -/****************************************************************/ /** - Add a work item to the queue. */ -void ib_wqueue_add( - /*==========*/ - ib_wqueue_t *wq, /*!< in: work queue */ - void *item, /*!< in: work item */ - mem_heap_t *heap); /*!< in: memory heap to use for - allocating the list node */ + +/** Free a work queue. */ +void ib_wqueue_free(ib_wqueue_t *wq); /*!< in: work queue */ + +/** Add a work item to the queue. */ +void ib_wqueue_add(ib_wqueue_t *wq, /*!< in: work queue */ + void *item, /*!< in: work item */ + mem_heap_t *heap); /*!< in: memory heap to use for + allocating the list node */ /******************************************************************** Check if queue is empty. */ ibool ib_wqueue_is_empty( - /*===============*/ /* out: TRUE if queue empty else FALSE */ const ib_wqueue_t *wq); /* in: work queue */ @@ -80,7 +69,6 @@ ibool ib_wqueue_is_empty( /******************************************************************** Wait for a work item to appear in the queue for specified time. */ void *ib_wqueue_timedwait( - /*================*/ /* out: work item or NULL on timeout*/ ib_wqueue_t *wq, /* in: work queue */ ib_time_t wait_in_usecs); /* in: wait time in micro seconds */ diff --git a/storage/innobase/lock/lock0iter.cc b/storage/innobase/lock/lock0iter.cc index b1b7fb54ff93..63b6a22184ce 100644 --- a/storage/innobase/lock/lock0iter.cc +++ b/storage/innobase/lock/lock0iter.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file lock/lock0iter.cc +/** @file lock/lock0iter.cc Lock queue iterator. Can iterate over table and record lock queues. @@ -42,8 +41,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "lock0priv.h" #include "univ.i" -/*******************************************************************/ /** - Initialize lock queue iterator so that it starts to iterate from +/** Initialize lock queue iterator so that it starts to iterate from "lock". bit_no specifies the record number within the heap where the record is stored. It can be undefined (ULINT_UNDEFINED) in two cases: 1. If the lock is a table lock, thus we have a table lock queue; @@ -52,7 +50,6 @@ this program; if not, write to the Free Software Foundation, Inc., lock_rec_find_set_bit(). There is exactly one bit set in the bitmap of a wait lock. */ void lock_queue_iterator_reset( - /*======================*/ lock_queue_iterator_t *iter, /*!< out: iterator */ const lock_t *lock, /*!< in: lock to start from */ ulint bit_no) /*!< in: record number in the @@ -79,13 +76,11 @@ void lock_queue_iterator_reset( } } -/*******************************************************************/ /** - Gets the previous lock in the lock queue, returns NULL if there are no +/** Gets the previous lock in the lock queue, returns NULL if there are no more locks (i.e. the current lock is the first one). The iterator is receded (if not-NULL is returned). @return previous lock or NULL */ const lock_t *lock_queue_iterator_get_prev( - /*=========================*/ lock_queue_iterator_t *iter) /*!< in/out: iterator */ { const lock_t *prev_lock; diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 24a199886a73..c272e716f4f8 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file lock/lock0lock.cc +/** @file lock/lock0lock.cc The transaction lock system Created 5/7/1996 Heikki Tuuri @@ -275,17 +274,13 @@ uint64_t DeadlockChecker::s_lock_mark_counter = 0; DeadlockChecker::state_t DeadlockChecker::s_states[MAX_STACK_SIZE]; #ifdef UNIV_DEBUG -/*********************************************************************/ /** - Validates the lock system. +/** Validates the lock system. @return true if ok */ static bool lock_validate(); -/*============*/ -/*********************************************************************/ /** - Validates the record lock queues on a page. +/** Validates the record lock queues on a page. @return true if ok */ static bool lock_rec_validate_page( - /*===================*/ const buf_block_t *block) /*!< in: buffer block */ MY_ATTRIBUTE((warn_unused_result)); #endif /* UNIV_DEBUG */ @@ -300,10 +295,8 @@ static bool lock_deadlock_found = false; /** Only created if !srv_read_only_mode */ static FILE *lock_latest_err_file; -/*********************************************************************/ /** - Reports that a transaction id is insensible, i.e., in the future. */ +/** Reports that a transaction id is insensible, i.e., in the future. */ void lock_report_trx_id_insanity( - /*========================*/ trx_id_t trx_id, /*!< in: trx id */ const rec_t *rec, /*!< in: user record */ const dict_index_t *index, /*!< in: index */ @@ -317,8 +310,7 @@ void lock_report_trx_id_insanity( << "! The table is corrupted."; } -/*********************************************************************/ /** - Checks that a transaction id is sensible, i.e., not in the future. +/** Checks that a transaction id is sensible, i.e., not in the future. @return true if ok */ #ifdef UNIV_DEBUG @@ -326,7 +318,6 @@ void lock_report_trx_id_insanity( static MY_ATTRIBUTE((warn_unused_result)) #endif bool lock_check_trx_id_sanity( - /*=====================*/ trx_id_t trx_id, /*!< in: trx id */ const rec_t *rec, /*!< in: user record */ const dict_index_t *index, /*!< in: index */ @@ -344,12 +335,10 @@ bool lock_check_trx_id_sanity( return (is_ok); } -/*********************************************************************/ /** - Checks that a record is seen in a consistent read. +/** Checks that a record is seen in a consistent read. @return true if sees, or false if an earlier version of the record should be retrieved */ bool lock_clust_rec_cons_read_sees( - /*==========================*/ const rec_t *rec, /*!< in: user record which should be read or passed over by a read cursor */ dict_index_t *index, /*!< in: clustered index */ @@ -377,8 +366,7 @@ bool lock_clust_rec_cons_read_sees( return (view->changes_visible(trx_id, index->table->name)); } -/*********************************************************************/ /** - Checks that a non-clustered index record is seen in a consistent read. +/** Checks that a non-clustered index record is seen in a consistent read. NOTE that a non-clustered index page contains so little information on its modifications that also in the case false, the present version of @@ -388,7 +376,6 @@ bool lock_clust_rec_cons_read_sees( @return true if certainly sees, or false if an earlier version of the clustered index record might be needed */ bool lock_sec_rec_cons_read_sees( - /*========================*/ const rec_t *rec, /*!< in: user record which should be read or passed over by a read cursor */ @@ -419,10 +406,8 @@ bool lock_sec_rec_cons_read_sees( return (view->sees(max_trx_id)); } -/*********************************************************************/ /** - Creates the lock system at database start. */ +/** Creates the lock system at database start. */ void lock_sys_create( - /*============*/ ulint n_cells) /*!< in: number of slots in lock hash table */ { ulint lock_sys_sz; @@ -507,11 +492,8 @@ void lock_sys_resize(ulint n_cells) { lock_mutex_exit(); } -/*********************************************************************/ /** - Closes the lock system at database shutdown. */ -void lock_sys_close(void) -/*================*/ -{ +/** Closes the lock system at database shutdown. */ +void lock_sys_close(void) { if (lock_latest_err_file != NULL) { fclose(lock_latest_err_file); lock_latest_err_file = NULL; @@ -539,22 +521,14 @@ void lock_sys_close(void) lock_sys = NULL; } -/*********************************************************************/ /** - Gets the size of a lock struct. +/** Gets the size of a lock struct. @return size in bytes */ -ulint lock_get_size(void) -/*===============*/ -{ - return ((ulint)sizeof(lock_t)); -} +ulint lock_get_size(void) { return ((ulint)sizeof(lock_t)); } -/*********************************************************************/ /** - Sets the wait flag of a lock and the back pointer in trx to lock. */ +/** Sets the wait flag of a lock and the back pointer in trx to lock. */ UNIV_INLINE -void lock_set_lock_and_trx_wait( - /*=======================*/ - lock_t *lock, /*!< in: lock */ - trx_t *trx) /*!< in/out: trx */ +void lock_set_lock_and_trx_wait(lock_t *lock, /*!< in: lock */ + trx_t *trx) /*!< in/out: trx */ { ut_ad(lock->trx == trx); ut_ad(trx->lock.wait_lock == NULL); @@ -565,13 +539,10 @@ void lock_set_lock_and_trx_wait( lock->type_mode |= LOCK_WAIT; } -/**********************************************************************/ /** - The back pointer to a waiting lock request in the transaction is set to NULL +/** The back pointer to a waiting lock request in the transaction is set to NULL and the wait bit in lock type_mode is reset. */ UNIV_INLINE -void lock_reset_lock_and_trx_wait( - /*=========================*/ - lock_t *lock) /*!< in/out: record lock */ +void lock_reset_lock_and_trx_wait(lock_t *lock) /*!< in/out: record lock */ { ut_ad(lock->trx->lock.wait_lock == lock); ut_ad(lock_get_wait(lock)); @@ -581,51 +552,40 @@ void lock_reset_lock_and_trx_wait( lock->type_mode &= ~LOCK_WAIT; } -/*********************************************************************/ /** - Gets the gap flag of a record lock. +/** Gets the gap flag of a record lock. @return LOCK_GAP or 0 */ UNIV_INLINE -ulint lock_rec_get_gap( - /*=============*/ - const lock_t *lock) /*!< in: record lock */ +ulint lock_rec_get_gap(const lock_t *lock) /*!< in: record lock */ { ut_ad(lock_get_type_low(lock) == LOCK_REC); return (lock->type_mode & LOCK_GAP); } -/*********************************************************************/ /** - Gets the LOCK_REC_NOT_GAP flag of a record lock. +/** Gets the LOCK_REC_NOT_GAP flag of a record lock. @return LOCK_REC_NOT_GAP or 0 */ UNIV_INLINE -ulint lock_rec_get_rec_not_gap( - /*=====================*/ - const lock_t *lock) /*!< in: record lock */ +ulint lock_rec_get_rec_not_gap(const lock_t *lock) /*!< in: record lock */ { ut_ad(lock_get_type_low(lock) == LOCK_REC); return (lock->type_mode & LOCK_REC_NOT_GAP); } -/*********************************************************************/ /** - Gets the waiting insert flag of a record lock. +/** Gets the waiting insert flag of a record lock. @return LOCK_INSERT_INTENTION or 0 */ UNIV_INLINE -ulint lock_rec_get_insert_intention( - /*==========================*/ - const lock_t *lock) /*!< in: record lock */ +ulint lock_rec_get_insert_intention(const lock_t *lock) /*!< in: record lock */ { ut_ad(lock_get_type_low(lock) == LOCK_REC); return (lock->type_mode & LOCK_INSERT_INTENTION); } -/*********************************************************************/ /** - Checks if a lock request for a new lock has to wait for request lock2. +/** Checks if a lock request for a new lock has to wait for request lock2. @return true if new lock has to wait for lock2 to be removed */ UNIV_INLINE bool lock_rec_has_to_wait( - /*=================*/ const trx_t *trx, /*!< in: trx of new lock */ ulint type_mode, /*!< in: precise mode of the new lock to set: LOCK_S or LOCK_X, possibly @@ -695,11 +655,9 @@ request is really for a 'gap' type lock */ return (false); } -/*********************************************************************/ /** - Checks if a lock request lock1 has to wait for request lock2. +/** Checks if a lock request lock1 has to wait for request lock2. @return true if lock1 has to wait for lock2 to be removed */ bool lock_has_to_wait( - /*=============*/ const lock_t *lock1, /*!< in: waiting lock */ const lock_t *lock2) /*!< in: another lock; NOTE that it is assumed that this has a lock bit set @@ -732,13 +690,11 @@ bool lock_has_to_wait( /*============== RECORD LOCK BASIC FUNCTIONS ============================*/ -/**********************************************************************/ /** - Looks for a set bit in a record lock bitmap. Returns ULINT_UNDEFINED, +/** Looks for a set bit in a record lock bitmap. Returns ULINT_UNDEFINED, if none found. @return bit index == heap number of the record, or ULINT_UNDEFINED if none found */ ulint lock_rec_find_set_bit( - /*==================*/ const lock_t *lock) /*!< in: record lock with at least one bit set */ { for (ulint i = 0; i < lock_rec_get_n_bits(lock); ++i) { @@ -801,13 +757,10 @@ void lock_rec_trx_wait(lock_t *lock, ulint i, ulint type) { } } -/*********************************************************************/ /** - Determines if there are explicit record locks on a page. +/** Determines if there are explicit record locks on a page. @return an explicit record lock on the page, or NULL if there are none */ -lock_t *lock_rec_expl_exist_on_page( - /*========================*/ - space_id_t space, /*!< in: space id */ - page_no_t page_no) /*!< in: page number */ +lock_t *lock_rec_expl_exist_on_page(space_id_t space, /*!< in: space id */ + page_no_t page_no) /*!< in: page number */ { lock_t *lock; @@ -819,13 +772,10 @@ lock_t *lock_rec_expl_exist_on_page( return (lock); } -/*********************************************************************/ /** - Resets the record lock bitmap to zero. NOTE: does not touch the wait_lock +/** Resets the record lock bitmap to zero. NOTE: does not touch the wait_lock pointer in the transaction! This function is used in lock object creation and resetting. */ -static void lock_rec_bitmap_reset( - /*==================*/ - lock_t *lock) /*!< in: record lock */ +static void lock_rec_bitmap_reset(lock_t *lock) /*!< in: record lock */ { ulint n_bytes; @@ -841,13 +791,10 @@ static void lock_rec_bitmap_reset( memset(&lock[1], 0, n_bytes); } -/*********************************************************************/ /** - Copies a record lock to heap. +/** Copies a record lock to heap. @return copy of lock */ -static lock_t *lock_rec_copy( - /*==========*/ - const lock_t *lock, /*!< in: record lock */ - mem_heap_t *heap) /*!< in: memory heap */ +static lock_t *lock_rec_copy(const lock_t *lock, /*!< in: record lock */ + mem_heap_t *heap) /*!< in: memory heap */ { ulint size; @@ -858,11 +805,9 @@ static lock_t *lock_rec_copy( return (static_cast(mem_heap_dup(heap, lock, size))); } -/*********************************************************************/ /** - Gets the previous record lock set on a record. +/** Gets the previous record lock set on a record. @return previous lock on the same record, NULL if none exists */ const lock_t *lock_rec_get_prev( - /*==============*/ const lock_t *in_lock, /*!< in: record lock */ ulint heap_no) /*!< in: heap number of the record */ { @@ -896,13 +841,11 @@ const lock_t *lock_rec_get_prev( /*============= FUNCTIONS FOR ANALYZING RECORD LOCK QUEUE ================*/ -/*********************************************************************/ /** - Checks if a transaction has a GRANTED explicit lock on rec stronger or equal +/** Checks if a transaction has a GRANTED explicit lock on rec stronger or equal to precise_mode. @return lock or NULL */ UNIV_INLINE const lock_t *lock_rec_has_expl( - /*==============*/ ulint precise_mode, /*!< in: LOCK_S or LOCK_X possibly ORed to LOCK_GAP or LOCK_REC_NOT_GAP, for a @@ -957,11 +900,9 @@ bool can_trx_be_ignored(const trx_t *trx) { #ifdef UNIV_DEBUG -/*********************************************************************/ /** - Checks if some other transaction has a lock request in the queue. +/** Checks if some other transaction has a lock request in the queue. @return lock or NULL */ static const lock_t *lock_rec_other_has_expl_req( - /*========================*/ lock_mode mode, /*!< in: LOCK_S or LOCK_X */ const buf_block_t *block, /*!< in: buffer block containing the record */ @@ -1000,12 +941,10 @@ static const lock_t *lock_rec_other_has_expl_req( } #endif /* UNIV_DEBUG */ -/*********************************************************************/ /** - Checks if some other transaction has a conflicting explicit lock request +/** Checks if some other transaction has a conflicting explicit lock request in the queue, so that we have to wait. @return lock or NULL */ static const lock_t *lock_rec_other_has_conflicting( - /*===========================*/ ulint mode, /*!< in: LOCK_S or LOCK_X, possibly ORed to LOCK_GAP or LOC_REC_NOT_GAP, @@ -1031,15 +970,13 @@ static const lock_t *lock_rec_other_has_conflicting( return (lock); } -/*********************************************************************/ /** - Checks if some transaction has an implicit x-lock on a record in a secondary +/** Checks if some transaction has an implicit x-lock on a record in a secondary index. @return transaction id of the transaction which has the x-lock, or 0; NOTE that this function can return false positives but never false negatives. The caller must confirm all positive results by calling trx_is_active(). */ static trx_t *lock_sec_rec_some_has_impl( - /*=======================*/ const rec_t *rec, /*!< in: user record */ dict_index_t *index, /*!< in: secondary index */ const ulint *offsets) /*!< in: rec_get_offsets(rec, index) */ @@ -1080,13 +1017,11 @@ static trx_t *lock_sec_rec_some_has_impl( } #ifdef UNIV_DEBUG -/*********************************************************************/ /** - Checks if some transaction, other than given trx_id, has an explicit +/** Checks if some transaction, other than given trx_id, has an explicit lock on the given rec, in the given precise_mode. @return the transaction, whose id is not equal to trx_id, that has an explicit lock on the given rec, in the given precise_mode or NULL.*/ static trx_t *lock_rec_other_trx_holds_expl( - /*==========================*/ ulint precise_mode, /*!< in: LOCK_S or LOCK_X possibly ORed to LOCK_GAP or LOCK_REC_NOT_GAP. */ @@ -1127,13 +1062,11 @@ static trx_t *lock_rec_other_trx_holds_expl( } #endif /* UNIV_DEBUG */ -/*********************************************************************/ /** - Return approximate number or record locks (bits set in the bitmap) for +/** Return approximate number or record locks (bits set in the bitmap) for this transaction. Since delete-marked records may be removed, the record count will not be precise. The caller must be holding lock_sys->mutex. */ ulint lock_number_of_rows_locked( - /*=======================*/ const trx_lock_t *trx_lock) /*!< in: transaction locks */ { ut_ad(lock_mutex_own()); @@ -1141,11 +1074,9 @@ ulint lock_number_of_rows_locked( return (trx_lock->n_rec_locks); } -/*********************************************************************/ /** - Return the number of table locks for a transaction. +/** Return the number of table locks for a transaction. The caller must be holding lock_sys->mutex. */ ulint lock_number_of_tables_locked( - /*=========================*/ const trx_lock_t *trx_lock) /*!< in: transaction locks */ { const lock_t *lock; @@ -1668,8 +1599,7 @@ dberr_t RecLock::add_to_waitq(const lock_t *wait_for, const lock_prdt_t *prdt) { return (err); } -/*********************************************************************/ /** - Adds a record lock request in the record queue. The request is normally +/** Adds a record lock request in the record queue. The request is normally added as the last in the queue, but if there are no waiting lock requests on the record, and the request to be added is not a waiting request, we can reuse a suitable record lock object already existing on the same page, @@ -1677,7 +1607,6 @@ dberr_t RecLock::add_to_waitq(const lock_t *wait_for, const lock_prdt_t *prdt) { which does NOT check for deadlocks or lock compatibility! @return lock where the bit was set */ static void lock_rec_add_to_queue( - /*==================*/ ulint type_mode, /*!< in: lock mode, wait, gap etc. flags; type is ignored and replaced by LOCK_REC */ @@ -1757,8 +1686,7 @@ static void lock_rec_add_to_queue( rec_lock.create(trx, true); } -/*********************************************************************/ /** - This is a fast routine for locking a record in the most common cases: +/** This is a fast routine for locking a record in the most common cases: there are no explicit locks on the page, or there is just one lock, owned by this transaction, and of the right type_mode. This is a low-level function which does NOT look at implicit locks! Checks lock compatibility within @@ -1767,7 +1695,6 @@ static void lock_rec_add_to_queue( @return whether the locking succeeded */ UNIV_INLINE lock_rec_req_status lock_rec_lock_fast( - /*===============*/ bool impl, /*!< in: if true, no lock is set if no wait is necessary: we assume that the caller will @@ -1980,11 +1907,9 @@ static dberr_t lock_rec_lock(bool impl, select_mode sel_mode, ulint mode, return (DB_ERROR); } -/*********************************************************************/ /** - Checks if a waiting record lock request still has to wait in a queue. +/** Checks if a waiting record lock request still has to wait in a queue. @return lock that is causing the wait */ static const lock_t *lock_rec_has_to_wait_in_queue( - /*==========================*/ const lock_t *wait_lock) /*!< in: waiting record lock */ { const lock_t *lock; @@ -2021,12 +1946,9 @@ static const lock_t *lock_rec_has_to_wait_in_queue( return (NULL); } -/*************************************************************/ /** - Grants a lock to a waiting lock request and releases the waiting transaction. - The caller must hold lock_sys->mutex but not lock->trx->mutex. */ -static void lock_grant( - /*=======*/ - lock_t *lock) /*!< in/out: waiting lock request */ +/** Grants a lock to a waiting lock request and releases the waiting + transaction. The caller must hold lock_sys->mutex but not lock->trx->mutex. */ +static void lock_grant(lock_t *lock) /*!< in/out: waiting lock request */ { ut_ad(lock_mutex_own()); @@ -2287,12 +2209,10 @@ void RecLock::make_trx_hit_list(lock_t *lock, const lock_t *conflict_lock) { ut_ad(next == lock); } -/*************************************************************/ /** - Cancels a waiting record lock request and releases the waiting transaction +/** Cancels a waiting record lock request and releases the waiting transaction that requested it. NOTE: does NOT check if waiting lock requests behind this one can now be granted! */ static void lock_rec_cancel( - /*============*/ lock_t *lock) /*!< in: waiting record lock request */ { que_thr_t *thr; @@ -2654,13 +2574,12 @@ void lock_rec_discard(lock_t *in_lock) { MONITOR_DEC(MONITOR_NUM_RECLOCK); } -/*************************************************************/ /** - Removes record lock objects set on an index page which is discarded. This +/** Removes record lock objects set on an index page which is discarded. This function does not move locks, or check for waiting locks, therefore the lock bitmaps must already be reset when this function is called. */ -static void lock_rec_free_all_from_discard_page_low( - /*====================================*/ - space_id_t space, page_no_t page_no, hash_table_t *lock_hash) { +static void lock_rec_free_all_from_discard_page_low(space_id_t space, + page_no_t page_no, + hash_table_t *lock_hash) { lock_t *lock; lock_t *next_lock; @@ -2678,12 +2597,10 @@ static void lock_rec_free_all_from_discard_page_low( } } -/*************************************************************/ /** - Removes record lock objects set on an index page which is discarded. This +/** Removes record lock objects set on an index page which is discarded. This function does not move locks, or check for waiting locks, therefore the lock bitmaps must already be reset when this function is called. */ void lock_rec_free_all_from_discard_page( - /*================================*/ const buf_block_t *block) /*!< in: page to be discarded */ { space_id_t space; @@ -2702,11 +2619,9 @@ void lock_rec_free_all_from_discard_page( /*============= RECORD LOCK MOVING AND INHERITING ===================*/ -/*************************************************************/ /** - Resets the lock bits for a single record. Releases transactions waiting for +/** Resets the lock bits for a single record. Releases transactions waiting for lock requests here. */ static void lock_rec_reset_and_release_wait_low( - /*================================*/ hash_table_t *hash, /*!< in: hash table */ const buf_block_t *block, /*!< in: buffer block containing the record */ @@ -2726,11 +2641,9 @@ static void lock_rec_reset_and_release_wait_low( } } -/*************************************************************/ /** - Resets the lock bits for a single record. Releases transactions waiting for +/** Resets the lock bits for a single record. Releases transactions waiting for lock requests here. */ static void lock_rec_reset_and_release_wait( - /*============================*/ const buf_block_t *block, /*!< in: buffer block containing the record */ ulint heap_no) /*!< in: heap number of record */ @@ -2743,13 +2656,11 @@ static void lock_rec_reset_and_release_wait( PAGE_HEAP_NO_INFIMUM); } -/*************************************************************/ /** - Makes a record to inherit the locks (except LOCK_INSERT_INTENTION type) +/** Makes a record to inherit the locks (except LOCK_INSERT_INTENTION type) of another record as gap type locks, but does not reset the lock bits of the other record. Also waiting lock requests on rec are inherited as GRANTED gap locks. */ static void lock_rec_inherit_to_gap( - /*====================*/ const buf_block_t *heir_block, /*!< in: block containing the record which inherits */ const buf_block_t *block, /*!< in: block containing the @@ -2790,12 +2701,10 @@ static void lock_rec_inherit_to_gap( } } -/*************************************************************/ /** - Makes a record to inherit the gap locks (except LOCK_INSERT_INTENTION type) +/** Makes a record to inherit the gap locks (except LOCK_INSERT_INTENTION type) of another record as gap type locks, but does not reset the lock bits of the other record. Also waiting lock requests are inherited as GRANTED gap locks. */ static void lock_rec_inherit_to_gap_if_gap_lock( - /*================================*/ const buf_block_t *block, /*!< in: buffer block */ ulint heir_heap_no, /*!< in: heap_no of record which inherits */ @@ -2825,11 +2734,9 @@ static void lock_rec_inherit_to_gap_if_gap_lock( lock_mutex_exit(); } -/*************************************************************/ /** - Moves the locks of a record to another record and resets the lock bits of +/** Moves the locks of a record to another record and resets the lock bits of the donating record. */ static void lock_rec_move_low( - /*==============*/ hash_table_t *lock_hash, /*!< in: hash table to use */ const buf_block_t *receiver, /*!< in: buffer block containing the receiving record */ @@ -2901,34 +2808,29 @@ static void lock_move_granted_locks_to_front(UT_LIST_BASE_NODE_T(lock_t) & } } -/*************************************************************/ /** - Moves the locks of a record to another record and resets the lock bits of +/** Moves the locks of a record to another record and resets the lock bits of the donating record. */ UNIV_INLINE -void lock_rec_move( - /*==========*/ - const buf_block_t *receiver, /*!< in: buffer block containing - the receiving record */ - const buf_block_t *donator, /*!< in: buffer block containing - the donating record */ - ulint receiver_heap_no, /*!< in: heap_no of the record - which gets the locks; there - must be no lock requests - on it! */ - ulint donator_heap_no) /*!< in: heap_no of the record - which gives the locks */ +void lock_rec_move(const buf_block_t *receiver, /*!< in: buffer block containing + the receiving record */ + const buf_block_t *donator, /*!< in: buffer block containing + the donating record */ + ulint receiver_heap_no, /*!< in: heap_no of the record + which gets the locks; there + must be no lock requests + on it! */ + ulint donator_heap_no) /*!< in: heap_no of the record + which gives the locks */ { lock_rec_move_low(lock_sys->rec_hash, receiver, donator, receiver_heap_no, donator_heap_no); } -/*************************************************************/ /** - Updates the lock table when we have reorganized a page. NOTE: we copy +/** Updates the lock table when we have reorganized a page. NOTE: we copy also the locks set on the infimum of the page; the infimum may carry locks if an update of a record is occurring on the page, and its locks were temporarily stored on the infimum. */ void lock_move_reorganize_page( - /*======================*/ const buf_block_t *block, /*!< in: old index page, now reorganized */ const buf_block_t *oblock) /*!< in: copy of the old, not @@ -3049,11 +2951,9 @@ void lock_move_reorganize_page( #endif /* UNIV_DEBUG_LOCK_VALIDATE */ } -/*************************************************************/ /** - Moves the explicit locks on user records to another page if a record +/** Moves the explicit locks on user records to another page if a record list end is moved to another page. */ void lock_move_rec_list_end( - /*===================*/ const buf_block_t *new_block, /*!< in: index page to move to */ const buf_block_t *block, /*!< in: index page */ const rec_t *rec) /*!< in: record on page: this @@ -3147,11 +3047,9 @@ void lock_move_rec_list_end( #endif /* UNIV_DEBUG_LOCK_VALIDATE */ } -/*************************************************************/ /** - Moves the explicit locks on user records to another page if a record +/** Moves the explicit locks on user records to another page if a record list start is moved to another page. */ void lock_move_rec_list_start( - /*=====================*/ const buf_block_t *new_block, /*!< in: index page to move to */ const buf_block_t *block, /*!< in: index page */ @@ -3244,17 +3142,14 @@ void lock_move_rec_list_start( #endif /* UNIV_DEBUG_LOCK_VALIDATE */ } -/*************************************************************/ /** - Moves the explicit locks on user records to another page if a record +/** Moves the explicit locks on user records to another page if a record list start is moved to another page. */ -void lock_rtr_move_rec_list( - /*===================*/ - const buf_block_t *new_block, /*!< in: index page to - move to */ - const buf_block_t *block, /*!< in: index page */ - rtr_rec_move_t *rec_move, /*!< in: recording records - moved */ - ulint num_move) /*!< in: num of rec to move */ +void lock_rtr_move_rec_list(const buf_block_t *new_block, /*!< in: index page to + move to */ + const buf_block_t *block, /*!< in: index page */ + rtr_rec_move_t *rec_move, /*!< in: recording records + moved */ + ulint num_move) /*!< in: num of rec to move */ { lock_t *lock; ulint comp; @@ -3321,10 +3216,8 @@ void lock_rtr_move_rec_list( ut_ad(lock_rec_validate_page(block)); #endif } -/*************************************************************/ /** - Updates the lock table when a page is split to the right. */ +/** Updates the lock table when a page is split to the right. */ void lock_update_split_right( - /*====================*/ const buf_block_t *right_block, /*!< in: right page */ const buf_block_t *left_block) /*!< in: left page */ { @@ -3347,10 +3240,8 @@ void lock_update_split_right( lock_mutex_exit(); } -/*************************************************************/ /** - Updates the lock table when a page is merged to the right. */ +/** Updates the lock table when a page is merged to the right. */ void lock_update_merge_right( - /*====================*/ const buf_block_t *right_block, /*!< in: right page to which merged */ const rec_t *orig_succ, /*!< in: original @@ -3391,15 +3282,13 @@ void lock_update_merge_right( lock_mutex_exit(); } -/*************************************************************/ /** - Updates the lock table when the root page is copied to another in +/** Updates the lock table when the root page is copied to another in btr_root_raise_and_insert. Note that we leave lock structs on the root page, even though they do not make sense on other than leaf pages: the reason is that in a pessimistic update the infimum record of the root page will act as a dummy carrier of the locks of the record to be updated. */ void lock_update_root_raise( - /*===================*/ const buf_block_t *block, /*!< in: index page to which copied */ const buf_block_t *root) /*!< in: root page */ { @@ -3412,11 +3301,9 @@ void lock_update_root_raise( lock_mutex_exit(); } -/*************************************************************/ /** - Updates the lock table when a page is copied to another and the original page - is removed from the chain of leaf pages, except if page is the root! */ +/** Updates the lock table when a page is copied to another and the original + page is removed from the chain of leaf pages, except if page is the root! */ void lock_update_copy_and_discard( - /*=========================*/ const buf_block_t *new_block, /*!< in: index page to which copied */ const buf_block_t *block) /*!< in: index page; @@ -3433,10 +3320,8 @@ void lock_update_copy_and_discard( lock_mutex_exit(); } -/*************************************************************/ /** - Updates the lock table when a page is split to the left. */ +/** Updates the lock table when a page is split to the left. */ void lock_update_split_left( - /*===================*/ const buf_block_t *right_block, /*!< in: right page */ const buf_block_t *left_block) /*!< in: left page */ { @@ -3453,10 +3338,8 @@ void lock_update_split_left( lock_mutex_exit(); } -/*************************************************************/ /** - Updates the lock table when a page is merged to the left. */ +/** Updates the lock table when a page is merged to the left. */ void lock_update_merge_left( - /*===================*/ const buf_block_t *left_block, /*!< in: left page to which merged */ const rec_t *orig_pred, /*!< in: original predecessor @@ -3509,11 +3392,9 @@ void lock_update_merge_left( lock_mutex_exit(); } -/*************************************************************/ /** - Resets the original locks on heir and replaces them with gap type locks +/** Resets the original locks on heir and replaces them with gap type locks inherited from rec. */ void lock_rec_reset_and_inherit_gap_locks( - /*=================================*/ const buf_block_t *heir_block, /*!< in: block containing the record which inherits */ const buf_block_t *block, /*!< in: block containing the @@ -3534,10 +3415,8 @@ void lock_rec_reset_and_inherit_gap_locks( lock_mutex_exit(); } -/*************************************************************/ /** - Updates the lock table when a page is discarded. */ +/** Updates the lock table when a page is discarded. */ void lock_update_discard( - /*================*/ const buf_block_t *heir_block, /*!< in: index page which will inherit the locks */ ulint heir_heap_no, /*!< in: heap_no of the record @@ -3594,10 +3473,8 @@ void lock_update_discard( lock_mutex_exit(); } -/*************************************************************/ /** - Updates the lock table when a new user record is inserted. */ +/** Updates the lock table when a new user record is inserted. */ void lock_update_insert( - /*===============*/ const buf_block_t *block, /*!< in: buffer block containing rec */ const rec_t *rec) /*!< in: the inserted record */ { @@ -3620,10 +3497,8 @@ void lock_update_insert( lock_rec_inherit_to_gap_if_gap_lock(block, receiver_heap_no, donator_heap_no); } -/*************************************************************/ /** - Updates the lock table when a record is removed. */ +/** Updates the lock table when a record is removed. */ void lock_update_delete( - /*===============*/ const buf_block_t *block, /*!< in: buffer block containing rec */ const rec_t *rec) /*!< in: the record to be removed */ { @@ -3654,15 +3529,13 @@ void lock_update_delete( lock_mutex_exit(); } -/*********************************************************************/ /** - Stores on the page infimum record the explicit locks of another record. +/** Stores on the page infimum record the explicit locks of another record. This function is used to store the lock state of a record when it is updated and the size of the record changes in the update. The record is moved in such an update, perhaps to another page. The infimum record acts as a dummy carrier record, taking care of lock releases while the actual record is being moved. */ void lock_rec_store_on_page_infimum( - /*===========================*/ const buf_block_t *block, /*!< in: buffer block containing rec */ const rec_t *rec) /*!< in: record whose lock state is stored on the infimum @@ -3681,11 +3554,9 @@ void lock_rec_store_on_page_infimum( lock_mutex_exit(); } -/*********************************************************************/ /** - Restores the state of explicit lock requests on a single record, where the +/** Restores the state of explicit lock requests on a single record, where the state was stored on the infimum of the page. */ void lock_rec_restore_from_page_infimum( - /*===============================*/ const buf_block_t *block, /*!< in: buffer block containing rec */ const rec_t *rec, /*!< in: record whose lock state is restored */ @@ -3713,18 +3584,15 @@ struct TableLockGetNode { } }; -/*********************************************************************/ /** - Creates a table lock object and adds it as the last in the lock queue +/** Creates a table lock object and adds it as the last in the lock queue of the table. Does NOT check for deadlocks or lock compatibility. @return own: new lock object */ UNIV_INLINE -lock_t *lock_table_create( - /*==============*/ - dict_table_t *table, /*!< in/out: database table - in dictionary cache */ - ulint type_mode, /*!< in: lock mode possibly ORed with - LOCK_WAIT */ - trx_t *trx) /*!< in: trx */ +lock_t *lock_table_create(dict_table_t *table, /*!< in/out: database table + in dictionary cache */ + ulint type_mode, /*!< in: lock mode possibly ORed with + LOCK_WAIT */ + trx_t *trx) /*!< in: trx */ { lock_t *lock; @@ -3787,13 +3655,11 @@ lock_t *lock_table_create( return (lock); } -/*************************************************************/ /** - Pops autoinc lock requests from the transaction's autoinc_locks. We +/** Pops autoinc lock requests from the transaction's autoinc_locks. We handle the case where there are gaps in the array and they need to be popped off the stack. */ UNIV_INLINE void lock_table_pop_autoinc_locks( - /*=========================*/ trx_t *trx) /*!< in/out: transaction that owns the AUTOINC locks */ { ut_ad(lock_mutex_own()); @@ -3812,11 +3678,9 @@ void lock_table_pop_autoinc_locks( } while (*(lock_t **)ib_vector_get_last(trx->autoinc_locks) == NULL); } -/*************************************************************/ /** - Removes an autoinc lock request from the transaction's autoinc_locks. */ +/** Removes an autoinc lock request from the transaction's autoinc_locks. */ UNIV_INLINE void lock_table_remove_autoinc_lock( - /*===========================*/ lock_t *lock, /*!< in: table lock */ trx_t *trx) /*!< in/out: transaction that owns the lock */ { @@ -3861,14 +3725,11 @@ void lock_table_remove_autoinc_lock( } } -/*************************************************************/ /** - Removes a table lock request from the queue and the trx list of locks; +/** Removes a table lock request from the queue and the trx list of locks; this is a low-level function which does NOT check if waiting requests can now be granted. */ UNIV_INLINE -void lock_table_remove_low( - /*==================*/ - lock_t *lock) /*!< in/out: table lock */ +void lock_table_remove_low(lock_t *lock) /*!< in/out: table lock */ { trx_t *trx; dict_table_t *table; @@ -3911,15 +3772,13 @@ void lock_table_remove_low( MONITOR_DEC(MONITOR_NUM_TABLELOCK); } -/*********************************************************************/ /** - Enqueues a waiting request for a table lock which cannot be granted +/** Enqueues a waiting request for a table lock which cannot be granted immediately. Checks for deadlocks. @return DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED, or DB_SUCCESS; DB_SUCCESS means that there was a deadlock, but another transaction was chosen as a victim, and we got the lock immediately: no need to wait then */ static dberr_t lock_table_enqueue_waiting( - /*=======================*/ ulint mode, /*!< in: lock mode this transaction is requesting */ dict_table_t *table, /*!< in/out: table */ @@ -3990,13 +3849,11 @@ static dberr_t lock_table_enqueue_waiting( return (DB_LOCK_WAIT); } -/*********************************************************************/ /** - Checks if other transactions have an incompatible mode lock request in +/** Checks if other transactions have an incompatible mode lock request in the lock queue. @return lock or NULL */ UNIV_INLINE const lock_t *lock_table_other_has_incompatible( - /*==============================*/ const trx_t *trx, /*!< in: transaction, or NULL if all transactions should be included */ ulint wait, /*!< in: LOCK_WAIT if also @@ -4020,18 +3877,15 @@ const lock_t *lock_table_other_has_incompatible( return (NULL); } -/*********************************************************************/ /** - Locks the specified database table in the mode given. If the lock cannot +/** Locks the specified database table in the mode given. If the lock cannot be granted immediately, the query thread is put to wait. @return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ -dberr_t lock_table( - /*=======*/ - ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG bit is set, - does nothing */ - dict_table_t *table, /*!< in/out: database table - in dictionary cache */ - lock_mode mode, /*!< in: lock mode */ - que_thr_t *thr) /*!< in: query thread */ +dberr_t lock_table(ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG bit is set, + does nothing */ + dict_table_t *table, /*!< in/out: database table + in dictionary cache */ + lock_mode mode, /*!< in: lock mode */ + que_thr_t *thr) /*!< in: query thread */ { trx_t *trx; dberr_t err; @@ -4098,12 +3952,9 @@ dberr_t lock_table( return (err); } -/*********************************************************************/ /** - Creates a table IX lock object for a resurrected transaction. */ -void lock_table_ix_resurrect( - /*====================*/ - dict_table_t *table, /*!< in/out: table */ - trx_t *trx) /*!< in/out: transaction */ +/** Creates a table IX lock object for a resurrected transaction. */ +void lock_table_ix_resurrect(dict_table_t *table, /*!< in/out: table */ + trx_t *trx) /*!< in/out: transaction */ { ut_ad(trx->is_recovered); @@ -4124,11 +3975,9 @@ void lock_table_ix_resurrect( trx_mutex_exit(trx); } -/*********************************************************************/ /** - Checks if a waiting table lock request still has to wait in a queue. +/** Checks if a waiting table lock request still has to wait in a queue. @return true if still has to wait */ static bool lock_table_has_to_wait_in_queue( - /*============================*/ const lock_t *wait_lock) /*!< in: waiting table lock */ { const dict_table_t *table; @@ -4149,12 +3998,10 @@ static bool lock_table_has_to_wait_in_queue( return (false); } -/*************************************************************/ /** - Removes a table lock request, waiting or granted, from the queue and grants +/** Removes a table lock request, waiting or granted, from the queue and grants locks to other transactions in the queue, if they now are entitled to a lock. */ static void lock_table_dequeue( - /*===============*/ lock_t *in_lock) /*!< in/out: table lock object; transactions waiting behind will get their lock requests granted, if they are now qualified to it */ @@ -4280,12 +4127,10 @@ static void lock_rec_unlock_grant(trx_t *trx, lock_t *first_lock, lock_t *lock, } } -/*************************************************************/ /** - Removes a granted record lock of a transaction from the queue and grants +/** Removes a granted record lock of a transaction from the queue and grants locks to other transactions waiting in the queue if they now are entitled to a lock. */ void lock_rec_unlock( - /*============*/ trx_t *trx, /*!< in/out: transaction that has set a record lock */ const buf_block_t *block, /*!< in: buffer block containing rec */ @@ -4420,12 +4265,9 @@ void lock_trx_release_read_locks(trx_t *trx, bool only_gap) { lock_mutex_exit(); } -/*********************************************************************/ /** - Releases transaction locks, and releases possible other transactions waiting +/** Releases transaction locks, and releases possible other transactions waiting because of these locks. */ -static void lock_release( - /*=========*/ - trx_t *trx) /*!< in/out: transaction */ +static void lock_release(trx_t *trx) /*!< in/out: transaction */ { lock_t *lock; ulint count = 0; @@ -4461,10 +4303,8 @@ static void lock_release( #define IS_LOCK_S_OR_X(lock) \ (lock_get_mode(lock) == LOCK_S || lock_get_mode(lock) == LOCK_X) -/*********************************************************************/ /** - Removes table locks of the transaction on a table to be dropped. */ +/** Removes table locks of the transaction on a table to be dropped. */ static void lock_trx_table_locks_remove( - /*========================*/ const lock_t *lock_to_remove) /*!< in: lock to remove */ { trx_t *trx = lock_to_remove->trx; @@ -4512,13 +4352,11 @@ static void lock_trx_table_locks_remove( ut_error; } -/*********************************************************************/ /** - Removes locks of a transaction on a table to be dropped. +/** Removes locks of a transaction on a table to be dropped. If remove_also_table_sx_locks is true then table-level S and X locks are also removed in addition to other table-level and record-level locks. No lock that is going to be removed is allowed to be a wait lock. */ static void lock_remove_all_on_table_for_trx( - /*=============================*/ dict_table_t *table, /*!< in: table to be dropped */ trx_t *trx, /*!< in: a transaction */ ibool remove_also_table_sx_locks) /*!< in: also removes @@ -4548,12 +4386,10 @@ static void lock_remove_all_on_table_for_trx( } } -/*******************************************************************/ /** - Remove any explicit record locks held by recovering transactions on +/** Remove any explicit record locks held by recovering transactions on the table. @return number of recovered transactions examined */ static ulint lock_remove_recovered_trx_record_locks( - /*===================================*/ dict_table_t *table) /*!< in: check if there are any locks held on records in this table or on the table itself */ @@ -4613,13 +4449,11 @@ static ulint lock_remove_recovered_trx_record_locks( return (n_recovered_trx); } -/*********************************************************************/ /** - Removes locks on a table to be dropped. +/** Removes locks on a table to be dropped. If remove_also_table_sx_locks is true then table-level S and X locks are also removed in addition to other table-level and record-level locks. No lock, that is going to be removed, is allowed to be a wait lock. */ void lock_remove_all_on_table( - /*=====================*/ dict_table_t *table, /*!< in: table to be dropped or discarded */ ibool remove_also_table_sx_locks) /*!< in: also removes @@ -4680,12 +4514,9 @@ void lock_remove_all_on_table( /*===================== VALIDATION AND DEBUGGING ====================*/ -/*********************************************************************/ /** - Prints info of a table lock. */ -static void lock_table_print( - /*=============*/ - FILE *file, /*!< in: file where to print */ - const lock_t *lock) /*!< in: table type lock */ +/** Prints info of a table lock. */ +static void lock_table_print(FILE *file, /*!< in: file where to print */ + const lock_t *lock) /*!< in: table type lock */ { ut_ad(lock_mutex_own()); ut_a(lock_get_type_low(lock) == LOCK_TABLE); @@ -4717,12 +4548,9 @@ static void lock_table_print( putc('\n', file); } -/*********************************************************************/ /** - Prints info of a record lock. */ -static void lock_rec_print( - /*===========*/ - FILE *file, /*!< in: file where to print */ - const lock_t *lock) /*!< in: record type lock */ +/** Prints info of a record lock. */ +static void lock_rec_print(FILE *file, /*!< in: file where to print */ + const lock_t *lock) /*!< in: record type lock */ { space_id_t space; page_no_t page_no; @@ -4815,12 +4643,9 @@ in non-production builds for performance reasons, see #endif /* UNIV_DEBUG */ #ifdef PRINT_NUM_OF_LOCK_STRUCTS -/*********************************************************************/ /** - Calculates the number of record lock structs in the record lock hash table. +/** Calculates the number of record lock structs in the record lock hash table. @return number of record locks */ -static ulint lock_get_n_rec_locks(void) -/*======================*/ -{ +static ulint lock_get_n_rec_locks(void) { ulint n_locks = 0; ulint i; @@ -4841,12 +4666,10 @@ static ulint lock_get_n_rec_locks(void) } #endif /* PRINT_NUM_OF_LOCK_STRUCTS */ -/*********************************************************************/ /** - Prints info of locks for all transactions. +/** Prints info of locks for all transactions. @return false if not able to obtain lock mutex and exits without printing info */ bool lock_print_info_summary( - /*====================*/ FILE *file, /*!< in: file where to print */ ibool nowait) /*!< in: whether to wait for the lock mutex */ { @@ -5074,13 +4897,10 @@ void lock_trx_print_wait_and_mvcc_state(FILE *file, const trx_t *trx) { } } -/*********************************************************************/ /** - Prints info of locks for a transaction. This function will release the +/** Prints info of locks for a transaction. This function will release the lock mutex and the trx_sys_t::mutex if the page was read from disk. @return true if page was read from the tablespace */ -static bool lock_rec_fetch_page( - /*================*/ - const lock_t *lock) /*!< in: record lock */ +static bool lock_rec_fetch_page(const lock_t *lock) /*!< in: record lock */ { ut_ad(lock_get_type_low(lock) == LOCK_REC); @@ -5121,11 +4941,9 @@ static bool lock_rec_fetch_page( return (false); } -/*********************************************************************/ /** - Prints info of locks for a transaction. +/** Prints info of locks for a transaction. @return true if all printed, false if latches were released. */ static bool lock_trx_print_locks( - /*=================*/ FILE *file, /*!< in/out: File to write */ const trx_t *trx, /*!< in: current transaction */ TrxLockIterator &iter, /*!< in: transaction lock iterator */ @@ -5187,12 +5005,10 @@ static bool lock_trx_print_locks( return (true); } -/*********************************************************************/ /** - Prints info of locks for each transaction. This function assumes that the +/** Prints info of locks for each transaction. This function assumes that the caller holds the lock mutex and more importantly it will release the lock mutex on behalf of the caller. (This should be fixed in the future). */ void lock_print_info_all_transactions( - /*=============================*/ FILE *file) /*!< in/out: file where to print */ { ut_ad(lock_mutex_own()); @@ -5265,11 +5081,9 @@ void lock_print_info_all_transactions( } #ifdef UNIV_DEBUG -/*********************************************************************/ /** - Find the the lock in the trx_t::trx_lock_t::table_locks vector. +/** Find the the lock in the trx_t::trx_lock_t::table_locks vector. @return true if found */ static bool lock_trx_table_locks_find( - /*======================*/ trx_t *trx, /*!< in: trx to validate */ const lock_t *find_lock) /*!< in: lock to find */ { @@ -5303,11 +5117,9 @@ static bool lock_trx_table_locks_find( return (found); } -/*********************************************************************/ /** - Validates the lock queue on a table. +/** Validates the lock queue on a table. @return true if ok */ static bool lock_table_queue_validate( - /*======================*/ const dict_table_t *table) /*!< in: table */ { const lock_t *lock; @@ -5336,11 +5148,9 @@ static bool lock_table_queue_validate( return (true); } -/*********************************************************************/ /** - Validates the lock queue on a single record. +/** Validates the lock queue on a single record. @return true if ok */ static bool lock_rec_queue_validate( - /*====================*/ ibool locked_lock_trx_sys, /*!< in: if the caller holds both the lock mutex and @@ -5480,11 +5290,9 @@ static bool lock_rec_queue_validate( return (true); } -/*********************************************************************/ /** - Validates the record lock queues on a page. +/** Validates the record lock queues on a page. @return true if ok */ static bool lock_rec_validate_page( - /*===================*/ const buf_block_t *block) /*!< in: buffer block */ { const lock_t *lock; @@ -5563,11 +5371,9 @@ static bool lock_rec_validate_page( return (true); } -/*********************************************************************/ /** - Validates the table locks. +/** Validates the table locks. @return true if ok */ static bool lock_validate_table_locks( - /*======================*/ const trx_ut_list_t *trx_list) /*!< in: trx list */ { const trx_t *trx; @@ -5594,11 +5400,9 @@ static bool lock_validate_table_locks( return (true); } -/*********************************************************************/ /** - Validate record locks up to a limit. +/** Validate record locks up to a limit. @return lock at limit or NULL if no more locks in the hash bucket */ static MY_ATTRIBUTE((warn_unused_result)) const lock_t *lock_rec_validate( - /*==============*/ ulint start, /*!< in: lock_sys->rec_hash bucket */ uint64_t *limit) /*!< in/out: upper limit of @@ -5627,11 +5431,8 @@ static MY_ATTRIBUTE((warn_unused_result)) const lock_t *lock_rec_validate( return (0); } -/*********************************************************************/ /** - Validate a record lock's block */ -static void lock_rec_block_validate( - /*====================*/ - space_id_t space_id, page_no_t page_no) { +/** Validate a record lock's block */ +static void lock_rec_block_validate(space_id_t space_id, page_no_t page_no) { /* The lock and the block that it is referring to may be freed at this point. We pass BUF_GET_POSSIBLY_FREED to skip a debug check. If the lock exists in lock_rec_validate_page() we assert @@ -5658,12 +5459,9 @@ static void lock_rec_block_validate( } } -/*********************************************************************/ /** - Validates the lock system. +/** Validates the lock system. @return true if ok */ -static bool lock_validate() -/*===========*/ -{ +static bool lock_validate() { typedef std::pair page_addr_t; typedef std::set, ut_allocator> @@ -5707,15 +5505,13 @@ static bool lock_validate() #endif /* UNIV_DEBUG */ /*============ RECORD LOCK CHECKS FOR ROW OPERATIONS ====================*/ -/*********************************************************************/ /** - Checks if locks of other transactions prevent an immediate insert of +/** Checks if locks of other transactions prevent an immediate insert of a record. If they do, first tests if the query thread should anyway be suspended for some reason; if not, then puts the transaction and the query thread to the lock wait state and inserts a waiting request for a gap x-lock to the lock queue. @return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ dberr_t lock_rec_insert_check_and_lock( - /*===========================*/ ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG bit is set, does nothing */ const rec_t *rec, /*!< in: record after which to insert */ @@ -5853,13 +5649,11 @@ dberr_t lock_rec_insert_check_and_lock( return (err); } -/*********************************************************************/ /** - Creates an explicit record lock for a running transaction that currently only - has an implicit lock on the record. The transaction instance must have a +/** Creates an explicit record lock for a running transaction that currently + only has an implicit lock on the record. The transaction instance must have a reference count > 0 so that it can't be committed and freed before this function has completed. */ static void lock_rec_convert_impl_to_expl_for_trx( - /*==================================*/ const buf_block_t *block, /*!< in: buffer block of rec */ const rec_t *rec, /*!< in: user record on page */ dict_index_t *index, /*!< in: index of record */ @@ -5938,8 +5732,7 @@ static void lock_rec_convert_impl_to_expl(const buf_block_t *block, } } -/*********************************************************************/ /** - Checks if locks of other transactions prevent an immediate modify (update, +/** Checks if locks of other transactions prevent an immediate modify (update, delete mark, or delete unmark) of a clustered index record. If they do, first tests if the query thread should anyway be suspended for some reason; if not, then puts the transaction and the query thread to the @@ -5947,7 +5740,6 @@ static void lock_rec_convert_impl_to_expl(const buf_block_t *block, lock queue. @return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ dberr_t lock_clust_rec_modify_check_and_lock( - /*=================================*/ ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG bit is set, does nothing */ const buf_block_t *block, /*!< in: buffer block of rec */ @@ -5997,12 +5789,10 @@ dberr_t lock_clust_rec_modify_check_and_lock( return (err); } -/*********************************************************************/ /** - Checks if locks of other transactions prevent an immediate modify (delete +/** Checks if locks of other transactions prevent an immediate modify (delete mark or delete unmark) of a secondary index record. @return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ dberr_t lock_sec_rec_modify_check_and_lock( - /*===============================*/ ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG bit is set, does nothing */ buf_block_t *block, /*!< in/out: buffer block of rec */ @@ -6210,8 +6000,7 @@ dberr_t lock_clust_rec_read_check_and_lock( return (err); } -/*********************************************************************/ /** - Checks if locks of other transactions prevent an immediate read, or passing +/** Checks if locks of other transactions prevent an immediate read, or passing over by a read cursor, of a clustered index record. If they do, first tests if the query thread should anyway be suspended for some reason; if not, then puts the transaction and the query thread to the lock wait state and inserts a @@ -6221,7 +6010,6 @@ dberr_t lock_clust_rec_read_check_and_lock( "offsets". @return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ dberr_t lock_clust_rec_read_check_and_lock_alt( - /*===================================*/ ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG bit is set, does nothing */ const buf_block_t *block, /*!< in: buffer block of rec */ @@ -6259,11 +6047,9 @@ dberr_t lock_clust_rec_read_check_and_lock_alt( return (err); } -/*******************************************************************/ /** - Release the last lock from the transaction's autoinc locks. */ +/** Release the last lock from the transaction's autoinc locks. */ UNIV_INLINE void lock_release_autoinc_last_lock( - /*===========================*/ ib_vector_t *autoinc_locks) /*!< in/out: vector of AUTOINC locks */ { ulint last; @@ -6289,11 +6075,9 @@ void lock_release_autoinc_last_lock( lock_trx_table_locks_remove(lock); } -/*******************************************************************/ /** - Check if a transaction holds any autoinc locks. +/** Check if a transaction holds any autoinc locks. @return true if the transaction holds any AUTOINC locks. */ static bool lock_trx_holds_autoinc_locks( - /*=========================*/ const trx_t *trx) /*!< in: transaction */ { ut_a(trx->autoinc_locks != NULL); @@ -6301,11 +6085,8 @@ static bool lock_trx_holds_autoinc_locks( return (!ib_vector_is_empty(trx->autoinc_locks)); } -/*******************************************************************/ /** - Release all the transaction's autoinc locks. */ -static void lock_release_autoinc_locks( - /*=======================*/ - trx_t *trx) /*!< in/out: transaction */ +/** Release all the transaction's autoinc locks. */ +static void lock_release_autoinc_locks(trx_t *trx) /*!< in/out: transaction */ { ut_ad(lock_mutex_own()); /* If this is invoked for a running transaction by the thread @@ -6327,23 +6108,17 @@ static void lock_release_autoinc_locks( ut_a(ib_vector_is_empty(trx->autoinc_locks)); } -/*******************************************************************/ /** - Gets the type of a lock. Non-inline version for using outside of the +/** Gets the type of a lock. Non-inline version for using outside of the lock module. @return LOCK_TABLE or LOCK_REC */ -uint32_t lock_get_type( - /*==========*/ - const lock_t *lock) /*!< in: lock */ +uint32_t lock_get_type(const lock_t *lock) /*!< in: lock */ { return (lock_get_type_low(lock)); } -/*******************************************************************/ /** - Gets the id of the transaction owning a lock. +/** Gets the id of the transaction owning a lock. @return transaction id */ -trx_id_t lock_get_trx_id( - /*============*/ - const lock_t *lock) /*!< in: lock */ +trx_id_t lock_get_trx_id(const lock_t *lock) /*!< in: lock */ { return (trx_get_id_for_print(lock->trx)); } @@ -6383,13 +6158,10 @@ const lock_t *lock_get_next_trx_locks(const lock_t *lock) { return (result); } -/*******************************************************************/ /** - Gets the mode of a lock in a human readable string. +/** Gets the mode of a lock in a human readable string. The string should not be free()'d or modified. @return lock mode */ -const char *lock_get_mode_str( - /*==============*/ - const lock_t *lock) /*!< in: lock */ +const char *lock_get_mode_str(const lock_t *lock) /*!< in: lock */ { ibool is_gap_lock; @@ -6427,13 +6199,10 @@ const char *lock_get_mode_str( } } -/*******************************************************************/ /** - Gets the type of a lock in a human readable string. +/** Gets the type of a lock in a human readable string. The string should not be free()'d or modified. @return lock type */ -const char *lock_get_type_str( - /*==============*/ - const lock_t *lock) /*!< in: lock */ +const char *lock_get_type_str(const lock_t *lock) /*!< in: lock */ { switch (lock_get_type_low(lock)) { case LOCK_REC: @@ -6445,13 +6214,10 @@ const char *lock_get_type_str( } } -/*******************************************************************/ /** - Gets the table on which the lock is. +/** Gets the table on which the lock is. @return table */ UNIV_INLINE -dict_table_t *lock_get_table( - /*===========*/ - const lock_t *lock) /*!< in: lock */ +dict_table_t *lock_get_table(const lock_t *lock) /*!< in: lock */ { switch (lock_get_type_low(lock)) { case LOCK_REC: @@ -6466,12 +6232,9 @@ dict_table_t *lock_get_table( } } -/*******************************************************************/ /** - Gets the id of the table on which the lock is. +/** Gets the id of the table on which the lock is. @return id of the table */ -table_id_t lock_get_table_id( - /*==============*/ - const lock_t *lock) /*!< in: lock */ +table_id_t lock_get_table_id(const lock_t *lock) /*!< in: lock */ { dict_table_t *table; @@ -6487,12 +6250,9 @@ const table_name_t &lock_get_table_name(const lock_t *lock) { return (lock_get_table(lock)->name); } -/*******************************************************************/ /** - For a record lock, gets the index on which the lock is. +/** For a record lock, gets the index on which the lock is. @return index */ -const dict_index_t *lock_rec_get_index( - /*===============*/ - const lock_t *lock) /*!< in: lock */ +const dict_index_t *lock_rec_get_index(const lock_t *lock) /*!< in: lock */ { ut_a(lock_get_type_low(lock) == LOCK_REC); ut_ad(lock->index->is_clustered() || !dict_index_is_online_ddl(lock->index)); @@ -6500,13 +6260,10 @@ const dict_index_t *lock_rec_get_index( return (lock->index); } -/*******************************************************************/ /** - For a record lock, gets the name of the index on which the lock is. +/** For a record lock, gets the name of the index on which the lock is. The string should not be free()'d or modified. @return name of the index */ -const char *lock_rec_get_index_name( - /*====================*/ - const lock_t *lock) /*!< in: lock */ +const char *lock_rec_get_index_name(const lock_t *lock) /*!< in: lock */ { ut_a(lock_get_type_low(lock) == LOCK_REC); ut_ad(lock->index->is_clustered() || !dict_index_is_online_ddl(lock->index)); @@ -6514,24 +6271,18 @@ const char *lock_rec_get_index_name( return (lock->index->name); } -/*******************************************************************/ /** - For a record lock, gets the tablespace number on which the lock is. +/** For a record lock, gets the tablespace number on which the lock is. @return tablespace number */ -space_id_t lock_rec_get_space_id( - /*==================*/ - const lock_t *lock) /*!< in: lock */ +space_id_t lock_rec_get_space_id(const lock_t *lock) /*!< in: lock */ { ut_a(lock_get_type_low(lock) == LOCK_REC); return (lock->rec_lock.space); } -/*******************************************************************/ /** - For a record lock, gets the page number on which the lock is. +/** For a record lock, gets the page number on which the lock is. @return page number */ -page_no_t lock_rec_get_page_no( - /*=================*/ - const lock_t *lock) /*!< in: lock */ +page_no_t lock_rec_get_page_no(const lock_t *lock) /*!< in: lock */ { ut_a(lock_get_type_low(lock) == LOCK_REC); @@ -6578,13 +6329,10 @@ void lock_cancel_waiting_and_release(lock_t *lock, bool use_fcfs) { lock->trx->lock.cancel = false; } -/*********************************************************************/ /** - Unlocks AUTO_INC type locks that were possibly reserved by a trx. This +/** Unlocks AUTO_INC type locks that were possibly reserved by a trx. This function should be called at the the end of an SQL statement, by the connection thread that owns the transaction (trx->mysql_thd). */ -void lock_unlock_table_autoinc( - /*======================*/ - trx_t *trx) /*!< in/out: transaction */ +void lock_unlock_table_autoinc(trx_t *trx) /*!< in/out: transaction */ { ut_ad(!lock_mutex_own()); ut_ad(!trx_mutex_own(trx)); @@ -6610,13 +6358,10 @@ void lock_unlock_table_autoinc( } } -/*********************************************************************/ /** - Releases a transaction's locks, and releases possible other transactions +/** Releases a transaction's locks, and releases possible other transactions waiting because of these locks. Change the state of the transaction to TRX_STATE_COMMITTED_IN_MEMORY. */ -void lock_trx_release_locks( - /*===================*/ - trx_t *trx) /*!< in/out: transaction */ +void lock_trx_release_locks(trx_t *trx) /*!< in/out: transaction */ { check_trx_state(trx); @@ -6726,14 +6471,11 @@ void lock_trx_release_locks( mem_heap_empty(trx->lock.lock_heap); } -/*********************************************************************/ /** - Check whether the transaction has already been rolled back because it +/** Check whether the transaction has already been rolled back because it was selected as a deadlock victim, or if it has to wait then cancel the wait lock. @return DB_DEADLOCK, DB_LOCK_WAIT or DB_SUCCESS */ -dberr_t lock_trx_handle_wait( - /*=================*/ - trx_t *trx) /*!< in/out: trx lock state */ +dberr_t lock_trx_handle_wait(trx_t *trx) /*!< in/out: trx lock state */ { dberr_t err; @@ -6762,12 +6504,9 @@ dberr_t lock_trx_handle_wait( return (err); } -/*********************************************************************/ /** - Get the number of locks on a table. +/** Get the number of locks on a table. @return number of locks */ -ulint lock_table_get_n_locks( - /*===================*/ - const dict_table_t *table) /*!< in: table */ +ulint lock_table_get_n_locks(const dict_table_t *table) /*!< in: table */ { ulint n_table_locks; @@ -6781,11 +6520,9 @@ ulint lock_table_get_n_locks( } #ifdef UNIV_DEBUG -/*******************************************************************/ /** - Do an exhaustive check for any locks (table or rec) against the table. +/** Do an exhaustive check for any locks (table or rec) against the table. @return lock if found */ static const lock_t *lock_table_locks_lookup( - /*====================*/ const dict_table_t *table, /*!< in: check if there are any locks held on records in this table or on the table @@ -6824,11 +6561,9 @@ static const lock_t *lock_table_locks_lookup( } #endif /* UNIV_DEBUG */ -/*******************************************************************/ /** - Check if there are any locks (table or rec) against table. +/** Check if there are any locks (table or rec) against table. @return true if table has either table or record locks. */ bool lock_table_has_locks( - /*=================*/ const dict_table_t *table) /*!< in: check if there are any locks held on records in this table or on the table itself */ @@ -6854,38 +6589,27 @@ bool lock_table_has_locks( return (has_locks); } -/*******************************************************************/ /** - Initialise the table lock list. */ +/** Initialise the table lock list. */ void lock_table_lock_list_init( - /*======================*/ table_lock_list_t *lock_list) /*!< List to initialise */ { UT_LIST_INIT(*lock_list, &lock_table_t::locks); } -/*******************************************************************/ /** - Initialise the trx lock list. */ +/** Initialise the trx lock list. */ void lock_trx_lock_list_init( - /*====================*/ trx_lock_list_t *lock_list) /*!< List to initialise */ { UT_LIST_INIT(*lock_list, &lock_t::trx_locks); } -/*******************************************************************/ /** - Set the lock system timeout event. */ -void lock_set_timeout_event() -/*====================*/ -{ - os_event_set(lock_sys->timeout_event); -} +/** Set the lock system timeout event. */ +void lock_set_timeout_event() { os_event_set(lock_sys->timeout_event); } #ifdef UNIV_DEBUG -/*******************************************************************/ /** - Check if the transaction holds an exclusive lock on a record. +/** Check if the transaction holds an exclusive lock on a record. @return whether the locks are held */ bool lock_trx_has_rec_x_lock( - /*====================*/ const trx_t *trx, /*!< in: transaction to check */ const dict_table_t *table, /*!< in: table to check */ const buf_block_t *block, /*!< in: buffer block of the record */ diff --git a/storage/innobase/lock/lock0prdt.cc b/storage/innobase/lock/lock0prdt.cc index 9c0bc88df09b..32d10af1d726 100644 --- a/storage/innobase/lock/lock0prdt.cc +++ b/storage/innobase/lock/lock0prdt.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2014, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2014, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file lock/lock0prdt.cc +/** @file lock/lock0prdt.cc The transaction lock system Created 9/7/2013 Jimmy Yang @@ -49,12 +48,10 @@ this program; if not, write to the Free Software Foundation, Inc., #include "usr0sess.h" #include "ut0vec.h" -/*********************************************************************/ /** - Get a minimum bounding box from a Predicate +/** Get a minimum bounding box from a Predicate @return the minimum bounding box */ UNIV_INLINE rtr_mbr_t *prdt_get_mbr_from_prdt( - /*===================*/ const lock_prdt_t *prdt) /*!< in: the lock predicate */ { rtr_mbr_t *mbr_loc = reinterpret_cast(prdt->data); @@ -62,12 +59,9 @@ rtr_mbr_t *prdt_get_mbr_from_prdt( return (mbr_loc); } -/*********************************************************************/ /** - Get a predicate from a lock +/** Get a predicate from a lock @return the predicate */ -lock_prdt_t *lock_get_prdt_from_lock( - /*====================*/ - const lock_t *lock) /*!< in: the lock */ +lock_prdt_t *lock_get_prdt_from_lock(const lock_t *lock) /*!< in: the lock */ { lock_prdt_t *prdt = reinterpret_cast(&((reinterpret_cast( @@ -76,13 +70,10 @@ lock_prdt_t *lock_get_prdt_from_lock( return (prdt); } -/*********************************************************************/ /** - Get a minimum bounding box directly from a lock +/** Get a minimum bounding box directly from a lock @return the minimum bounding box*/ UNIV_INLINE -rtr_mbr_t *lock_prdt_get_mbr_from_lock( - /*========================*/ - const lock_t *lock) /*!< in: the lock */ +rtr_mbr_t *lock_prdt_get_mbr_from_lock(const lock_t *lock) /*!< in: the lock */ { ut_ad(lock->type_mode & LOCK_PREDICATE); @@ -93,12 +84,9 @@ rtr_mbr_t *lock_prdt_get_mbr_from_lock( return (mbr_loc); } -/*********************************************************************/ /** - Append a predicate to the lock */ -void lock_prdt_set_prdt( - /*===============*/ - lock_t *lock, /*!< in: lock */ - const lock_prdt_t *prdt) /*!< in: Predicate */ +/** Append a predicate to the lock */ +void lock_prdt_set_prdt(lock_t *lock, /*!< in: lock */ + const lock_prdt_t *prdt) /*!< in: Predicate */ { ut_ad(lock->type_mode & LOCK_PREDICATE); @@ -153,12 +141,10 @@ static bool lock_prdt_consistent(lock_prdt_t *prdt1, lock_prdt_t *prdt2, return (ret); } -/*********************************************************************/ /** - Checks if a predicate lock request for a new lock has to wait for +/** Checks if a predicate lock request for a new lock has to wait for another lock. @return true if new lock has to wait for lock2 to be released */ bool lock_prdt_has_to_wait( - /*==================*/ const trx_t *trx, /*!< in: trx of new lock */ ulint type_mode, /*!< in: precise mode of the new lock to set: LOCK_S or LOCK_X, possibly @@ -222,20 +208,17 @@ bool lock_prdt_has_to_wait( return (FALSE); } -/*********************************************************************/ /** - Checks if a transaction has a GRANTED stronger or equal predicate lock +/** Checks if a transaction has a GRANTED stronger or equal predicate lock on the page @return lock or NULL */ UNIV_INLINE -lock_t *lock_prdt_has_lock( - /*===============*/ - ulint precise_mode, /*!< in: LOCK_S or LOCK_X */ - ulint type_mode, /*!< in: LOCK_PREDICATE etc. */ - const buf_block_t *block, /*!< in: buffer block - containing the record */ - lock_prdt_t *prdt, /*!< in: The predicate to be - attached to the new lock */ - const trx_t *trx) /*!< in: transaction */ +lock_t *lock_prdt_has_lock(ulint precise_mode, /*!< in: LOCK_S or LOCK_X */ + ulint type_mode, /*!< in: LOCK_PREDICATE etc. */ + const buf_block_t *block, /*!< in: buffer block + containing the record */ + lock_prdt_t *prdt, /*!< in: The predicate to be + attached to the new lock */ + const trx_t *trx) /*!< in: transaction */ { lock_t *lock; @@ -273,12 +256,10 @@ lock_t *lock_prdt_has_lock( return (NULL); } -/*********************************************************************/ /** - Checks if some other transaction has a conflicting predicate +/** Checks if some other transaction has a conflicting predicate lock request in the queue, so that we have to wait. @return lock or NULL */ static const lock_t *lock_prdt_other_has_conflicting( - /*============================*/ ulint mode, /*!< in: LOCK_S or LOCK_X, possibly ORed to LOCK_PREDICATE or LOCK_PRDT_PAGE, LOCK_INSERT_INTENTION */ @@ -306,10 +287,8 @@ static const lock_t *lock_prdt_other_has_conflicting( return (NULL); } -/*********************************************************************/ /** - Reset the Minimum Bounding Rectangle (to a large area) */ +/** Reset the Minimum Bounding Rectangle (to a large area) */ static void lock_prdt_enlarge_mbr( - /*==================*/ const lock_t *lock, /*!< in/out: lock to modify */ rtr_mbr_t *mbr) /*!< in: Minimum Bounding Rectangle */ { @@ -332,23 +311,18 @@ static void lock_prdt_enlarge_mbr( } } -/*********************************************************************/ /** - Reset the predicates to a "covering" (larger) predicates */ -static void lock_prdt_enlarge_prdt( - /*===================*/ - lock_t *lock, /*!< in/out: lock to modify */ - lock_prdt_t *prdt) /*!< in: predicate */ +/** Reset the predicates to a "covering" (larger) predicates */ +static void lock_prdt_enlarge_prdt(lock_t *lock, /*!< in/out: lock to modify */ + lock_prdt_t *prdt) /*!< in: predicate */ { rtr_mbr_t *mbr = prdt_get_mbr_from_prdt(prdt); lock_prdt_enlarge_mbr(lock, mbr); } -/*********************************************************************/ /** - Check two predicates' MBRs are the same +/** Check two predicates' MBRs are the same @return true if they are the same */ static bool lock_prdt_is_same( - /*==============*/ lock_prdt_t *prdt1, /*!< in: MBR with the lock */ lock_prdt_t *prdt2, /*!< in: MBR with the lock */ const dd::Spatial_reference_system *srs) /*!< in: SRS of R-tree */ @@ -363,13 +337,11 @@ static bool lock_prdt_is_same( return (false); } -/*********************************************************************/ /** - Looks for a similar predicate lock struct by the same trx on the same page. +/** Looks for a similar predicate lock struct by the same trx on the same page. This can be used to save space when a new record lock should be set on a page: no new struct is needed, if a suitable old one is found. @return lock or NULL */ static lock_t *lock_prdt_find_on_page( - /*===================*/ ulint type_mode, /*!< in: lock type_mode field */ const buf_block_t *block, /*!< in: buffer block */ lock_prdt_t *prdt, /*!< in: MBR with the lock */ @@ -398,11 +370,9 @@ static lock_t *lock_prdt_find_on_page( return (NULL); } -/*********************************************************************/ /** - Adds a predicate lock request in the predicate lock queue. +/** Adds a predicate lock request in the predicate lock queue. @return lock where the bit was set */ static lock_t *lock_prdt_add_to_queue( - /*===================*/ ulint type_mode, /*!< in: lock mode, wait, predicate etc. flags; type is ignored and replaced by LOCK_REC */ @@ -463,13 +433,11 @@ static lock_t *lock_prdt_add_to_queue( return (rec_lock.create(trx, true, prdt)); } -/*********************************************************************/ /** - Checks if locks of other transactions prevent an immediate insert of +/** Checks if locks of other transactions prevent an immediate insert of a predicate record. @return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ dberr_t lock_prdt_insert_check_and_lock( - /*============================*/ ulint flags, /*!< in: if BTR_NO_LOCKING_FLAG bit is set, does nothing */ const rec_t *rec, /*!< in: record after which to insert */ @@ -571,11 +539,9 @@ dberr_t lock_prdt_insert_check_and_lock( return (err); } -/**************************************************************/ /** - Check whether any predicate lock in parent needs to propagate to +/** Check whether any predicate lock in parent needs to propagate to child page after split. */ void lock_prdt_update_parent( - /*====================*/ buf_block_t *left_block, /*!< in/out: page to be split */ buf_block_t *right_block, /*!< in/out: the new half page */ lock_prdt_t *left_prdt, /*!< in: MBR on the old page */ @@ -626,10 +592,8 @@ void lock_prdt_update_parent( lock_mutex_exit(); } -/**************************************************************/ /** - Update predicate lock when page splits */ +/** Update predicate lock when page splits */ static void lock_prdt_update_split_low( - /*=======================*/ buf_block_t *block, /*!< in/out: page to be split */ buf_block_t *new_block, /*!< in/out: the new half page */ lock_prdt_t *prdt, /*!< in: MBR on the old page */ @@ -712,10 +676,8 @@ static void lock_prdt_update_split_low( lock_mutex_exit(); } -/**************************************************************/ /** - Update predicate lock when page splits */ +/** Update predicate lock when page splits */ void lock_prdt_update_split( - /*===================*/ buf_block_t *block, /*!< in/out: page to be split */ buf_block_t *new_block, /*!< in/out: the new half page */ lock_prdt_t *prdt, /*!< in: MBR on the old page */ @@ -730,10 +692,8 @@ void lock_prdt_update_split( LOCK_PRDT_PAGE); } -/*********************************************************************/ /** - Initiate a Predicate Lock from a MBR */ +/** Initiate a Predicate Lock from a MBR */ void lock_init_prdt_from_mbr( - /*====================*/ lock_prdt_t *prdt, /*!< in/out: predicate to initialized */ rtr_mbr_t *mbr, /*!< in: Minimum Bounding Rectangle */ ulint mode, /*!< in: Search mode */ @@ -751,25 +711,22 @@ void lock_init_prdt_from_mbr( prdt->op = static_cast(mode); } -/*********************************************************************/ /** - Acquire a predicate lock on a block +/** Acquire a predicate lock on a block @return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ -dberr_t lock_prdt_lock( - /*===========*/ - buf_block_t *block, /*!< in/out: buffer block of rec */ - lock_prdt_t *prdt, /*!< in: Predicate for the lock */ - dict_index_t *index, /*!< in: secondary index */ - lock_mode mode, /*!< in: mode of the lock which - the read cursor should set on - records: LOCK_S or LOCK_X; the - latter is possible in - SELECT FOR UPDATE */ - ulint type_mode, - /*!< in: LOCK_PREDICATE or LOCK_PRDT_PAGE */ - que_thr_t *thr, /*!< in: query thread - (can be NULL if BTR_NO_LOCKING_FLAG) */ - mtr_t *mtr) /*!< in/out: mini-transaction */ +dberr_t lock_prdt_lock(buf_block_t *block, /*!< in/out: buffer block of rec */ + lock_prdt_t *prdt, /*!< in: Predicate for the lock */ + dict_index_t *index, /*!< in: secondary index */ + lock_mode mode, /*!< in: mode of the lock which + the read cursor should set on + records: LOCK_S or LOCK_X; the + latter is possible in + SELECT FOR UPDATE */ + ulint type_mode, + /*!< in: LOCK_PREDICATE or LOCK_PRDT_PAGE */ + que_thr_t *thr, /*!< in: query thread + (can be NULL if BTR_NO_LOCKING_FLAG) */ + mtr_t *mtr) /*!< in/out: mini-transaction */ { trx_t *trx = thr_get_trx(thr); dberr_t err = DB_SUCCESS; @@ -859,12 +816,10 @@ dberr_t lock_prdt_lock( return (err); } -/*********************************************************************/ /** - Acquire a "Page" lock on a block +/** Acquire a "Page" lock on a block @return DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ dberr_t lock_place_prdt_page_lock( - /*======================*/ space_id_t space, /*!< in: space for the page to lock */ page_no_t page_no, /*!< in: page number */ dict_index_t *index, /*!< in: secondary index */ @@ -940,11 +895,9 @@ bool lock_test_prdt_page_lock(const trx_t *trx, space_id_t space, return (lock == NULL || trx == lock->trx); } -/*************************************************************/ /** - Moves the locks of a page to another page and resets the lock bits of +/** Moves the locks of a page to another page and resets the lock bits of the donating records. */ void lock_prdt_rec_move( - /*===============*/ const buf_block_t *receiver, /*!< in: buffer block containing the receiving record */ const buf_block_t *donator) /*!< in: buffer block containing diff --git a/storage/innobase/lock/lock0wait.cc b/storage/innobase/lock/lock0wait.cc index 91fa87c4d237..e62649a83d00 100644 --- a/storage/innobase/lock/lock0wait.cc +++ b/storage/innobase/lock/lock0wait.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file lock/lock0wait.cc +/** @file lock/lock0wait.cc The transaction lock system Created 25/5/2010 Sunny Bains @@ -48,11 +47,8 @@ this program; if not, write to the Free Software Foundation, Inc., #include "srv0mon.h" #include "srv0start.h" -/*********************************************************************/ /** - Print the contents of the lock_sys_t::waiting_threads array. */ -static void lock_wait_table_print(void) -/*=======================*/ -{ +/** Print the contents of the lock_sys_t::waiting_threads array. */ +static void lock_wait_table_print(void) { ut_ad(lock_wait_mutex_own()); const srv_slot_t *slot = lock_sys->waiting_threads; @@ -67,11 +63,9 @@ static void lock_wait_table_print(void) } } -/*********************************************************************/ /** - Release a slot in the lock_sys_t::waiting_threads. Adjust the array last +/** Release a slot in the lock_sys_t::waiting_threads. Adjust the array last pointer if there are empty slots towards the end of the table. */ static void lock_wait_table_release_slot( - /*=========================*/ srv_slot_t *slot) /*!< in: slot to release */ { #ifdef UNIV_DEBUG @@ -127,11 +121,9 @@ static void lock_wait_table_release_slot( lock_wait_mutex_exit(); } -/*********************************************************************/ /** - Reserves a slot in the thread table for the current user OS thread. +/** Reserves a slot in the thread table for the current user OS thread. @return reserved slot */ static srv_slot_t *lock_wait_table_reserve_slot( - /*=========================*/ que_thr_t *thr, /*!< in: query thread associated with the user OS thread */ ulong wait_timeout) /*!< in: lock wait timeout value */ @@ -181,14 +173,12 @@ static srv_slot_t *lock_wait_table_reserve_slot( return (NULL); } -/***************************************************************/ /** - Puts a user OS thread to wait for a lock to be released. If an error +/** Puts a user OS thread to wait for a lock to be released. If an error occurs during the wait trx->error_state associated with thr is != DB_SUCCESS when we return. DB_LOCK_WAIT_TIMEOUT and DB_DEADLOCK are possible errors. DB_DEADLOCK is returned if selective deadlock resolution chose this transaction as a victim. */ void lock_wait_suspend_thread( - /*=====================*/ que_thr_t *thr) /*!< in: query thread associated with the user OS thread */ { @@ -378,11 +368,9 @@ void lock_wait_suspend_thread( } } -/********************************************************************/ /** - Releases a user OS thread waiting for a lock to be released, if the +/** Releases a user OS thread waiting for a lock to be released, if the thread is already suspended. */ void lock_wait_release_thread_if_suspended( - /*==================================*/ que_thr_t *thr) /*!< in: query thread associated with the user OS thread */ { @@ -408,11 +396,9 @@ void lock_wait_release_thread_if_suspended( } } -/*********************************************************************/ /** - Check if the thread lock wait has timed out. Release its locks if the +/** Check if the thread lock wait has timed out. Release its locks if the wait has actually timed out. */ static void lock_wait_check_and_cancel( - /*=======================*/ const srv_slot_t *slot) /*!< in: slot reserved by a user thread when the wait started */ { diff --git a/storage/innobase/log/log0ddl.cc b/storage/innobase/log/log0ddl.cc index 77df4e94b782..68f9e19a33fd 100644 --- a/storage/innobase/log/log0ddl.cc +++ b/storage/innobase/log/log0ddl.cc @@ -30,8 +30,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file log/log0ddl.cc +/** @file log/log0ddl.cc DDL log Created 12/1/2016 Shaohua Wang diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index fc672121f885..9295c934b3a8 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -31,8 +31,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file log/log0log.cc +/** @file log/log0log.cc Database log Created 12/9/1995 Heikki Tuuri @@ -137,18 +136,13 @@ should be bigger than LOG_POOL_PREFLUSH_RATIO_SYNC */ the previous */ #define LOG_POOL_PREFLUSH_RATIO_ASYNC 8 -/******************************************************/ /** - Completes a checkpoint write i/o to a log file. */ +/** Completes a checkpoint write i/o to a log file. */ static void log_io_complete_checkpoint(void); -/*============================*/ -/****************************************************************/ /** - Returns the oldest modified block lsn in the pool, or log_sys->lsn if none +/** Returns the oldest modified block lsn in the pool, or log_sys->lsn if none exists. @return LSN of oldest modification */ -static lsn_t log_buf_pool_get_oldest_modification(void) -/*======================================*/ -{ +static lsn_t log_buf_pool_get_oldest_modification(void) { lsn_t lsn; ut_ad(log_mutex_own()); @@ -414,13 +408,10 @@ lsn_t log_reserve_and_open(ulint len) { return (log_sys->lsn); } -/************************************************************/ /** - Writes to the log the string given. It is assumed that the caller holds the +/** Writes to the log the string given. It is assumed that the caller holds the log mutex. */ -void log_write_low( - /*==========*/ - const byte *str, /*!< in: string */ - ulint str_len) /*!< in: string length */ +void log_write_low(const byte *str, /*!< in: string */ + ulint str_len) /*!< in: string length */ { log_t *log = log_sys; ulint len; @@ -479,12 +470,9 @@ void log_write_low( srv_stats.log_write_requests.inc(); } -/************************************************************/ /** - Closes the log. +/** Closes the log. @return lsn */ -lsn_t log_close(void) -/*===========*/ -{ +lsn_t log_close(void) { byte *log_block; ulint first_rec_group; lsn_t oldest_lsn; @@ -546,12 +534,10 @@ lsn_t log_close(void) return (lsn); } -/******************************************************/ /** - Calculates the data capacity of a log group, when the log file headers are not - included. +/** Calculates the data capacity of a log group, when the log file headers are + not included. @return capacity in bytes */ static lsn_t log_group_get_capacity( - /*===================*/ const log_group_t *group) /*!< in: log group */ { /* The lsn parameters are updated while holding both the mutexes @@ -561,16 +547,13 @@ static lsn_t log_group_get_capacity( return ((group->file_size - LOG_FILE_HDR_SIZE) * group->n_files); } -/******************************************************/ /** - Calculates the offset within a log group, when the log file headers are not +/** Calculates the offset within a log group, when the log file headers are not included. @return size offset (<= offset) */ UNIV_INLINE -lsn_t log_group_calc_size_offset( - /*=======================*/ - lsn_t offset, /*!< in: real offset within the - log group */ - const log_group_t *group) /*!< in: log group */ +lsn_t log_group_calc_size_offset(lsn_t offset, /*!< in: real offset within the + log group */ + const log_group_t *group) /*!< in: log group */ { /* The lsn parameters are updated while holding both the mutexes and it is ok to have either of them while reading */ @@ -579,16 +562,13 @@ lsn_t log_group_calc_size_offset( return (offset - LOG_FILE_HDR_SIZE * (1 + offset / group->file_size)); } -/******************************************************/ /** - Calculates the offset within a log group, when the log file headers are +/** Calculates the offset within a log group, when the log file headers are included. @return real offset (>= offset) */ UNIV_INLINE -lsn_t log_group_calc_real_offset( - /*=======================*/ - lsn_t offset, /*!< in: size offset within the - log group */ - const log_group_t *group) /*!< in: log group */ +lsn_t log_group_calc_real_offset(lsn_t offset, /*!< in: size offset within the + log group */ + const log_group_t *group) /*!< in: log group */ { /* The lsn parameters are updated while holding both the mutexes and it is ok to have either of them while reading */ @@ -640,29 +620,23 @@ lsn_t log_group_calc_lsn_offset(lsn_t lsn, const log_group_t *group) { return (log_group_calc_real_offset(offset, group)); } -/********************************************************/ /** - Sets the field values in group to correspond to a given lsn. For this function - to work, the values must already be correctly initialized to correspond to - some lsn, for instance, a checkpoint lsn. */ -void log_group_set_fields( - /*=================*/ - log_group_t *group, /*!< in/out: group */ - lsn_t lsn) /*!< in: lsn for which the values should be - set */ +/** Sets the field values in group to correspond to a given lsn. For this + function to work, the values must already be correctly initialized to + correspond to some lsn, for instance, a checkpoint lsn. */ +void log_group_set_fields(log_group_t *group, /*!< in/out: group */ + lsn_t lsn) /*!< in: lsn for which the values should be + set */ { group->lsn_offset = log_group_calc_lsn_offset(lsn, group); group->lsn = lsn; } -/*****************************************************************/ /** - Calculates the recommended highest values for lsn - last_checkpoint_lsn +/** Calculates the recommended highest values for lsn - last_checkpoint_lsn and lsn - buf_get_oldest_modification(). @retval true on success @retval false if the smallest log group is too small to accommodate the number of OS threads in the database server */ -static MY_ATTRIBUTE((warn_unused_result)) bool log_calc_max_ages(void) -/*===================*/ -{ +static MY_ATTRIBUTE((warn_unused_result)) bool log_calc_max_ages(void) { log_group_t *group; lsn_t margin; ulint free; @@ -736,11 +710,8 @@ static MY_ATTRIBUTE((warn_unused_result)) bool log_calc_max_ages(void) return (success); } -/******************************************************/ /** - Initializes the log. */ -void log_init(void) -/*==========*/ -{ +/** Initializes the log. */ +void log_init(void) { ut_ad(static_cast(MTR_MEMO_PAGE_S_FIX) == static_cast(RW_S_LATCH)); ut_ad(static_cast(MTR_MEMO_PAGE_X_FIX) == static_cast(RW_X_LATCH)); ut_ad(static_cast(MTR_MEMO_PAGE_SX_FIX) == @@ -810,18 +781,15 @@ void log_init(void) log_sys->lsn - log_sys->last_checkpoint_lsn); } -/******************************************************************/ /** - Inits a log group to the log system. +/** Inits a log group to the log system. @return true if success, false if not */ MY_ATTRIBUTE((warn_unused_result)) -bool log_group_init( - /*===========*/ - ulint id, /*!< in: group id */ - ulint n_files, /*!< in: number of log files */ - lsn_t file_size, /*!< in: log file size in bytes */ - space_id_t space_id) /*!< in: space id of the file space - which contains the log files of this - group */ +bool log_group_init(ulint id, /*!< in: group id */ + ulint n_files, /*!< in: number of log files */ + lsn_t file_size, /*!< in: log file size in bytes */ + space_id_t space_id) /*!< in: space id of the file space + which contains the log files of this + group */ { ulint i; log_group_t *group; @@ -1170,21 +1138,17 @@ void log_enable_encryption_if_set() { } } -/******************************************************/ /** - Stores a 4-byte checksum to the trailer checksum field of a log block +/** Stores a 4-byte checksum to the trailer checksum field of a log block before writing it to a log file. This checksum is used in recovery to check the consistency of a log block. */ static void log_block_store_checksum( - /*=====================*/ byte *block) /*!< in/out: pointer to a log block */ { log_block_set_checksum(block, log_block_calc_checksum(block)); } -/******************************************************/ /** - Writes a buffer to a log file group. */ +/** Writes a buffer to a log file group. */ static void log_group_write_buf( - /*================*/ log_group_t *group, /*!< in: log group */ byte *buf, /*!< in: buffer */ ulint len, /*!< in: buffer len; must be divisible @@ -1578,13 +1542,11 @@ void log_buffer_flush_to_disk(bool sync) { log_write_up_to(log_get_lsn(), sync); } -/****************************************************************/ /** - This functions writes the log buffer to the log file and if 'flush' +/** This functions writes the log buffer to the log file and if 'flush' is set it forces a flush of the log file as well. This is meant to be called from background master thread only as it does not wait for the write (+ possible flush) to finish. */ void log_buffer_sync_in_background( - /*==========================*/ bool flush) /*!< in: flush the logs to disk */ { lsn_t lsn; @@ -1609,9 +1571,7 @@ void log_buffer_sync_in_background( Tries to establish a big enough margin of free space in the log buffer, such that a new log entry can be catenated without an immediate need for a flush. */ -static void log_flush_margin(void) -/*==================*/ -{ +static void log_flush_margin(void) { log_t *log = log_sys; lsn_t lsn = 0; @@ -1720,11 +1680,8 @@ static void log_io_complete_checkpoint() { log_mutex_exit(); } -/******************************************************/ /** - Writes the checkpoint info to a log group header. */ -static void log_group_checkpoint( - /*=================*/ - log_group_t *group) /*!< in: log group */ +/** Writes the checkpoint info to a log group header. */ +static void log_group_checkpoint(log_group_t *group) /*!< in: log group */ { lsn_t lsn_offset; byte *buf; @@ -1965,14 +1922,11 @@ void log_make_checkpoint_at(lsn_t lsn, bool write_always) { } } -/****************************************************************/ /** - Tries to establish a big enough margin of free space in the log groups, such +/** Tries to establish a big enough margin of free space in the log groups, such that a new log entry can be catenated without an immediate need for a checkpoint. NOTE: this function may only be called if the calling thread owns no synchronization objects! */ -static void log_checkpoint_margin(void) -/*=======================*/ -{ +static void log_checkpoint_margin(void) { log_t *log = log_sys; lsn_t age; lsn_t checkpoint_age; @@ -2070,14 +2024,11 @@ void log_check_margins(void) { } while (check); } -/****************************************************************/ /** - Makes a checkpoint at the latest lsn and writes it to first page of each +/** Makes a checkpoint at the latest lsn and writes it to first page of each data file in the database, so that we know that the file spaces contain all modifications up to that lsn. This can only be called at database shutdown. This function also writes all log in log files to the log archive. */ -void logs_empty_and_mark_files_at_shutdown(void) -/*=======================================*/ -{ +void logs_empty_and_mark_files_at_shutdown(void) { lsn_t lsn; ulint count = 0; ulint total_trx; @@ -2354,12 +2305,9 @@ void logs_empty_and_mark_files_at_shutdown(void) ut_a(lsn == log_sys->lsn); } -/******************************************************/ /** - Peeks the current lsn. +/** Peeks the current lsn. @return true if success, false if could not get the log system mutex */ -ibool log_peek_lsn( - /*=========*/ - lsn_t *lsn) /*!< out: if returns TRUE, current lsn is here */ +ibool log_peek_lsn(lsn_t *lsn) /*!< out: if returns TRUE, current lsn is here */ { if (0 == mutex_enter_nowait(&(log_sys->mutex))) { *lsn = log_sys->lsn; @@ -2372,18 +2320,14 @@ ibool log_peek_lsn( return (FALSE); } -/******************************************************/ /** - Lock log. */ +/** Lock log. */ void log_lock(void) { log_mutex_enter(); } -/******************************************************/ /** - Unlock log. */ +/** Unlock log. */ void log_unlock(void) { log_mutex_exit(); } -/******************************************************/ /** - Collect log info. */ +/** Collect log info. */ void log_collect_lsn_info( - /*=========*/ lsn_t *lsn, /*!< out: current lsn */ lsn_t *lsn_checkpoint) /*!< out: current last_checkpoint_lsn */ { @@ -2391,11 +2335,8 @@ void log_collect_lsn_info( *lsn_checkpoint = log_sys->last_checkpoint_lsn; } -/******************************************************/ /** - Prints info of the log. */ -void log_print( - /*======*/ - FILE *file) /*!< in: file where to print */ +/** Prints info of the log. */ +void log_print(FILE *file) /*!< in: file where to print */ { double time_elapsed; time_t current_time; @@ -2436,20 +2377,14 @@ void log_print( log_mutex_exit(); } -/**********************************************************************/ /** - Refreshes the statistics used to print per-second averages. */ -void log_refresh_stats(void) -/*===================*/ -{ +/** Refreshes the statistics used to print per-second averages. */ +void log_refresh_stats(void) { log_sys->n_log_ios_old = log_sys->n_log_ios; log_sys->last_printout_time = time(NULL); } -/********************************************************/ /** - Closes a log group. */ -static void log_group_close( - /*===========*/ - log_group_t *group) /* in,own: log group to close */ +/** Closes a log group. */ +static void log_group_close(log_group_t *group) /* in,own: log group to close */ { ulint i; @@ -2463,11 +2398,8 @@ static void log_group_close( ut_free(group); } -/********************************************************/ /** - Closes all log groups. */ -void log_group_close_all(void) -/*=====================*/ -{ +/** Closes all log groups. */ +void log_group_close_all(void) { log_group_t *group; group = UT_LIST_GET_FIRST(log_sys->log_groups); diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index c0270dca5413..e6e765b7a331 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -25,8 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file log/log0recv.cc +/** @file log/log0recv.cc Recovery Created 9/20/1997 Heikki Tuuri diff --git a/storage/innobase/mach/mach0data.cc b/storage/innobase/mach/mach0data.cc index 47c3b51c747c..ef1eaf75da13 100644 --- a/storage/innobase/mach/mach0data.cc +++ b/storage/innobase/mach/mach0data.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file mach/mach0data.cc +/** @file mach/mach0data.cc Utilities for converting data from the database file to the machine format. diff --git a/storage/innobase/mem/memory.cc b/storage/innobase/mem/memory.cc index dc8a49922bf6..665fa8207a80 100644 --- a/storage/innobase/mem/memory.cc +++ b/storage/innobase/mem/memory.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file mem/memory.cc +/** @file mem/memory.cc The memory management Created 6/9/1994 Heikki Tuuri @@ -52,11 +51,9 @@ char *mem_heap_strdup(mem_heap_t *heap, const char *str) { return (static_cast(mem_heap_dup(heap, str, strlen(str) + 1))); } -/**********************************************************************/ /** - Duplicate a block of data, allocated from a memory heap. +/** Duplicate a block of data, allocated from a memory heap. @return own: a copy of the data */ void *mem_heap_dup( - /*=========*/ mem_heap_t *heap, /*!< in: memory heap where copy is allocated */ const void *data, /*!< in: data to be copied */ ulint len) /*!< in: length of data, in bytes */ @@ -64,11 +61,9 @@ void *mem_heap_dup( return (memcpy(mem_heap_alloc(heap, len), data, len)); } -/**********************************************************************/ /** - Concatenate two strings and return the result, using a memory heap. +/** Concatenate two strings and return the result, using a memory heap. @return own: the result */ char *mem_heap_strcat( - /*============*/ mem_heap_t *heap, /*!< in: memory heap where string is allocated */ const char *s1, /*!< in: string 1 */ const char *s2) /*!< in: string 2 */ @@ -87,11 +82,9 @@ char *mem_heap_strcat( return (s); } -/****************************************************************/ /** - Helper function for mem_heap_printf. +/** Helper function for mem_heap_printf. @return length of formatted string, including terminating NUL */ static ulint mem_heap_printf_low( - /*================*/ char *buf, /*!< in/out: buffer to store formatted string in, or NULL to just calculate length */ const char *format, /*!< in: format string */ @@ -193,17 +186,14 @@ static ulint mem_heap_printf_low( return (len); } -/****************************************************************/ /** - A simple sprintf replacement that dynamically allocates the space for the +/** A simple sprintf replacement that dynamically allocates the space for the formatted string from the given heap. This supports a very limited set of the printf syntax: types 's' and 'u' and length modifier 'l' (which is required for the 'u' type). @return heap-allocated formatted string */ -char *mem_heap_printf( - /*============*/ - mem_heap_t *heap, /*!< in: memory heap */ - const char *format, /*!< in: format string */ - ...) { +char *mem_heap_printf(mem_heap_t *heap, /*!< in: memory heap */ + const char *format, /*!< in: format string */ + ...) { va_list ap; char *str; ulint len; @@ -253,12 +243,10 @@ void mem_heap_validate(const mem_heap_t *heap) { } #endif /* UNIV_DEBUG */ -/***************************************************************/ /** - Creates a memory heap block where data can be allocated. +/** Creates a memory heap block where data can be allocated. @return own: memory heap block, NULL if did not succeed (only possible for MEM_HEAP_BTR_SEARCH type heaps) */ mem_block_t *mem_heap_create_block_func( - /*=======================*/ mem_heap_t *heap, /*!< in: memory heap or NULL if first block should be created */ ulint n, /*!< in: number of bytes needed for user data */ @@ -359,14 +347,11 @@ mem_block_t *mem_heap_create_block_func( return (block); } -/***************************************************************/ /** - Adds a new block to a memory heap. +/** Adds a new block to a memory heap. @return created block, NULL if did not succeed (only possible for MEM_HEAP_BTR_SEARCH type heaps) */ -mem_block_t *mem_heap_add_block( - /*===============*/ - mem_heap_t *heap, /*!< in: memory heap */ - ulint n) /*!< in: number of bytes user needs */ +mem_block_t *mem_heap_add_block(mem_heap_t *heap, /*!< in: memory heap */ + ulint n) /*!< in: number of bytes user needs */ { mem_block_t *block; mem_block_t *new_block; @@ -410,12 +395,9 @@ mem_block_t *mem_heap_add_block( return (new_block); } -/******************************************************************/ /** - Frees a block from a memory heap. */ -void mem_heap_block_free( - /*================*/ - mem_heap_t *heap, /*!< in: heap */ - mem_block_t *block) /*!< in: block to free */ +/** Frees a block from a memory heap. */ +void mem_heap_block_free(mem_heap_t *heap, /*!< in: heap */ + mem_block_t *block) /*!< in: block to free */ { #ifndef UNIV_LIBRARY buf_block_t *buf_block; @@ -466,11 +448,8 @@ void mem_heap_block_free( #ifndef UNIV_HOTBACKUP #ifndef UNIV_LIBRARY -/******************************************************************/ /** - Frees the free_block field from a memory heap. */ -void mem_heap_free_block_free( - /*=====================*/ - mem_heap_t *heap) /*!< in: heap */ +/** Frees the free_block field from a memory heap. */ +void mem_heap_free_block_free(mem_heap_t *heap) /*!< in: heap */ { if (UNIV_LIKELY_NULL(heap->free_block)) { #ifdef UNIV_DEBUG_VALGRIND diff --git a/storage/innobase/mtr/mtr0log.cc b/storage/innobase/mtr/mtr0log.cc index d2121a18cea8..f4b2afd465f0 100644 --- a/storage/innobase/mtr/mtr0log.cc +++ b/storage/innobase/mtr/mtr0log.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file mtr/mtr0log.cc +/** @file mtr/mtr0log.cc Mini-transaction log routines Created 12/7/1995 Heikki Tuuri @@ -46,13 +45,10 @@ this program; if not, write to the Free Software Foundation, Inc., #include "dict0boot.h" #endif /* !UNIV_HOTBACKUP */ -/********************************************************/ /** - Catenates n bytes to the mtr log. */ -void mlog_catenate_string( - /*=================*/ - mtr_t *mtr, /*!< in: mtr */ - const byte *str, /*!< in: string to write */ - ulint len) /*!< in: string length */ +/** Catenates n bytes to the mtr log. */ +void mlog_catenate_string(mtr_t *mtr, /*!< in: mtr */ + const byte *str, /*!< in: string to write */ + ulint len) /*!< in: string length */ { if (mtr_get_log_mode(mtr) == MTR_LOG_NONE) { return; @@ -62,12 +58,10 @@ void mlog_catenate_string( } #ifndef UNIV_HOTBACKUP -/********************************************************/ /** - Writes the initial part of a log record consisting of one-byte item +/** Writes the initial part of a log record consisting of one-byte item type and four-byte space and page numbers. Also pushes info to the mtr memo that a buffer page has been modified. */ void mlog_write_initial_log_record( - /*==========================*/ const byte *ptr, /*!< in: pointer to (inside) a buffer frame holding the file page where modification is made */ @@ -127,11 +121,9 @@ byte *mlog_parse_initial_dict_log_record(const byte *ptr, const byte *end_ptr, return (const_cast(ptr)); } -/********************************************************/ /** - Parses an initial log record written by mlog_write_initial_log_record. +/** Parses an initial log record written by mlog_write_initial_log_record. @return parsed record end, NULL if not a complete record */ byte *mlog_parse_initial_log_record( - /*==========================*/ const byte *ptr, /*!< in: buffer */ const byte *end_ptr, /*!< in: buffer end */ mlog_id_t *type, /*!< out: log record type: MLOG_1BYTE, ... */ @@ -160,11 +152,9 @@ byte *mlog_parse_initial_log_record( return (const_cast(ptr)); } -/********************************************************/ /** - Parses a log record written by mlog_write_ulint or mlog_write_ull. +/** Parses a log record written by mlog_write_ulint or mlog_write_ull. @return parsed record end, NULL if not a complete record or a corrupt record */ byte *mlog_parse_nbytes( - /*==============*/ mlog_id_t type, /*!< in: log record type: MLOG_1BYTE, ... */ const byte *ptr, /*!< in: buffer */ const byte *end_ptr, /*!< in: buffer end */ @@ -255,11 +245,9 @@ byte *mlog_parse_nbytes( return (const_cast(ptr)); } -/********************************************************/ /** - Writes 1, 2 or 4 bytes to a file page. Writes the corresponding log +/** Writes 1, 2 or 4 bytes to a file page. Writes the corresponding log record to the mini-transaction log if mtr is not NULL. */ void mlog_write_ulint( - /*=============*/ byte *ptr, /*!< in: pointer where to write */ ulint val, /*!< in: value to write */ mlog_id_t type, /*!< in: MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES */ @@ -297,14 +285,11 @@ void mlog_write_ulint( } } -/********************************************************/ /** - Writes 8 bytes to a file page. Writes the corresponding log +/** Writes 8 bytes to a file page. Writes the corresponding log record to the mini-transaction log, only if mtr is not NULL */ -void mlog_write_ull( - /*===========*/ - byte *ptr, /*!< in: pointer where to write */ - ib_uint64_t val, /*!< in: value to write */ - mtr_t *mtr) /*!< in: mini-transaction handle */ +void mlog_write_ull(byte *ptr, /*!< in: pointer where to write */ + ib_uint64_t val, /*!< in: value to write */ + mtr_t *mtr) /*!< in: mini-transaction handle */ { mach_write_to_8(ptr, val); @@ -327,15 +312,12 @@ void mlog_write_ull( } #ifndef UNIV_HOTBACKUP -/********************************************************/ /** - Writes a string to a file page buffered in the buffer pool. Writes the +/** Writes a string to a file page buffered in the buffer pool. Writes the corresponding log record to the mini-transaction log. */ -void mlog_write_string( - /*==============*/ - byte *ptr, /*!< in: pointer where to write */ - const byte *str, /*!< in: string to write */ - ulint len, /*!< in: string length */ - mtr_t *mtr) /*!< in: mini-transaction handle */ +void mlog_write_string(byte *ptr, /*!< in: pointer where to write */ + const byte *str, /*!< in: string to write */ + ulint len, /*!< in: string length */ + mtr_t *mtr) /*!< in: mini-transaction handle */ { ut_ad(ptr && mtr); ut_a(len < UNIV_PAGE_SIZE); @@ -345,14 +327,11 @@ void mlog_write_string( mlog_log_string(ptr, len, mtr); } -/********************************************************/ /** - Logs a write of a string to a file page buffered in the buffer pool. +/** Logs a write of a string to a file page buffered in the buffer pool. Writes the corresponding log record to the mini-transaction log. */ -void mlog_log_string( - /*============*/ - byte *ptr, /*!< in: pointer written to */ - ulint len, /*!< in: string length */ - mtr_t *mtr) /*!< in: mini-transaction handle */ +void mlog_log_string(byte *ptr, /*!< in: pointer written to */ + ulint len, /*!< in: string length */ + mtr_t *mtr) /*!< in: mini-transaction handle */ { byte *log_ptr; @@ -380,11 +359,9 @@ void mlog_log_string( } #endif /* !UNIV_HOTBACKUP */ -/********************************************************/ /** - Parses a log record written by mlog_write_string. +/** Parses a log record written by mlog_write_string. @return parsed record end, NULL if not a complete record */ byte *mlog_parse_string( - /*==============*/ byte *ptr, /*!< in: buffer */ byte *end_ptr, /*!< in: buffer end */ byte *page, /*!< in: page where to apply the log record, or NULL */ @@ -426,12 +403,10 @@ byte *mlog_parse_string( return (ptr + len); } -/********************************************************/ /** - Opens a buffer for mlog, writes the initial log record and, +/** Opens a buffer for mlog, writes the initial log record and, if needed, the field lengths of an index. @return buffer, NULL if log mode MTR_LOG_NONE */ byte *mlog_open_and_write_index( - /*======================*/ mtr_t *mtr, /*!< in: mtr */ const byte *rec, /*!< in: index record or page */ const dict_index_t *index, /*!< in: record descriptor */ @@ -542,15 +517,12 @@ byte *mlog_open_and_write_index( #endif /* !UNIV_HOTBACKUP */ } -/********************************************************/ /** - Parses a log record written by mlog_open_and_write_index. +/** Parses a log record written by mlog_open_and_write_index. @return parsed record end, NULL if not a complete record */ -byte *mlog_parse_index( - /*=============*/ - byte *ptr, /*!< in: buffer */ - const byte *end_ptr, /*!< in: buffer end */ - ibool comp, /*!< in: TRUE=compact row format */ - dict_index_t **index) /*!< out, own: dummy index */ +byte *mlog_parse_index(byte *ptr, /*!< in: buffer */ + const byte *end_ptr, /*!< in: buffer end */ + ibool comp, /*!< in: TRUE=compact row format */ + dict_index_t **index) /*!< out, own: dummy index */ { ulint i, n, n_uniq; dict_table_t *table; diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc index f241c1fdf1fb..c9778be2ce51 100644 --- a/storage/innobase/mtr/mtr0mtr.cc +++ b/storage/innobase/mtr/mtr0mtr.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file mtr/mtr0mtr.cc +/** @file mtr/mtr0mtr.cc Mini-transaction buffer Created 11/26/1995 Heikki Tuuri diff --git a/storage/innobase/os/file.cc b/storage/innobase/os/file.cc index b39a833a1005..275026ec847b 100644 --- a/storage/innobase/os/file.cc +++ b/storage/innobase/os/file.cc @@ -1,6 +1,6 @@ /*********************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Percona Inc. Portions of this file contain modifications contributed and copyrighted @@ -32,8 +32,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ***********************************************************************/ -/**************************************************/ /** - @file os/file.cc +/** @file os/file.cc The interface to the operating system file i/o primitives Created 10/21/1995 Heikki Tuuri diff --git a/storage/innobase/os/file.h b/storage/innobase/os/file.h index 5117a7fcd636..1b3c38e2a2ff 100644 --- a/storage/innobase/os/file.h +++ b/storage/innobase/os/file.h @@ -1,6 +1,6 @@ /*********************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Percona Inc. Portions of this file contain modifications contributed and copyrighted @@ -38,8 +38,7 @@ external tools. */ #include "my_compiler.h" -/**************************************************/ /** - @file os/file.h +/** @file os/file.h The interface to the operating system file io Created 10/21/1995 Heikki Tuuri diff --git a/storage/innobase/os/os0event.cc b/storage/innobase/os/os0event.cc index cf8bfd6e0b70..bdbba1f51c1a 100644 --- a/storage/innobase/os/os0event.cc +++ b/storage/innobase/os/os0event.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2013, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2013, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file os/os0event.cc +/** @file os/os0event.cc The interface to the operating system condition variables. Created 2012-09-23 Sunny Bains @@ -428,11 +427,9 @@ Creates an event semaphore, i.e., a semaphore which may just have two states: signaled and nonsignaled. The created event is manual reset: it must be reset explicitly by calling sync_os_reset_event. @return the event handle */ -os_event_t os_event_create( - /*============*/ - const char *name) /*!< in: the name of the - event, if NULL the event - is created without a name */ +os_event_t os_event_create(const char *name) /*!< in: the name of the + event, if NULL the event + is created without a name */ { return (UT_NEW_NOKEY(os_event(name))); } @@ -440,9 +437,7 @@ os_event_t os_event_create( /** Check if the event is set. @return true if set */ -bool os_event_is_set( - /*============*/ - const os_event_t event) /*!< in: event to test */ +bool os_event_is_set(const os_event_t event) /*!< in: event to test */ { return (event->is_set()); } @@ -450,9 +445,7 @@ bool os_event_is_set( /** Sets an event semaphore to the signaled state: lets waiting threads proceed. */ -void os_event_set( - /*=========*/ - os_event_t event) /*!< in/out: event to set */ +void os_event_set(os_event_t event) /*!< in/out: event to set */ { event->set(); } @@ -465,9 +458,7 @@ that this thread should not wait in case of an intervening call to os_event_set() between this os_event_reset() and the os_event_wait_low() call. See comments for os_event_wait_low(). @return current signal_count. */ -int64_t os_event_reset( - /*===========*/ - os_event_t event) /*!< in/out: event to reset */ +int64_t os_event_reset(os_event_t event) /*!< in/out: event to reset */ { return (event->reset()); } @@ -477,7 +468,6 @@ Waits for an event object until it is in the signaled state or a timeout is exceeded. @return 0 if success, OS_SYNC_TIME_EXCEEDED if timeout was exceeded */ ulint os_event_wait_time_low( - /*===================*/ os_event_t event, /*!< in/out: event to wait */ ulint time_in_usec, /*!< in: timeout in microseconds, or @@ -495,21 +485,17 @@ Waits for an event object until it is in the signaled state. Where such a scenario is possible, to avoid infinite wait, the value returned by os_event_reset() should be passed in as reset_sig_count. */ -void os_event_wait_low( - /*==============*/ - os_event_t event, /*!< in: event to wait */ - int64_t reset_sig_count) /*!< in: zero or the value - returned by previous call of - os_event_reset(). */ +void os_event_wait_low(os_event_t event, /*!< in: event to wait */ + int64_t reset_sig_count) /*!< in: zero or the value + returned by previous call of + os_event_reset(). */ { event->wait_low(reset_sig_count); } /** Frees an event object. */ -void os_event_destroy( - /*=============*/ - os_event_t &event) /*!< in/own: event to free */ +void os_event_destroy(os_event_t &event) /*!< in/own: event to free */ { if (event != NULL) { diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 684b829aa246..133722983217 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -32,8 +32,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ***********************************************************************/ -/**************************************************/ /** - @file os/os0file.cc +/** @file os/os0file.cc The interface to the operating system file i/o primitives Created 10/21/1995 Heikki Tuuri diff --git a/storage/innobase/os/os0proc.cc b/storage/innobase/os/os0proc.cc index 5d954ead62ab..d0bf20dc6464 100644 --- a/storage/innobase/os/os0proc.cc +++ b/storage/innobase/os/os0proc.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file os/os0proc.cc +/** @file os/os0proc.cc The interface to the operating system process control primitives @@ -65,9 +64,7 @@ uint os_large_page_size; /** Converts the current process id to a number. @return process id as a number */ -ulint os_proc_get_number(void) -/*====================*/ -{ +ulint os_proc_get_number(void) { #ifdef _WIN32 return (static_cast(GetCurrentProcessId())); #else diff --git a/storage/innobase/os/os0thread.cc b/storage/innobase/os/os0thread.cc index 1fa040ff8b16..f228c5895036 100644 --- a/storage/innobase/os/os0thread.cc +++ b/storage/innobase/os/os0thread.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file os/os0thread.cc +/** @file os/os0thread.cc The interface to the operating system thread control primitives Created 9/8/1995 Heikki Tuuri diff --git a/storage/innobase/page/page.ic b/storage/innobase/page/page.ic index d3de891a1b44..43afba3be601 100644 --- a/storage/innobase/page/page.ic +++ b/storage/innobase/page/page.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file page/page.ic +/** @file page/page.ic Index page routines Created 2/2/1994 Heikki Tuuri @@ -39,26 +38,20 @@ external tools. */ #define page_page_h #include "mach0data.h" -/*************************************************************/ /** - Reads the given header field. */ +/** Reads the given header field. */ UNIV_INLINE -ulint page_header_get_field( - /*==================*/ - const page_t *page, /*!< in: page */ - ulint field) /*!< in: PAGE_LEVEL, ... */ +ulint page_header_get_field(const page_t *page, /*!< in: page */ + ulint field) /*!< in: PAGE_LEVEL, ... */ { ut_ad(page); ut_ad(field <= PAGE_INDEX_ID); return (mach_read_from_2(page + PAGE_HEADER + field)); } -/*************************************************************/ /** - Gets the number of records in the heap. +/** Gets the number of records in the heap. @return number of user records */ UNIV_INLINE -ulint page_dir_get_n_heap( - /*================*/ - const page_t *page) /*!< in: index page */ +ulint page_dir_get_n_heap(const page_t *page) /*!< in: index page */ { return (page_header_get_field(page, PAGE_N_HEAP) & 0x7fff); } diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc index cc1e225e68e6..80d6190a0ee6 100644 --- a/storage/innobase/page/page0cur.cc +++ b/storage/innobase/page/page0cur.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -25,8 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file page/page0cur.cc +/** @file page/page0cur.cc The page cursor Created 10/4/1994 Heikki Tuuri @@ -53,8 +52,7 @@ static ulint page_cur_short_succ = 0; #endif /* UNIV_SEARCH_PERF_STAT */ #ifndef UNIV_HOTBACKUP -/*******************************************************************/ /** - This is a linear congruential generator PRNG. Returns a pseudo random +/** This is a linear congruential generator PRNG. Returns a pseudo random number between 0 and 2^64-1 inclusive. The formula and the constants being used are: X[n+1] = (a * X[n] + c) mod m @@ -65,9 +63,7 @@ static ulint page_cur_short_succ = 0; m = 18446744073709551616 (2^64) @return number between 0 and 2^64-1 */ -static ib_uint64_t page_cur_lcg_prng(void) -/*===================*/ -{ +static ib_uint64_t page_cur_lcg_prng(void) { #define LCG_a 1103515245 #define LCG_c 12345 static ib_uint64_t lcg_current = 0; @@ -239,13 +235,11 @@ bool page_cur_try_search_shortcut_bytes( #endif /* !UNIV_HOTBACKUP */ #ifdef PAGE_CUR_LE_OR_EXTENDS -/****************************************************************/ /** - Checks if the nth field in a record is a character type field which extends +/** Checks if the nth field in a record is a character type field which extends the nth field in tuple, i.e., the field is longer or equal in length and has common first characters. @return true if rec field extends tuple field */ static ibool page_cur_rec_field_extends( - /*=======================*/ const dtuple_t *tuple, /*!< in: data tuple */ const rec_t *rec, /*!< in: record */ const ulint *offsets, /*!< in: array returned by rec_get_offsets() */ @@ -364,10 +358,8 @@ static ulint *populate_offsets(const rec_t *rec, const dtuple_t *tuple, #endif /* PAGE_CUR_ADAPT */ #ifndef UNIV_HOTBACKUP -/****************************************************************/ /** - Searches the right position for a page cursor. */ +/** Searches the right position for a page cursor. */ void page_cur_search_with_match( - /*=======================*/ const buf_block_t *block, /*!< in: buffer block */ const dict_index_t *index, /*!< in/out: record descriptor */ const dtuple_t *tuple, /*!< in: data tuple */ @@ -836,13 +828,10 @@ void page_cur_search_with_match_bytes( } } -/***********************************************************/ /** - Positions a page cursor on a randomly chosen user record on a page. If there +/** Positions a page cursor on a randomly chosen user record on a page. If there are no user records, sets the cursor on the infimum record. */ -void page_cur_open_on_rnd_user_rec( - /*==========================*/ - buf_block_t *block, /*!< in: page */ - page_cur_t *cursor) /*!< out: page cursor */ +void page_cur_open_on_rnd_user_rec(buf_block_t *block, /*!< in: page */ + page_cur_t *cursor) /*!< out: page cursor */ { ulint rnd; ulint n_recs = page_get_n_recs(buf_block_get_frame(block)); @@ -860,10 +849,8 @@ void page_cur_open_on_rnd_user_rec( } while (rnd--); } -/***********************************************************/ /** - Writes the log record of a record insert on a page. */ +/** Writes the log record of a record insert on a page. */ static void page_cur_insert_rec_write_log( - /*==========================*/ rec_t *insert_rec, /*!< in: inserted physical record */ ulint rec_size, /*!< in: insert_rec size */ rec_t *cursor_rec, /*!< in: record the @@ -1042,11 +1029,9 @@ static void page_cur_insert_rec_write_log( #define page_cur_insert_rec_write_log(ins_rec, size, cur, index, mtr) ((void)0) #endif /* !UNIV_HOTBACKUP */ -/***********************************************************/ /** - Parses a log record of a record insert on a page. +/** Parses a log record of a record insert on a page. @return end of log record or NULL */ byte *page_cur_parse_insert_rec( - /*======================*/ ibool is_short, /*!< in: TRUE if short inserts */ const byte *ptr, /*!< in: buffer */ const byte *end_ptr, /*!< in: buffer end */ @@ -1208,13 +1193,11 @@ byte *page_cur_parse_insert_rec( return (const_cast(ptr + end_seg_len)); } -/***********************************************************/ /** - Inserts a record next to page cursor on an uncompressed page. +/** Inserts a record next to page cursor on an uncompressed page. Returns pointer to inserted record if succeed, i.e., enough space available, NULL otherwise. The cursor stays at the same position. @return pointer to record if succeed, NULL otherwise */ rec_t *page_cur_insert_rec_low( - /*====================*/ rec_t *current_rec, /*!< in: pointer to current record after which the new record is inserted */ dict_index_t *index, /*!< in: record descriptor */ @@ -1584,8 +1567,7 @@ rec_t *page_cur_direct_insert_rec_low(rec_t *current_rec, dict_index_t *index, return (insert_rec); } -/***********************************************************/ /** - Inserts a record next to page cursor on a compressed and uncompressed +/** Inserts a record next to page cursor on a compressed and uncompressed page. Returns pointer to inserted record if succeed, i.e., enough space available, NULL otherwise. The cursor stays at the same position. @@ -1597,7 +1579,6 @@ rec_t *page_cur_direct_insert_rec_low(rec_t *current_rec, dict_index_t *index, @return pointer to record if succeed, NULL otherwise */ rec_t *page_cur_insert_rec_zip( - /*====================*/ page_cur_t *cursor, /*!< in/out: page cursor */ dict_index_t *index, /*!< in: record descriptor */ const rec_t *rec, /*!< in: pointer to a physical record */ @@ -1989,13 +1970,11 @@ rec_t *page_cur_insert_rec_zip( } #ifndef UNIV_HOTBACKUP -/**********************************************************/ /** - Writes a log record of copying a record list end to a new created page. +/** Writes a log record of copying a record list end to a new created page. @return 4-byte field where to write the log data length, or NULL if logging is disabled */ UNIV_INLINE byte *page_copy_rec_list_to_created_page_write_log( - /*=========================================*/ page_t *page, /*!< in: index page */ dict_index_t *index, /*!< in: record descriptor */ mtr_t *mtr) /*!< in: mtr */ @@ -2017,11 +1996,9 @@ byte *page_copy_rec_list_to_created_page_write_log( } #endif /* !UNIV_HOTBACKUP */ -/**********************************************************/ /** - Parses a log record of copying a record list end to a new created page. +/** Parses a log record of copying a record list end to a new created page. @return end of log record or NULL */ byte *page_parse_copy_rec_list_to_created_page( - /*=====================================*/ byte *ptr, /*!< in: buffer */ byte *end_ptr, /*!< in: buffer end */ buf_block_t *block, /*!< in: page or NULL */ @@ -2070,16 +2047,14 @@ byte *page_parse_copy_rec_list_to_created_page( } #ifndef UNIV_HOTBACKUP -/*************************************************************/ /** - Copies records from page to a newly created page, from a given record onward, - including that record. Infimum and supremum records are not copied. +/** Copies records from page to a newly created page, from a given record + onward, including that record. Infimum and supremum records are not copied. IMPORTANT: The caller will have to update IBUF_BITMAP_FREE if this is a compressed leaf page in a secondary index. This has to be done either within the same mini-transaction, or by invoking ibuf_reset_free_bits() before mtr_commit(). */ void page_copy_rec_list_end_to_created_page( - /*===================================*/ page_t *new_page, /*!< in/out: index page to copy to */ rec_t *rec, /*!< in: first record to copy */ dict_index_t *index, /*!< in: record descriptor */ @@ -2241,11 +2216,9 @@ void page_copy_rec_list_end_to_created_page( mtr_set_log_mode(mtr, log_mode); } -/***********************************************************/ /** - Writes log record of a record delete on a page. */ +/** Writes log record of a record delete on a page. */ UNIV_INLINE void page_cur_delete_rec_write_log( - /*==========================*/ rec_t *rec, /*!< in: record to be deleted */ const dict_index_t *index, /*!< in: record descriptor */ mtr_t *mtr) /*!< in: mini-transaction handle */ @@ -2273,11 +2246,9 @@ void page_cur_delete_rec_write_log( #define page_cur_delete_rec_write_log(rec, index, mtr) ((void)0) #endif /* !UNIV_HOTBACKUP */ -/***********************************************************/ /** - Parses log record of a record delete on a page. +/** Parses log record of a record delete on a page. @return pointer to record end or NULL */ byte *page_cur_parse_delete_rec( - /*======================*/ byte *ptr, /*!< in: buffer */ byte *end_ptr, /*!< in: buffer end */ buf_block_t *block, /*!< in: page or NULL */ @@ -2322,11 +2293,9 @@ byte *page_cur_parse_delete_rec( return (ptr); } -/***********************************************************/ /** - Deletes a record at the page cursor. The cursor is moved to the next +/** Deletes a record at the page cursor. The cursor is moved to the next record after the deleted one. */ void page_cur_delete_rec( - /*================*/ page_cur_t *cursor, /*!< in/out: a page cursor */ const dict_index_t *index, /*!< in: record descriptor */ const ulint *offsets, /*!< in: rec_get_offsets( @@ -2469,12 +2438,9 @@ void page_cur_delete_rec( #ifdef UNIV_COMPILE_TEST_FUNCS -/*******************************************************************/ /** - Print the first n numbers, generated by page_cur_lcg_prng() to make sure +/** Print the first n numbers, generated by page_cur_lcg_prng() to make sure (visually) that it works properly. */ -void test_page_cur_lcg_prng( - /*===================*/ - int n) /*!< in: print first n numbers */ +void test_page_cur_lcg_prng(int n) /*!< in: print first n numbers */ { int i; unsigned long long rnd; diff --git a/storage/innobase/page/page0page.cc b/storage/innobase/page/page0page.cc index bb5305aecc1d..a63f46548428 100644 --- a/storage/innobase/page/page0page.cc +++ b/storage/innobase/page/page0page.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -25,8 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file page/page0page.cc +/** @file page/page0page.cc Index page routines Created 2/2/1994 Heikki Tuuri @@ -89,12 +88,9 @@ Assuming a page size of 8 kB, a typical index page of a secondary index contains 300 index entries, and the size of the page directory is 50 x 4 bytes = 200 bytes. */ -/***************************************************************/ /** - Looks for the directory slot which owns the given record. +/** Looks for the directory slot which owns the given record. @return the directory slot number */ -ulint page_dir_find_owner_slot( - /*=====================*/ - const rec_t *rec) /*!< in: the physical record */ +ulint page_dir_find_owner_slot(const rec_t *rec) /*!< in: the physical record */ { const page_t *page; uint16 rec_offs_bytes; @@ -154,12 +150,9 @@ ulint page_dir_find_owner_slot( return (((ulint)(first_slot - slot)) / PAGE_DIR_SLOT_SIZE); } -/**************************************************************/ /** - Used to check the consistency of a directory slot. +/** Used to check the consistency of a directory slot. @return true if succeed */ -static ibool page_dir_slot_check( - /*================*/ - const page_dir_slot_t *slot) /*!< in: slot */ +static ibool page_dir_slot_check(const page_dir_slot_t *slot) /*!< in: slot */ { const page_t *page; ulint n_slots; @@ -195,10 +188,8 @@ static ibool page_dir_slot_check( return (TRUE); } -/*************************************************************/ /** - Sets the max trx id field value. */ +/** Sets the max trx id field value. */ void page_set_max_trx_id( - /*================*/ buf_block_t *block, /*!< in/out: page */ page_zip_des_t *page_zip, /*!< in/out: compressed page, or NULL */ trx_id_t trx_id, /*!< in: transaction id */ @@ -226,11 +217,9 @@ void page_set_max_trx_id( } } -/************************************************************/ /** - Allocates a block of memory from the heap of an index page. +/** Allocates a block of memory from the heap of an index page. @return pointer to start of allocated buffer, or NULL if allocation fails */ byte *page_mem_alloc_heap( - /*================*/ page_t *page, /*!< in/out: index page */ page_zip_des_t *page_zip, /*!< in/out: compressed page with enough space available for inserting the record, @@ -434,13 +423,10 @@ page_t *page_create_zip(buf_block_t *block, dict_index_t *index, ulint level, return (page); } -/**********************************************************/ /** - Empty a previously created B-tree index page. */ -void page_create_empty( - /*==============*/ - buf_block_t *block, /*!< in/out: B-tree block */ - dict_index_t *index, /*!< in: the index of the page */ - mtr_t *mtr) /*!< in/out: mini-transaction */ +/** Empty a previously created B-tree index page. */ +void page_create_empty(buf_block_t *block, /*!< in/out: B-tree block */ + dict_index_t *index, /*!< in: the index of the page */ + mtr_t *mtr) /*!< in/out: mini-transaction */ { trx_id_t max_trx_id = 0; page_t *page = buf_block_get_frame(block); @@ -471,8 +457,7 @@ void page_create_empty( } } -/*************************************************************/ /** - Differs from page_copy_rec_list_end, because this function does not +/** Differs from page_copy_rec_list_end, because this function does not touch the lock table and max trx id on page or compress the page. IMPORTANT: The caller will have to update IBUF_BITMAP_FREE @@ -480,7 +465,6 @@ void page_create_empty( This has to be done either within the same mini-transaction, or by invoking ibuf_reset_free_bits() before mtr_commit(). */ void page_copy_rec_list_end_no_locks( - /*============================*/ buf_block_t *new_block, /*!< in: index page to copy to */ buf_block_t *block, /*!< in: index page of rec */ rec_t *rec, /*!< in: record on page */ @@ -531,8 +515,7 @@ void page_copy_rec_list_end_no_locks( } #ifndef UNIV_HOTBACKUP -/*************************************************************/ /** - Copies records from page to new_page, from a given record onward, +/** Copies records from page to new_page, from a given record onward, including that record. Infimum and supremum records are not copied. The records are copied to the start of the record list on new_page. @@ -544,7 +527,6 @@ void page_copy_rec_list_end_no_locks( @return pointer to the original successor of the infimum record on new_page, or NULL on zip overflow (new_block will be decompressed) */ rec_t *page_copy_rec_list_end( - /*===================*/ buf_block_t *new_block, /*!< in/out: index page to copy to */ buf_block_t *block, /*!< in: index page containing rec */ rec_t *rec, /*!< in: record on page */ @@ -670,8 +652,7 @@ rec_t *page_copy_rec_list_end( return (ret); } -/*************************************************************/ /** - Copies records from page to new_page, up to the given record, +/** Copies records from page to new_page, up to the given record, NOT including that record. Infimum and supremum records are not copied. The records are copied to the end of the record list on new_page. @@ -683,7 +664,6 @@ rec_t *page_copy_rec_list_end( @return pointer to the original predecessor of the supremum record on new_page, or NULL on zip overflow (new_block will be decompressed) */ rec_t *page_copy_rec_list_start( - /*=====================*/ buf_block_t *new_block, /*!< in/out: index page to copy to */ buf_block_t *block, /*!< in: index page containing rec */ rec_t *rec, /*!< in: record on page */ @@ -815,11 +795,9 @@ rec_t *page_copy_rec_list_start( return (ret); } -/**********************************************************/ /** - Writes a log record of a record list end or start deletion. */ +/** Writes a log record of a record list end or start deletion. */ UNIV_INLINE void page_delete_rec_list_write_log( - /*===========================*/ rec_t *rec, /*!< in: record on page */ dict_index_t *index, /*!< in: record descriptor */ mlog_id_t type, /*!< in: operation type: @@ -842,11 +820,9 @@ void page_delete_rec_list_write_log( #define page_delete_rec_list_write_log(rec, index, type, mtr) ((void)0) #endif /* !UNIV_HOTBACKUP */ -/**********************************************************/ /** - Parses a log record of a record list end or start deletion. +/** Parses a log record of a record list end or start deletion. @return end of log record or NULL */ byte *page_parse_delete_rec_list( - /*=======================*/ mlog_id_t type, /*!< in: MLOG_LIST_END_DELETE, MLOG_LIST_START_DELETE, MLOG_COMP_LIST_END_DELETE or @@ -891,11 +867,9 @@ byte *page_parse_delete_rec_list( return (ptr); } -/*************************************************************/ /** - Deletes records from a page from a given record onward, including that record. - The infimum and supremum records are not deleted. */ +/** Deletes records from a page from a given record onward, including that + record. The infimum and supremum records are not deleted. */ void page_delete_rec_list_end( - /*=====================*/ rec_t *rec, /*!< in: pointer to record on page */ buf_block_t *block, /*!< in: buffer block of the page */ dict_index_t *index, /*!< in: record descriptor */ @@ -1089,11 +1063,9 @@ void page_delete_rec_list_end( (ulint)(page_get_n_recs(page) - n_recs)); } -/*************************************************************/ /** - Deletes records from page, up to the given record, NOT including +/** Deletes records from page, up to the given record, NOT including that record. Infimum and supremum records are not deleted. */ void page_delete_rec_list_start( - /*=======================*/ rec_t *rec, /*!< in: record on page */ buf_block_t *block, /*!< in: buffer block of the page */ dict_index_t *index, /*!< in: record descriptor */ @@ -1166,8 +1138,7 @@ void page_delete_rec_list_start( } #ifndef UNIV_HOTBACKUP -/*************************************************************/ /** - Moves record list end to another page. Moved records include +/** Moves record list end to another page. Moved records include split_rec. IMPORTANT: The caller will have to update IBUF_BITMAP_FREE @@ -1178,7 +1149,6 @@ void page_delete_rec_list_start( @return true on success; false on compression failure (new_block will be decompressed) */ ibool page_move_rec_list_end( - /*===================*/ buf_block_t *new_block, /*!< in/out: index page where to move */ buf_block_t *block, /*!< in: index page from where to move */ rec_t *split_rec, /*!< in: first record to move */ @@ -1222,8 +1192,7 @@ ibool page_move_rec_list_end( return (TRUE); } -/*************************************************************/ /** - Moves record list start to another page. Moved records do not include +/** Moves record list start to another page. Moved records do not include split_rec. IMPORTANT: The caller will have to update IBUF_BITMAP_FREE @@ -1233,7 +1202,6 @@ ibool page_move_rec_list_end( @return true on success; false on compression failure */ ibool page_move_rec_list_start( - /*=====================*/ buf_block_t *new_block, /*!< in/out: index page where to move */ buf_block_t *block, /*!< in/out: page containing split_rec */ rec_t *split_rec, /*!< in: first record not to move */ @@ -1251,13 +1219,11 @@ ibool page_move_rec_list_start( } #endif /* !UNIV_HOTBACKUP */ -/**************************************************************/ /** - Used to delete n slots from the directory. This function updates +/** Used to delete n slots from the directory. This function updates also n_owned fields in the records, so that the first slot after the deleted ones inherits the records of the deleted slots. */ UNIV_INLINE void page_dir_delete_slot( - /*=================*/ page_t *page, /*!< in/out: the index page */ page_zip_des_t *page_zip, /*!< in/out: compressed page, or NULL */ ulint slot_no) /*!< in: slot to be deleted */ @@ -1298,13 +1264,11 @@ void page_dir_delete_slot( page_header_set_field(page, page_zip, PAGE_N_DIR_SLOTS, n_slots - 1); } -/**************************************************************/ /** - Used to add n slots to the directory. Does not set the record pointers +/** Used to add n slots to the directory. Does not set the record pointers in the added slots or update n_owned values: this is the responsibility of the caller. */ UNIV_INLINE void page_dir_add_slot( - /*==============*/ page_t *page, /*!< in/out: the index page */ page_zip_des_t *page_zip, /*!< in/out: comprssed page, or NULL */ ulint start) /*!< in: the slot above which the new slots @@ -1326,10 +1290,8 @@ void page_dir_add_slot( (n_slots - 1 - start) * PAGE_DIR_SLOT_SIZE); } -/****************************************************************/ /** - Splits a directory slot which owns too many records. */ +/** Splits a directory slot which owns too many records. */ void page_dir_split_slot( - /*================*/ page_t *page, /*!< in/out: index page */ page_zip_des_t *page_zip, /*!< in/out: compressed page whose uncompressed part will be written, or NULL */ @@ -1385,12 +1347,10 @@ void page_dir_split_slot( page_dir_slot_set_n_owned(slot, page_zip, n_owned - (n_owned / 2)); } -/*************************************************************/ /** - Tries to balance the given directory slot with too few records with the upper - neighbor, so that there are at least the minimum number of records owned by - the slot; this may result in the merging of two slots. */ +/** Tries to balance the given directory slot with too few records with the + upper neighbor, so that there are at least the minimum number of records owned + by the slot; this may result in the merging of two slots. */ void page_dir_balance_slot( - /*==================*/ page_t *page, /*!< in/out: index page */ page_zip_des_t *page_zip, /*!< in/out: compressed page, or NULL */ ulint slot_no) /*!< in: the directory slot */ @@ -1452,14 +1412,11 @@ void page_dir_balance_slot( } } -/************************************************************/ /** - Returns the nth record of the record list. +/** Returns the nth record of the record list. This is the inverse function of page_rec_get_n_recs_before(). @return nth record */ -const rec_t *page_rec_get_nth_const( - /*===================*/ - const page_t *page, /*!< in: page */ - ulint nth) /*!< in: nth record */ +const rec_t *page_rec_get_nth_const(const page_t *page, /*!< in: page */ + ulint nth) /*!< in: nth record */ { const page_dir_slot_t *slot; ulint i; @@ -1502,12 +1459,10 @@ const rec_t *page_rec_get_nth_const( return (rec); } -/***************************************************************/ /** - Returns the number of records before the given record in chain. +/** Returns the number of records before the given record in chain. The number includes infimum and supremum records. @return number of records */ ulint page_rec_get_n_recs_before( - /*=======================*/ const rec_t *rec) /*!< in: the physical record */ { const page_dir_slot_t *slot; @@ -1562,13 +1517,10 @@ ulint page_rec_get_n_recs_before( } #ifndef UNIV_HOTBACKUP -/************************************************************/ /** - Prints record contents including the data relevant only in +/** Prints record contents including the data relevant only in the index page context. */ -void page_rec_print( - /*===========*/ - const rec_t *rec, /*!< in: physical record */ - const ulint *offsets) /*!< in: record descriptor */ +void page_rec_print(const rec_t *rec, /*!< in: physical record */ + const ulint *offsets) /*!< in: record descriptor */ { ut_a(!page_rec_is_comp(rec) == !rec_offs_comp(offsets)); rec_print_new(stderr, rec, offsets); @@ -1587,13 +1539,10 @@ void page_rec_print( } #ifdef UNIV_BTR_PRINT -/***************************************************************/ /** - This is used to print the contents of the directory for +/** This is used to print the contents of the directory for debugging purposes. */ -void page_dir_print( - /*===========*/ - page_t *page, /*!< in: index page */ - ulint pr_n) /*!< in: print n first and n last entries */ +void page_dir_print(page_t *page, /*!< in: index page */ + ulint pr_n) /*!< in: print n first and n last entries */ { ulint n; ulint i; @@ -1627,11 +1576,9 @@ void page_dir_print( (ulong)(PAGE_HEAP_NO_USER_LOW + page_get_n_recs(page))); } -/***************************************************************/ /** - This is used to print the contents of the page record list for +/** This is used to print the contents of the page record list for debugging purposes. */ void page_print_list( - /*============*/ buf_block_t *block, /*!< in: index page */ dict_index_t *index, /*!< in: dictionary index of the page */ ulint pr_n) /*!< in: print n first and n last entries */ @@ -1696,11 +1643,8 @@ void page_print_list( } } -/***************************************************************/ /** - Prints the info in a page header. */ -void page_header_print( - /*==============*/ - const page_t *page) { +/** Prints the info in a page header. */ +void page_header_print(const page_t *page) { fprintf(stderr, "--------------------------------\n" "PAGE HEADER INFO\n" @@ -1720,17 +1664,14 @@ void page_header_print( (ulong)page_header_get_field(page, PAGE_N_DIRECTION)); } -/***************************************************************/ /** - This is used to print the contents of the page for +/** This is used to print the contents of the page for debugging purposes. */ -void page_print( - /*=======*/ - buf_block_t *block, /*!< in: index page */ - dict_index_t *index, /*!< in: dictionary index of the page */ - ulint dn, /*!< in: print dn first and last entries - in directory */ - ulint rn) /*!< in: print rn first and last records - in directory */ +void page_print(buf_block_t *block, /*!< in: index page */ + dict_index_t *index, /*!< in: dictionary index of the page */ + ulint dn, /*!< in: print dn first and last entries + in directory */ + ulint rn) /*!< in: print rn first and last records + in directory */ { page_t *page = block->frame; @@ -1741,13 +1682,11 @@ void page_print( #endif /* UNIV_BTR_PRINT */ #endif /* !UNIV_HOTBACKUP */ -/***************************************************************/ /** - The following is used to validate a record on a page. This function +/** The following is used to validate a record on a page. This function differs from rec_validate as it can also check the n_owned field and the heap_no field. @return true if ok */ ibool page_rec_validate( - /*==============*/ const rec_t *rec, /*!< in: physical record */ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ { @@ -1786,13 +1725,10 @@ ibool page_rec_validate( #ifndef UNIV_HOTBACKUP #ifdef UNIV_DEBUG -/***************************************************************/ /** - Checks that the first directory slot points to the infimum record and +/** Checks that the first directory slot points to the infimum record and the last to the supremum. This function is intended to track if the bug fixed in 4.0.14 has caused corruption to users' databases. */ -void page_check_dir( - /*===========*/ - const page_t *page) /*!< in: index page */ +void page_check_dir(const page_t *page) /*!< in: index page */ { ulint n_slots; ulint infimum_offs; @@ -1815,13 +1751,11 @@ void page_check_dir( #endif /* UNIV_DEBUG */ #endif /* !UNIV_HOTBACKUP */ -/***************************************************************/ /** - This function checks the consistency of an index page when we do not +/** This function checks the consistency of an index page when we do not know the index. This is also resilient so that this should never crash even if the page is total garbage. @return true if ok */ ibool page_simple_validate_old( - /*=====================*/ const page_t *page) /*!< in: index page in ROW_FORMAT=REDUNDANT */ { const page_dir_slot_t *slot; @@ -1992,13 +1926,11 @@ ibool page_simple_validate_old( return (ret); } -/***************************************************************/ /** - This function checks the consistency of an index page when we do not +/** This function checks the consistency of an index page when we do not know the index. This is also resilient so that this should never crash even if the page is total garbage. @return true if ok */ ibool page_simple_validate_new( - /*=====================*/ const page_t *page) /*!< in: index page in ROW_FORMAT!=REDUNDANT */ { const page_dir_slot_t *slot; @@ -2170,11 +2102,9 @@ ibool page_simple_validate_new( return (ret); } -/***************************************************************/ /** - This function checks the consistency of an index page. +/** This function checks the consistency of an index page. @return true if ok */ ibool page_validate( - /*==========*/ const page_t *page, /*!< in: index page */ dict_index_t *index) /*!< in: data dictionary index containing the page record type definition */ @@ -2483,11 +2413,9 @@ ibool page_validate( } #ifndef UNIV_HOTBACKUP -/***************************************************************/ /** - Looks in the page record list for a record with the given heap number. +/** Looks in the page record list for a record with the given heap number. @return record, NULL if not found */ const rec_t *page_find_rec_with_heap_no( - /*=======================*/ const page_t *page, /*!< in: index page */ ulint heap_no) /*!< in: heap number */ { @@ -2524,13 +2452,11 @@ const rec_t *page_find_rec_with_heap_no( } } -/*******************************************************/ /** - Removes the record from a leaf page. This function does not log +/** Removes the record from a leaf page. This function does not log any changes. It is used by the IMPORT tablespace functions. The cursor is moved to the next record after the deleted one. @return true if success, i.e., the page did not become too empty */ bool page_delete_rec( - /*============*/ const dict_index_t *index, /*!< in: The index that the record belongs to */ page_cur_t *pcur, /*!< in/out: page cursor on record diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index ab056255f024..82ce79a1ed53 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -25,8 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file page/page0zip.cc +/** @file page/page0zip.cc Compressed page interface Created June 2005 by Marko Makela @@ -102,11 +101,9 @@ Compare at most sizeof(field_ref_zero) bytes. #define ASSERT_ZERO_BLOB(b) \ ut_ad(!memcmp(b, field_ref_zero, sizeof field_ref_zero)) -/**********************************************************************/ /** - Determine the guaranteed free space on an empty page. +/** Determine the guaranteed free space on an empty page. @return minimum payload size on the page */ ulint page_zip_empty_size( - /*================*/ ulint n_fields, /*!< in: number of columns in the index */ ulint zip_size) /*!< in: compressed page size in bytes */ { @@ -166,30 +163,25 @@ bool page_zip_is_too_big(const dict_index_t *index, const dtuple_t *entry) { return (false); } -/*************************************************************/ /** - Gets a pointer to the compressed page trailer (the dense page directory), +/** Gets a pointer to the compressed page trailer (the dense page directory), including deleted records (the free list). @param[in] page_zip compressed page @param[in] n_dense number of entries in the directory @return pointer to the dense page directory */ #define page_zip_dir_start_low(page_zip, n_dense) \ ((page_zip)->data + page_zip_dir_start_offs(page_zip, n_dense)) -/*************************************************************/ /** - Gets a pointer to the compressed page trailer (the dense page directory), +/** Gets a pointer to the compressed page trailer (the dense page directory), including deleted records (the free list). @param[in] page_zip compressed page @return pointer to the dense page directory */ #define page_zip_dir_start(page_zip) \ page_zip_dir_start_low(page_zip, page_zip_dir_elems(page_zip)) -/*************************************************************/ /** - Find the slot of the given non-free record in the dense page directory. +/** Find the slot of the given non-free record in the dense page directory. @return dense directory slot, or NULL if record not found */ UNIV_INLINE -byte *page_zip_dir_find( - /*==============*/ - page_zip_des_t *page_zip, /*!< in: compressed page */ - ulint offset) /*!< in: offset of user record */ +byte *page_zip_dir_find(page_zip_des_t *page_zip, /*!< in: compressed page */ + ulint offset) /*!< in: offset of user record */ { byte *end = page_zip->data + page_zip_get_size(page_zip); @@ -200,10 +192,8 @@ byte *page_zip_dir_find( } #ifndef UNIV_HOTBACKUP -/**********************************************************************/ /** - Write a log record of compressing an index page. */ +/** Write a log record of compressing an index page. */ static void page_zip_compress_write_log( - /*========================*/ const page_zip_des_t *page_zip, /*!< in: compressed page */ const page_t *page, /*!< in: uncompressed page */ dict_index_t *index, /*!< in: index of the B-tree node */ @@ -261,11 +251,9 @@ static void page_zip_compress_write_log( } #endif /* !UNIV_HOTBACKUP */ -/******************************************************/ /** - Determine how many externally stored columns are contained +/** Determine how many externally stored columns are contained in existing records with smaller heap_no than rec. */ static ulint page_zip_get_n_prev_extern( - /*=======================*/ const page_zip_des_t *page_zip, /*!< in: dense page directory on compressed page */ const rec_t *rec, /*!< in: compact physical record @@ -307,11 +295,9 @@ static ulint page_zip_get_n_prev_extern( return (n_ext); } -/**********************************************************************/ /** - Encode the length of a fixed-length column. +/** Encode the length of a fixed-length column. @return buf + length of encoded val */ static byte *page_zip_fixed_field_encode( - /*========================*/ byte *buf, /*!< in: pointer to buffer where to write */ ulint val) /*!< in: value to write */ { @@ -333,11 +319,9 @@ static byte *page_zip_fixed_field_encode( return (buf); } -/**********************************************************************/ /** - Write the index information for the compressed page. +/** Write the index information for the compressed page. @return used size of buf */ ulint page_zip_fields_encode( - /*===================*/ ulint n, /*!< in: number of fields to compress */ const dict_index_t *index, /*!< in: index comprising @@ -454,10 +438,8 @@ ulint page_zip_fields_encode( return ((ulint)(buf - buf_start)); } -/**********************************************************************/ /** - Populate the dense page directory from the sparse directory. */ +/** Populate the dense page directory from the sparse directory. */ static void page_zip_dir_encode( - /*================*/ const page_t *page, /*!< in: compact page */ byte *buf, /*!< in: pointer to dense page directory[-1]; out: dense directory on compressed page */ @@ -582,11 +564,9 @@ When this variable is nonzero, it will act as a log file name generator. */ static unsigned page_zip_compress_log; -/**********************************************************************/ /** - Wrapper for deflate(). Log the operation if page_zip_compress_dbg is set. +/** Wrapper for deflate(). Log the operation if page_zip_compress_dbg is set. @return deflate() status: Z_OK, Z_BUF_ERROR, ... */ static int page_zip_compress_deflate( - /*======================*/ FILE *logfile, /*!< in: log file, or NULL */ z_streamp strm, /*!< in/out: compressed stream for deflate() */ int flush) /*!< in: deflate() flushing method */ @@ -626,11 +606,9 @@ Log the operation if page_zip_compress_dbg is set. #define LOGFILE #endif /* PAGE_ZIP_COMPRESS_DBG */ -/**********************************************************************/ /** - Compress the records of a node pointer page. +/** Compress the records of a node pointer page. @return Z_OK, or a zlib error code */ static int page_zip_compress_node_ptrs( - /*========================*/ FILE_LOGFILE z_stream *c_stream, /*!< in/out: compressed page stream */ const rec_t **recs, /*!< in: dense page directory sorted by address */ @@ -687,11 +665,9 @@ static int page_zip_compress_node_ptrs( return (err); } -/**********************************************************************/ /** - Compress the records of a leaf node of a secondary index. +/** Compress the records of a leaf node of a secondary index. @return Z_OK, or a zlib error code */ static int page_zip_compress_sec( - /*==================*/ FILE_LOGFILE z_stream *c_stream, /*!< in/out: compressed page stream */ const rec_t **recs, /*!< in: dense page directory sorted by address */ @@ -727,12 +703,10 @@ static int page_zip_compress_sec( return (err); } -/**********************************************************************/ /** - Compress a record of a leaf node of a clustered index that contains +/** Compress a record of a leaf node of a clustered index that contains externally stored columns. @return Z_OK, or a zlib error code */ static int page_zip_compress_clust_ext( - /*========================*/ FILE_LOGFILE z_stream *c_stream, /*!< in/out: compressed page stream */ const rec_t *rec, /*!< in: record */ const ulint *offsets, /*!< in: rec_get_offsets(rec) */ @@ -836,11 +810,9 @@ static int page_zip_compress_clust_ext( return (Z_OK); } -/**********************************************************************/ /** - Compress the records of a leaf node of a clustered index. +/** Compress the records of a leaf node of a clustered index. @return Z_OK, or a zlib error code */ static int page_zip_compress_clust( - /*====================*/ FILE_LOGFILE z_stream *c_stream, /*!< in/out: compressed page stream */ const rec_t **recs, /*!< in: dense page directory sorted by address */ @@ -953,20 +925,17 @@ static int page_zip_compress_clust( return (err); } -/**********************************************************************/ /** - Compress a page. +/** Compress a page. @return true on success, false on failure; page_zip will be left intact on failure. */ -ibool page_zip_compress( - /*==============*/ - page_zip_des_t *page_zip, /*!< in: size; out: data, - n_blobs, m_start, m_end, - m_nonempty */ - const page_t *page, /*!< in: uncompressed page */ - dict_index_t *index, /*!< in: index tree */ - ulint level, /*!< in: commpression level */ - mtr_t *mtr) /*!< in/out: mini-transaction, - or NULL */ +ibool page_zip_compress(page_zip_des_t *page_zip, /*!< in: size; out: data, + n_blobs, m_start, m_end, + m_nonempty */ + const page_t *page, /*!< in: uncompressed page */ + dict_index_t *index, /*!< in: index tree */ + ulint level, /*!< in: commpression level */ + mtr_t *mtr) /*!< in/out: mini-transaction, + or NULL */ { z_stream c_stream; int err; @@ -1294,13 +1263,11 @@ ibool page_zip_compress( return (TRUE); } -/**********************************************************************/ /** - Decompress a page. This function should tolerate errors on the compressed +/** Decompress a page. This function should tolerate errors on the compressed page. Instead of letting assertions fail, it will return FALSE if an inconsistency is detected. @return true on success, false on failure */ ibool page_zip_decompress( - /*================*/ page_zip_des_t *page_zip, /*!< in: data, ssize; out: m_start, m_end, m_nonempty, n_blobs */ page_t *page, /*!< out: uncompressed page, may be trashed */ @@ -1341,10 +1308,8 @@ ibool page_zip_decompress( } #ifdef UNIV_ZIP_DEBUG -/**********************************************************************/ /** - Dump a block of memory on the standard error stream. */ +/** Dump a block of memory on the standard error stream. */ static void page_zip_hexdump_func( - /*==================*/ const char *name, /*!< in: name of the data structure */ const void *buf, /*!< in: data */ ulint size) /*!< in: length of the data, in bytes */ @@ -1381,11 +1346,9 @@ ibool page_zip_validate_header_only = FALSE; #define page_zip_fail(fmt_args) page_zip_fail_func fmt_args int page_zip_fail_func(const char *fmt, ...); -/**********************************************************************/ /** - Check that the compressed and decompressed pages match. +/** Check that the compressed and decompressed pages match. @return true if valid, false if not */ ibool page_zip_validate_low( - /*==================*/ const page_zip_des_t *page_zip, /*!< in: compressed page */ const page_t *page, /*!< in: uncompressed page */ const dict_index_t *index, /*!< in: index of the page, if known */ @@ -1566,11 +1529,9 @@ ibool page_zip_validate_low( return (valid); } -/**********************************************************************/ /** - Check that the compressed and decompressed pages match. +/** Check that the compressed and decompressed pages match. @return true if valid, false if not */ ibool page_zip_validate( - /*==============*/ const page_zip_des_t *page_zip, /*!< in: compressed page */ const page_t *page, /*!< in: uncompressed page */ const dict_index_t *index) /*!< in: index of the page, if known */ @@ -1580,11 +1541,9 @@ ibool page_zip_validate( #endif /* UNIV_ZIP_DEBUG */ #ifdef UNIV_DEBUG -/**********************************************************************/ /** - Assert that the compressed and decompressed page headers match. +/** Assert that the compressed and decompressed page headers match. @return true */ static ibool page_zip_header_cmp( - /*================*/ const page_zip_des_t *page_zip, /*!< in: compressed page */ const byte *page) /*!< in: uncompressed page */ { @@ -1598,12 +1557,10 @@ static ibool page_zip_header_cmp( } #endif /* UNIV_DEBUG */ -/**********************************************************************/ /** - Write a record on the compressed page that contains externally stored +/** Write a record on the compressed page that contains externally stored columns. The data must already have been written to the uncompressed page. @return end of modification log */ static byte *page_zip_write_rec_ext( - /*===================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ const page_t *page, /*!< in: page containing rec */ const byte *rec, /*!< in: record being written */ @@ -1704,11 +1661,9 @@ static byte *page_zip_write_rec_ext( return (data); } -/**********************************************************************/ /** - Write an entire record on the compressed page. The data must already +/** Write an entire record on the compressed page. The data must already have been written to the uncompressed page. */ void page_zip_write_rec( - /*===============*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ const byte *rec, /*!< in: record being written */ dict_index_t *index, /*!< in: the index the record belongs to */ @@ -1874,11 +1829,9 @@ void page_zip_write_rec( #endif /* UNIV_ZIP_DEBUG */ } -/***********************************************************/ /** - Parses a log record of writing a BLOB pointer of a record. +/** Parses a log record of writing a BLOB pointer of a record. @return end of log record or NULL */ byte *page_zip_parse_write_blob_ptr( - /*==========================*/ byte *ptr, /*!< in: redo log buffer */ byte *end_ptr, /*!< in: redo log buffer end */ page_t *page, /*!< in/out: uncompressed page */ @@ -1926,11 +1879,9 @@ byte *page_zip_parse_write_blob_ptr( return (ptr + (2 + 2 + BTR_EXTERN_FIELD_REF_SIZE)); } -/**********************************************************************/ /** - Write a BLOB pointer of a record on the leaf page of a clustered index. +/** Write a BLOB pointer of a record on the leaf page of a clustered index. The information must already have been updated on the uncompressed page. */ void page_zip_write_blob_ptr( - /*====================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ const byte *rec, /*!< in/out: record whose data is being written */ @@ -2008,11 +1959,9 @@ void page_zip_write_blob_ptr( } } -/***********************************************************/ /** - Parses a log record of writing the node pointer of a record. +/** Parses a log record of writing the node pointer of a record. @return end of log record or NULL */ byte *page_zip_parse_write_node_ptr( - /*==========================*/ byte *ptr, /*!< in: redo log buffer */ byte *end_ptr, /*!< in: redo log buffer end */ page_t *page, /*!< in/out: uncompressed page */ @@ -2078,10 +2027,8 @@ byte *page_zip_parse_write_node_ptr( return (ptr + (2 + 2 + REC_NODE_PTR_SIZE)); } -/**********************************************************************/ /** - Write the node pointer of a record on a non-leaf compressed page. */ +/** Write the node pointer of a record on a non-leaf compressed page. */ void page_zip_write_node_ptr( - /*====================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ byte *rec, /*!< in/out: record */ ulint size, /*!< in: data size of rec */ @@ -2140,10 +2087,8 @@ void page_zip_write_node_ptr( } } -/**********************************************************************/ /** - Write the trx_id and roll_ptr of a record on a B-tree leaf node page. */ +/** Write the trx_id and roll_ptr of a record on a B-tree leaf node page. */ void page_zip_write_trx_id_and_roll_ptr( - /*===============================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ byte *rec, /*!< in/out: record */ const ulint *offsets, /*!< in: rec_get_offsets(rec, index) */ @@ -2202,11 +2147,9 @@ void page_zip_write_trx_id_and_roll_ptr( UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); } -/**********************************************************************/ /** - Clear an area on the uncompressed and compressed page. +/** Clear an area on the uncompressed and compressed page. Do not clear the data payload, as that would grow the modification log. */ static void page_zip_clear_rec( - /*===============*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ byte *rec, /*!< in: record to clear */ const dict_index_t *index, /*!< in: index of rec */ @@ -2283,11 +2226,9 @@ static void page_zip_clear_rec( #endif /* UNIV_ZIP_DEBUG */ } -/**********************************************************************/ /** - Write the "deleted" flag of a record on a compressed page. The flag must +/** Write the "deleted" flag of a record on a compressed page. The flag must already have been written on the uncompressed page. */ void page_zip_rec_set_deleted( - /*=====================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ const byte *rec, /*!< in: record on the uncompressed page */ ulint flag) /*!< in: the deleted flag (nonzero=TRUE) */ @@ -2305,11 +2246,9 @@ void page_zip_rec_set_deleted( #endif /* UNIV_ZIP_DEBUG */ } -/**********************************************************************/ /** - Write the "owned" flag of a record on a compressed page. The n_owned field +/** Write the "owned" flag of a record on a compressed page. The n_owned field must already have been written on the uncompressed page. */ void page_zip_rec_set_owned( - /*===================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ const byte *rec, /*!< in: record on the uncompressed page */ ulint flag) /*!< in: the owned flag (nonzero=TRUE) */ @@ -2324,10 +2263,8 @@ void page_zip_rec_set_owned( } } -/**********************************************************************/ /** - Insert a record to the dense page directory. */ +/** Insert a record to the dense page directory. */ void page_zip_dir_insert( - /*================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ const byte *prev_rec, /*!< in: record after which to insert */ const byte *free_rec, /*!< in: record from which rec was @@ -2483,10 +2420,8 @@ void page_zip_dir_delete(page_zip_des_t *page_zip, byte *rec, page_zip_clear_rec(page_zip, rec, index, offsets); } -/**********************************************************************/ /** - Add a slot to the dense page directory. */ +/** Add a slot to the dense page directory. */ void page_zip_dir_add_slot( - /*==================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ bool is_clustered) /*!< in: nonzero for clustered index, zero for others */ @@ -2528,11 +2463,9 @@ void page_zip_dir_add_slot( memmove(stored - PAGE_ZIP_DIR_SLOT_SIZE, stored, dir - stored); } -/***********************************************************/ /** - Parses a log record of writing to the header of a page. +/** Parses a log record of writing to the header of a page. @return end of log record or NULL */ byte *page_zip_parse_write_header( - /*========================*/ byte *ptr, /*!< in: redo log buffer */ byte *end_ptr, /*!< in: redo log buffer end */ page_t *page, /*!< in/out: uncompressed page */ @@ -2583,10 +2516,9 @@ byte *page_zip_parse_write_header( } #ifndef UNIV_HOTBACKUP -/**********************************************************************/ /** - Write a log record of writing to the uncompressed header portion of a page. */ +/** Write a log record of writing to the uncompressed header portion of a page. + */ void page_zip_write_header_log( - /*======================*/ const byte *data, /*!< in: data on the uncompressed page */ ulint length, /*!< in: length of the data */ mtr_t *mtr) /*!< in: mini-transaction */ @@ -2616,8 +2548,7 @@ void page_zip_write_header_log( } #endif /* !UNIV_HOTBACKUP */ -/**********************************************************************/ /** - Reorganize and compress a page. This is a low-level operation for +/** Reorganize and compress a page. This is a low-level operation for compressed pages, to be used when page_zip_compress() fails. On success, a redo log entry MLOG_ZIP_PAGE_COMPRESS will be written. The function btr_page_reorganize() should be preferred whenever possible. @@ -2628,7 +2559,6 @@ void page_zip_write_header_log( @return true on success, false on failure; page_zip will be left intact on failure, but page will be overwritten. */ ibool page_zip_reorganize( - /*================*/ buf_block_t *block, /*!< in/out: page with compressed page; on the compressed page, in: size; out: data, n_blobs, @@ -2710,13 +2640,11 @@ ibool page_zip_reorganize( } #ifndef UNIV_HOTBACKUP -/**********************************************************************/ /** - Copy the records of a page byte for byte. Do not copy the page header +/** Copy the records of a page byte for byte. Do not copy the page header or trailer, except those B-tree header fields that are directly related to the storage of records. Also copy PAGE_MAX_TRX_ID. NOTE: The caller must update the lock table and the adaptive hash index. */ void page_zip_copy_recs( - /*===============*/ page_zip_des_t *page_zip, /*!< out: copy of src_zip (n_blobs, m_start, m_end, m_nonempty, data[0..size-1]) */ @@ -2797,11 +2725,9 @@ void page_zip_copy_recs( } #endif /* !UNIV_HOTBACKUP */ -/**********************************************************************/ /** - Parses a log record of compressing an index page. +/** Parses a log record of compressing an index page. @return end of log record or NULL */ byte *page_zip_parse_compress( - /*====================*/ byte *ptr, /*!< in: buffer */ byte *end_ptr, /*!< in: buffer end */ page_t *page, /*!< out: uncompressed page */ diff --git a/storage/innobase/page/zipdecompress.cc b/storage/innobase/page/zipdecompress.cc index 1b390955bd54..02bb365dc632 100644 --- a/storage/innobase/page/zipdecompress.cc +++ b/storage/innobase/page/zipdecompress.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -25,8 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file page/zipdecompress.cc +/** @file page/zipdecompress.cc Page Decompression interface Created June 2005 by Marko Makela @@ -54,17 +53,14 @@ independently of any UNIV_ debugging conditions. */ #include MY_ATTRIBUTE((format(printf, 1, 2))) -/**********************************************************************/ /** - Report a failure to decompress or compress. +/** Report a failure to decompress or compress. @return number of characters printed */ #ifndef UNIV_HOTBACKUP static #endif /* !UNIV_HOTBACKUP */ int - page_zip_fail_func( - /*===============*/ - const char *fmt, /*!< in: printf(3) format string */ - ...) /*!< in: arguments corresponding to fmt */ + page_zip_fail_func(const char *fmt, /*!< in: printf(3) format string */ + ...) /*!< in: arguments corresponding to fmt */ { int res; va_list ap; @@ -88,31 +84,24 @@ static extern "C" { -/**********************************************************************/ /** - Allocate memory for zlib. */ -static void *page_zip_zalloc( - /*============*/ - void *opaque, /*!< in/out: memory heap */ - uInt items, /*!< in: number of items to allocate */ - uInt size) /*!< in: size of an item in bytes */ +/** Allocate memory for zlib. */ +static void *page_zip_zalloc(void *opaque, /*!< in/out: memory heap */ + uInt items, /*!< in: number of items to allocate */ + uInt size) /*!< in: size of an item in bytes */ { return (mem_heap_zalloc(static_cast(opaque), items * size)); } -/**********************************************************************/ /** - Deallocate memory for zlib. */ +/** Deallocate memory for zlib. */ static void page_zip_free( - /*==========*/ void *opaque MY_ATTRIBUTE((unused)), /*!< in: memory heap */ void *address MY_ATTRIBUTE((unused))) /*!< in: object to free */ {} } /* extern "C" */ -/**********************************************************************/ /** - Deallocate the index information initialized by page_zip_fields_decode(). */ +/** Deallocate the index information initialized by page_zip_fields_decode(). */ static void page_zip_fields_free( - /*=================*/ dict_index_t *index) /*!< in: dummy index to be freed */ { if (index) { @@ -126,12 +115,9 @@ static void page_zip_fields_free( } } -/**********************************************************************/ /** - Configure the zlib allocator to use the given memory heap. */ -void page_zip_set_alloc( - /*===============*/ - void *stream, /*!< in/out: zlib stream */ - mem_heap_t *heap) /*!< in: memory heap to use */ +/** Configure the zlib allocator to use the given memory heap. */ +void page_zip_set_alloc(void *stream, /*!< in/out: zlib stream */ + mem_heap_t *heap) /*!< in: memory heap to use */ { z_stream *strm = static_cast(stream); @@ -140,11 +126,9 @@ void page_zip_set_alloc( strm->opaque = heap; } -/**********************************************************************/ /** - Populate the sparse page directory from the dense directory. +/** Populate the sparse page directory from the dense directory. @return true on success, false on failure */ static MY_ATTRIBUTE((warn_unused_result)) ibool page_zip_dir_decode( - /*================*/ const page_zip_des_t *page_zip, /*!< in: dense page directory on compressed page */ page_t *page, /*!< in: compact page with valid header; @@ -345,12 +329,10 @@ static dict_index_t *page_zip_fields_decode(const byte *buf, const byte *end, return (index); } -/**********************************************************************/ /** - Apply the modification log to a record containing externally stored +/** Apply the modification log to a record containing externally stored columns. Do not copy the fields that are stored separately. @return pointer to modification log, or NULL on failure */ static const byte *page_zip_apply_log_ext( - /*===================*/ rec_t *rec, /*!< in/out: record */ const ulint *offsets, /*!< in: rec_get_offsets(rec) */ ulint trx_id_col, /*!< in: position of of DB_TRX_ID */ @@ -421,12 +403,10 @@ static const byte *page_zip_apply_log_ext( return (data); } -/**********************************************************************/ /** - Apply the modification log to an uncompressed page. +/** Apply the modification log to an uncompressed page. Do not copy the fields that are stored separately. @return pointer to end of modification log, or NULL on failure */ static const byte *page_zip_apply_log( - /*===============*/ const byte *data, /*!< in: modification log */ ulint size, /*!< in: maximum length of the log, in bytes */ rec_t **recs, /*!< in: dense page directory, @@ -611,12 +591,10 @@ static const byte *page_zip_apply_log( } } -/**********************************************************************/ /** - Set the heap_no in a record, and skip the fixed-size record header +/** Set the heap_no in a record, and skip the fixed-size record header that is not included in the d_stream. @return true on success, false if d_stream does not end at rec */ static ibool page_zip_decompress_heap_no( - /*========================*/ z_stream *d_stream, /*!< in/out: compressed page stream */ rec_t *rec, /*!< in/out: record */ ulint &heap_status) /*!< in/out: heap_no and status bits */ @@ -635,11 +613,9 @@ static ibool page_zip_decompress_heap_no( return (TRUE); } -/**********************************************************************/ /** - Decompress the records of a node pointer page. +/** Decompress the records of a node pointer page. @return true on success, false on failure */ static ibool page_zip_decompress_node_ptrs( - /*==========================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ z_stream *d_stream, /*!< in/out: compressed page stream */ rec_t **recs, /*!< in: dense page directory @@ -815,11 +791,9 @@ static ibool page_zip_decompress_node_ptrs( return (TRUE); } -/**********************************************************************/ /** - Decompress the records of a leaf node of a secondary index. +/** Decompress the records of a leaf node of a secondary index. @return true on success, false on failure */ static ibool page_zip_decompress_sec( - /*====================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ z_stream *d_stream, /*!< in/out: compressed page stream */ rec_t **recs, /*!< in: dense page directory @@ -944,11 +918,9 @@ static ibool page_zip_decompress_sec( return (TRUE); } -/**********************************************************************/ /** - Initialize the REC_N_NEW_EXTRA_BYTES of each record. +/** Initialize the REC_N_NEW_EXTRA_BYTES of each record. @return true on success, false on failure */ static ibool page_zip_set_extra_bytes( - /*=====================*/ const page_zip_des_t *page_zip, /*!< in: compressed page */ page_t *page, /*!< in/out: uncompressed page */ ulint info_bits) /*!< in: REC_INFO_MIN_REC_FLAG or 0 */ @@ -1035,12 +1007,10 @@ static ibool page_zip_set_extra_bytes( return (TRUE); } -/**********************************************************************/ /** - Decompress a record of a leaf node of a clustered index that contains +/** Decompress a record of a leaf node of a clustered index that contains externally stored columns. @return true on success */ static ibool page_zip_decompress_clust_ext( - /*==========================*/ z_stream *d_stream, /*!< in/out: compressed page stream */ rec_t *rec, /*!< in/out: record */ const ulint *offsets, /*!< in: rec_get_offsets(rec) */ @@ -1140,11 +1110,9 @@ static ibool page_zip_decompress_clust_ext( return (TRUE); } -/**********************************************************************/ /** - Compress the records of a leaf node of a clustered index. +/** Compress the records of a leaf node of a clustered index. @return true on success, false on failure */ static ibool page_zip_decompress_clust( - /*======================*/ page_zip_des_t *page_zip, /*!< in/out: compressed page */ z_stream *d_stream, /*!< in/out: compressed page stream */ rec_t **recs, /*!< in: dense page directory @@ -1414,13 +1382,11 @@ static ibool page_zip_decompress_clust( return (TRUE); } -/**********************************************************************/ /** - Decompress a page. This function should tolerate errors on the compressed +/** Decompress a page. This function should tolerate errors on the compressed page. Instead of letting assertions fail, it will return FALSE if an inconsistency is detected. @return true on success, false on failure */ ibool page_zip_decompress_low( - /*====================*/ page_zip_des_t *page_zip, /*!< in: data, ssize; out: m_start, m_end, m_nonempty, n_blobs */ page_t *page, /*!< out: uncompressed page, may be trashed */ diff --git a/storage/innobase/page/zipdecompress.h b/storage/innobase/page/zipdecompress.h index 9676c68895cc..8b9f82513d34 100644 --- a/storage/innobase/page/zipdecompress.h +++ b/storage/innobase/page/zipdecompress.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -25,8 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file page/zipdecompress.h +/** @file page/zipdecompress.h Compressed page interface Created June 2005 by Marko Makela @@ -45,13 +44,11 @@ external tools. */ #include "page/page.ic" #include "page/zipdecompress.ic" -/**********************************************************************/ /** - Decompress a page. This function should tolerate errors on the compressed +/** Decompress a page. This function should tolerate errors on the compressed page. Instead of letting assertions fail, it will return FALSE if an inconsistency is detected. @return true on success, false on failure */ ibool page_zip_decompress_low( - /*====================*/ page_zip_des_t *page_zip, /*!< in: data, ssize; out: m_start, m_end, m_nonempty, n_blobs */ page_t *page, /*!< out: uncompressed page, may be trashed */ diff --git a/storage/innobase/page/zipdecompress.ic b/storage/innobase/page/zipdecompress.ic index 09ebf7aa1dde..0738765e0969 100644 --- a/storage/innobase/page/zipdecompress.ic +++ b/storage/innobase/page/zipdecompress.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2005, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2005, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -25,8 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file page/zipdecompress.ic +/** @file page/zipdecompress.ic Compressed page interface Created June 2005 by Marko Makela @@ -47,28 +46,24 @@ external tools. */ /** Size of an compressed page directory entry */ #define PAGE_ZIP_DIR_SLOT_SIZE 2 -/*************************************************************/ /** - Gets a pointer to the compressed page trailer (the dense page directory), +/** Gets a pointer to the compressed page trailer (the dense page directory), including deleted records (the free list). @param[in] page_zip compressed page @param[in] n_dense number of entries in the directory @return pointer to the dense page directory */ #define page_zip_dir_start_low(page_zip, n_dense) \ ((page_zip)->data + page_zip_dir_start_offs(page_zip, n_dense)) -/*************************************************************/ /** - Gets a pointer to the compressed page trailer (the dense page directory), +/** Gets a pointer to the compressed page trailer (the dense page directory), including deleted records (the free list). @param[in] page_zip compressed page @return pointer to the dense page directory */ #define page_zip_dir_start(page_zip) \ page_zip_dir_start_low(page_zip, page_zip_dir_elems(page_zip)) -/**********************************************************************/ /** - Determine the size of a compressed page in bytes. +/** Determine the size of a compressed page in bytes. @return size in bytes */ UNIV_INLINE ulint page_zip_get_size( - /*==============*/ const page_zip_des_t *page_zip) /*!< in: compressed page */ { ulint size; @@ -86,12 +81,10 @@ ulint page_zip_get_size( } #ifdef UNIV_DEBUG -/**********************************************************************/ /** - Validate a compressed page descriptor. +/** Validate a compressed page descriptor. @return true if ok */ UNIV_INLINE ibool page_zip_simple_validate( - /*=====================*/ const page_zip_des_t *page_zip) /*!< in: compressed page descriptor */ { ut_ad(page_zip); @@ -106,38 +99,32 @@ ibool page_zip_simple_validate( } #endif /* UNIV_DEBUG */ -/*************************************************************/ /** - Gets the number of elements in the dense page directory, +/** Gets the number of elements in the dense page directory, including deleted records (the free list). @return number of elements in the dense page directory */ UNIV_INLINE ulint page_zip_dir_elems( - /*===============*/ const page_zip_des_t *page_zip) /*!< in: compressed page */ { /* Exclude the page infimum and supremum from the record count. */ return (page_dir_get_n_heap(page_zip->data) - PAGE_HEAP_NO_USER_LOW); } -/*************************************************************/ /** - Gets the size of the compressed page trailer (the dense page directory), +/** Gets the size of the compressed page trailer (the dense page directory), including deleted records (the free list). @return length of dense page directory, in bytes */ UNIV_INLINE ulint page_zip_dir_size( - /*==============*/ const page_zip_des_t *page_zip) /*!< in: compressed page */ { return (PAGE_ZIP_DIR_SLOT_SIZE * page_zip_dir_elems(page_zip)); } -/*************************************************************/ /** - Read a given slot in the dense page directory. +/** Read a given slot in the dense page directory. @return record offset on the uncompressed page, possibly ORed with PAGE_ZIP_DIR_SLOT_DEL or PAGE_ZIP_DIR_SLOT_OWNED */ UNIV_INLINE ulint page_zip_dir_get( - /*=============*/ const page_zip_des_t *page_zip, /*!< in: compressed page */ ulint slot) /*!< in: slot (0=first user record) */ diff --git a/storage/innobase/pars/pars0opt.cc b/storage/innobase/pars/pars0opt.cc index db49cffde9fa..be5159fa7382 100644 --- a/storage/innobase/pars/pars0opt.cc +++ b/storage/innobase/pars/pars0opt.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file pars/pars0opt.cc +/** @file pars/pars0opt.cc Simple SQL optimizer Created 12/21/1997 Heikki Tuuri @@ -55,12 +54,9 @@ this program; if not, write to the Free Software Foundation, Inc., #define OPT_TEST_COND 3 #define OPT_SCROLL_COND 4 -/*******************************************************************/ /** - Inverts a comparison operator. +/** Inverts a comparison operator. @return the equivalent operator when the order of the arguments is switched */ -static int opt_invert_cmp_op( - /*==============*/ - int op) /*!< in: operator */ +static int opt_invert_cmp_op(int op) /*!< in: operator */ { if (op == '<') { return ('>'); @@ -80,13 +76,11 @@ static int opt_invert_cmp_op( return (0); } -/*******************************************************************/ /** - Checks if the value of an expression can be calculated BEFORE the nth table +/** Checks if the value of an expression can be calculated BEFORE the nth table in a join is accessed. If this is the case, it can possibly be used in an index search for the nth table. @return true if already determined */ static ibool opt_check_exp_determined_before( - /*============================*/ que_node_t *exp, /*!< in: expression */ sel_node_t *sel_node, /*!< in: select node */ ulint nth_table) /*!< in: nth table will be accessed */ @@ -134,12 +128,10 @@ static ibool opt_check_exp_determined_before( return (FALSE); } -/*******************************************************************/ /** - Looks in a comparison condition if a column value is already restricted by +/** Looks in a comparison condition if a column value is already restricted by it BEFORE the nth table is accessed. @return expression restricting the value of the column, or NULL if not known */ static que_node_t *opt_look_for_col_in_comparison_before( - /*==================================*/ ulint cmp_type, /*!< in: OPT_EQUAL, OPT_COMPARISON */ ulint col_no, /*!< in: column number */ func_node_t *search_cond, /*!< in: comparison condition */ @@ -224,14 +216,12 @@ static que_node_t *opt_look_for_col_in_comparison_before( return (NULL); } -/*******************************************************************/ /** - Looks in a search condition if a column value is already restricted by the +/** Looks in a search condition if a column value is already restricted by the search condition BEFORE the nth table is accessed. Takes into account that if we will fetch in an ascending order, we cannot utilize an upper limit for a column value; in a descending order, respectively, a lower limit. @return expression restricting the value of the column, or NULL if not known */ static que_node_t *opt_look_for_col_in_cond_before( - /*============================*/ ulint cmp_type, /*!< in: OPT_EQUAL, OPT_COMPARISON */ ulint col_no, /*!< in: column number */ func_node_t *search_cond, /*!< in: search condition or NULL */ @@ -289,8 +279,7 @@ static que_node_t *opt_look_for_col_in_cond_before( return (exp); } -/*******************************************************************/ /** - Calculates the goodness for an index according to a select node. The +/** Calculates the goodness for an index according to a select node. The goodness is 4 times the number of first fields in index whose values we already know exactly in the query. If we have a comparison condition for an additional field, 2 point are added. If the index is unique, and we know @@ -298,7 +287,6 @@ static que_node_t *opt_look_for_col_in_cond_before( we add 1 point. @return goodness */ static ulint opt_calc_index_goodness( - /*====================*/ dict_index_t *index, /*!< in: index */ sel_node_t *sel_node, /*!< in: parsed select node */ ulint nth_table, /*!< in: nth table in a join */ @@ -382,24 +370,19 @@ static ulint opt_calc_index_goodness( return (goodness); } -/*******************************************************************/ /** - Calculates the number of matched fields based on an index goodness. +/** Calculates the number of matched fields based on an index goodness. @return number of excatly or partially matched fields */ UNIV_INLINE -ulint opt_calc_n_fields_from_goodness( - /*============================*/ - ulint goodness) /*!< in: goodness */ +ulint opt_calc_n_fields_from_goodness(ulint goodness) /*!< in: goodness */ { return (((goodness % 1024) + 2) / 4); } -/*******************************************************************/ /** - Converts a comparison operator to the corresponding search mode PAGE_CUR_GE, +/** Converts a comparison operator to the corresponding search mode PAGE_CUR_GE, ... @return search mode */ UNIV_INLINE page_cur_mode_t opt_op_to_search_mode( - /*==================*/ ibool asc, /*!< in: TRUE if the rows should be fetched in an ascending order */ ulint op) /*!< in: operator '=', PARS_GE_TOKEN, ... */ @@ -431,13 +414,10 @@ page_cur_mode_t opt_op_to_search_mode( return (PAGE_CUR_UNSUPP); } -/*******************************************************************/ /** - Determines if a node is an argument node of a function node. +/** Determines if a node is an argument node of a function node. @return true if is an argument */ -static ibool opt_is_arg( - /*=======*/ - que_node_t *arg_node, /*!< in: possible argument node */ - func_node_t *func_node) /*!< in: function node */ +static ibool opt_is_arg(que_node_t *arg_node, /*!< in: possible argument node */ + func_node_t *func_node) /*!< in: function node */ { que_node_t *arg; @@ -454,12 +434,10 @@ static ibool opt_is_arg( return (FALSE); } -/*******************************************************************/ /** - Decides if the fetching of rows should be made in a descending order, and +/** Decides if the fetching of rows should be made in a descending order, and also checks that the chosen query plan produces a result which satisfies the order-by. */ static void opt_check_order_by( - /*===============*/ sel_node_t *sel_node) /*!< in: select node; asserts an error if the plan does not agree with the order-by */ @@ -498,12 +476,10 @@ static void opt_check_order_by( } } -/*******************************************************************/ /** - Optimizes a select. Decides which indexes to tables to use. The tables +/** Optimizes a select. Decides which indexes to tables to use. The tables are accessed in the order that they were written to the FROM part in the select statement. */ static void opt_search_plan_for_table( - /*======================*/ sel_node_t *sel_node, /*!< in: parsed select node */ ulint i, /*!< in: this is the ith table */ dict_table_t *table) /*!< in: table */ @@ -588,14 +564,12 @@ static void opt_search_plan_for_table( btr_pcur_init(&(plan->clust_pcur)); } -/*******************************************************************/ /** - Looks at a comparison condition and decides if it can, and need, be tested for - a table AFTER the table has been accessed. +/** Looks at a comparison condition and decides if it can, and need, be tested + for a table AFTER the table has been accessed. @return OPT_NOT_COND if not for this table, else OPT_END_COND, OPT_TEST_COND, or OPT_SCROLL_COND, where the last means that the condition need not be tested, except when scroll cursors are used */ static ulint opt_classify_comparison( - /*====================*/ sel_node_t *sel_node, /*!< in: select node */ ulint i, /*!< in: ith table in the join */ func_node_t *cond) /*!< in: comparison condition */ @@ -669,10 +643,8 @@ static ulint opt_classify_comparison( return (OPT_TEST_COND); } -/*******************************************************************/ /** - Recursively looks for test conditions for a table in a join. */ +/** Recursively looks for test conditions for a table in a join. */ static void opt_find_test_conds( - /*================*/ sel_node_t *sel_node, /*!< in: select node */ ulint i, /*!< in: ith table in the join */ func_node_t *cond) /*!< in: conjunction of search @@ -710,12 +682,10 @@ static void opt_find_test_conds( } } -/*******************************************************************/ /** - Normalizes a list of comparison conditions so that a column of the table +/** Normalizes a list of comparison conditions so that a column of the table appears on the left side of the comparison if possible. This is accomplished by switching the arguments of the operator. */ static void opt_normalize_cmp_conds( - /*====================*/ func_node_t *cond, /*!< in: first in a list of comparison conditions, or NULL */ dict_table_t *table) /*!< in: table */ @@ -747,12 +717,10 @@ static void opt_normalize_cmp_conds( } } -/*******************************************************************/ /** - Finds out the search condition conjuncts we can, and need, to test as the ith - table in a join is accessed. The search tuple can eliminate the need to test - some conjuncts. */ +/** Finds out the search condition conjuncts we can, and need, to test as the + ith table in a join is accessed. The search tuple can eliminate the need to + test some conjuncts. */ static void opt_determine_and_normalize_test_conds( - /*===================================*/ sel_node_t *sel_node, /*!< in: select node */ ulint i) /*!< in: ith table in the join */ { @@ -773,15 +741,13 @@ static void opt_determine_and_normalize_test_conds( ut_a(UT_LIST_GET_LEN(plan->end_conds) >= plan->n_exact_match); } -/*******************************************************************/ /** - Looks for occurrences of the columns of the table in the query subgraph and +/** Looks for occurrences of the columns of the table in the query subgraph and adds them to the list of columns if an occurrence of the same column does not already exist in the list. If the column is already in the list, puts a value indirection to point to the occurrence in the column list, except if the column occurrence we are looking at is in the column list, in which case nothing is done. */ void opt_find_all_cols( - /*==============*/ ibool copy_val, /*!< in: if TRUE, new found columns are added as columns to copy */ dict_index_t *index, /*!< in: index of the table to use */ @@ -870,13 +836,11 @@ void opt_find_all_cols( } } -/*******************************************************************/ /** - Looks for occurrences of the columns of the table in conditions which are +/** Looks for occurrences of the columns of the table in conditions which are not yet determined AFTER the join operation has fetched a row in the ith table. The values for these column must be copied to dynamic memory for later use. */ static void opt_find_copy_cols( - /*===============*/ sel_node_t *sel_node, /*!< in: select node */ ulint i, /*!< in: ith table in the join */ func_node_t *search_cond) /*!< in: search condition or NULL */ @@ -913,15 +877,12 @@ static void opt_find_copy_cols( } } -/*******************************************************************/ /** - Classifies the table columns according to whether we use the column only while - holding the latch on the page, or whether we have to copy the column value to - dynamic memory. Puts the first occurrence of a column to either list in the - plan node, and puts indirections to later occurrences of the column. */ -static void opt_classify_cols( - /*==============*/ - sel_node_t *sel_node, /*!< in: select node */ - ulint i) /*!< in: ith table in the join */ +/** Classifies the table columns according to whether we use the column only + while holding the latch on the page, or whether we have to copy the column + value to dynamic memory. Puts the first occurrence of a column to either list + in the plan node, and puts indirections to later occurrences of the column. */ +static void opt_classify_cols(sel_node_t *sel_node, /*!< in: select node */ + ulint i) /*!< in: ith table in the join */ { plan_t *plan; que_node_t *exp; @@ -952,13 +913,10 @@ static void opt_classify_cols( static_cast(sel_node->search_cond)); } -/*******************************************************************/ /** - Fills in the info in plan which is used in accessing a clustered index +/** Fills in the info in plan which is used in accessing a clustered index record. The columns must already be classified for the plan node. */ -static void opt_clust_access( - /*=============*/ - sel_node_t *sel_node, /*!< in: select node */ - ulint n) /*!< in: nth table in select */ +static void opt_clust_access(sel_node_t *sel_node, /*!< in: select node */ + ulint n) /*!< in: nth table in select */ { plan_t *plan; dict_table_t *table; @@ -1027,13 +985,10 @@ static void opt_clust_access( static void opt_print_query_plan(sel_node_t *sel_node); #endif -/*******************************************************************/ /** - Optimizes a select. Decides which indexes to tables to use. The tables +/** Optimizes a select. Decides which indexes to tables to use. The tables are accessed in the order that they were written to the FROM part in the select statement. */ -void opt_search_plan( - /*============*/ - sel_node_t *sel_node) /*!< in: parsed select node */ +void opt_search_plan(sel_node_t *sel_node) /*!< in: parsed select node */ { sym_node_t *table_node; dict_table_t *table; diff --git a/storage/innobase/pars/pars0pars.cc b/storage/innobase/pars/pars0pars.cc index 5a8f7f005602..f5e6153c3a0e 100644 --- a/storage/innobase/pars/pars0pars.cc +++ b/storage/innobase/pars/pars0pars.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file pars/pars0pars.cc +/** @file pars/pars0pars.cc SQL parser Created 11/19/1996 Heikki Tuuri @@ -105,7 +104,6 @@ void pars_close() { mutex_free(&pars_mutex); } Get user function with the given name.*/ UNIV_INLINE pars_user_func_t *pars_info_lookup_user_func( - /*=======================*/ /* out: user func, or NULL if not found */ pars_info_t *info, /* in: info struct */ @@ -133,7 +131,6 @@ pars_user_func_t *pars_info_lookup_user_func( Get bound identifier with the given name.*/ UNIV_INLINE pars_bound_id_t *pars_info_lookup_bound_id( - /*======================*/ /* out: bound literal, or NULL if not found */ pars_info_t *info, /* in: info struct */ @@ -161,7 +158,6 @@ pars_bound_id_t *pars_info_lookup_bound_id( Get bound literal with the given name.*/ UNIV_INLINE pars_bound_lit_t *pars_info_lookup_bound_lit( - /*=======================*/ /* out: bound literal, or NULL if not found */ pars_info_t *info, /* in: info struct */ @@ -185,11 +181,9 @@ pars_bound_lit_t *pars_info_lookup_bound_lit( return (NULL); } -/*********************************************************************/ /** - Determines the class of a function code. +/** Determines the class of a function code. @return function class: PARS_FUNC_ARITH, ... */ static ulint pars_func_get_class( - /*================*/ int func) /*!< in: function code: '=', PARS_GE_TOKEN, ... */ { switch (func) { @@ -229,11 +223,9 @@ static ulint pars_func_get_class( } } -/*********************************************************************/ /** - Parses an operator or predefined function expression. +/** Parses an operator or predefined function expression. @return own: function node in a query tree */ static func_node_t *pars_func_low( - /*==========*/ int func, /*!< in: function token code */ que_node_t *arg) /*!< in: first argument in the argument list */ { @@ -257,11 +249,9 @@ static func_node_t *pars_func_low( return (node); } -/*********************************************************************/ /** - Parses a function expression. +/** Parses a function expression. @return own: function node in a query tree */ func_node_t *pars_func( - /*======*/ que_node_t *res_word, /*!< in: function name reserved word */ que_node_t *arg) /*!< in: first argument in the argument list */ { @@ -272,7 +262,6 @@ func_node_t *pars_func( Rebind a LIKE search string. NOTE: We ignore any '%' characters embedded within the search string.*/ int pars_like_rebind( - /*=============*/ /* out, own: function node in a query tree */ sym_node_t *node, /* in: The search string node.*/ const byte *ptr, /* in: literal to (re) bind */ @@ -379,7 +368,6 @@ int pars_like_rebind( /************************************************************************* Parses a LIKE operator expression. */ static int pars_like_op( - /*=========*/ /* out, own: function node in a query tree */ que_node_t *arg) /* in: LIKE comparison string.*/ { @@ -402,11 +390,9 @@ static int pars_like_op( return (func); } -/*********************************************************************/ /** - Parses an operator expression. +/** Parses an operator expression. @return own: function node in a query tree */ func_node_t *pars_op( - /*====*/ int func, /*!< in: operator token code */ que_node_t *arg1, /*!< in: first argument */ que_node_t *arg2) /*!< in: second argument or NULL for an unary @@ -432,11 +418,9 @@ func_node_t *pars_op( return (pars_func_low(func, arg1)); } -/*********************************************************************/ /** - Parses an ORDER BY clause. Order by a single column only is supported. +/** Parses an ORDER BY clause. Order by a single column only is supported. @return own: order-by node in a query tree */ order_node_t *pars_order_by( - /*==========*/ sym_node_t *column, /*!< in: column name */ pars_res_word_t *asc) /*!< in: &pars_asc_token or pars_desc_token */ { @@ -459,13 +443,10 @@ order_node_t *pars_order_by( return (node); } -/*********************************************************************/ /** - Determine if a data type is a built-in string data type of the InnoDB +/** Determine if a data type is a built-in string data type of the InnoDB SQL parser. @return true if string data type */ -static ibool pars_is_string_type( - /*================*/ - ulint mtype) /*!< in: main data type */ +static ibool pars_is_string_type(ulint mtype) /*!< in: main data type */ { switch (mtype) { case DATA_VARCHAR: @@ -478,11 +459,9 @@ static ibool pars_is_string_type( return (FALSE); } -/*********************************************************************/ /** - Resolves the data type of a function in an expression. The argument data +/** Resolves the data type of a function in an expression. The argument data types must already be resolved. */ static void pars_resolve_func_data_type( - /*========================*/ func_node_t *node) /*!< in: function node */ { que_node_t *arg; @@ -557,11 +536,9 @@ static void pars_resolve_func_data_type( } } -/*********************************************************************/ /** - Resolves the meaning of variables in an expression and the data types of +/** Resolves the meaning of variables in an expression and the data types of functions. It is an error if some identifier cannot be resolved here. */ static void pars_resolve_exp_variables_and_types( - /*=================================*/ sel_node_t *select_node, /*!< in: select node or NULL; if this is not NULL then the variable sym nodes are added to the @@ -637,12 +614,10 @@ static void pars_resolve_exp_variables_and_types( dfield_set_type(que_node_get_val(sym_node), que_node_get_data_type(node)); } -/*********************************************************************/ /** - Resolves the meaning of variables in an expression list. It is an error if +/** Resolves the meaning of variables in an expression list. It is an error if some identifier cannot be resolved here. Resolves also the data types of functions. */ static void pars_resolve_exp_list_variables_and_types( - /*======================================*/ sel_node_t *select_node, /*!< in: select node or NULL */ que_node_t *exp_node) /*!< in: expression list first node, or NULL */ @@ -654,10 +629,8 @@ static void pars_resolve_exp_list_variables_and_types( } } -/*********************************************************************/ /** - Resolves the columns in an expression. */ +/** Resolves the columns in an expression. */ static void pars_resolve_exp_columns( - /*=====================*/ sym_node_t *table_node, /*!< in: first node in a table list */ que_node_t *exp_node) /*!< in: expression */ { @@ -726,10 +699,8 @@ static void pars_resolve_exp_columns( } } -/*********************************************************************/ /** - Resolves the meaning of columns in an expression list. */ +/** Resolves the meaning of columns in an expression list. */ static void pars_resolve_exp_list_columns( - /*==========================*/ sym_node_t *table_node, /*!< in: first node in a table list */ que_node_t *exp_node) /*!< in: expression list first node, or NULL */ @@ -741,11 +712,8 @@ static void pars_resolve_exp_list_columns( } } -/*********************************************************************/ /** - Retrieves the table definition for a table name id. */ -static void pars_retrieve_table_def( - /*====================*/ - sym_node_t *sym_node) /*!< in: table node */ +/** Retrieves the table definition for a table name id. */ +static void pars_retrieve_table_def(sym_node_t *sym_node) /*!< in: table node */ { ut_a(sym_node); ut_a(que_node_get_type(sym_node) == QUE_NODE_SYMBOL); @@ -771,11 +739,9 @@ static void pars_retrieve_table_def( } } -/*********************************************************************/ /** - Retrieves the table definitions for a list of table name ids. +/** Retrieves the table definitions for a list of table name ids. @return number of tables */ static ulint pars_retrieve_table_list_defs( - /*==========================*/ sym_node_t *sym_node) /*!< in: first table node in list */ { ulint count = 0; @@ -795,10 +761,8 @@ static ulint pars_retrieve_table_list_defs( return (count); } -/*********************************************************************/ /** - Adds all columns to the select list if the query is SELECT * FROM ... */ +/** Adds all columns to the select list if the query is SELECT * FROM ... */ static void pars_select_all_columns( - /*====================*/ sel_node_t *select_node) /*!< in: select node already containing the table list */ { @@ -828,12 +792,10 @@ static void pars_select_all_columns( } } -/*********************************************************************/ /** - Parses a select list; creates a query graph node for the whole SELECT +/** Parses a select list; creates a query graph node for the whole SELECT statement. @return own: select node in a query tree */ sel_node_t *pars_select_list( - /*=============*/ que_node_t *select_list, /*!< in: select list */ sym_node_t *into_list) /*!< in: variables list or NULL */ { @@ -849,11 +811,9 @@ sel_node_t *pars_select_list( return (node); } -/*********************************************************************/ /** - Checks if the query is an aggregate query, in which case the selct list must +/** Checks if the query is an aggregate query, in which case the selct list must contain only aggregate function items. */ static void pars_check_aggregate( - /*=================*/ sel_node_t *select_node) /*!< in: select node already containing the select list */ { @@ -887,11 +847,9 @@ static void pars_check_aggregate( } } -/*********************************************************************/ /** - Parses a select statement. +/** Parses a select statement. @return own: select node in a query tree */ sel_node_t *pars_select_statement( - /*==================*/ sel_node_t *select_node, /*!< in: select node already containing the select list */ sym_node_t *table_list, /*!< in: table list */ @@ -967,11 +925,9 @@ sel_node_t *pars_select_statement( return (select_node); } -/*********************************************************************/ /** - Parses a cursor declaration. +/** Parses a cursor declaration. @return sym_node */ que_node_t *pars_cursor_declaration( - /*====================*/ sym_node_t *sym_node, /*!< in: cursor id node in the symbol table */ sel_node_t *select_node) /*!< in: select node */ @@ -986,11 +942,9 @@ que_node_t *pars_cursor_declaration( return (sym_node); } -/*********************************************************************/ /** - Parses a function declaration. +/** Parses a function declaration. @return sym_node */ que_node_t *pars_function_declaration( - /*======================*/ sym_node_t *sym_node) /*!< in: function id node in the symbol table */ { @@ -1003,11 +957,9 @@ que_node_t *pars_function_declaration( return (sym_node); } -/*********************************************************************/ /** - Parses a delete or update statement start. +/** Parses a delete or update statement start. @return own: update node in a query tree */ upd_node_t *pars_update_statement_start( - /*========================*/ ibool is_delete, /*!< in: TRUE if delete */ sym_node_t *table_sym, /*!< in: table name node */ col_assign_node_t *col_assign_list) /*!< in: column assignment list, NULL @@ -1025,11 +977,9 @@ upd_node_t *pars_update_statement_start( return (node); } -/*********************************************************************/ /** - Parses a column assignment in an update. +/** Parses a column assignment in an update. @return column assignment node */ col_assign_node_t *pars_column_assignment( - /*===================*/ sym_node_t *column, /*!< in: column to assign */ que_node_t *exp) /*!< in: value to assign */ { @@ -1045,11 +995,8 @@ col_assign_node_t *pars_column_assignment( return (node); } -/*********************************************************************/ /** - Processes an update node assignment list. */ -static void pars_process_assign_list( - /*=====================*/ - upd_node_t *node) /*!< in: update node */ +/** Processes an update node assignment list. */ +static void pars_process_assign_list(upd_node_t *node) /*!< in: update node */ { col_assign_node_t *col_assign_list; sym_node_t *table_sym; @@ -1128,11 +1075,9 @@ static void pars_process_assign_list( node->cmpl_info = changes_ord_field | changes_field_size; } -/*********************************************************************/ /** - Parses an update or delete statement. +/** Parses an update or delete statement. @return own: update node in a query tree */ upd_node_t *pars_update_statement( - /*==================*/ upd_node_t *node, /*!< in: update node */ sym_node_t *cursor_sym, /*!< in: pointer to a cursor entry in the symbol table or NULL */ @@ -1211,11 +1156,9 @@ upd_node_t *pars_update_statement( return (node); } -/*********************************************************************/ /** - Parses an insert statement. +/** Parses an insert statement. @return own: update node in a query tree */ ins_node_t *pars_insert_statement( - /*==================*/ sym_node_t *table_sym, /*!< in: table name node */ que_node_t *values_list, /*!< in: value expression list or NULL */ sel_node_t *select) /*!< in: select condition or NULL */ @@ -1264,10 +1207,8 @@ ins_node_t *pars_insert_statement( return (node); } -/*********************************************************************/ /** - Set the type of a dfield. */ +/** Set the type of a dfield. */ static void pars_set_dfield_type( - /*=================*/ dfield_t *dfield, /*!< in: dfield */ pars_res_word_t *type, /*!< in: pointer to a type token */ @@ -1314,11 +1255,9 @@ static void pars_set_dfield_type( } } -/*********************************************************************/ /** - Parses a variable declaration. +/** Parses a variable declaration. @return own: symbol table node of type SYM_VAR */ sym_node_t *pars_variable_declaration( - /*======================*/ sym_node_t *node, /*!< in: symbol table node allocated for the id of the variable */ pars_res_word_t *type) /*!< in: pointer to a type token */ @@ -1333,11 +1272,9 @@ sym_node_t *pars_variable_declaration( return (node); } -/*********************************************************************/ /** - Parses a procedure parameter declaration. +/** Parses a procedure parameter declaration. @return own: symbol table node of type SYM_VAR */ sym_node_t *pars_parameter_declaration( - /*=======================*/ sym_node_t *node, /*!< in: symbol table node allocated for the id of the parameter */ ulint param_type, @@ -1353,10 +1290,8 @@ sym_node_t *pars_parameter_declaration( return (node); } -/*********************************************************************/ /** - Sets the parent field in a query node list. */ +/** Sets the parent field in a query node list. */ static void pars_set_parent_in_list( - /*====================*/ que_node_t *node_list, /*!< in: first node in a list */ que_node_t *parent) /*!< in: parent value to set in all nodes of the list */ @@ -1372,11 +1307,9 @@ static void pars_set_parent_in_list( } } -/*********************************************************************/ /** - Parses an elsif element. +/** Parses an elsif element. @return elsif node */ elsif_node_t *pars_elsif_element( - /*===============*/ que_node_t *cond, /*!< in: if-condition */ que_node_t *stat_list) /*!< in: statement list */ { @@ -1396,11 +1329,9 @@ elsif_node_t *pars_elsif_element( return (node); } -/*********************************************************************/ /** - Parses an if-statement. +/** Parses an if-statement. @return if-statement node */ if_node_t *pars_if_statement( - /*==============*/ que_node_t *cond, /*!< in: if-condition */ que_node_t *stat_list, /*!< in: statement list */ que_node_t *else_part) /*!< in: else-part statement list @@ -1445,11 +1376,9 @@ if_node_t *pars_if_statement( return (node); } -/*********************************************************************/ /** - Parses a while-statement. +/** Parses a while-statement. @return while-statement node */ while_node_t *pars_while_statement( - /*=================*/ que_node_t *cond, /*!< in: while-condition */ que_node_t *stat_list) /*!< in: statement list */ { @@ -1471,11 +1400,9 @@ while_node_t *pars_while_statement( return (node); } -/*********************************************************************/ /** - Parses a for-loop-statement. +/** Parses a for-loop-statement. @return for-statement node */ for_node_t *pars_for_statement( - /*===============*/ sym_node_t *loop_var, /*!< in: loop variable */ que_node_t *loop_start_limit, /*!< in: loop start expression */ que_node_t *loop_end_limit, /*!< in: loop end expression */ @@ -1506,12 +1433,9 @@ for_node_t *pars_for_statement( return (node); } -/*********************************************************************/ /** - Parses an exit statement. +/** Parses an exit statement. @return exit statement node */ -exit_node_t *pars_exit_statement(void) -/*=====================*/ -{ +exit_node_t *pars_exit_statement(void) { exit_node_t *node; node = static_cast( @@ -1521,12 +1445,9 @@ exit_node_t *pars_exit_statement(void) return (node); } -/*********************************************************************/ /** - Parses a return-statement. +/** Parses a return-statement. @return return-statement node */ -return_node_t *pars_return_statement(void) -/*=======================*/ -{ +return_node_t *pars_return_statement(void) { return_node_t *node; node = static_cast( @@ -1536,11 +1457,9 @@ return_node_t *pars_return_statement(void) return (node); } -/*********************************************************************/ /** - Parses an assignment statement. +/** Parses an assignment statement. @return assignment statement node */ assign_node_t *pars_assignment_statement( - /*======================*/ sym_node_t *var, /*!< in: variable to assign */ que_node_t *val) /*!< in: value to assign */ { @@ -1562,12 +1481,10 @@ assign_node_t *pars_assignment_statement( return (node); } -/*********************************************************************/ /** - Parses a fetch statement. into_list or user_func (but not both) must be +/** Parses a fetch statement. into_list or user_func (but not both) must be non-NULL. @return fetch statement node */ fetch_node_t *pars_fetch_statement( - /*=================*/ sym_node_t *cursor, /*!< in: cursor node */ sym_node_t *into_list, /*!< in: variables to set, or NULL */ sym_node_t *user_func) /*!< in: user function name, or NULL */ @@ -1614,14 +1531,11 @@ fetch_node_t *pars_fetch_statement( return (node); } -/*********************************************************************/ /** - Parses an open or close cursor statement. +/** Parses an open or close cursor statement. @return fetch statement node */ -open_node_t *pars_open_statement( - /*================*/ - ulint type, /*!< in: ROW_SEL_OPEN_CURSOR - or ROW_SEL_CLOSE_CURSOR */ - sym_node_t *cursor) /*!< in: cursor node */ +open_node_t *pars_open_statement(ulint type, /*!< in: ROW_SEL_OPEN_CURSOR + or ROW_SEL_CLOSE_CURSOR */ + sym_node_t *cursor) /*!< in: cursor node */ { sym_node_t *cursor_decl; open_node_t *node; @@ -1643,38 +1557,29 @@ open_node_t *pars_open_statement( return (node); } -/*********************************************************************/ /** - Parses a commit statement. +/** Parses a commit statement. @return own: commit node struct */ -commit_node_t *pars_commit_statement(void) -/*=======================*/ -{ +commit_node_t *pars_commit_statement(void) { return (trx_commit_node_create(pars_sym_tab_global->heap)); } -/*********************************************************************/ /** - Parses a rollback statement. +/** Parses a rollback statement. @return own: rollback node struct */ -roll_node_t *pars_rollback_statement(void) -/*=========================*/ -{ +roll_node_t *pars_rollback_statement(void) { return (roll_node_create(pars_sym_tab_global->heap)); } -/*********************************************************************/ /** - Parses a column definition at a table creation. +/** Parses a column definition at a table creation. @return column sym table node */ -sym_node_t *pars_column_def( - /*============*/ - sym_node_t *sym_node, /*!< in: column node in the - symbol table */ - pars_res_word_t *type, /*!< in: data type */ - sym_node_t *len, /*!< in: length of column, or - NULL */ - void *is_unsigned, /*!< in: if not NULL, column - is of type UNSIGNED. */ - void *is_not_null) /*!< in: if not NULL, column - is of type NOT NULL. */ +sym_node_t *pars_column_def(sym_node_t *sym_node, /*!< in: column node in the + symbol table */ + pars_res_word_t *type, /*!< in: data type */ + sym_node_t *len, /*!< in: length of column, or + NULL */ + void *is_unsigned, /*!< in: if not NULL, column + is of type UNSIGNED. */ + void *is_not_null) /*!< in: if not NULL, column + is of type NOT NULL. */ { ulint len2; @@ -1711,11 +1616,9 @@ tab_node_t *pars_create_table(sym_node_t *table_sym, sym_node_t *column_defs, return (NULL); } -/*********************************************************************/ /** - Parses an index creation operation. +/** Parses an index creation operation. @return index create subgraph */ ind_node_t *pars_create_index( - /*==============*/ pars_res_word_t *unique_def, /*!< in: not NULL if a unique index */ pars_res_word_t *clustered_def, /*!< in: not NULL if a clustered index */ sym_node_t *index_sym, /*!< in: index name node in the symbol @@ -1727,11 +1630,9 @@ ind_node_t *pars_create_index( return (NULL); } -/*********************************************************************/ /** - Parses a procedure definition. +/** Parses a procedure definition. @return query fork node */ que_fork_t *pars_procedure_definition( - /*======================*/ sym_node_t *sym_node, /*!< in: procedure id node in the symbol table */ sym_node_t *param_list, /*!< in: parameter declaration list */ @@ -1772,10 +1673,8 @@ que_fork_t *pars_procedure_definition( return (fork); } -/*************************************************************/ /** - Retrieves characters to the lexical analyzer. */ +/** Retrieves characters to the lexical analyzer. */ int pars_get_lex_chars( - /*===============*/ char *buf, /*!< in/out: buffer where to copy */ size_t max_size) /*!< in: maximum number of characters which fit in the buffer */ @@ -1801,11 +1700,8 @@ int pars_get_lex_chars( return (len); } -/*************************************************************/ /** - Called by yyparse on error. */ -void yyerror( - /*====*/ - const char *s MY_ATTRIBUTE((unused))) +/** Called by yyparse on error. */ +void yyerror(const char *s MY_ATTRIBUTE((unused))) /*!< in: error message string */ { ut_ad(s); @@ -1813,13 +1709,10 @@ void yyerror( ib::fatal() << "PARSER: Syntax error in SQL string"; } -/*************************************************************/ /** - Parses an SQL string returning the query graph. +/** Parses an SQL string returning the query graph. @return own: the query graph */ -que_t *pars_sql( - /*=====*/ - pars_info_t *info, /*!< in: extra information, or NULL */ - const char *str) /*!< in: SQL string */ +que_t *pars_sql(pars_info_t *info, /*!< in: extra information, or NULL */ + const char *str) /*!< in: SQL string */ { sym_node_t *sym_node; mem_heap_t *heap; @@ -1894,12 +1787,9 @@ que_thr_t *pars_complete_graph_for_exec(que_node_t *node, trx_t *trx, return (thr); } -/****************************************************************/ /** - Create parser info struct. +/** Create parser info struct. @return own: info struct */ -pars_info_t *pars_info_create(void) -/*==================*/ -{ +pars_info_t *pars_info_create(void) { pars_info_t *info; mem_heap_t *heap; @@ -1916,26 +1806,20 @@ pars_info_t *pars_info_create(void) return (info); } -/****************************************************************/ /** - Free info struct and everything it contains. */ -void pars_info_free( - /*===========*/ - pars_info_t *info) /*!< in, own: info struct */ +/** Free info struct and everything it contains. */ +void pars_info_free(pars_info_t *info) /*!< in, own: info struct */ { mem_heap_free(info->heap); } -/****************************************************************/ /** - Add bound literal. */ -void pars_info_add_literal( - /*==================*/ - pars_info_t *info, /*!< in: info struct */ - const char *name, /*!< in: name */ - const void *address, /*!< in: address */ - ulint length, /*!< in: length of data */ - ulint type, /*!< in: type, e.g. DATA_FIXBINARY */ - ulint prtype) /*!< in: precise type, e.g. - DATA_UNSIGNED */ +/** Add bound literal. */ +void pars_info_add_literal(pars_info_t *info, /*!< in: info struct */ + const char *name, /*!< in: name */ + const void *address, /*!< in: address */ + ulint length, /*!< in: length of data */ + ulint type, /*!< in: type, e.g. DATA_FIXBINARY */ + ulint prtype) /*!< in: precise type, e.g. + DATA_UNSIGNED */ { pars_bound_lit_t *pbl; @@ -1962,14 +1846,11 @@ void pars_info_add_literal( ib_vector_push(info->bound_lits, pbl); } -/****************************************************************/ /** - Equivalent to pars_info_add_literal(info, name, str, strlen(str), +/** Equivalent to pars_info_add_literal(info, name, str, strlen(str), DATA_VARCHAR, DATA_ENGLISH). */ -void pars_info_add_str_literal( - /*======================*/ - pars_info_t *info, /*!< in: info struct */ - const char *name, /*!< in: name */ - const char *str) /*!< in: string */ +void pars_info_add_str_literal(pars_info_t *info, /*!< in: info struct */ + const char *name, /*!< in: name */ + const char *str) /*!< in: string */ { pars_info_add_literal(info, name, str, strlen(str), DATA_VARCHAR, DATA_ENGLISH); @@ -1978,14 +1859,12 @@ void pars_info_add_str_literal( /******************************************************************** If the literal value already exists then it rebinds otherwise it creates a new entry.*/ -void pars_info_bind_literal( - /*===================*/ - pars_info_t *info, /* in: info struct */ - const char *name, /* in: name */ - const void *address, /* in: address */ - ulint length, /* in: length of data */ - ulint type, /* in: type, e.g. DATA_FIXBINARY */ - ulint prtype) /* in: precise type, e.g. */ +void pars_info_bind_literal(pars_info_t *info, /* in: info struct */ + const char *name, /* in: name */ + const void *address, /* in: address */ + ulint length, /* in: length of data */ + ulint type, /* in: type, e.g. DATA_FIXBINARY */ + ulint prtype) /* in: precise type, e.g. */ { pars_bound_lit_t *pbl; @@ -2004,12 +1883,10 @@ void pars_info_bind_literal( /******************************************************************** If the literal value already exists then it rebinds otherwise it creates a new entry.*/ -void pars_info_bind_varchar_literal( - /*===========================*/ - pars_info_t *info, /*!< in: info struct */ - const char *name, /*!< in: name */ - const byte *str, /*!< in: string */ - ulint str_len) /*!< in: string length */ +void pars_info_bind_varchar_literal(pars_info_t *info, /*!< in: info struct */ + const char *name, /*!< in: name */ + const byte *str, /*!< in: string */ + ulint str_len) /*!< in: string length */ { pars_bound_lit_t *pbl; @@ -2025,8 +1902,7 @@ void pars_info_bind_varchar_literal( } } -/****************************************************************/ /** - Equivalent to: +/** Equivalent to: char buf[4]; mach_write_to_4(buf, val); @@ -2034,11 +1910,9 @@ void pars_info_bind_varchar_literal( except that the buffer is dynamically allocated from the info struct's heap. */ -void pars_info_add_int4_literal( - /*=======================*/ - pars_info_t *info, /*!< in: info struct */ - const char *name, /*!< in: name */ - lint val) /*!< in: value */ +void pars_info_add_int4_literal(pars_info_t *info, /*!< in: info struct */ + const char *name, /*!< in: name */ + lint val) /*!< in: value */ { byte *buf = static_cast(mem_heap_alloc(info->heap, 4)); @@ -2088,8 +1962,7 @@ void pars_info_bind_int8_literal(pars_info_t *info, const char *name, } } -/****************************************************************/ /** - Equivalent to: +/** Equivalent to: char buf[8]; mach_write_to_8(buf, val); @@ -2097,11 +1970,9 @@ void pars_info_bind_int8_literal(pars_info_t *info, const char *name, except that the buffer is dynamically allocated from the info struct's heap. */ -void pars_info_add_ull_literal( - /*======================*/ - pars_info_t *info, /*!< in: info struct */ - const char *name, /*!< in: name */ - ib_uint64_t val) /*!< in: value */ +void pars_info_add_ull_literal(pars_info_t *info, /*!< in: info struct */ + const char *name, /*!< in: name */ + ib_uint64_t val) /*!< in: value */ { byte *buf = static_cast(mem_heap_alloc(info->heap, 8)); @@ -2110,14 +1981,11 @@ void pars_info_add_ull_literal( pars_info_add_literal(info, name, buf, 8, DATA_FIXBINARY, 0); } -/****************************************************************/ /** - If the literal value already exists then it rebinds otherwise it +/** If the literal value already exists then it rebinds otherwise it creates a new entry. */ -void pars_info_bind_ull_literal( - /*=======================*/ - pars_info_t *info, /*!< in: info struct */ - const char *name, /*!< in: name */ - const ib_uint64_t *val) /*!< in: value */ +void pars_info_bind_ull_literal(pars_info_t *info, /*!< in: info struct */ + const char *name, /*!< in: name */ + const ib_uint64_t *val) /*!< in: value */ { pars_bound_lit_t *pbl; @@ -2133,10 +2001,8 @@ void pars_info_bind_ull_literal( } } -/****************************************************************/ /** - Add user function. */ +/** Add user function. */ void pars_info_bind_function( - /*====================*/ pars_info_t *info, /*!< in: info struct */ const char *name, /*!< in: function name */ pars_user_func_cb_t func, /*!< in: function address */ @@ -2201,11 +2067,9 @@ pars_bound_id_t *pars_info_get_bound_id(pars_info_t *info, const char *name) { return (pars_info_lookup_bound_id(info, name)); } -/****************************************************************/ /** - Get bound literal with the given name. +/** Get bound literal with the given name. @return bound literal, or NULL if not found */ pars_bound_lit_t *pars_info_get_bound_lit( - /*====================*/ pars_info_t *info, /*!< in: info struct */ const char *name) /*!< in: bound literal name to find */ { diff --git a/storage/innobase/pars/pars0sym.cc b/storage/innobase/pars/pars0sym.cc index 8c531b1f5aee..ad30cafa597d 100644 --- a/storage/innobase/pars/pars0sym.cc +++ b/storage/innobase/pars/pars0sym.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file pars/pars0sym.cc +/** @file pars/pars0sym.cc SQL parser symbol table Created 12/15/1997 Heikki Tuuri @@ -45,11 +44,9 @@ this program; if not, write to the Free Software Foundation, Inc., #include "que0que.h" #include "row0sel.h" -/******************************************************************/ /** - Creates a symbol table for a single stored procedure or query. +/** Creates a symbol table for a single stored procedure or query. @return own: symbol table */ sym_tab_t *sym_tab_create( - /*===========*/ mem_heap_t *heap) /*!< in: memory heap where to create */ { sym_tab_t *sym_tab; @@ -64,13 +61,10 @@ sym_tab_t *sym_tab_create( return (sym_tab); } -/******************************************************************/ /** - Frees the memory allocated dynamically AFTER parsing phase for variables +/** Frees the memory allocated dynamically AFTER parsing phase for variables etc. in the symbol table. Does not free the mem heap where the table was originally created. Frees also SQL explicit cursor definitions. */ -void sym_tab_free_private( - /*=================*/ - sym_tab_t *sym_tab) /*!< in, own: symbol table */ +void sym_tab_free_private(sym_tab_t *sym_tab) /*!< in, own: symbol table */ { sym_node_t *sym; func_node_t *func; @@ -110,13 +104,10 @@ void sym_tab_free_private( } } -/******************************************************************/ /** - Adds an integer literal to a symbol table. +/** Adds an integer literal to a symbol table. @return symbol table node */ -sym_node_t *sym_tab_add_int_lit( - /*================*/ - sym_tab_t *sym_tab, /*!< in: symbol table */ - ulint val) /*!< in: integer value */ +sym_node_t *sym_tab_add_int_lit(sym_tab_t *sym_tab, /*!< in: symbol table */ + ulint val) /*!< in: integer value */ { sym_node_t *node; byte *data; @@ -152,11 +143,9 @@ sym_node_t *sym_tab_add_int_lit( return (node); } -/******************************************************************/ /** - Adds a string literal to a symbol table. +/** Adds a string literal to a symbol table. @return symbol table node */ sym_node_t *sym_tab_add_str_lit( - /*================*/ sym_tab_t *sym_tab, /*!< in: symbol table */ const byte *str, /*!< in: string with no quotes around it */ @@ -196,11 +185,9 @@ sym_node_t *sym_tab_add_str_lit( return (node); } -/******************************************************************/ /** - Add a bound literal to a symbol table. +/** Add a bound literal to a symbol table. @return symbol table node */ sym_node_t *sym_tab_add_bound_lit( - /*==================*/ sym_tab_t *sym_tab, /*!< in: symbol table */ const char *name, /*!< in: name of bound literal */ ulint *lit_type) /*!< out: type of literal (PARS_*_LIT) */ @@ -277,7 +264,6 @@ sym_node_t *sym_tab_add_bound_lit( /********************************************************************** Rebind literal to a node in the symbol table. */ sym_node_t *sym_tab_rebind_lit( - /*===============*/ /* out: symbol table node */ sym_node_t *node, /* in: node that is bound to literal*/ const void *address, /* in: pointer to data */ @@ -314,12 +300,9 @@ sym_node_t *sym_tab_rebind_lit( return (node); } -/******************************************************************/ /** - Adds an SQL null literal to a symbol table. +/** Adds an SQL null literal to a symbol table. @return symbol table node */ -sym_node_t *sym_tab_add_null_lit( - /*=================*/ - sym_tab_t *sym_tab) /*!< in: symbol table */ +sym_node_t *sym_tab_add_null_lit(sym_tab_t *sym_tab) /*!< in: symbol table */ { sym_node_t *node; @@ -351,14 +334,11 @@ sym_node_t *sym_tab_add_null_lit( return (node); } -/******************************************************************/ /** - Adds an identifier to a symbol table. +/** Adds an identifier to a symbol table. @return symbol table node */ -sym_node_t *sym_tab_add_id( - /*===========*/ - sym_tab_t *sym_tab, /*!< in: symbol table */ - byte *name, /*!< in: identifier name */ - ulint len) /*!< in: identifier length */ +sym_node_t *sym_tab_add_id(sym_tab_t *sym_tab, /*!< in: symbol table */ + byte *name, /*!< in: identifier name */ + ulint len) /*!< in: identifier length */ { sym_node_t *node; @@ -379,13 +359,10 @@ sym_node_t *sym_tab_add_id( return (node); } -/******************************************************************/ /** - Add a bound identifier to a symbol table. +/** Add a bound identifier to a symbol table. @return symbol table node */ -sym_node_t *sym_tab_add_bound_id( - /*=================*/ - sym_tab_t *sym_tab, /*!< in: symbol table */ - const char *name) /*!< in: name of bound id */ +sym_node_t *sym_tab_add_bound_id(sym_tab_t *sym_tab, /*!< in: symbol table */ + const char *name) /*!< in: name of bound id */ { sym_node_t *node; pars_bound_id_t *bid; diff --git a/storage/innobase/que/que0que.cc b/storage/innobase/que/que0que.cc index e74f3de90c87..05211ca7eb2e 100644 --- a/storage/innobase/que/que0que.cc +++ b/storage/innobase/que/que0que.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file que/que0que.cc +/** @file que/que0que.cc Query graph Created 5/27/1996 Heikki Tuuri @@ -111,20 +110,16 @@ When the execution of the graph completes, it is like returning from a subprocedure: the query thread which requested the operation starts running again. */ -/**********************************************************************/ /** - Moves a thread from another state to the QUE_THR_RUNNING state. Increments +/** Moves a thread from another state to the QUE_THR_RUNNING state. Increments the n_active_thrs counters of the query graph and transaction. ***NOTE***: This is the only function in which such a transition is allowed to happen! */ static void que_thr_move_to_run_state( - /*======================*/ que_thr_t *thr); /*!< in: an query thread */ -/***********************************************************************/ /** - Creates a query graph fork node. +/** Creates a query graph fork node. @return own: fork node */ que_fork_t *que_fork_create( - /*============*/ que_t *graph, /*!< in: graph, if NULL then this fork node is assumed to be the graph root */ @@ -188,14 +183,12 @@ que_thr_t *que_thr_create(que_fork_t *parent, mem_heap_t *heap, return (thr); } -/**********************************************************************/ /** - Moves a suspended query thread to the QUE_THR_RUNNING state and may release +/** Moves a suspended query thread to the QUE_THR_RUNNING state and may release a worker thread to execute it. This function should be used to end the wait state of a query thread waiting for a lock or a stored procedure completion. @return the query thread that needs to be released. */ que_thr_t *que_thr_end_lock_wait( - /*==================*/ trx_t *trx) /*!< in: transaction with que_state in QUE_THR_LOCK_WAIT */ { @@ -227,12 +220,9 @@ que_thr_t *que_thr_end_lock_wait( return ((!was_active && thr != NULL) ? thr : NULL); } -/**********************************************************************/ /** - Inits a query thread for a command. */ +/** Inits a query thread for a command. */ UNIV_INLINE -void que_thr_init_command( - /*=================*/ - que_thr_t *thr) /*!< in: query thread */ +void que_thr_init_command(que_thr_t *thr) /*!< in: query thread */ { thr->run_node = thr; thr->prev_node = thr->common.parent; @@ -240,13 +230,11 @@ void que_thr_init_command( que_thr_move_to_run_state(thr); } -/**********************************************************************/ /** - Round robin scheduler. +/** Round robin scheduler. @return a query thread of the graph moved to QUE_THR_RUNNING state, or NULL; the query thread should be executed by que_run_threads by the caller */ que_thr_t *que_fork_scheduler_round_robin( - /*===========================*/ que_fork_t *fork, /*!< in: a query fork */ que_thr_t *thr) /*!< in: current pos */ { @@ -283,17 +271,14 @@ que_thr_t *que_fork_scheduler_round_robin( return (thr); } -/**********************************************************************/ /** - Starts execution of a command in a query fork. Picks a query thread which +/** Starts execution of a command in a query fork. Picks a query thread which is not in the QUE_THR_RUNNING state and moves it to that state. If none can be chosen, a situation which may arise in parallelized fetches, NULL is returned. @return a query thread of the graph moved to QUE_THR_RUNNING state, or NULL; the query thread should be executed by que_run_threads by the caller */ -que_thr_t *que_fork_start_command( - /*===================*/ - que_fork_t *fork) /*!< in: a query fork */ +que_thr_t *que_fork_start_command(que_fork_t *fork) /*!< in: a query fork */ { que_thr_t *thr; que_thr_t *suspended_thr = NULL; @@ -367,10 +352,8 @@ que_thr_t *que_fork_start_command( return (thr); } -/**********************************************************************/ /** - Calls que_graph_free_recursive for statements in a statement list. */ +/** Calls que_graph_free_recursive for statements in a statement list. */ static void que_graph_free_stat_list( - /*=====================*/ que_node_t *node) /*!< in: first query graph node in the list */ { while (node) { @@ -380,12 +363,9 @@ static void que_graph_free_stat_list( } } -/**********************************************************************/ /** - Frees a query graph, but not the heap where it was created. Does not free +/** Frees a query graph, but not the heap where it was created. Does not free explicit cursor declarations, they are freed in que_graph_free. */ -void que_graph_free_recursive( - /*=====================*/ - que_node_t *node) /*!< in: query graph node */ +void que_graph_free_recursive(que_node_t *node) /*!< in: query graph node */ { que_fork_t *fork; que_thr_t *thr; @@ -528,10 +508,8 @@ void que_graph_free_recursive( DBUG_VOID_RETURN; } -/**********************************************************************/ /** - Frees a query graph. */ +/** Frees a query graph. */ void que_graph_free( - /*===========*/ que_t *graph) /*!< in: query graph; we assume that the memory heap where this graph was created is private to this graph: if not, then use @@ -558,11 +536,9 @@ void que_graph_free( mem_heap_free(graph->heap); } -/****************************************************************/ /** - Performs an execution step on a thr node. +/** Performs an execution step on a thr node. @return query thread to run next, or NULL if none */ static que_thr_t *que_thr_node_step( - /*==============*/ que_thr_t *thr) /*!< in: query thread where run_node must be the thread node itself */ { @@ -594,14 +570,12 @@ static que_thr_t *que_thr_node_step( return (NULL); } -/**********************************************************************/ /** - Moves a thread from another state to the QUE_THR_RUNNING state. Increments +/** Moves a thread from another state to the QUE_THR_RUNNING state. Increments the n_active_thrs counters of the query graph and transaction if thr was not active. ***NOTE***: This and ..._mysql are the only functions in which such a transition is allowed to happen! */ static void que_thr_move_to_run_state( - /*======================*/ que_thr_t *thr) /*!< in: an query thread */ { ut_ad(thr->state != QUE_THR_RUNNING); @@ -621,13 +595,10 @@ static void que_thr_move_to_run_state( thr->state = QUE_THR_RUNNING; } -/**********************************************************************/ /** - Stops a query thread if graph or trx is in a state requiring it. The +/** Stops a query thread if graph or trx is in a state requiring it. The conditions are tested in the order (1) graph, (2) trx. @return true if stopped */ -ibool que_thr_stop( - /*=========*/ - que_thr_t *thr) /*!< in: query thread */ +ibool que_thr_stop(que_thr_t *thr) /*!< in: query thread */ { que_t *graph; trx_t *trx = thr_get_trx(thr); @@ -662,8 +633,7 @@ ibool que_thr_stop( return (TRUE); } -/**********************************************************************/ /** - Decrements the query thread reference counts in the query graph and the +/** Decrements the query thread reference counts in the query graph and the transaction. *** NOTE ***: This and que_thr_stop_for_mysql are the only functions where the reference @@ -671,7 +641,6 @@ ibool que_thr_stop( que_run_threads! These restrictions exist to make the rollback code easier to maintain. */ static void que_thr_dec_refer_count( - /*====================*/ que_thr_t *thr, /*!< in: query thread */ que_thr_t **next_thr) /*!< in/out: next query thread to run; if the value which is passed in is @@ -724,14 +693,11 @@ static void que_thr_dec_refer_count( thr->is_active = FALSE; } -/**********************************************************************/ /** - A patch for MySQL used to 'stop' a dummy query thread used in MySQL. The +/** A patch for MySQL used to 'stop' a dummy query thread used in MySQL. The query thread is stopped and made inactive, except in the case where it was put to the lock wait state in lock0lock.cc, but the lock has already been granted or the transaction chosen as a victim in deadlock resolution. */ -void que_thr_stop_for_mysql( - /*===================*/ - que_thr_t *thr) /*!< in: query thread */ +void que_thr_stop_for_mysql(que_thr_t *thr) /*!< in: query thread */ { trx_t *trx; @@ -766,12 +732,10 @@ void que_thr_stop_for_mysql( trx_mutex_exit(trx); } -/**********************************************************************/ /** - Moves a thread from another state to the QUE_THR_RUNNING state. Increments +/** Moves a thread from another state to the QUE_THR_RUNNING state. Increments the n_active_thrs counters of the query graph and transaction if thr was not active. */ void que_thr_move_to_run_state_for_mysql( - /*================================*/ que_thr_t *thr, /*!< in: an query thread */ trx_t *trx) /*!< in: transaction */ { @@ -788,13 +752,10 @@ void que_thr_move_to_run_state_for_mysql( thr->state = QUE_THR_RUNNING; } -/**********************************************************************/ /** - A patch for MySQL used to 'stop' a dummy query thread used in MySQL +/** A patch for MySQL used to 'stop' a dummy query thread used in MySQL select, when there is no error or lock wait. */ -void que_thr_stop_for_mysql_no_error( - /*============================*/ - que_thr_t *thr, /*!< in: query thread */ - trx_t *trx) /*!< in: transaction */ +void que_thr_stop_for_mysql_no_error(que_thr_t *thr, /*!< in: query thread */ + trx_t *trx) /*!< in: transaction */ { ut_ad(thr->state == QUE_THR_RUNNING); ut_ad(thr->is_active == TRUE); @@ -810,13 +771,10 @@ void que_thr_stop_for_mysql_no_error( trx->lock.n_active_thrs--; } -/****************************************************************/ /** - Get the first containing loop node (e.g. while_node_t or for_node_t) for the +/** Get the first containing loop node (e.g. while_node_t or for_node_t) for the given node, or NULL if the node is not within a loop. @return containing loop node, or NULL. */ -que_node_t *que_node_get_containing_loop_node( - /*==============================*/ - que_node_t *node) /*!< in: node */ +que_node_t *que_node_get_containing_loop_node(que_node_t *node) /*!< in: node */ { ut_ad(node); @@ -843,7 +801,6 @@ que_node_t *que_node_get_containing_loop_node( /** Gets information of an SQL query graph node. @return type description */ static MY_ATTRIBUTE((warn_unused_result)) const char *que_node_type_string( - /*=================*/ const que_node_t *node) /*!< in: query graph node */ { switch (que_node_get_type(node)) { @@ -892,14 +849,11 @@ static MY_ATTRIBUTE((warn_unused_result)) const char *que_node_type_string( } #endif /* UNIV_DEBUG */ -/**********************************************************************/ /** - Performs an execution step on a query thread. +/** Performs an execution step on a query thread. @return query thread to run next: it may differ from the input parameter if, e.g., a subprocedure call is made */ UNIV_INLINE -que_thr_t *que_thr_step( - /*=========*/ - que_thr_t *thr) /*!< in: query thread */ +que_thr_t *que_thr_step(que_thr_t *thr) /*!< in: query thread */ { que_node_t *node; que_thr_t *old_thr; @@ -997,11 +951,8 @@ que_thr_t *que_thr_step( return (thr); } -/**********************************************************************/ /** - Run a query thread until it finishes or encounters e.g. a lock wait. */ -static void que_run_threads_low( - /*================*/ - que_thr_t *thr) /*!< in: query thread */ +/** Run a query thread until it finishes or encounters e.g. a lock wait. */ +static void que_run_threads_low(que_thr_t *thr) /*!< in: query thread */ { trx_t *trx; que_thr_t *next_thr; @@ -1054,11 +1005,8 @@ static void que_run_threads_low( } while (next_thr != NULL); } -/**********************************************************************/ /** - Run a query thread. Handles lock waits. */ -void que_run_threads( - /*============*/ - que_thr_t *thr) /*!< in: query thread */ +/** Run a query thread. Handles lock waits. */ +void que_run_threads(que_thr_t *thr) /*!< in: query thread */ { ut_ad(!trx_mutex_own(thr_get_trx(thr))); @@ -1103,17 +1051,14 @@ void que_run_threads( } } -/*********************************************************************/ /** - Evaluate the given SQL. +/** Evaluate the given SQL. @return error code or DB_SUCCESS */ -dberr_t que_eval_sql( - /*=========*/ - pars_info_t *info, /*!< in: info struct, or NULL */ - const char *sql, /*!< in: SQL string */ - ibool reserve_dict_mutex, - /*!< in: if TRUE, acquire/release - dict_sys->mutex around call to pars_sql. */ - trx_t *trx) /*!< in: trx */ +dberr_t que_eval_sql(pars_info_t *info, /*!< in: info struct, or NULL */ + const char *sql, /*!< in: SQL string */ + ibool reserve_dict_mutex, + /*!< in: if TRUE, acquire/release + dict_sys->mutex around call to pars_sql. */ + trx_t *trx) /*!< in: trx */ { que_thr_t *thr; que_t *graph; @@ -1145,18 +1090,10 @@ dberr_t que_eval_sql( DBUG_RETURN(trx->error_state); } -/*********************************************************************/ /** - Initialise the query sub-system. */ -void que_init(void) -/*==========*/ -{ - /* No op */ +/** Initialise the query sub-system. */ +void que_init(void) { /* No op */ } -/*********************************************************************/ /** - Close the query sub-system. */ -void que_close(void) -/*===========*/ -{ - /* No op */ +/** Close the query sub-system. */ +void que_close(void) { /* No op */ } diff --git a/storage/innobase/read/read0read.cc b/storage/innobase/read/read0read.cc index 8a4ef3ea3ea1..de70651cf34c 100644 --- a/storage/innobase/read/read0read.cc +++ b/storage/innobase/read/read0read.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file read/read0read.cc +/** @file read/read0read.cc Cursor read Created 2/16/1997 Heikki Tuuri diff --git a/storage/innobase/rem/rec.cc b/storage/innobase/rem/rec.cc index 64012bddebb9..96d23d9ce4cf 100644 --- a/storage/innobase/rem/rec.cc +++ b/storage/innobase/rem/rec.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file rem/rec.cc +/** @file rem/rec.cc Record manager Created 5/30/1994 Heikki Tuuri @@ -41,8 +40,7 @@ external tools. */ #include "mem0mem.h" #include "rem/rec.h" -/******************************************************/ /** - The following function determines the offsets to each field in the +/** The following function determines the offsets to each field in the record. The offsets are written to a previously allocated array of ulint, where rec_offs_n_fields(offsets) has been initialized to the number of fields in the record. The rest of the array will be @@ -55,12 +53,10 @@ external tools. */ is set (REC_OFFS_SQL_NULL), the field i is NULL. When the second high-order bit of the offset at [i+1] is set (REC_OFFS_EXTERNAL), the field i is being stored externally. */ -void rec_init_offsets( - /*=============*/ - const rec_t *rec, /*!< in: physical record */ - const dict_index_t *index, /*!< in: record descriptor */ - ulint *offsets) /*!< in/out: array of offsets; - in: n=rec_offs_n_fields(offsets) */ +void rec_init_offsets(const rec_t *rec, /*!< in: physical record */ + const dict_index_t *index, /*!< in: record descriptor */ + ulint *offsets) /*!< in/out: array of offsets; + in: n=rec_offs_n_fields(offsets) */ { ulint i = 0; ulint offs; @@ -204,12 +200,10 @@ void rec_init_offsets( } } -/******************************************************/ /** - The following function determines the offsets to each field +/** The following function determines the offsets to each field in the record. It can reuse a previously returned array. @return the new offsets */ ulint *rec_get_offsets_func( - /*=================*/ const rec_t *rec, /*!< in: physical record */ const dict_index_t *index, /*!< in: record descriptor */ ulint *offsets, /*!< in/out: array consisting of @@ -279,11 +273,9 @@ ulint *rec_get_offsets_func( return (offsets); } -/******************************************************/ /** - The following function determines the offsets to each field +/** The following function determines the offsets to each field in the record. It can reuse a previously allocated array. */ void rec_get_offsets_reverse( - /*====================*/ const byte *extra, /*!< in: the extra bytes of a compact record in reverse order, excluding the fixed-size diff --git a/storage/innobase/rem/rec.h b/storage/innobase/rem/rec.h index 284f5e72e95c..02de2f5d2a8b 100644 --- a/storage/innobase/rem/rec.h +++ b/storage/innobase/rem/rec.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -27,8 +27,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "my_compiler.h" #include "my_inttypes.h" -/********************************************************************/ /** - @file rem/rec.h +/** @file rem/rec.h Record manager Created 5/30/1994 Heikki Tuuri @@ -165,12 +164,10 @@ this position, and following positions hold the end offsets of the fields. */ #define rec_offs_base(offsets) (offsets + REC_OFFS_HEADER_SIZE) -/******************************************************/ /** - The following function determines the offsets to each field +/** The following function determines the offsets to each field in the record. It can reuse a previously allocated array. @return the new offsets */ ulint *rec_get_offsets_func( - /*=================*/ const rec_t *rec, /*!< in: physical record */ const dict_index_t *index, /*!< in: record descriptor */ ulint *offsets, /*!< in/out: array consisting of @@ -187,11 +184,9 @@ ulint *rec_get_offsets_func( mem_heap_t **heap) /*!< in/out: memory heap */ MY_ATTRIBUTE((warn_unused_result)); -/******************************************************/ /** - The following function determines the offsets to each field +/** The following function determines the offsets to each field in the record. It can reuse a previously allocated array. */ void rec_get_offsets_reverse( - /*====================*/ const byte *extra, /*!< in: the extra bytes of a compact record in reverse order, excluding the fixed-size @@ -202,11 +197,9 @@ void rec_get_offsets_reverse( ulint *offsets); /*!< in/out: array consisting of offsets[0] allocated elements */ -/******************************************************/ /** - Gets a bit field from within 1 byte. */ +/** Gets a bit field from within 1 byte. */ UNIV_INLINE ulint rec_get_bit_field_1( - /*================*/ const rec_t *rec, /*!< in: pointer to record origin */ ulint offs, /*!< in: offset from the origin down */ ulint mask, /*!< in: mask used to filter bits */ @@ -217,11 +210,9 @@ ulint rec_get_bit_field_1( return ((mach_read_from_1(rec - offs) & mask) >> shift); } -/******************************************************/ /** - Gets a bit field from within 2 bytes. */ +/** Gets a bit field from within 2 bytes. */ UNIV_INLINE ulint rec_get_bit_field_2( - /*================*/ const rec_t *rec, /*!< in: pointer to record origin */ ulint offs, /*!< in: offset from the origin down */ ulint mask, /*!< in: mask used to filter bits */ @@ -232,12 +223,10 @@ ulint rec_get_bit_field_2( return ((mach_read_from_2(rec - offs) & mask) >> shift); } -/******************************************************/ /** - The following function retrieves the status bits of a new-style record. +/** The following function retrieves the status bits of a new-style record. @return status bits */ -UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ulint rec_get_status( - /*===========*/ - const rec_t *rec) /*!< in: physical record */ +UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ulint + rec_get_status(const rec_t *rec) /*!< in: physical record */ { ulint ret; @@ -250,13 +239,11 @@ UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ulint rec_get_status( return (ret); } -/******************************************************/ /** - The following function is used to get the number of fields +/** The following function is used to get the number of fields in an old-style record. @return number of data fields */ -UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ulint rec_get_n_fields_old( - /*=================*/ - const rec_t *rec) /*!< in: physical record */ +UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ulint + rec_get_n_fields_old(const rec_t *rec) /*!< in: physical record */ { ulint ret; @@ -270,15 +257,12 @@ UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ulint rec_get_n_fields_old( return (ret); } -/******************************************************/ /** - The following function is used to get the number of fields +/** The following function is used to get the number of fields in a record. @return number of data fields */ UNIV_INLINE -ulint rec_get_n_fields( - /*=============*/ - const rec_t *rec, /*!< in: physical record */ - const dict_index_t *index) /*!< in: record descriptor */ +ulint rec_get_n_fields(const rec_t *rec, /*!< in: physical record */ + const dict_index_t *index) /*!< in: record descriptor */ { ut_ad(rec); ut_ad(index); @@ -317,12 +301,10 @@ bool rec_n_fields_is_sane(dict_index_t *index, const rec_t *rec, rec_get_n_fields(rec, index) == dtuple_get_n_fields(entry) - 1)); } -/**********************************************************/ /** - The following function returns the number of allocated elements +/** The following function returns the number of allocated elements for an array of offsets. @return number of elements */ UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ulint rec_offs_get_n_alloc( - /*=================*/ const ulint *offsets) /*!< in: array for rec_get_offsets() */ { ulint n_alloc; @@ -333,15 +315,12 @@ UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ulint rec_offs_get_n_alloc( return (n_alloc); } -/**********************************************************/ /** - The following function sets the number of allocated elements +/** The following function sets the number of allocated elements for an array of offsets. */ UNIV_INLINE -void rec_offs_set_n_alloc( - /*=================*/ - ulint *offsets, /*!< out: array for rec_get_offsets(), - must be allocated */ - ulint n_alloc) /*!< in: number of elements */ +void rec_offs_set_n_alloc(ulint *offsets, /*!< out: array for rec_get_offsets(), + must be allocated */ + ulint n_alloc) /*!< in: number of elements */ { ut_ad(offsets); ut_ad(n_alloc > REC_OFFS_HEADER_SIZE); @@ -349,14 +328,11 @@ void rec_offs_set_n_alloc( offsets[0] = n_alloc; } -/**********************************************************/ /** - The following function sets the number of fields in offsets. */ +/** The following function sets the number of fields in offsets. */ UNIV_INLINE -void rec_offs_set_n_fields( - /*==================*/ - ulint *offsets, /*!< in/out: array returned by - rec_get_offsets() */ - ulint n_fields) /*!< in: number of fields */ +void rec_offs_set_n_fields(ulint *offsets, /*!< in/out: array returned by + rec_get_offsets() */ + ulint n_fields) /*!< in: number of fields */ { ut_ad(offsets); ut_ad(n_fields > 0); @@ -365,11 +341,9 @@ void rec_offs_set_n_fields( offsets[1] = n_fields; } -/**********************************************************/ /** - The following function returns the number of fields in a record. +/** The following function returns the number of fields in a record. @return number of fields */ UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ulint rec_offs_n_fields( - /*==============*/ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ { ulint n_fields; @@ -381,8 +355,7 @@ UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ulint rec_offs_n_fields( return (n_fields); } -/******************************************************/ /** - The following function determines the offsets to each field in the +/** The following function determines the offsets to each field in the record. The offsets are written to a previously allocated array of ulint, where rec_offs_n_fields(offsets) has been initialized to the number of fields in the record. The rest of the array will be @@ -395,19 +368,15 @@ UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ulint rec_offs_n_fields( is set (REC_OFFS_SQL_NULL), the field i is NULL. When the second high-order bit of the offset at [i+1] is set (REC_OFFS_EXTERNAL), the field i is being stored externally. */ -void rec_init_offsets( - /*=============*/ - const rec_t *rec, /*!< in: physical record */ - const dict_index_t *index, /*!< in: record descriptor */ - ulint *offsets); /*!< in/out: array of offsets; - in: n=rec_offs_n_fields(offsets) */ +void rec_init_offsets(const rec_t *rec, /*!< in: physical record */ + const dict_index_t *index, /*!< in: record descriptor */ + ulint *offsets); /*!< in/out: array of offsets; + in: n=rec_offs_n_fields(offsets) */ #ifdef UNIV_DEBUG -/************************************************************/ /** - Validates offsets returned by rec_get_offsets(). +/** Validates offsets returned by rec_get_offsets(). @return true if valid */ UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ibool rec_offs_validate( - /*==============*/ const rec_t *rec, /*!< in: record or NULL */ const dict_index_t *index, /*!< in: record descriptor or NULL */ const ulint *offsets) /*!< in: array returned by @@ -455,12 +424,10 @@ UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ibool rec_offs_validate( return (TRUE); } -/************************************************************/ /** - Updates debug data in offsets, in order to avoid bogus +/** Updates debug data in offsets, in order to avoid bogus rec_offs_validate() failures. */ UNIV_INLINE void rec_offs_make_valid( - /*================*/ const rec_t *rec, /*!< in: record */ const dict_index_t *index, /*!< in: record descriptor */ ulint *offsets) /*!< in: array returned by @@ -477,13 +444,11 @@ void rec_offs_make_valid( #define rec_offs_make_valid(rec, index, offsets) ((void)0) #endif /* UNIV_DEBUG */ -/******************************************************/ /** - Determine the offset to each field in a leaf-page record +/** Determine the offset to each field in a leaf-page record in ROW_FORMAT=COMPACT. This is a special case of rec_init_offsets() and rec_get_offsets_func(). */ UNIV_INLINE void rec_init_offsets_comp_ordinary( - /*===========================*/ const rec_t *rec, /*!< in: physical record in ROW_FORMAT=COMPACT */ bool temp, /*!< in: whether to use the @@ -585,13 +550,11 @@ void rec_init_offsets_comp_ordinary( *rec_offs_base(offsets) = (rec - (lens + 1)) | REC_OFFS_COMPACT | any_ext; } -/******************************************************/ /** - The following function is used to test whether the data offsets in the record - are stored in one-byte or two-byte format. +/** The following function is used to test whether the data offsets in the + record are stored in one-byte or two-byte format. @return true if 1-byte form */ -UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ibool rec_get_1byte_offs_flag( - /*====================*/ - const rec_t *rec) /*!< in: physical record */ +UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ibool + rec_get_1byte_offs_flag(const rec_t *rec) /*!< in: physical record */ { #if TRUE != 1 #error "TRUE != 1" @@ -601,15 +564,13 @@ UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ibool rec_get_1byte_offs_flag( REC_OLD_SHORT_SHIFT)); } -/******************************************************/ /** - Returns the offset of nth field end if the record is stored in the 1-byte +/** Returns the offset of nth field end if the record is stored in the 1-byte offsets form. If the field is SQL null, the flag is ORed in the returned value. @return offset of the start of the field, SQL null flag ORed */ -UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ulint rec_1_get_field_end_info( - /*=====================*/ - const rec_t *rec, /*!< in: record */ - ulint n) /*!< in: field index */ +UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ulint + rec_1_get_field_end_info(const rec_t *rec, /*!< in: record */ + ulint n) /*!< in: field index */ { ut_ad(rec_get_1byte_offs_flag(rec)); ut_ad(n < rec_get_n_fields_old(rec)); @@ -617,16 +578,14 @@ UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ulint rec_1_get_field_end_info( return (mach_read_from_1(rec - (REC_N_OLD_EXTRA_BYTES + n + 1))); } -/******************************************************/ /** - Returns the offset of nth field end if the record is stored in the 2-byte +/** Returns the offset of nth field end if the record is stored in the 2-byte offsets form. If the field is SQL null, the flag is ORed in the returned value. @return offset of the start of the field, SQL null flag and extern storage flag ORed */ -UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ulint rec_2_get_field_end_info( - /*=====================*/ - const rec_t *rec, /*!< in: record */ - ulint n) /*!< in: field index */ +UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ulint + rec_2_get_field_end_info(const rec_t *rec, /*!< in: record */ + ulint n) /*!< in: field index */ { ut_ad(!rec_get_1byte_offs_flag(rec)); ut_ad(n < rec_get_n_fields_old(rec)); diff --git a/storage/innobase/rem/rem0cmp.cc b/storage/innobase/rem/rem0cmp.cc index 2d27fd15f565..023fd396b658 100644 --- a/storage/innobase/rem/rem0cmp.cc +++ b/storage/innobase/rem/rem0cmp.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/*******************************************************************/ /** - @file rem/rem0cmp.cc +/** @file rem/rem0cmp.cc Comparison services for records Created 7/1/1994 Heikki Tuuri @@ -117,14 +116,11 @@ int innobase_mysql_cmp(ulint prtype, const byte *a, size_t a_length, return (0); } -/*************************************************************/ /** - Returns TRUE if two columns are equal for comparison purposes. +/** Returns TRUE if two columns are equal for comparison purposes. @return true if the columns are considered equal in comparisons */ -ibool cmp_cols_are_equal( - /*===============*/ - const dict_col_t *col1, /*!< in: column 1 */ - const dict_col_t *col2, /*!< in: column 2 */ - ibool check_charsets) +ibool cmp_cols_are_equal(const dict_col_t *col1, /*!< in: column 1 */ + const dict_col_t *col2, /*!< in: column 2 */ + ibool check_charsets) /*!< in: whether to check charsets */ { if (dtype_is_non_binary_string_type(col1->mtype, col1->prtype) && @@ -235,19 +231,16 @@ static UNIV_COLD int cmp_decimal(const byte *a, unsigned int a_length, return (swap_flag); } -/*************************************************************/ /** - Innobase uses this function to compare two geometry data fields +/** Innobase uses this function to compare two geometry data fields @return 1, 0, -1, if a is greater, equal, less than b, respectively */ -static int cmp_geometry_field( - /*===============*/ - ulint mtype, /*!< in: main type */ - ulint prtype, /*!< in: precise type */ - const byte *a, /*!< in: data field */ - unsigned int a_length, /*!< in: data field length, - not UNIV_SQL_NULL */ - const byte *b, /*!< in: data field */ - unsigned int b_length) /*!< in: data field length, - not UNIV_SQL_NULL */ +static int cmp_geometry_field(ulint mtype, /*!< in: main type */ + ulint prtype, /*!< in: precise type */ + const byte *a, /*!< in: data field */ + unsigned int a_length, /*!< in: data field length, + not UNIV_SQL_NULL */ + const byte *b, /*!< in: data field */ + unsigned int b_length) /*!< in: data field length, + not UNIV_SQL_NULL */ { double x1, x2; double y1, y2; @@ -296,13 +289,11 @@ static int cmp_geometry_field( return (0); } -/*************************************************************/ /** - Innobase uses this function to compare two gis data fields +/** Innobase uses this function to compare two gis data fields @return 1, 0, -1, if mode == PAGE_CUR_MBR_EQUAL. And return 1, 0 for rest compare modes, depends on a and b qualifies the relationship (CONTAINT, WITHIN etc.) */ static int cmp_gis_field( - /*============*/ page_cur_mode_t mode, /*!< in: compare mode */ const byte *a, /*!< in: data field */ unsigned int a_length, /*!< in: data field length, @@ -554,7 +545,6 @@ inline int cmp_data(ulint mtype, ulint prtype, bool is_asc, const byte *data1, @param[in] srs Spatial reference system of R-tree @retval negative if dtuple is less than rec */ int cmp_dtuple_rec_with_gis( - /*====================*/ const dtuple_t *dtuple, /*!< in: data tuple */ const rec_t *rec, /*!< in: physical record which differs from dtuple in some of the common fields, or which @@ -959,13 +949,11 @@ ibool cmp_dtuple_is_prefix_of_rec(const dtuple_t *dtuple, const rec_t *rec, !cmp_dtuple_rec_with_match(dtuple, rec, index, offsets, &matched_fields)); } -/*************************************************************/ /** - Compare two physical record fields. +/** Compare two physical record fields. @retval positive if rec1 field is greater than rec2 @retval negative if rec1 field is less than rec2 @retval 0 if rec1 field equals to rec2 */ static MY_ATTRIBUTE((warn_unused_result)) int cmp_rec_rec_simple_field( - /*=====================*/ const rec_t *rec1, /*!< in: physical record */ const rec_t *rec2, /*!< in: physical record */ const ulint *offsets1, /*!< in: rec_get_offsets(rec1, ...) */ @@ -996,7 +984,6 @@ none of which are stored externally. @retval negative if rec1 (including non-ordering columns) is less than rec2 @retval 0 if rec1 is a duplicate of rec2 */ int cmp_rec_rec_simple( - /*===============*/ const rec_t *rec1, /*!< in: physical record */ const rec_t *rec2, /*!< in: physical record */ const ulint *offsets1, /*!< in: rec_get_offsets(rec1, ...) */ diff --git a/storage/innobase/rem/rem0rec.cc b/storage/innobase/rem/rem0rec.cc index d23501066c08..59739a448c84 100644 --- a/storage/innobase/rem/rem0rec.cc +++ b/storage/innobase/rem/rem0rec.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file rem/rem0rec.cc +/** @file rem/rem0rec.cc Record manager Created 5/30/1994 Heikki Tuuri @@ -156,19 +155,14 @@ end of some field (containing also ). A record is a complete-field prefix of another record, if the corresponding canonical strings have the same property. */ -/***************************************************************/ /** - Validates the consistency of an old-style physical record. +/** Validates the consistency of an old-style physical record. @return true if ok */ -static ibool rec_validate_old( - /*=============*/ - const rec_t *rec); /*!< in: physical record */ +static ibool rec_validate_old(const rec_t *rec); /*!< in: physical record */ -/******************************************************/ /** - Determine how many of the first n columns in a compact +/** Determine how many of the first n columns in a compact physical record are stored externally. @return number of externally stored columns */ ulint rec_get_n_extern_new( - /*=================*/ const rec_t *rec, /*!< in: compact physical record */ const dict_index_t *index, /*!< in: record descriptor */ ulint n) /*!< in: number of columns to scan */ @@ -240,16 +234,13 @@ ulint rec_get_n_extern_new( return (n_extern); } -/************************************************************/ /** - The following function is used to get the offset to the nth +/** The following function is used to get the offset to the nth data field in an old-style record. @return offset to the field */ -ulint rec_get_nth_field_offs_old( - /*=======================*/ - const rec_t *rec, /*!< in: record */ - ulint n, /*!< in: index of the field */ - ulint *len) /*!< out: length of the field; - UNIV_SQL_NULL if SQL null */ +ulint rec_get_nth_field_offs_old(const rec_t *rec, /*!< in: record */ + ulint n, /*!< in: index of the field */ + ulint *len) /*!< out: length of the field; + UNIV_SQL_NULL if SQL null */ { ulint os; ulint next_os; @@ -291,12 +282,10 @@ ulint rec_get_nth_field_offs_old( return (os); } -/**********************************************************/ /** - Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT. +/** Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT. @return total size */ UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ulint rec_get_converted_size_comp_prefix_low( - /*===================================*/ const dict_index_t *index, /*!< in: record descriptor; dict_table_is_comp() is assumed to hold, even if @@ -451,11 +440,9 @@ UNIV_INLINE MY_ATTRIBUTE((warn_unused_result)) ulint return (extra_size + data_size); } -/**********************************************************/ /** - Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT. +/** Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT. @return total size */ ulint rec_get_converted_size_comp_prefix( - /*===============================*/ const dict_index_t *index, /*!< in: record descriptor */ const dfield_t *fields, /*!< in: array of data fields */ ulint n_fields, /*!< in: number of data fields */ @@ -466,11 +453,9 @@ ulint rec_get_converted_size_comp_prefix( extra, false)); } -/**********************************************************/ /** - Determines the size of a data tuple in ROW_FORMAT=COMPACT. +/** Determines the size of a data tuple in ROW_FORMAT=COMPACT. @return total size */ ulint rec_get_converted_size_comp( - /*========================*/ const dict_index_t *index, /*!< in: record descriptor; dict_table_is_comp() is assumed to hold, even if @@ -510,13 +495,10 @@ ulint rec_get_converted_size_comp( NULL, extra, false)); } -/***********************************************************/ /** - Sets the value of the ith field SQL null bit of an old-style record. */ -void rec_set_nth_field_null_bit( - /*=======================*/ - rec_t *rec, /*!< in: record */ - ulint i, /*!< in: ith field */ - ibool val) /*!< in: value to set */ +/** Sets the value of the ith field SQL null bit of an old-style record. */ +void rec_set_nth_field_null_bit(rec_t *rec, /*!< in: record */ + ulint i, /*!< in: ith field */ + ibool val) /*!< in: value to set */ { ulint info; @@ -545,13 +527,10 @@ void rec_set_nth_field_null_bit( rec_2_set_field_end_info(rec, i, info); } -/***********************************************************/ /** - Sets an old-style record field to SQL null. +/** Sets an old-style record field to SQL null. The physical size of the field is not changed. */ -void rec_set_nth_field_sql_null( - /*=======================*/ - rec_t *rec, /*!< in: record */ - ulint n) /*!< in: index of the field */ +void rec_set_nth_field_sql_null(rec_t *rec, /*!< in: record */ + ulint n) /*!< in: index of the field */ { ulint offset; @@ -562,12 +541,10 @@ void rec_set_nth_field_sql_null( rec_set_nth_field_null_bit(rec, n, TRUE); } -/*********************************************************/ /** - Builds an old-style physical record out of a data tuple and +/** Builds an old-style physical record out of a data tuple and stores it beginning from the start of the given buffer. @return pointer to the origin of physical record */ static rec_t *rec_convert_dtuple_to_rec_old( - /*==========================*/ byte *buf, /*!< in: start address of the physical record */ const dtuple_t *dtuple, /*!< in: data tuple */ ulint n_ext) /*!< in: number of externally stored columns */ @@ -665,11 +642,9 @@ static rec_t *rec_convert_dtuple_to_rec_old( return (rec); } -/*********************************************************/ /** - Builds a ROW_FORMAT=COMPACT record out of a data tuple. */ +/** Builds a ROW_FORMAT=COMPACT record out of a data tuple. */ UNIV_INLINE void rec_convert_dtuple_to_rec_comp( - /*===========================*/ rec_t *rec, /*!< in: origin of record */ const dict_index_t *index, /*!< in: record descriptor */ const dfield_t *fields, /*!< in: array of data fields */ @@ -876,12 +851,10 @@ void rec_convert_dtuple_to_rec_comp( mach_write_to_2(end, ptr - end); } -/*********************************************************/ /** - Builds a new-style physical record out of a data tuple and +/** Builds a new-style physical record out of a data tuple and stores it beginning from the start of the given buffer. @return pointer to the origin of physical record */ static rec_t *rec_convert_dtuple_to_rec_new( - /*==========================*/ byte *buf, /*!< in: start address of the physical record */ const dict_index_t *index, /*!< in: record descriptor */ @@ -905,12 +878,10 @@ static rec_t *rec_convert_dtuple_to_rec_new( return (rec); } -/*********************************************************/ /** - Builds a physical record out of a data tuple and +/** Builds a physical record out of a data tuple and stores it beginning from the start of the given buffer. @return pointer to the origin of physical record */ rec_t *rec_convert_dtuple_to_rec( - /*======================*/ byte *buf, /*!< in: start address of the physical record */ const dict_index_t *index, /*!< in: record descriptor */ @@ -958,11 +929,9 @@ rec_t *rec_convert_dtuple_to_rec( } #ifndef UNIV_HOTBACKUP -/**********************************************************/ /** - Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT. +/** Determines the size of a data tuple prefix in ROW_FORMAT=COMPACT. @return total size */ ulint rec_get_converted_size_temp( - /*========================*/ const dict_index_t *index, /*!< in: record descriptor */ const dfield_t *fields, /*!< in: array of data fields */ ulint n_fields, /*!< in: number of data fields */ @@ -974,11 +943,9 @@ ulint rec_get_converted_size_temp( v_entry, extra, true)); } -/******************************************************/ /** - Determine the offset to each field in temporary file. +/** Determine the offset to each field in temporary file. @see rec_convert_dtuple_to_temp() */ void rec_init_offsets_temp( - /*==================*/ const rec_t *rec, /*!< in: temporary file record */ const dict_index_t *index, /*!< in: record descriptor */ ulint *offsets) /*!< in/out: array of offsets; @@ -987,11 +954,9 @@ void rec_init_offsets_temp( rec_init_offsets_comp_ordinary(rec, true, index, offsets); } -/*********************************************************/ /** - Builds a temporary file record out of a data tuple. +/** Builds a temporary file record out of a data tuple. @see rec_init_offsets_temp() */ void rec_convert_dtuple_to_temp( - /*=======================*/ rec_t *rec, /*!< out: record */ const dict_index_t *index, /*!< in: record descriptor */ const dfield_t *fields, /*!< in: array of data fields */ @@ -1003,11 +968,9 @@ void rec_convert_dtuple_to_temp( REC_STATUS_ORDINARY, true); } -/**************************************************************/ /** - Copies the first n fields of a physical record to a data tuple. The fields +/** Copies the first n fields of a physical record to a data tuple. The fields are copied to the memory heap. */ void rec_copy_prefix_to_dtuple( - /*======================*/ dtuple_t *tuple, /*!< out: data tuple */ const rec_t *rec, /*!< in: physical record */ const dict_index_t *index, /*!< in: record descriptor */ @@ -1045,12 +1008,10 @@ void rec_copy_prefix_to_dtuple( } } -/**************************************************************/ /** - Copies the first n fields of an old-style physical record +/** Copies the first n fields of an old-style physical record to a new physical record in a buffer. @return own: copied record */ static rec_t *rec_copy_prefix_to_buf_old( - /*=======================*/ const rec_t *rec, /*!< in: physical record */ ulint n_fields, /*!< in: number of fields to copy */ ulint area_end, /*!< in: end of the prefix data */ @@ -1085,12 +1046,10 @@ static rec_t *rec_copy_prefix_to_buf_old( return (copy_rec); } -/**************************************************************/ /** - Copies the first n fields of a physical record to a new physical record in +/** Copies the first n fields of a physical record to a new physical record in a buffer. @return own: copied record */ rec_t *rec_copy_prefix_to_buf( - /*===================*/ const rec_t *rec, /*!< in: physical record */ const dict_index_t *index, /*!< in: record descriptor */ ulint n_fields, /*!< in: number of fields @@ -1214,12 +1173,9 @@ rec_t *rec_copy_prefix_to_buf( } #endif /* UNIV_HOTBACKUP */ -/***************************************************************/ /** - Validates the consistency of an old-style physical record. +/** Validates the consistency of an old-style physical record. @return true if ok */ -static ibool rec_validate_old( - /*=============*/ - const rec_t *rec) /*!< in: physical record */ +static ibool rec_validate_old(const rec_t *rec) /*!< in: physical record */ { ulint len; ulint n_fields; @@ -1258,11 +1214,9 @@ static ibool rec_validate_old( return (TRUE); } -/***************************************************************/ /** - Validates the consistency of a physical record. +/** Validates the consistency of a physical record. @return true if ok */ ibool rec_validate( - /*=========*/ const rec_t *rec, /*!< in: physical record */ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ { @@ -1309,12 +1263,9 @@ ibool rec_validate( return (TRUE); } -/***************************************************************/ /** - Prints an old-style physical record. */ -void rec_print_old( - /*==========*/ - FILE *file, /*!< in: file where to print */ - const rec_t *rec) /*!< in: physical record */ +/** Prints an old-style physical record. */ +void rec_print_old(FILE *file, /*!< in: file where to print */ + const rec_t *rec) /*!< in: physical record */ { const byte *data; ulint len; @@ -1357,11 +1308,9 @@ void rec_print_old( } #ifndef UNIV_HOTBACKUP -/***************************************************************/ /** - Prints a physical record in ROW_FORMAT=COMPACT. Ignores the +/** Prints a physical record in ROW_FORMAT=COMPACT. Ignores the record header. */ static void rec_print_comp( - /*===========*/ FILE *file, /*!< in: file where to print */ const rec_t *rec, /*!< in: physical record */ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ @@ -1397,12 +1346,9 @@ static void rec_print_comp( } } -/***************************************************************/ /** - Prints an old-style spatial index record. */ -static void rec_print_mbr_old( - /*==============*/ - FILE *file, /*!< in: file where to print */ - const rec_t *rec) /*!< in: physical record */ +/** Prints an old-style spatial index record. */ +static void rec_print_mbr_old(FILE *file, /*!< in: file where to print */ + const rec_t *rec) /*!< in: physical record */ { const byte *data; ulint len; @@ -1467,10 +1413,8 @@ static void rec_print_mbr_old( rec_validate_old(rec); } -/***************************************************************/ /** - Prints a spatial index record. */ +/** Prints a spatial index record. */ void rec_print_mbr_rec( - /*==============*/ FILE *file, /*!< in: file where to print */ const rec_t *rec, /*!< in: physical record */ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ @@ -1532,12 +1476,9 @@ void rec_print_mbr_rec( rec_validate(rec, offsets); } -/***************************************************************/ /** - Prints a physical record. */ -/***************************************************************/ /** - Prints a physical record. */ +/** Prints a physical record. */ +/** Prints a physical record. */ void rec_print_new( - /*==========*/ FILE *file, /*!< in: file where to print */ const rec_t *rec, /*!< in: physical record */ const ulint *offsets) /*!< in: array returned by rec_get_offsets() */ @@ -1569,13 +1510,10 @@ void rec_print_new( rec_validate(rec, offsets); } -/***************************************************************/ /** - Prints a physical record. */ -void rec_print( - /*======*/ - FILE *file, /*!< in: file where to print */ - const rec_t *rec, /*!< in: physical record */ - const dict_index_t *index) /*!< in: record descriptor */ +/** Prints a physical record. */ +void rec_print(FILE *file, /*!< in: file where to print */ + const rec_t *rec, /*!< in: physical record */ + const dict_index_t *index) /*!< in: record descriptor */ { ut_ad(index); @@ -1666,13 +1604,10 @@ std::ostream &operator<<(std::ostream &o, const rec_offsets_print &r) { return (o); } -/************************************************************/ /** - Reads the DB_TRX_ID of a clustered index record. +/** Reads the DB_TRX_ID of a clustered index record. @return the value of DB_TRX_ID */ -trx_id_t rec_get_trx_id( - /*===========*/ - const rec_t *rec, /*!< in: record */ - const dict_index_t *index) /*!< in: clustered index */ +trx_id_t rec_get_trx_id(const rec_t *rec, /*!< in: record */ + const dict_index_t *index) /*!< in: clustered index */ { ulint trx_id_col = index->get_sys_col_pos(DATA_TRX_ID); const byte *trx_id; diff --git a/storage/innobase/row/row0ext.cc b/storage/innobase/row/row0ext.cc index 4a5d2d83758f..3b76754bf345 100644 --- a/storage/innobase/row/row0ext.cc +++ b/storage/innobase/row/row0ext.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file row/row0ext.cc +/** @file row/row0ext.cc Caching of externally stored column prefixes Created September 2006 Marko Makela diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc index a199a19acae1..416c558395f1 100644 --- a/storage/innobase/row/row0ftsort.cc +++ b/storage/innobase/row/row0ftsort.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2010, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2010, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file row/row0ftsort.cc +/** @file row/row0ftsort.cc Create Full Text Index with (parallel) merge sort Created 10/13/2010 Jimmy Yang @@ -64,8 +63,7 @@ this program; if not, write to the Free Software Foundation, Inc., /** Parallel sort degree */ ulong fts_sort_pll_degree = 2; -/*********************************************************************/ /** - Create a temporary "fts sort index" used to merge sort the +/** Create a temporary "fts sort index" used to merge sort the tokenized doc string. The index has three "fields": 1) Tokenized word, @@ -75,7 +73,6 @@ ulong fts_sort_pll_degree = 2; @return dict_index_t structure for the fts sort index */ dict_index_t *row_merge_create_fts_sort_index( - /*============================*/ dict_index_t *index, /*!< in: Original FTS index based on which this sort index is created */ @@ -178,11 +175,9 @@ store Doc ID during sort */ return (new_index); } -/*********************************************************************/ /** - Initialize FTS parallel sort structures. +/** Initialize FTS parallel sort structures. @return true if all successful */ ibool row_fts_psort_info_init( - /*====================*/ trx_t *trx, /*!< in: transaction */ row_merge_dup_t *dup, /*!< in,own: descriptor of FTS index being created */ @@ -297,11 +292,9 @@ ibool row_fts_psort_info_init( return (ret); } -/*********************************************************************/ /** - Clean up and deallocate FTS parallel sort structures, and close the +/** Clean up and deallocate FTS parallel sort structures, and close the merge sort files */ void row_fts_psort_info_destroy( - /*=======================*/ fts_psort_t *psort_info, /*!< parallel sort info */ fts_psort_t *merge_info) /*!< parallel merge info */ { @@ -331,10 +324,8 @@ void row_fts_psort_info_destroy( ut_free(merge_info); } -/*********************************************************************/ /** - Free up merge buffers when merge sort is done */ +/** Free up merge buffers when merge sort is done */ void row_fts_free_pll_merge_buf( - /*=======================*/ fts_psort_t *psort_info) /*!< in: parallel sort info */ { ulint j; @@ -353,12 +344,10 @@ void row_fts_free_pll_merge_buf( return; } -/*********************************************************************/ /** - FTS plugin parser 'myql_add_word' callback function for row merge. +/** FTS plugin parser 'myql_add_word' callback function for row merge. Refer to 'MYSQL_FTPARSER_PARAM' for more detail. @return always returns 0 */ static int row_merge_fts_doc_add_word_for_parser( - /*==================================*/ MYSQL_FTPARSER_PARAM *param, /* in: parser paramter */ char *word, /* in: token word */ int word_len, /* in: word len */ @@ -402,10 +391,8 @@ static int row_merge_fts_doc_add_word_for_parser( return (0); } -/*********************************************************************/ /** - Tokenize by fts plugin parser */ +/** Tokenize by fts plugin parser */ static void row_merge_fts_doc_tokenize_by_parser( - /*=================================*/ fts_doc_t *doc, /* in: doc to tokenize */ st_mysql_ftparser *parser, /* in: plugin parser instance */ fts_tokenize_ctx_t *t_ctx) /* in/out: tokenize ctx instance */ @@ -429,11 +416,9 @@ static void row_merge_fts_doc_tokenize_by_parser( PARSER_DEINIT(parser, ¶m); } -/*********************************************************************/ /** - Tokenize incoming text data and add to the sort buffer. +/** Tokenize incoming text data and add to the sort buffer. @return true if the record passed, false if out of space */ static ibool row_merge_fts_doc_tokenize( - /*=======================*/ row_merge_buf_t **sort_buf, /*!< in/out: sort buffer */ doc_id_t doc_id, /*!< in: Doc ID */ fts_doc_t *doc, /*!< in: Doc to be tokenized */ @@ -671,11 +656,9 @@ static ibool row_merge_fts_doc_tokenize( return (!buf_full); } -/*********************************************************************/ /** - Get next doc item from fts_doc_list */ +/** Get next doc item from fts_doc_list */ UNIV_INLINE void row_merge_fts_get_next_doc_item( - /*============================*/ fts_psort_t *psort_info, /*!< in: psort_info */ fts_doc_item_t **doc_item) /*!< in/out: doc item */ { @@ -1074,11 +1057,9 @@ static dberr_t row_merge_write_fts_node(const fts_psort_insert_t *ins_ctx, return (ret); } -/********************************************************************/ /** - Insert processed FTS data to auxillary index tables. +/** Insert processed FTS data to auxillary index tables. @return DB_SUCCESS if insertion runs fine */ static dberr_t row_merge_write_fts_word( - /*=====================*/ fts_psort_insert_t *ins_ctx, /*!< in: insert context */ fts_tokenizer_word_t *word) /*!< in: sorted and tokenized word */ @@ -1114,11 +1095,9 @@ static dberr_t row_merge_write_fts_word( return (ret); } -/*********************************************************************/ /** - Read sorted FTS data files and insert data tuples to auxillary tables. +/** Read sorted FTS data files and insert data tuples to auxillary tables. */ static void row_fts_insert_tuple( - /*=================*/ fts_psort_insert_t *ins_ctx, /*!< in: insert context */ fts_tokenizer_word_t *word, /*!< in: last processed tokenized word */ @@ -1230,11 +1209,9 @@ static void row_fts_insert_tuple( *in_doc_id = doc_id; } -/*********************************************************************/ /** - Propagate a newly added record up one level in the selection tree +/** Propagate a newly added record up one level in the selection tree @return parent where this value propagated to */ static int row_fts_sel_tree_propagate( - /*=======================*/ int propogated, /*!< in: tree node propagated */ int *sel_tree, /*!< in: selection tree */ const mrec_t **mrec, /*!< in: sort record */ @@ -1274,11 +1251,9 @@ static int row_fts_sel_tree_propagate( return (static_cast(parent)); } -/*********************************************************************/ /** - Readjust selection tree after popping the root and read a new value +/** Readjust selection tree after popping the root and read a new value @return the new root */ static int row_fts_sel_tree_update( - /*====================*/ int *sel_tree, /*!< in/out: selection tree */ ulint propagated, /*!< in: node to propagate up */ ulint height, /*!< in: tree height */ @@ -1296,10 +1271,8 @@ static int row_fts_sel_tree_update( return (sel_tree[0]); } -/*********************************************************************/ /** - Build selection tree at a specified level */ +/** Build selection tree at a specified level */ static void row_fts_build_sel_tree_level( - /*=========================*/ int *sel_tree, /*!< in/out: selection tree */ ulint level, /*!< in: selection tree level */ const mrec_t **mrec, /*!< in: sort record */ @@ -1353,12 +1326,10 @@ static void row_fts_build_sel_tree_level( } } -/*********************************************************************/ /** - Build a selection tree for merge. The selection tree is a binary tree +/** Build a selection tree for merge. The selection tree is a binary tree and should have fts_sort_pll_degree / 2 levels. With root as level 0 @return number of tree levels */ static ulint row_fts_build_sel_tree( - /*===================*/ int *sel_tree, /*!< in/out: selection tree */ const mrec_t **mrec, /*!< in: sort record */ ulint **offsets, /*!< in: record offsets */ diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index 9d8a99b1db52..4594f383c346 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2012, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2012, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file row/row0import.cc +/** @file row/row0import.cc Import a tablespace to a running instance. Created 2012-02-08 by Sunny Bains. @@ -1994,12 +1993,10 @@ dberr_t PageConverter::operator()(os_offset_t offset, return (err); } -/*****************************************************************/ /** - Clean up after import tablespace failure, this function will acquire +/** Clean up after import tablespace failure, this function will acquire the dictionary latches on behalf of the transaction if the transaction hasn't already acquired them. */ static void row_import_discard_changes( - /*=======================*/ row_prebuilt_t *prebuilt, /*!< in/out: prebuilt from handler */ trx_t *trx, /*!< in/out: transaction for import */ dberr_t err) /*!< in: error code */ @@ -2037,10 +2034,8 @@ static void row_import_discard_changes( ut_a(err == DB_SUCCESS || err == DB_TABLESPACE_NOT_FOUND); } -/*****************************************************************/ /** - Clean up after import tablespace. */ +/** Clean up after import tablespace. */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_import_cleanup( - /*===============*/ row_prebuilt_t *prebuilt, /*!< in/out: prebuilt from handler */ trx_t *trx, /*!< in/out: transaction for import */ dberr_t err) /*!< in: error code */ @@ -2073,10 +2068,8 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_import_cleanup( return (err); } -/*****************************************************************/ /** - Report error during tablespace import. */ +/** Report error during tablespace import. */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_import_error( - /*=============*/ row_prebuilt_t *prebuilt, /*!< in/out: prebuilt from handler */ trx_t *trx, /*!< in/out: transaction for import */ dberr_t err) /*!< in: error code */ @@ -2094,13 +2087,11 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_import_error( return (row_import_cleanup(prebuilt, trx, err)); } -/*****************************************************************/ /** - Adjust the root page index node and leaf node segment headers, update +/** Adjust the root page index node and leaf node segment headers, update with the new space id. For all the table's secondary indexes. @return error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_import_adjust_root_pages_of_secondary_indexes( - /*==============================================*/ row_prebuilt_t *prebuilt, /*!< in/out: prebuilt from handler */ trx_t *trx, /*!< in: transaction used for @@ -2196,11 +2187,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t return (err); } -/*****************************************************************/ /** - Ensure that dict_sys->row_id exceeds SELECT MAX(DB_ROW_ID). +/** Ensure that dict_sys->row_id exceeds SELECT MAX(DB_ROW_ID). @return error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_import_set_sys_max_row_id( - /*==========================*/ row_prebuilt_t *prebuilt, /*!< in/out: prebuilt from handler */ dict_table_t *table) /*!< in: table to import */ @@ -2289,11 +2278,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_import_set_sys_max_row_id( return (DB_SUCCESS); } -/*****************************************************************/ /** - Read the a string from the meta data file. +/** Read the a string from the meta data file. @return DB_SUCCESS or error code. */ static dberr_t row_import_cfg_read_string( - /*=======================*/ FILE *file, /*!< in/out: File to read from */ byte *ptr, /*!< out: string to read */ ulint max_len) /*!< in: maximum length of the output @@ -2329,12 +2316,10 @@ static dberr_t row_import_cfg_read_string( return (DB_IO_ERROR); } -/*********************************************************************/ /** - Write the meta data (index user fields) config file. +/** Write the meta data (index user fields) config file. @return DB_SUCCESS or error code. */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_import_cfg_read_index_fields( - /*=============================*/ FILE *file, /*!< in: file to write to */ THD *thd, /*!< in/out: session */ row_index_t *index, /*!< Index being read in */ @@ -2404,15 +2389,13 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t return (DB_SUCCESS); } -/*****************************************************************/ /** - Read the index names and root page numbers of the indexes and set the values. - Row format [root_page_no, len of str, str ... ] +/** Read the index names and root page numbers of the indexes and set the + values. Row format [root_page_no, len of str, str ... ] @return DB_SUCCESS or error code. */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_import_read_index_data( - /*=======================*/ - FILE *file, /*!< in: File to read from */ - THD *thd, /*!< in: session */ - row_import *cfg) /*!< in/out: meta-data read */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + row_import_read_index_data(FILE *file, /*!< in: File to read from */ + THD *thd, /*!< in: session */ + row_import *cfg) /*!< in/out: meta-data read */ { byte *ptr; row_index_t *cfg_index; @@ -2543,11 +2526,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_import_read_index_data( return (DB_SUCCESS); } -/*****************************************************************/ /** - Set the index root page number for v1 format. +/** Set the index root page number for v1 format. @return DB_SUCCESS or error code. */ static dberr_t row_import_read_indexes( - /*====================*/ FILE *file, /*!< in: File to read from */ THD *thd, /*!< in: session */ row_import *cfg) /*!< in/out: meta-data read */ @@ -2587,14 +2568,12 @@ static dberr_t row_import_read_indexes( return (row_import_read_index_data(file, thd, cfg)); } -/*********************************************************************/ /** - Read the meta data (table columns) config file. Deserialise the contents of +/** Read the meta data (table columns) config file. Deserialise the contents of dict_col_t structure, along with the column name. */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_import_read_columns( - /*====================*/ - FILE *file, /*!< in: file to write to */ - THD *thd, /*!< in/out: session */ - row_import *cfg) /*!< in/out: meta-data read */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + row_import_read_columns(FILE *file, /*!< in: file to write to */ + THD *thd, /*!< in/out: session */ + row_import *cfg) /*!< in/out: meta-data read */ { dict_col_t *col; byte row[sizeof(ib_uint32_t) * 8]; @@ -2701,14 +2680,12 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_import_read_columns( return (DB_SUCCESS); } -/*****************************************************************/ /** - Read the contents of the @.cfg file. +/** Read the contents of the @.cfg file. @return DB_SUCCESS or error code. */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_import_read_v1( - /*===============*/ - FILE *file, /*!< in: File to read from */ - THD *thd, /*!< in: session */ - row_import *cfg) /*!< out: meta data */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + row_import_read_v1(FILE *file, /*!< in: File to read from */ + THD *thd, /*!< in: session */ + row_import *cfg) /*!< out: meta data */ { byte value[sizeof(ib_uint32_t)]; @@ -2891,7 +2868,6 @@ static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t Read the contents of the @.cfg file. @return DB_SUCCESS or error code. */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_import_read_meta_data( - /*======================*/ dict_table_t *table, /*!< in: table */ FILE *file, /*!< in: File to read from */ THD *thd, /*!< in: session */ diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 0097aff0004f..2a0e832829d8 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file row/row0ins.cc +/** @file row/row0ins.cc Insert into a table Created 4/20/1996 Heikki Tuuri @@ -75,11 +74,9 @@ check. If you make a change in this module make sure that no codepath is introduced where a call to log_free_check() is bypassed. */ -/*********************************************************************/ /** - Creates an insert node struct. +/** Creates an insert node struct. @return own: insert node struct */ ins_node_t *ins_node_create( - /*============*/ ulint ins_type, /*!< in: INS_VALUES, ... */ dict_table_t *table, /*!< in: table where to insert */ mem_heap_t *heap) /*!< in: mem heap where created */ @@ -109,10 +106,8 @@ ins_node_t *ins_node_create( return (node); } -/***********************************************************/ /** - Creates an entry template for each index of a table. */ +/** Creates an entry template for each index of a table. */ static void ins_node_create_entry_list( - /*=======================*/ ins_node_t *node) /*!< in: row insert node */ { dict_index_t *index; @@ -134,11 +129,8 @@ static void ins_node_create_entry_list( } } -/*****************************************************************/ /** - Adds system field buffers to a row. */ -static void row_ins_alloc_sys_fields( - /*=====================*/ - ins_node_t *node) /*!< in: insert node */ +/** Adds system field buffers to a row. */ +static void row_ins_alloc_sys_fields(ins_node_t *node) /*!< in: insert node */ { dtuple_t *row; dict_table_t *table; @@ -192,12 +184,10 @@ static void row_ins_alloc_sys_fields( } } -/*********************************************************************/ /** - Sets a new row to insert for an INS_DIRECT node. This function is only used +/** Sets a new row to insert for an INS_DIRECT node. This function is only used if we have constructed the row separately, which is a rare case; this function is quite slow. */ void ins_node_set_new_row( - /*=================*/ ins_node_t *node, /*!< in: insert node */ dtuple_t *row) /*!< in: new row (or first row) for the node */ { @@ -224,14 +214,12 @@ void ins_node_set_new_row( node->trx_id = 0; } -/*******************************************************************/ /** - Does an insert operation by updating a delete-marked existing record +/** Does an insert operation by updating a delete-marked existing record in the index. This situation can occur if the delete-marked record is kept in the index for consistent reads. @return DB_SUCCESS or error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_ins_sec_index_entry_by_modify( - /*==============================*/ ulint flags, /*!< in: undo logging and locking flags */ ulint mode, /*!< in: BTR_MODIFY_LEAF or BTR_MODIFY_TREE, depending on whether mtr holds just a leaf @@ -314,14 +302,12 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t return (err); } -/*******************************************************************/ /** - Does an insert operation by delete unmarking and updating a delete marked +/** Does an insert operation by delete unmarking and updating a delete marked existing record in the index. This situation can occur if the delete marked record is kept in the index for consistent reads. @return DB_SUCCESS, DB_FAIL, or error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_ins_clust_index_entry_by_modify( - /*================================*/ btr_pcur_t *pcur, /*!< in/out: a persistent cursor pointing to the clust_rec that is being modified. */ ulint flags, /*!< in: undo logging and locking flags */ @@ -405,12 +391,10 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t return (err); } -/*********************************************************************/ /** - Returns TRUE if in a cascaded update/delete an ancestor node of node +/** Returns TRUE if in a cascaded update/delete an ancestor node of node updates (not DELETE, but UPDATE) table. @return true if an ancestor updates table */ static ibool row_ins_cascade_ancestor_updates_table( - /*===================================*/ que_node_t *node, /*!< in: node in a query graph */ dict_table_t *table) /*!< in: table */ { @@ -431,12 +415,10 @@ static ibool row_ins_cascade_ancestor_updates_table( return (FALSE); } -/*********************************************************************/ /** - Returns the number of ancestor UPDATE or DELETE nodes of a +/** Returns the number of ancestor UPDATE or DELETE nodes of a cascaded update/delete node. @return number of ancestors */ static MY_ATTRIBUTE((warn_unused_result)) ulint row_ins_cascade_n_ancestors( - /*========================*/ que_node_t *node) /*!< in: node in a query graph */ { que_node_t *parent; @@ -451,15 +433,13 @@ static MY_ATTRIBUTE((warn_unused_result)) ulint row_ins_cascade_n_ancestors( return (n_ancestors); } -/******************************************************************/ /** - Calculates the update vector node->cascade->update for a child table in +/** Calculates the update vector node->cascade->update for a child table in a cascaded update. @return number of fields in the calculated update vector; the value can also be 0 if no foreign key fields changed; the returned value is ULINT_UNDEFINED if the column type in the child table is too short to fit the new value in the parent table: that means the update fails */ static MY_ATTRIBUTE((warn_unused_result)) ulint row_ins_cascade_calc_update_vec( - /*============================*/ upd_node_t *node, /*!< in: update node of the parent table */ dict_foreign_t *foreign, /*!< in: foreign key constraint whose @@ -681,11 +661,9 @@ static MY_ATTRIBUTE((warn_unused_result)) ulint row_ins_cascade_calc_update_vec( return (n_fields_updated); } -/*********************************************************************/ /** - Set detailed error message associated with foreign key errors for +/** Set detailed error message associated with foreign key errors for the given transaction. */ static void row_ins_set_detailed( - /*=================*/ trx_t *trx, /*!< in: transaction */ dict_foreign_t *foreign) /*!< in: foreign key constraint */ { @@ -706,13 +684,10 @@ static void row_ins_set_detailed( mutex_exit(&srv_misc_tmpfile_mutex); } -/*********************************************************************/ /** - Acquires dict_foreign_err_mutex, rewinds dict_foreign_err_file +/** Acquires dict_foreign_err_mutex, rewinds dict_foreign_err_file and displays information about the given transaction. The caller must release dict_foreign_err_mutex. */ -static void row_ins_foreign_trx_print( - /*======================*/ - trx_t *trx) /*!< in: transaction */ +static void row_ins_foreign_trx_print(trx_t *trx) /*!< in: transaction */ { ulint n_rec_locks; ulint n_trx_locks; @@ -743,11 +718,9 @@ static void row_ins_foreign_trx_print( ut_ad(mutex_own(&dict_foreign_err_mutex)); } -/*********************************************************************/ /** - Reports a foreign key error associated with an update or a delete of a +/** Reports a foreign key error associated with an update or a delete of a parent table index entry. */ static void row_ins_foreign_report_err( - /*=======================*/ const char *errstr, /*!< in: error string from the viewpoint of the parent table */ que_thr_t *thr, /*!< in: query thread whose run_node @@ -795,12 +768,10 @@ static void row_ins_foreign_report_err( mutex_exit(&dict_foreign_err_mutex); } -/*********************************************************************/ /** - Reports a foreign key error to dict_foreign_err_file when we are trying +/** Reports a foreign key error to dict_foreign_err_file when we are trying to add an index entry to a child table. Note that the adding may be the result of an update, too. */ static void row_ins_foreign_report_add_err( - /*===========================*/ trx_t *trx, /*!< in: transaction */ dict_foreign_t *foreign, /*!< in: foreign key constraint */ const rec_t *rec, /*!< in: a record in the parent table: @@ -947,14 +918,12 @@ static void row_ins_foreign_fill_virtual(trx_t *trx, upd_node_t *cascade, } } -/*********************************************************************/ /** - Perform referential actions or checks when a parent row is deleted or updated - and the constraint had an ON DELETE or ON UPDATE condition which was not - RESTRICT. +/** Perform referential actions or checks when a parent row is deleted or + updated and the constraint had an ON DELETE or ON UPDATE condition which was + not RESTRICT. @return DB_SUCCESS, DB_LOCK_WAIT, or error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_ins_foreign_check_on_constraint( - /*================================*/ que_thr_t *thr, /*!< in: query thread whose run_node is an update node */ dict_foreign_t *foreign, /*!< in: foreign key constraint whose @@ -1316,12 +1285,10 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t DBUG_RETURN(err); } -/*********************************************************************/ /** - Sets a shared lock on a record. Used in locking possible duplicate key +/** Sets a shared lock on a record. Used in locking possible duplicate key records and also in checking foreign key constraints. @return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, or error code */ static dberr_t row_ins_set_shared_rec_lock( - /*========================*/ ulint type, /*!< in: LOCK_ORDINARY, LOCK_GAP, or LOCK_REC_NOT_GAP type lock */ const buf_block_t *block, /*!< in: buffer block of rec */ @@ -1345,12 +1312,10 @@ static dberr_t row_ins_set_shared_rec_lock( return (err); } -/*********************************************************************/ /** - Sets a exclusive lock on a record. Used in locking possible duplicate key +/** Sets a exclusive lock on a record. Used in locking possible duplicate key records @return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, or error code */ static dberr_t row_ins_set_exclusive_rec_lock( - /*===========================*/ ulint type, /*!< in: LOCK_ORDINARY, LOCK_GAP, or LOCK_REC_NOT_GAP type lock */ const buf_block_t *block, /*!< in: buffer block of rec */ @@ -1384,13 +1349,11 @@ class ib_dec_in_dtor { ulint &counter; }; -/***************************************************************/ /** - Checks if foreign key constraint fails for an index entry. Sets shared locks +/** Checks if foreign key constraint fails for an index entry. Sets shared locks which lock either the success or the failure of the constraint. NOTE that the caller must have a shared latch on dict_operation_lock. @return DB_SUCCESS, DB_NO_REFERENCED_ROW, or DB_ROW_IS_REFERENCED */ dberr_t row_ins_check_foreign_constraint( - /*=============================*/ ibool check_ref, /*!< in: TRUE if we want to check that the referenced table is ok, FALSE if we want to check the foreign key table */ @@ -1766,8 +1729,7 @@ dberr_t row_ins_check_foreign_constraint( DBUG_RETURN(err); } -/***************************************************************/ /** - Checks if foreign key constraints fail for an index entry. If index +/** Checks if foreign key constraints fail for an index entry. If index is not mentioned in any constraint, this function does nothing, Otherwise does searches to the indexes of referenced tables and sets shared locks which lock either the success or the failure of @@ -1775,7 +1737,6 @@ dberr_t row_ins_check_foreign_constraint( @return DB_SUCCESS or error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_ins_check_foreign_constraints( - /*==============================*/ dict_table_t *table, /*!< in: table */ dict_index_t *index, /*!< in: index */ dtuple_t *entry, /*!< in: index entry for index */ @@ -1840,12 +1801,10 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t return (DB_SUCCESS); } -/***************************************************************/ /** - Checks if a unique key violation to rec would occur at the index entry +/** Checks if a unique key violation to rec would occur at the index entry insert. @return true if error */ static ibool row_ins_dupl_error_with_rec( - /*========================*/ const rec_t *rec, /*!< in: user record; NOTE that we assume that the caller already has a record lock on the record! */ @@ -1883,14 +1842,12 @@ static ibool row_ins_dupl_error_with_rec( return (!rec_get_deleted_flag(rec, rec_offs_comp(offsets))); } -/***************************************************************/ /** - Scans a unique non-clustered index at a given index entry to determine +/** Scans a unique non-clustered index at a given index entry to determine whether a uniqueness violation has occurred for the key value of the entry. Set shared locks on possible duplicate records. @return DB_SUCCESS, DB_DUPLICATE_KEY, or DB_LOCK_WAIT */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_ins_scan_sec_index_for_duplicate( - /*=================================*/ ulint flags, /*!< in: undo logging and locking flags */ dict_index_t *index, /*!< in: non-clustered unique index */ dtuple_t *entry, /*!< in: index entry */ @@ -2093,7 +2050,6 @@ a newer version of entry (the entry should not be inserted) @retval DB_DUPLICATE_KEY when entry is a duplicate of rec */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_ins_duplicate_error_in_clust_online( - /*====================================*/ ulint n_uniq, /*!< in: offset of DB_TRX_ID */ const dtuple_t *entry, /*!< in: entry that is being inserted */ const btr_cur_t *cursor, /*!< in: cursor on insert position */ @@ -2123,8 +2079,7 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t return (err); } -/***************************************************************/ /** - Checks if a unique key violation error would occur at an index entry +/** Checks if a unique key violation error would occur at an index entry insert. Sets shared locks on possible duplicate records. Works only for a clustered index! @retval DB_SUCCESS if no error @@ -2135,7 +2090,6 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t in online table rebuild (flags & (BTR_KEEP_SYS_FLAG | BTR_NO_LOCKING_FLAG)) */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_ins_duplicate_error_in_clust( - /*=============================*/ ulint flags, /*!< in: undo logging and locking flags */ btr_cur_t *cursor, /*!< in: B-tree cursor */ const dtuple_t *entry, /*!< in: entry to insert */ @@ -2270,8 +2224,7 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t return (err); } -/***************************************************************/ /** - Checks if an index entry has long enough common prefix with an +/** Checks if an index entry has long enough common prefix with an existing record so that the intended insert of the entry must be changed to a modify of the existing record. In the case of a clustered index, the prefix must be n_unique fields long. In the case of a @@ -2282,9 +2235,7 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t but we do not do so, because it could have some locking implications. @return true if the existing record should be updated; false if not */ UNIV_INLINE -ibool row_ins_must_modify_rec( - /*====================*/ - const btr_cur_t *cursor) /*!< in: B-tree cursor */ +ibool row_ins_must_modify_rec(const btr_cur_t *cursor) /*!< in: B-tree cursor */ { /* NOTE: (compare to the note in row_ins_duplicate_error_in_clust) Because node pointers on upper levels of the B-tree may match more @@ -2379,8 +2330,7 @@ static void row_ins_temp_prebuilt_tree_modified(dict_table_t *table) { } } -/***************************************************************/ /** - Tries to insert an entry into a clustered index, ignoring foreign key +/** Tries to insert an entry into a clustered index, ignoring foreign key constraints. If a record with the same unique key is found, the other record is necessarily marked deleted by a committed transaction, or a unique key violation error occurs. The delete marked record is then @@ -2391,7 +2341,6 @@ static void row_ins_temp_prebuilt_tree_modified(dict_table_t *table) { @retval DB_FAIL if retry with BTR_MODIFY_TREE is needed @return error code */ dberr_t row_ins_clust_index_entry_low( - /*==========================*/ ulint flags, /*!< in: undo logging and locking flags */ ulint mode, /*!< in: BTR_MODIFY_LEAF or BTR_MODIFY_TREE, depending on whether we wish optimistic or @@ -3126,14 +3075,12 @@ dberr_t row_ins_sec_index_entry_low(ulint flags, ulint mode, DBUG_RETURN(err); } -/***************************************************************/ /** - Inserts an entry into a clustered index. Tries first optimistic, +/** Inserts an entry into a clustered index. Tries first optimistic, then pessimistic descent down the tree. If the entry matches enough to a delete marked record, performs the insert by updating or delete unmarking the delete marked record. @return DB_SUCCESS, DB_LOCK_WAIT, DB_DUPLICATE_KEY, or some other error code */ dberr_t row_ins_clust_index_entry( - /*======================*/ dict_index_t *index, /*!< in: clustered index */ dtuple_t *entry, /*!< in/out: index entry to insert */ que_thr_t *thr, /*!< in: query thread */ @@ -3215,14 +3162,12 @@ and return. don't execute actual insert. */ DBUG_RETURN(err); } -/***************************************************************/ /** - Inserts an entry into a secondary index. Tries first optimistic, +/** Inserts an entry into a secondary index. Tries first optimistic, then pessimistic descent down the tree. If the entry matches enough to a delete marked record, performs the insert by updating or delete unmarking the delete marked record. @return DB_SUCCESS, DB_LOCK_WAIT, DB_DUPLICATE_KEY, or some other error code */ dberr_t row_ins_sec_index_entry( - /*====================*/ dict_index_t *index, /*!< in: secondary index */ dtuple_t *entry, /*!< in/out: index entry to insert */ que_thr_t *thr, /*!< in: query thread */ @@ -3297,14 +3242,12 @@ and return. don't execute actual insert. */ return (err); } -/***************************************************************/ /** - Inserts an index entry to index. Tries first optimistic, then pessimistic +/** Inserts an index entry to index. Tries first optimistic, then pessimistic descent down the tree. If the entry matches enough to a delete marked record, performs the insert by updating or delete unmarking the delete marked record. @return DB_SUCCESS, DB_LOCK_WAIT, DB_DUPLICATE_KEY, or some other error code */ static dberr_t row_ins_index_entry( - /*================*/ dict_index_t *index, /*!< in: index */ dtuple_t *entry, /*!< in/out: index entry to insert */ que_thr_t *thr) /*!< in: query thread */ @@ -3323,11 +3266,9 @@ static dberr_t row_ins_index_entry( } } -/*****************************************************************/ /** - This function generate MBR (Minimum Bounding Box) for spatial objects +/** This function generate MBR (Minimum Bounding Box) for spatial objects and set it to spatial index field. */ static void row_ins_spatial_index_entry_set_mbr_field( - /*======================================*/ dfield_t *field, /*!< in/out: mbr field */ const dfield_t *row_field, /*!< in: row field */ uint32_t *srid, /*!< in/out: spatial reference id */ @@ -3432,14 +3373,12 @@ dberr_t row_ins_index_entry_set_vals(const dict_index_t *index, dtuple_t *entry, return (DB_SUCCESS); } -/***********************************************************/ /** - Inserts a single index entry to the table. +/** Inserts a single index entry to the table. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_ins_index_entry_step( - /*=====================*/ - ins_node_t *node, /*!< in: row insert node */ - que_thr_t *thr) /*!< in: query thread */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + row_ins_index_entry_step(ins_node_t *node, /*!< in: row insert node */ + que_thr_t *thr) /*!< in: query thread */ { dberr_t err; @@ -3463,12 +3402,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_ins_index_entry_step( DBUG_RETURN(err); } -/***********************************************************/ /** - Allocates a row id for row and inits the node->index field. */ +/** Allocates a row id for row and inits the node->index field. */ UNIV_INLINE -void row_ins_alloc_row_id_step( - /*======================*/ - ins_node_t *node) /*!< in: row insert node */ +void row_ins_alloc_row_id_step(ins_node_t *node) /*!< in: row insert node */ { row_id_t row_id; @@ -3487,12 +3423,9 @@ void row_ins_alloc_row_id_step( dict_sys_write_row_id(node->row_id_buf, row_id); } -/***********************************************************/ /** - Gets a row to insert from the values list. */ +/** Gets a row to insert from the values list. */ UNIV_INLINE -void row_ins_get_row_from_values( - /*========================*/ - ins_node_t *node) /*!< in: row insert node */ +void row_ins_get_row_from_values(ins_node_t *node) /*!< in: row insert node */ { que_node_t *list_node; dfield_t *dfield; @@ -3519,12 +3452,9 @@ void row_ins_get_row_from_values( } } -/***********************************************************/ /** - Gets a row to insert from the select list. */ +/** Gets a row to insert from the select list. */ UNIV_INLINE -void row_ins_get_row_from_select( - /*========================*/ - ins_node_t *node) /*!< in: row insert node */ +void row_ins_get_row_from_select(ins_node_t *node) /*!< in: row insert node */ { que_node_t *list_node; dfield_t *dfield; @@ -3549,14 +3479,12 @@ void row_ins_get_row_from_select( } } -/***********************************************************/ /** - Inserts a row to a table. +/** Inserts a row to a table. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_ins( - /*====*/ - ins_node_t *node, /*!< in: row insert node */ - que_thr_t *thr) /*!< in: query thread */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + row_ins(ins_node_t *node, /*!< in: row insert node */ + que_thr_t *thr) /*!< in: query thread */ { dberr_t err; @@ -3665,13 +3593,10 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_ins( DBUG_RETURN(node->duplicate ? DB_DUPLICATE_KEY : DB_SUCCESS); } -/***********************************************************/ /** - Inserts a row to a table. This is a high-level function used in SQL execution - graphs. +/** Inserts a row to a table. This is a high-level function used in SQL + execution graphs. @return query thread to run next or NULL */ -que_thr_t *row_ins_step( - /*=========*/ - que_thr_t *thr) /*!< in: query thread */ +que_thr_t *row_ins_step(que_thr_t *thr) /*!< in: query thread */ { ins_node_t *node; que_node_t *parent; diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc index f207a18d8996..c4674793016f 100644 --- a/storage/innobase/row/row0log.cc +++ b/storage/innobase/row/row0log.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file row/row0log.cc +/** @file row/row0log.cc Modification log for online index creation and online table rebuild Created 2011-05-26 Marko Makela @@ -260,10 +259,8 @@ static void row_log_block_free(row_log_buf_t &log_buf) { DBUG_VOID_RETURN; } -/******************************************************/ /** - Logs an operation to a secondary index that is (or was) being created. */ +/** Logs an operation to a secondary index that is (or was) being created. */ void row_log_online_op( - /*==============*/ dict_index_t *index, /*!< in/out: index, S or X latched */ const dtuple_t *tuple, /*!< in: index tuple */ trx_id_t trx_id) /*!< in: transaction ID for insert, @@ -390,11 +387,9 @@ void row_log_online_op( mutex_exit(&log->mutex); } -/******************************************************/ /** - Gets the error status of the online index rebuild log. +/** Gets the error status of the online index rebuild log. @return DB_SUCCESS or error code */ dberr_t row_log_table_get_error( - /*====================*/ const dict_index_t *index) /*!< in: clustered index of a table that is being rebuilt online */ { @@ -403,11 +398,9 @@ dberr_t row_log_table_get_error( return (index->online_log->error); } -/******************************************************/ /** - Starts logging an operation to a table that is being rebuilt. +/** Starts logging an operation to a table that is being rebuilt. @return pointer to log, or NULL if no logging is necessary */ static MY_ATTRIBUTE((warn_unused_result)) byte *row_log_table_open( - /*===============*/ row_log_t *log, /*!< in/out: online rebuild log */ ulint size, /*!< in: size of log record */ ulint *avail) /*!< out: available size for log record */ @@ -439,10 +432,8 @@ static MY_ATTRIBUTE((warn_unused_result)) byte *row_log_table_open( } } -/******************************************************/ /** - Stops logging an operation to a table that is being rebuilt. */ +/** Stops logging an operation to a table that is being rebuilt. */ static void row_log_table_close_func( - /*=====================*/ row_log_t *log, /*!< in/out: online rebuild log */ #ifdef UNIV_DEBUG const byte *b, /*!< in: end of log record */ @@ -516,11 +507,9 @@ bool row_log_col_is_indexed(const dict_index_t *index, ulint v_no) { dict_table_get_nth_v_col(index->online_log->table, v_no)->m_col.ord_part); } -/******************************************************/ /** - Logs a delete operation to a table that is being rebuilt. +/** Logs a delete operation to a table that is being rebuilt. This will be merged in row_log_table_apply_delete(). */ void row_log_table_delete( - /*=================*/ trx_t *trx, /*!< in: current transaction */ const rec_t *rec, /*!< in: clustered index leaf page record, page X-latched */ @@ -640,10 +629,8 @@ void row_log_table_delete( mem_heap_free(heap); } -/******************************************************/ /** - Logs an insert or update to a table that is being rebuilt. */ +/** Logs an insert or update to a table that is being rebuilt. */ static void row_log_table_low_redundant( - /*========================*/ const rec_t *rec, /*!< in: clustered index leaf page record in ROW_FORMAT=REDUNDANT, page X-latched */ @@ -791,10 +778,8 @@ new table, not latched */ mem_heap_free(heap); } -/******************************************************/ /** - Logs an insert or update to a table that is being rebuilt. */ +/** Logs an insert or update to a table that is being rebuilt. */ static void row_log_table_low( - /*==============*/ const rec_t *rec, /*!< in: clustered index leaf page record, page X-latched */ const dtuple_t *ventry, /*!< in: dtuple holding virtual column info */ @@ -934,11 +919,9 @@ static void row_log_table_low( } } -/******************************************************/ /** - Logs an update to a table that is being rebuilt. +/** Logs an update to a table that is being rebuilt. This will be merged in row_log_table_apply_update(). */ void row_log_table_update( - /*=================*/ const rec_t *rec, /*!< in: clustered index leaf page record, page X-latched */ dict_index_t *index, /*!< in/out: clustered index, S-latched @@ -959,9 +942,9 @@ void row_log_table_update( @param col_map mapping of old column numbers to new ones @param col_no column position in the new table @return old table column, or NULL if this is an added column */ -static const dict_col_t *row_log_table_get_pk_old_col( - /*=========================*/ - const dict_table_t *table, const ulint *col_map, ulint col_no) { +static const dict_col_t *row_log_table_get_pk_old_col(const dict_table_t *table, + const ulint *col_map, + ulint col_no) { for (ulint i = 0; i < table->n_cols; i++) { if (col_no == col_map[i]) { return (table->get_col(i)); @@ -1031,13 +1014,11 @@ static dberr_t row_log_table_get_pk_col(trx_t *trx, dict_index_t *index, return (DB_SUCCESS); } -/******************************************************/ /** - Constructs the old PRIMARY KEY and DB_TRX_ID,DB_ROLL_PTR +/** Constructs the old PRIMARY KEY and DB_TRX_ID,DB_ROLL_PTR of a table that is being rebuilt. @return tuple of PRIMARY KEY,DB_TRX_ID,DB_ROLL_PTR in the rebuilt table, or NULL if the PRIMARY KEY definition does not change */ const dtuple_t *row_log_table_get_pk( - /*=================*/ trx_t *trx, /*!< in: current transaction */ const rec_t *rec, /*!< in: clustered index leaf page record, page X-latched */ @@ -1201,11 +1182,9 @@ const dtuple_t *row_log_table_get_pk( return (tuple); } -/******************************************************/ /** - Logs an insert to a table that is being rebuilt. +/** Logs an insert to a table that is being rebuilt. This will be merged in row_log_table_apply_insert(). */ void row_log_table_insert( - /*=================*/ const rec_t *rec, /*!< in: clustered index leaf page record, page X-latched */ const dtuple_t *ventry, /*!< in: dtuple holding virtual column info */ @@ -1216,10 +1195,8 @@ void row_log_table_insert( row_log_table_low(rec, ventry, NULL, index, offsets, true, NULL); } -/******************************************************/ /** - Notes that a BLOB is being freed during online ALTER TABLE. */ +/** Notes that a BLOB is being freed during online ALTER TABLE. */ void row_log_table_blob_free( - /*====================*/ dict_index_t *index, /*!< in/out: clustered index, X-latched */ page_no_t page_no) /*!< in: starting page number of the BLOB */ { @@ -1260,10 +1237,8 @@ void row_log_table_blob_free( DBUG_VOID_RETURN; } -/******************************************************/ /** - Notes that a BLOB is being allocated during online ALTER TABLE. */ +/** Notes that a BLOB is being allocated during online ALTER TABLE. */ void row_log_table_blob_alloc( - /*=====================*/ dict_index_t *index, /*!< in/out: clustered index, X-latched */ page_no_t page_no) /*!< in: starting page number of the BLOB */ { @@ -1294,12 +1269,10 @@ void row_log_table_blob_alloc( DBUG_VOID_RETURN; } -/******************************************************/ /** - Converts a log record to a table row. +/** Converts a log record to a table row. @return converted row, or NULL if the conversion fails */ static MY_ATTRIBUTE((warn_unused_result)) const dtuple_t *row_log_table_apply_convert_mrec( - /*=============================*/ trx_t *trx, /*!< in: current transaction */ const mrec_t *mrec, /*!< in: merge record */ dict_index_t *index, /*!< in: index of mrec */ @@ -1447,12 +1420,10 @@ static MY_ATTRIBUTE((warn_unused_result)) return (row); } -/******************************************************/ /** - Replays an insert operation on a table that was rebuilt. +/** Replays an insert operation on a table that was rebuilt. @return DB_SUCCESS or error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_log_table_apply_insert_low( - /*===========================*/ que_thr_t *thr, /*!< in: query graph */ const dtuple_t *row, /*!< in: table row in the old table definition */ @@ -1518,11 +1489,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t return (error); } -/******************************************************/ /** - Replays an insert operation on a table that was rebuilt. +/** Replays an insert operation on a table that was rebuilt. @return DB_SUCCESS or error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_log_table_apply_insert( - /*=======================*/ que_thr_t *thr, /*!< in: query graph */ const mrec_t *mrec, /*!< in: record to insert */ const ulint *offsets, /*!< in: offsets of mrec */ @@ -1569,12 +1538,10 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_log_table_apply_insert( return (error); } -/******************************************************/ /** - Deletes a record from a table that is being rebuilt. +/** Deletes a record from a table that is being rebuilt. @return DB_SUCCESS or error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_log_table_apply_delete_low( - /*===========================*/ trx_t *trx, /*!< in: current transaction*/ btr_pcur_t *pcur, /*!< in/out: B-tree cursor, will be trashed */ @@ -1663,11 +1630,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t return (error); } -/******************************************************/ /** - Replays a delete operation on a table that was rebuilt. +/** Replays a delete operation on a table that was rebuilt. @return DB_SUCCESS or error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_log_table_apply_delete( - /*=======================*/ que_thr_t *thr, /*!< in: query graph */ ulint trx_id_col, /*!< in: position of DB_TRX_ID in the new @@ -1790,11 +1755,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_log_table_apply_delete( row_log_table_apply_delete_low(trx, &pcur, old_pk, offsets, heap, &mtr)); } -/******************************************************/ /** - Replays an update operation on a table that was rebuilt. +/** Replays an update operation on a table that was rebuilt. @return DB_SUCCESS or error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_log_table_apply_update( - /*=======================*/ que_thr_t *thr, /*!< in: query graph */ ulint new_trx_id_col, /*!< in: position of DB_TRX_ID in the new @@ -2137,12 +2100,10 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_log_table_apply_update( goto func_exit; } -/******************************************************/ /** - Applies an operation to a table that was rebuilt. +/** Applies an operation to a table that was rebuilt. @return NULL on failure (mrec corruption) or when out of data; pointer to next record on success */ static MY_ATTRIBUTE((warn_unused_result)) const mrec_t *row_log_table_apply_op( - /*===================*/ que_thr_t *thr, /*!< in: query graph */ ulint trx_id_col, /*!< in: position of DB_TRX_ID in old index */ @@ -2855,12 +2816,10 @@ dberr_t row_log_table_apply(que_thr_t *thr, dict_table_t *old_table, return (error); } -/******************************************************/ /** - Allocate the row log for an index and flag the index +/** Allocate the row log for an index and flag the index for online creation. @retval true if success, false if not */ bool row_log_allocate( - /*=============*/ dict_index_t *index, /*!< in/out: index */ dict_table_t *table, /*!< in/out: new table being rebuilt, or NULL when creating a secondary index */ @@ -2920,11 +2879,8 @@ bool row_log_allocate( DBUG_RETURN(true); } -/******************************************************/ /** - Free the row log for an index that was being created online. */ -void row_log_free( - /*=========*/ - row_log_t *&log) /*!< in,own: row log */ +/** Free the row log for an index that was being created online. */ +void row_log_free(row_log_t *&log) /*!< in,own: row log */ { MONITOR_ATOMIC_DEC(MONITOR_ONLINE_CREATE_INDEX); @@ -2937,12 +2893,10 @@ void row_log_free( log = NULL; } -/******************************************************/ /** - Get the latest transaction ID that has invoked row_log_online_op() +/** Get the latest transaction ID that has invoked row_log_online_op() during online creation. @return latest transaction ID, or 0 if nothing was logged */ trx_id_t row_log_get_max_trx( - /*================*/ dict_index_t *index) /*!< in: index, must be locked */ { ut_ad(dict_index_get_online_status(index) == ONLINE_INDEX_CREATION); @@ -2954,10 +2908,8 @@ trx_id_t row_log_get_max_trx( return (index->online_log->max_trx); } -/******************************************************/ /** - Applies an operation to a secondary index that was being created. */ +/** Applies an operation to a secondary index that was being created. */ static void row_log_apply_op_low( - /*=================*/ dict_index_t *index, /*!< in/out: index */ row_merge_dup_t *dup, /*!< in/out: for reporting duplicate key errors */ @@ -3166,12 +3118,10 @@ static void row_log_apply_op_low( mtr_commit(&mtr); } -/******************************************************/ /** - Applies an operation to a secondary index that was being created. +/** Applies an operation to a secondary index that was being created. @return NULL on failure (mrec corruption) or when out of data; pointer to next record on success */ static MY_ATTRIBUTE((warn_unused_result)) const mrec_t *row_log_apply_op( - /*=============*/ dict_index_t *index, /*!< in/out: index */ row_merge_dup_t *dup, /*!< in/out: for reporting duplicate key errors */ diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index c27689f3590f..0ee370f350c3 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file row/row0merge.cc +/** @file row/row0merge.cc New index creation routines using a merge sort Created 12/4/2005 Jan Lindstrom @@ -267,10 +266,8 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_merge_insert_index_tuples( row_merge_block_t *block, const row_merge_buf_t *row_buf, BtrBulk *btr_bulk, ut_stage_alter_t *stage = NULL); -/******************************************************/ /** - Encode an index record. */ +/** Encode an index record. */ static void row_merge_buf_encode( - /*=================*/ byte **b, /*!< in/out: pointer to current end of output buffer */ const dict_index_t *index, /*!< in: index */ @@ -301,11 +298,9 @@ static void row_merge_buf_encode( *b += size; } -/******************************************************/ /** - Allocate a sort buffer. +/** Allocate a sort buffer. @return own: sort buffer */ static MY_ATTRIBUTE((malloc)) row_merge_buf_t *row_merge_buf_create_low( - /*=====================*/ mem_heap_t *heap, /*!< in: heap where allocated */ dict_index_t *index, /*!< in: secondary index */ ulint max_tuples, /*!< in: maximum number of @@ -330,11 +325,9 @@ static MY_ATTRIBUTE((malloc)) row_merge_buf_t *row_merge_buf_create_low( return (buf); } -/******************************************************/ /** - Allocate a sort buffer. +/** Allocate a sort buffer. @return own: sort buffer */ row_merge_buf_t *row_merge_buf_create( - /*=================*/ dict_index_t *index) /*!< in: secondary index */ { row_merge_buf_t *buf; @@ -354,11 +347,9 @@ row_merge_buf_t *row_merge_buf_create( return (buf); } -/******************************************************/ /** - Empty a sort buffer. +/** Empty a sort buffer. @return sort buffer */ row_merge_buf_t *row_merge_buf_empty( - /*================*/ row_merge_buf_t *buf) /*!< in,own: sort buffer */ { ulint buf_size = sizeof *buf; @@ -379,10 +370,8 @@ row_merge_buf_t *row_merge_buf_empty( return (buf); } -/******************************************************/ /** - Deallocate a sort buffer. */ +/** Deallocate a sort buffer. */ void row_merge_buf_free( - /*===============*/ row_merge_buf_t *buf) /*!< in,own: sort buffer to be freed */ { ut_free(buf->tuples); @@ -789,10 +778,8 @@ static ulint row_merge_buf_add(row_merge_buf_t *buf, dict_index_t *fts_index, DBUG_RETURN(n_row_added); } -/*************************************************************/ /** - Report a duplicate key. */ +/** Report a duplicate key. */ void row_merge_dup_report( - /*=================*/ row_merge_dup_t *dup, /*!< in/out: for reporting duplicates */ const dfield_t *entry) /*!< in: duplicate index entry */ { @@ -803,8 +790,7 @@ void row_merge_dup_report( } } -/*************************************************************/ /** - Compare two tuples. +/** Compare two tuples. @param[in] index index tree @param[in] n_uniq number of unique fields @param[in] n_field number of fields @@ -814,7 +800,6 @@ void row_merge_dup_report( @return positive, 0, negative if a is greater, equal, less, than b, respectively */ static MY_ATTRIBUTE((warn_unused_result)) int row_merge_tuple_cmp( - /*================*/ const dict_index_t *index, ulint n_uniq, ulint n_field, const mtuple_t &a, const mtuple_t &b, row_merge_dup_t *dup) { int cmp; @@ -884,10 +869,8 @@ respectively */ #define row_merge_tuple_cmp_ctx(a, b) \ row_merge_tuple_cmp(index, n_uniq, n_field, a, b, dup) -/**********************************************************************/ /** - Merge sort the tuple buffer in main memory. */ +/** Merge sort the tuple buffer in main memory. */ static void row_merge_tuple_sort( - /*=================*/ const dict_index_t *index, /*!< in: index tree */ ulint n_uniq, /*!< in: number of unique fields */ ulint n_field, /*!< in: number of fields */ @@ -907,10 +890,8 @@ static void row_merge_tuple_sort( row_merge_tuple_cmp_ctx); } -/******************************************************/ /** - Sort a buffer. */ +/** Sort a buffer. */ void row_merge_buf_sort( - /*===============*/ row_merge_buf_t *buf, /*!< in/out: sort buffer */ row_merge_dup_t *dup) /*!< in/out: reporter of duplicates (NULL if non-unique index) */ @@ -922,10 +903,8 @@ void row_merge_buf_sort( buf->tmp_tuples, 0, buf->n_tuples); } -/******************************************************/ /** - Write a buffer to a block. */ +/** Write a buffer to a block. */ void row_merge_buf_write( - /*================*/ const row_merge_buf_t *buf, /*!< in: sorted buffer */ const merge_file_t *of UNIV_UNUSED, /*!< in: output file */ @@ -964,12 +943,10 @@ void row_merge_buf_write( DBUG_VOID_RETURN; } -/******************************************************/ /** - Create a memory heap and allocate space for row_merge_rec_offsets() +/** Create a memory heap and allocate space for row_merge_rec_offsets() and mrec_buf_t[3]. @return memory heap */ static mem_heap_t *row_merge_heap_create( - /*==================*/ const dict_index_t *index, /*!< in: record descriptor */ mrec_buf_t **buf, /*!< out: 3 buffers */ ulint **offsets1, /*!< out: offsets */ @@ -989,16 +966,13 @@ static mem_heap_t *row_merge_heap_create( return (heap); } -/********************************************************************/ /** - Read a merge block from the file system. +/** Read a merge block from the file system. @return true if request was successful, false if fail */ -ibool row_merge_read( - /*===========*/ - int fd, /*!< in: file descriptor */ - ulint offset, /*!< in: offset where to read - in number of row_merge_block_t - elements */ - row_merge_block_t *buf) /*!< out: data */ +ibool row_merge_read(int fd, /*!< in: file descriptor */ + ulint offset, /*!< in: offset where to read + in number of row_merge_block_t + elements */ + row_merge_block_t *buf) /*!< out: data */ { os_offset_t ofs = ((os_offset_t)offset) * srv_sort_buf_size; dberr_t err; @@ -1027,15 +1001,12 @@ ibool row_merge_read( DBUG_RETURN(err == DB_SUCCESS); } -/********************************************************************/ /** - Write a merge block to the file system. +/** Write a merge block to the file system. @return true if request was successful, false if fail */ -ibool row_merge_write( - /*============*/ - int fd, /*!< in: file descriptor */ - ulint offset, /*!< in: offset where to write, - in number of row_merge_block_t elements */ - const void *buf) /*!< in: data */ +ibool row_merge_write(int fd, /*!< in: file descriptor */ + ulint offset, /*!< in: offset where to write, + in number of row_merge_block_t elements */ + const void *buf) /*!< in: data */ { size_t buf_len = srv_sort_buf_size; os_offset_t ofs = buf_len * (os_offset_t)offset; @@ -1060,11 +1031,9 @@ ibool row_merge_write( DBUG_RETURN(err == DB_SUCCESS); } -/********************************************************************/ /** - Read a merge record. +/** Read a merge record. @return pointer to next record, or NULL on I/O error or end of list */ const byte *row_merge_read_rec( - /*===============*/ row_merge_block_t *block, /*!< in/out: file buffer */ mrec_buf_t *buf, /*!< in/out: secondary buffer */ const byte *b, /*!< in: pointer to record */ @@ -1215,10 +1184,8 @@ const byte *row_merge_read_rec( DBUG_RETURN(b); } -/********************************************************************/ /** - Write a merge record. */ +/** Write a merge record. */ static void row_merge_write_rec_low( - /*====================*/ byte *b, /*!< out: buffer */ ulint e, /*!< in: encoded extra_size */ #ifdef UNIV_DEBUG @@ -1255,11 +1222,9 @@ static void row_merge_write_rec_low( DBUG_VOID_RETURN; } -/********************************************************************/ /** - Write a merge record. +/** Write a merge record. @return pointer to end of block, or NULL on error */ static byte *row_merge_write_rec( - /*================*/ row_merge_block_t *block, /*!< in/out: file buffer */ mrec_buf_t *buf, /*!< in/out: secondary buffer */ byte *b, /*!< in: pointer to end of block */ @@ -1317,11 +1282,9 @@ static byte *row_merge_write_rec( return (b); } -/********************************************************************/ /** - Write an end-of-list marker. +/** Write an end-of-list marker. @return pointer to end of block, or NULL on error */ static byte *row_merge_write_eof( - /*================*/ row_merge_block_t *block, /*!< in/out: file buffer */ byte *b, /*!< in: pointer to end of block */ int fd, /*!< in: file descriptor */ @@ -3040,14 +3003,11 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_merge_insert_index_tuples( DBUG_RETURN(error); } -/*********************************************************************/ /** - Sets an exclusive lock on a table, for the duration of creating indexes. +/** Sets an exclusive lock on a table, for the duration of creating indexes. @return error code or DB_SUCCESS */ -dberr_t row_merge_lock_table( - /*=================*/ - trx_t *trx, /*!< in/out: transaction */ - dict_table_t *table, /*!< in: table to lock */ - enum lock_mode mode) /*!< in: LOCK_X or LOCK_S */ +dberr_t row_merge_lock_table(trx_t *trx, /*!< in/out: transaction */ + dict_table_t *table, /*!< in: table to lock */ + enum lock_mode mode) /*!< in: LOCK_X or LOCK_S */ { ut_ad(!srv_read_only_mode); ut_ad(mode == LOCK_X || mode == LOCK_S); @@ -3061,12 +3021,10 @@ dberr_t row_merge_lock_table( return (err); } -/*********************************************************************/ /** - Drop indexes that were created before an error occurred. +/** Drop indexes that were created before an error occurred. The data dictionary must have been locked exclusively by the caller, because the transaction will not be committed. */ void row_merge_drop_indexes( - /*===================*/ trx_t *trx, /*!< in/out: dictionary transaction */ dict_table_t *table, /*!< in/out: table containing the indexes */ ibool locked) /*!< in: TRUE=table locked, @@ -3281,12 +3239,9 @@ int row_merge_file_create(merge_file_t *merge_file, const char *path) { return (merge_file->fd); } -/*********************************************************************/ /** - Destroy a merge file. And de-register the file from Performance Schema +/** Destroy a merge file. And de-register the file from Performance Schema if UNIV_PFS_IO is defined. */ -void row_merge_file_destroy_low( - /*=======================*/ - int fd) /*!< in: merge file descriptor */ +void row_merge_file_destroy_low(int fd) /*!< in: merge file descriptor */ { #ifdef UNIV_PFS_IO struct PSI_file_locker *locker = NULL; @@ -3306,10 +3261,8 @@ void row_merge_file_destroy_low( } #endif } -/*********************************************************************/ /** - Destroy a merge file. */ +/** Destroy a merge file. */ void row_merge_file_destroy( - /*===================*/ merge_file_t *merge_file) /*!< in/out: merge file structure */ { ut_ad(!srv_read_only_mode); @@ -3320,15 +3273,12 @@ void row_merge_file_destroy( } } -/*********************************************************************/ /** - Provide a new pathname for a table that is being renamed if it belongs to +/** Provide a new pathname for a table that is being renamed if it belongs to a file-per-table tablespace. The caller is responsible for freeing the memory allocated for the return value. @return new pathname of tablespace file, or NULL if space = 0 */ -char *row_make_new_pathname( - /*==================*/ - dict_table_t *table, /*!< in: table to be renamed */ - const char *new_name) /*!< in: new name */ +char *row_make_new_pathname(dict_table_t *table, /*!< in: table to be renamed */ + const char *new_name) /*!< in: new name */ { ut_ad(dict_table_is_file_per_table(table)); @@ -3456,16 +3406,13 @@ dict_index_t *row_merge_create_index(trx_t *trx, dict_table_t *table, DBUG_RETURN(index); } -/*********************************************************************/ /** - Drop a table. The caller must have ensured that the background stats +/** Drop a table. The caller must have ensured that the background stats thread is not processing the table. This can be done by calling dict_stats_wait_bg_to_stop_using_table() after locking the dictionary and before calling this function. @return DB_SUCCESS or error code */ -dberr_t row_merge_drop_table( - /*=================*/ - trx_t *trx, /*!< in: transaction */ - dict_table_t *table) /*!< in: table to drop */ +dberr_t row_merge_drop_table(trx_t *trx, /*!< in: transaction */ + dict_table_t *table) /*!< in: table to drop */ { ut_ad(!srv_read_only_mode); diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index b71f73d316a0..632d8f17d41d 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file row/row0mysql.cc +/** @file row/row0mysql.cc Interface between Innobase row operations and MySQL. Contains also create table and other data dictionary operations. @@ -110,15 +109,13 @@ static ib_mutex_t row_drop_list_mutex; /** Flag: has row_mysql_drop_list been initialized? */ static ibool row_mysql_drop_list_inited = FALSE; -/*********************************************************************/ /** - If a table is not yet in the drop list, adds the table to the list of tables +/** If a table is not yet in the drop list, adds the table to the list of tables which the master thread drops in background. We need this on Unix because in ALTER TABLE MySQL may call drop table even if the table has running queries on it. Also, if there are running foreign key checks on the table, we drop the table lazily. @return true if the table was not yet in the drop list, and was added there */ static ibool row_add_table_to_background_drop_list( - /*==================================*/ const char *name); /*!< in: table name */ #ifdef UNIV_DEBUG @@ -136,20 +133,15 @@ void row_wait_for_background_drop_list_empty() { extern ib_mutex_t master_key_id_mutex; -/*******************************************************************/ /** - Delays an INSERT, DELETE or UPDATE operation if the purge is lagging. */ -static void row_mysql_delay_if_needed(void) -/*===========================*/ -{ +/** Delays an INSERT, DELETE or UPDATE operation if the purge is lagging. */ +static void row_mysql_delay_if_needed(void) { if (srv_dml_needed_delay) { os_thread_sleep(srv_dml_needed_delay); } } -/*******************************************************************/ /** - Frees the blob heap in prebuilt when no longer needed. */ +/** Frees the blob heap in prebuilt when no longer needed. */ void row_mysql_prebuilt_free_blob_heap( - /*==============================*/ row_prebuilt_t *prebuilt) /*!< in: prebuilt struct of a ha_innobase:: table handle */ { @@ -163,13 +155,11 @@ void row_mysql_prebuilt_free_blob_heap( DBUG_VOID_RETURN; } -/*******************************************************************/ /** - Stores a >= 5.0.3 format true VARCHAR length to dest, in the MySQL row +/** Stores a >= 5.0.3 format true VARCHAR length to dest, in the MySQL row format. @return pointer to the data, we skip the 1 or 2 bytes at the start that are used to store the len */ byte *row_mysql_store_true_var_len( - /*=========================*/ byte *dest, /*!< in: where to store */ ulint len, /*!< in: length, must fit in two bytes */ ulint lenlen) /*!< in: storage length of len: either 1 or 2 bytes */ @@ -190,13 +180,11 @@ byte *row_mysql_store_true_var_len( return (dest + 1); } -/*******************************************************************/ /** - Reads a >= 5.0.3 format true VARCHAR length, in the MySQL row format, and +/** Reads a >= 5.0.3 format true VARCHAR length, in the MySQL row format, and returns a pointer to the data. @return pointer to the data, we skip the 1 or 2 bytes at the start that are used to store the len */ const byte *row_mysql_read_true_varchar( - /*========================*/ ulint *len, /*!< out: variable-length field length */ const byte *field, /*!< in: field in the MySQL format */ ulint lenlen) /*!< in: storage length of len: either 1 @@ -215,10 +203,8 @@ const byte *row_mysql_read_true_varchar( return (field + 1); } -/*******************************************************************/ /** - Stores a reference to a BLOB in the MySQL format. */ +/** Stores a reference to a BLOB in the MySQL format. */ void row_mysql_store_blob_ref( - /*=====================*/ byte *dest, /*!< in: where to store */ ulint col_len, /*!< in: dest buffer size: determines into how many bytes the BLOB length is stored, @@ -250,11 +236,9 @@ void row_mysql_store_blob_ref( memcpy(dest + col_len - 8, &data, sizeof data); } -/*******************************************************************/ /** - Reads a reference to a BLOB in the MySQL format. +/** Reads a reference to a BLOB in the MySQL format. @return pointer to BLOB data */ const byte *row_mysql_read_blob_ref( - /*====================*/ ulint *len, /*!< out: BLOB length */ const byte *ref, /*!< in: BLOB reference in the MySQL format */ @@ -270,10 +254,8 @@ const byte *row_mysql_read_blob_ref( return (data); } -/*******************************************************************/ /** - Converting InnoDB geometry data format to MySQL data format. */ +/** Converting InnoDB geometry data format to MySQL data format. */ void row_mysql_store_geometry( - /*=====================*/ byte *dest, /*!< in/out: where to store */ ulint dest_len, /*!< in: dest buffer size: determines into how many bytes the GEOMETRY length @@ -327,11 +309,9 @@ void row_mysql_store_geometry( }); } -/*******************************************************************/ /** - Read geometry data in the MySQL format. +/** Read geometry data in the MySQL format. @return pointer to geometry data */ static const byte *row_mysql_read_geometry( - /*====================*/ ulint *len, /*!< out: data length */ const byte *ref, /*!< in: geometry data in the MySQL format */ @@ -364,14 +344,11 @@ static const byte *row_mysql_read_geometry( return (data); } -/**************************************************************/ /** - Pad a column with spaces. */ -void row_mysql_pad_col( - /*==============*/ - ulint mbminlen, /*!< in: minimum size of a character, - in bytes */ - byte *pad, /*!< out: padded buffer */ - ulint len) /*!< in: number of bytes to pad */ +/** Pad a column with spaces. */ +void row_mysql_pad_col(ulint mbminlen, /*!< in: minimum size of a character, + in bytes */ + byte *pad, /*!< out: padded buffer */ + ulint len) /*!< in: number of bytes to pad */ { const byte *pad_end; @@ -405,13 +382,11 @@ void row_mysql_pad_col( } } -/**************************************************************/ /** - Stores a non-SQL-NULL field given in the MySQL format in the InnoDB format. +/** Stores a non-SQL-NULL field given in the MySQL format in the InnoDB format. The counterpart of this function is row_sel_field_store_in_mysql_format() in row0sel.cc. @return up to which byte we used buf in the conversion */ byte *row_mysql_store_col_in_innobase_format( - /*===================================*/ dfield_t *dfield, /*!< in/out: dfield where dtype information must be already set when this function is called! */ @@ -582,12 +557,10 @@ byte *row_mysql_store_col_in_innobase_format( return (buf); } -/**************************************************************/ /** - Convert a row in the MySQL format to a row in the Innobase format. Note that +/** Convert a row in the MySQL format to a row in the Innobase format. Note that the function to convert a MySQL format key value to an InnoDB dtuple is row_sel_convert_mysql_key_to_innobase() in row0sel.cc. */ static void row_mysql_convert_row_to_innobase( - /*==============================*/ dtuple_t *row, /*!< in/out: Innobase row where the field type information is already copied there! */ @@ -660,12 +633,10 @@ static void row_mysql_convert_row_to_innobase( } } -/****************************************************************/ /** - Handles user errors and lock waits detected by the database engine. +/** Handles user errors and lock waits detected by the database engine. @return true if it was a lock wait and we should continue running the query thread and in that case the thr is ALREADY in the running state. */ bool row_mysql_handle_errors( - /*====================*/ dberr_t *new_err, /*!< out: possible new error encountered in lock wait, or if no new error, the value of trx->error_state at the entry of this @@ -779,11 +750,9 @@ bool row_mysql_handle_errors( return (false); } -/********************************************************************/ /** - Create a prebuilt struct for a MySQL table handle. +/** Create a prebuilt struct for a MySQL table handle. @return own: a prebuilt struct */ row_prebuilt_t *row_create_prebuilt( - /*================*/ dict_table_t *table, /*!< in: Innobase table handle */ ulint mysql_row_len) /*!< in: length in bytes of a row in the MySQL format */ @@ -934,10 +903,8 @@ row_prebuilt_t *row_create_prebuilt( DBUG_RETURN(prebuilt); } -/********************************************************************/ /** - Free a prebuilt struct for a MySQL table handle. */ +/** Free a prebuilt struct for a MySQL table handle. */ void row_prebuilt_free( - /*==============*/ row_prebuilt_t *prebuilt, /*!< in, own: prebuilt struct */ ibool dict_locked) /*!< in: TRUE=data dictionary locked */ { @@ -1009,11 +976,9 @@ void row_prebuilt_free( DBUG_VOID_RETURN; } -/*********************************************************************/ /** - Updates the transaction pointers in query graphs stored in the prebuilt +/** Updates the transaction pointers in query graphs stored in the prebuilt struct. */ void row_update_prebuilt_trx( - /*====================*/ row_prebuilt_t *prebuilt, /*!< in/out: prebuilt struct in MySQL handle */ trx_t *trx) /*!< in: transaction handle */ @@ -1037,13 +1002,11 @@ void row_update_prebuilt_trx( } } -/*********************************************************************/ /** - Gets pointer to a prebuilt dtuple used in insertions. If the insert graph +/** Gets pointer to a prebuilt dtuple used in insertions. If the insert graph has not yet been built in the prebuilt struct, then this function first builds it. @return prebuilt dtuple; the column type information is also set in it */ static dtuple_t *row_get_prebuilt_insert_row( - /*========================*/ row_prebuilt_t *prebuilt) /*!< in: prebuilt struct in MySQL handle */ { @@ -1101,13 +1064,10 @@ static dtuple_t *row_get_prebuilt_insert_row( return (prebuilt->ins_node->row); } -/*********************************************************************/ /** - Updates the table modification counter and calculates new estimates +/** Updates the table modification counter and calculates new estimates for table and index statistics if necessary. */ UNIV_INLINE -void row_update_statistics_if_needed( - /*============================*/ - dict_table_t *table) /*!< in: table */ +void row_update_statistics_if_needed(dict_table_t *table) /*!< in: table */ { ib_uint64_t counter; ib_uint64_t n_rows; @@ -1144,15 +1104,13 @@ void row_update_statistics_if_needed( } } -/*********************************************************************/ /** - Sets an AUTO_INC type lock on the table mentioned in prebuilt. The +/** Sets an AUTO_INC type lock on the table mentioned in prebuilt. The AUTO_INC lock gives exclusive access to the auto-inc counter of the table. The lock is reserved only for the duration of an SQL statement. It is not compatible with another AUTO_INC or exclusive lock on the table. @return error code or DB_SUCCESS */ dberr_t row_lock_table_autoinc_for_mysql( - /*=============================*/ row_prebuilt_t *prebuilt) /*!< in: prebuilt struct in the MySQL table handle */ { @@ -1719,10 +1677,8 @@ dberr_t row_insert_for_mysql(const byte *mysql_rec, row_prebuilt_t *prebuilt) { } } -/*********************************************************************/ /** - Builds a dummy query graph used in selects. */ +/** Builds a dummy query graph used in selects. */ void row_prebuild_sel_graph( - /*===================*/ row_prebuilt_t *prebuilt) /*!< in: prebuilt struct in MySQL handle */ { @@ -1741,12 +1697,10 @@ void row_prebuild_sel_graph( } } -/*********************************************************************/ /** - Creates an query graph node of 'update' type to be used in the MySQL +/** Creates an query graph node of 'update' type to be used in the MySQL interface. @return own: update node */ upd_node_t *row_create_update_node_for_mysql( - /*=============================*/ dict_table_t *table, /*!< in: table to update */ mem_heap_t *heap) /*!< in: mem heap from which allocated */ { @@ -1782,13 +1736,11 @@ upd_node_t *row_create_update_node_for_mysql( DBUG_RETURN(node); } -/*********************************************************************/ /** - Gets pointer to a prebuilt update vector used in updates. If the update +/** Gets pointer to a prebuilt update vector used in updates. If the update graph has not yet been built in the prebuilt struct, then this function first builds it. @return prebuilt update vector */ upd_t *row_get_prebuilt_update_vector( - /*===========================*/ row_prebuilt_t *prebuilt) /*!< in: prebuilt struct in MySQL handle */ { @@ -1818,7 +1770,6 @@ upd_t *row_get_prebuilt_update_vector( /******************************************************************** Handle an update of a column that has an FTS index. */ static void row_fts_do_update( - /*==============*/ trx_t *trx, /* in: transaction */ dict_table_t *table, /* in: Table with FTS index */ doc_id_t old_doc_id, /* in: old document id */ @@ -1836,7 +1787,6 @@ static void row_fts_do_update( Handles FTS matters for an update or a delete. NOTE: should not be called if the table does not have an FTS index. .*/ static dberr_t row_fts_update_or_delete( - /*=====================*/ row_prebuilt_t *prebuilt) /* in: prebuilt struct in MySQL handle */ { @@ -1867,10 +1817,8 @@ static dberr_t row_fts_update_or_delete( DBUG_RETURN(DB_SUCCESS); } -/*********************************************************************/ /** - Initialize the Doc ID system for FK table with FTS index */ +/** Initialize the Doc ID system for FK table with FTS index */ static void init_fts_doc_id_for_ref( - /*====================*/ dict_table_t *table, /*!< in: table */ ulint *depth) /*!< in: recusive call depth */ { @@ -2512,11 +2460,9 @@ void row_unlock_for_mysql(row_prebuilt_t *prebuilt, ibool has_latches_on_recs) { trx->op_info = ""; } -/**********************************************************************/ /** - Does a cascaded delete or set null in a foreign key operation. +/** Does a cascaded delete or set null in a foreign key operation. @return error code or DB_SUCCESS */ dberr_t row_update_cascade_for_mysql( - /*=========================*/ que_thr_t *thr, /*!< in: query thread */ upd_node_t *node, /*!< in: update node used in the cascade or set null operation */ @@ -2597,12 +2543,10 @@ dberr_t row_update_cascade_for_mysql( return (err); } -/*********************************************************************/ /** - Checks if a table is such that we automatically created a clustered +/** Checks if a table is such that we automatically created a clustered index on it (on row id). @return true if the clustered index was generated automatically */ ibool row_table_got_default_clust_index( - /*==============================*/ const dict_table_t *table) /*!< in: table */ { const dict_index_t *clust_index; @@ -2612,11 +2556,9 @@ ibool row_table_got_default_clust_index( return (clust_index->get_col(0)->mtype == DATA_SYS); } -/*********************************************************************/ /** - Locks the data dictionary in shared mode from modifications, for performing +/** Locks the data dictionary in shared mode from modifications, for performing foreign key check, rollback, or other operation invisible to MySQL. */ void row_mysql_freeze_data_dictionary_func( - /*==================================*/ trx_t *trx, /*!< in/out: transaction */ const char *file, /*!< in: file name */ ulint line) /*!< in: line number */ @@ -2628,11 +2570,8 @@ void row_mysql_freeze_data_dictionary_func( trx->dict_operation_lock_mode = RW_S_LATCH; } -/*********************************************************************/ /** - Unlocks the data dictionary shared lock. */ -void row_mysql_unfreeze_data_dictionary( - /*===============================*/ - trx_t *trx) /*!< in/out: transaction */ +/** Unlocks the data dictionary shared lock. */ +void row_mysql_unfreeze_data_dictionary(trx_t *trx) /*!< in/out: transaction */ { ut_a(trx->dict_operation_lock_mode == RW_S_LATCH); @@ -2641,14 +2580,11 @@ void row_mysql_unfreeze_data_dictionary( trx->dict_operation_lock_mode = 0; } -/*********************************************************************/ /** - Locks the data dictionary exclusively for performing a table create or other +/** Locks the data dictionary exclusively for performing a table create or other data dictionary modification operation. */ -void row_mysql_lock_data_dictionary_func( - /*================================*/ - trx_t *trx, /*!< in/out: transaction */ - const char *file, /*!< in: file name */ - ulint line) /*!< in: line number */ +void row_mysql_lock_data_dictionary_func(trx_t *trx, /*!< in/out: transaction */ + const char *file, /*!< in: file name */ + ulint line) /*!< in: line number */ { ut_a(trx->dict_operation_lock_mode == 0 || trx->dict_operation_lock_mode == RW_X_LATCH); @@ -2662,11 +2598,8 @@ void row_mysql_lock_data_dictionary_func( mutex_enter(&dict_sys->mutex); } -/*********************************************************************/ /** - Unlocks the data dictionary exclusive lock. */ -void row_mysql_unlock_data_dictionary( - /*=============================*/ - trx_t *trx) /*!< in/out: transaction */ +/** Unlocks the data dictionary exclusive lock. */ +void row_mysql_unlock_data_dictionary(trx_t *trx) /*!< in/out: transaction */ { ut_a(trx->dict_operation_lock_mode == RW_X_LATCH); @@ -2818,13 +2751,11 @@ dberr_t row_create_table_for_mysql(dict_table_t *table, const char *compression, return (err); } -/*********************************************************************/ /** - Does an index creation operation for MySQL. TODO: currently failure +/** Does an index creation operation for MySQL. TODO: currently failure to create an index results in dropping the whole table! This is no problem currently as all indexes must be created at the same time as the table. @return error number or DB_SUCCESS */ dberr_t row_create_index_for_mysql( - /*=======================*/ dict_index_t *index, /*!< in, own: index definition (will be freed) */ trx_t *trx, /*!< in: transaction handle */ @@ -2975,8 +2906,7 @@ dberr_t row_create_index_for_mysql( return (err); } -/*********************************************************************/ /** - Scans a table create SQL string and adds to the data dictionary +/** Scans a table create SQL string and adds to the data dictionary the foreign key constraints declared in the string. This function should be called after the indexes for a table have been created. Each foreign key constraint must be accompanied with indexes in @@ -3063,8 +2993,7 @@ dberr_t row_table_add_foreign_constraints(trx_t *trx, const char *sql_string, DBUG_RETURN(err); } -/*********************************************************************/ /** - Drops a table for MySQL as a background operation. MySQL relies on Unix +/** Drops a table for MySQL as a background operation. MySQL relies on Unix in ALTER TABLE to the fact that the table handler does not remove the table before all handles to it has been removed. Furhermore, the MySQL's call to drop table must be non-blocking. Therefore we do the drop table @@ -3072,7 +3001,6 @@ dberr_t row_table_add_foreign_constraints(trx_t *trx, const char *sql_string, in srv0srv.cc. @return error code or DB_SUCCESS */ static dberr_t row_drop_table_for_mysql_in_background( - /*===================================*/ const char *name) /*!< in: table name */ { dberr_t error; @@ -3103,16 +3031,13 @@ static dberr_t row_drop_table_for_mysql_in_background( return (error); } -/*********************************************************************/ /** - TODO: NewDD: Need to check if there is need to keep background +/** TODO: NewDD: Need to check if there is need to keep background drop, in such case, the thd would be NULL (no MDL can be acquired) The master thread in srv0srv.cc calls this regularly to drop tables which we must drop in background after queries to them have ended. Such lazy dropping of tables is needed in ALTER TABLE on Unix. @return how many tables dropped + remaining tables in list */ -ulint row_drop_tables_for_mysql_in_background(void) -/*=========================================*/ -{ +ulint row_drop_tables_for_mysql_in_background(void) { row_mysql_drop_t *drop; dict_table_t *table; ulint n_tables; @@ -3204,13 +3129,10 @@ ulint row_drop_tables_for_mysql_in_background(void) goto loop; } -/*********************************************************************/ /** - Get the background drop list length. NOTE: the caller must own the +/** Get the background drop list length. NOTE: the caller must own the drop list mutex! @return how many tables in list */ -ulint row_get_background_drop_list_len_low(void) -/*======================================*/ -{ +ulint row_get_background_drop_list_len_low(void) { ulint len; mutex_enter(&row_drop_list_mutex); @@ -3224,15 +3146,13 @@ ulint row_get_background_drop_list_len_low(void) return (len); } -/*********************************************************************/ /** - If a table is not yet in the drop list, adds the table to the list of tables +/** If a table is not yet in the drop list, adds the table to the list of tables which the master thread drops in background. We need this on Unix because in ALTER TABLE MySQL may call drop table even if the table has running queries on it. Also, if there are running foreign key checks on the table, we drop the table lazily. @return true if the table was not yet in the drop list, and was added there */ static ibool row_add_table_to_background_drop_list( - /*==================================*/ const char *name) /*!< in: table name */ { /* WL6049, remove after WL6049. */ @@ -3284,12 +3204,10 @@ static dberr_t row_mysql_table_id_reassign(dict_table_t *table, return (DB_SUCCESS); } -/*********************************************************************/ /** - Setup the pre-requisites for DISCARD TABLESPACE. It will start the transaction, - acquire the data dictionary lock in X mode and open the table. +/** Setup the pre-requisites for DISCARD TABLESPACE. It will start the + transaction, acquire the data dictionary lock in X mode and open the table. @return table instance or 0 if not found. */ static dict_table_t *row_discard_tablespace_begin( - /*=========================*/ const char *name, /*!< in: table name */ trx_t *trx) /*!< in: transaction handle */ { @@ -3318,11 +3236,9 @@ static dict_table_t *row_discard_tablespace_begin( return (table); } -/*********************************************************************/ /** - Do the foreign key constraint checks. +/** Do the foreign key constraint checks. @return DB_SUCCESS or error code. */ static dberr_t row_discard_tablespace_foreign_key_checks( - /*======================================*/ const trx_t *trx, /*!< in: transaction handle */ const dict_table_t *table) /*!< in: table to be discarded */ { @@ -3548,13 +3464,11 @@ static dberr_t row_discard_tablespace(trx_t *trx, dict_table_t *table, return (err); } -/*********************************************************************/ /** - Discards the tablespace of a table which stored in an .ibd file. Discarding +/** Discards the tablespace of a table which stored in an .ibd file. Discarding means that this function renames the .ibd file and assigns a new table id for the table. Also the flag table->ibd_file_missing is set to TRUE. @return error code or DB_SUCCESS */ dberr_t row_discard_tablespace_for_mysql( - /*=============================*/ const char *name, /*!< in: table name */ trx_t *trx) /*!< in: transaction handle */ { @@ -3607,11 +3521,9 @@ dberr_t row_discard_tablespace_for_mysql( return (row_discard_tablespace_end(trx, table, err, &aux_vec)); } -/*********************************************************************/ /** - Sets an exclusive lock on a table. +/** Sets an exclusive lock on a table. @return error code or DB_SUCCESS */ dberr_t row_mysql_lock_table( - /*=================*/ trx_t *trx, /*!< in/out: transaction */ dict_table_t *table, /*!< in: table to lock */ enum lock_mode mode, /*!< in: LOCK_X or LOCK_S */ @@ -4226,13 +4138,11 @@ dberr_t row_drop_table_for_mysql(const char *name, trx_t *trx, DBUG_RETURN(err); } -/*********************************************************************/ /** - Checks if a table name contains the string "/#sql" which denotes temporary +/** Checks if a table name contains the string "/#sql" which denotes temporary tables in MySQL. @return true if temporary table */ MY_ATTRIBUTE((warn_unused_result)) bool row_is_mysql_tmp_table_name( - /*========================*/ const char *name) /*!< in: table name in the form 'database/tablename' */ { @@ -4456,14 +4366,12 @@ dberr_t row_rename_table_for_mysql(const char *old_name, const char *new_name, return (err); } -/*********************************************************************/ /** - Scans an index for either COUNT(*) or CHECK TABLE. +/** Scans an index for either COUNT(*) or CHECK TABLE. If CHECK TABLE; Checks that the index contains entries in an ascending order, unique constraint is not broken, and calculates the number of index entries in the read view of the current transaction. @return DB_SUCCESS or other error */ dberr_t row_scan_index_for_mysql( - /*=====================*/ row_prebuilt_t *prebuilt, /*!< in: prebuilt struct in MySQL handle */ const dict_index_t *index, /*!< in: index */ @@ -4631,11 +4539,8 @@ dberr_t row_scan_index_for_mysql( goto loop; } -/*********************************************************************/ /** - Initialize this module */ -void row_mysql_init(void) -/*================*/ -{ +/** Initialize this module */ +void row_mysql_init(void) { mutex_create(LATCH_ID_ROW_DROP_LIST, &row_drop_list_mutex); UT_LIST_INIT(row_mysql_drop_list, &row_mysql_drop_t::row_mysql_drop_list); @@ -4643,11 +4548,8 @@ void row_mysql_init(void) row_mysql_drop_list_inited = TRUE; } -/*********************************************************************/ /** - Close this module */ -void row_mysql_close(void) -/*================*/ -{ +/** Close this module */ +void row_mysql_close(void) { ut_a(UT_LIST_GET_LEN(row_mysql_drop_list) == 0); mutex_free(&row_drop_list_mutex); diff --git a/storage/innobase/row/row0purge.cc b/storage/innobase/row/row0purge.cc index 2017547ef621..a6926d660a8c 100644 --- a/storage/innobase/row/row0purge.cc +++ b/storage/innobase/row/row0purge.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file row/row0purge.cc +/** @file row/row0purge.cc Purge obsolete records Created 3/14/1997 Heikki Tuuri @@ -96,12 +95,10 @@ purge_node_t *row_purge_node_create(que_thr_t *parent, mem_heap_t *heap) { return (node); } -/***********************************************************/ /** - Repositions the pcur in the purge node on the clustered index record, +/** Repositions the pcur in the purge node on the clustered index record, if found. If the record is not found, close pcur. @return true if the record was found */ static ibool row_purge_reposition_pcur( - /*======================*/ ulint mode, /*!< in: latching mode */ purge_node_t *node, /*!< in: row purge node */ mtr_t *mtr) /*!< in: mtr */ @@ -128,12 +125,10 @@ static ibool row_purge_reposition_pcur( return (node->found_clust); } -/***********************************************************/ /** - Removes a delete marked clustered index record if possible. +/** Removes a delete marked clustered index record if possible. @retval true if the row was not found, or it was successfully removed @retval false if the row was modified after the delete marking */ static MY_ATTRIBUTE((warn_unused_result)) bool row_purge_remove_clust_if_poss_low( - /*===============================*/ purge_node_t *node, /*!< in/out: row purge node */ ulint mode) /*!< in: BTR_MODIFY_LEAF or BTR_MODIFY_TREE */ { @@ -213,14 +208,12 @@ static MY_ATTRIBUTE((warn_unused_result)) bool row_purge_remove_clust_if_poss_lo return (success); } -/***********************************************************/ /** - Removes a clustered index record if it has not been modified after the delete - marking. +/** Removes a clustered index record if it has not been modified after the + delete marking. @retval true if the row was not found, or it was successfully removed @retval false the purge needs to be suspended because of running out of file space. */ static MY_ATTRIBUTE((warn_unused_result)) bool row_purge_remove_clust_if_poss( - /*===========================*/ purge_node_t *node) /*!< in/out: row purge node */ { if (row_purge_remove_clust_if_poss_low(node, BTR_MODIFY_LEAF)) { @@ -239,8 +232,7 @@ static MY_ATTRIBUTE((warn_unused_result)) bool row_purge_remove_clust_if_poss( return (false); } -/***********************************************************/ /** - Determines if it is possible to remove a secondary index entry. +/** Determines if it is possible to remove a secondary index entry. Removal is possible if the secondary index entry does not refer to any not delete marked version of a clustered index record where DB_TRX_ID is newer than the purge view. @@ -254,11 +246,9 @@ static MY_ATTRIBUTE((warn_unused_result)) bool row_purge_remove_clust_if_poss( secondary index entry after purge has removed it and released the leaf page latch. @return true if the secondary index record can be purged */ -bool row_purge_poss_sec( - /*===============*/ - purge_node_t *node, /*!< in/out: row purge node */ - dict_index_t *index, /*!< in: secondary index */ - const dtuple_t *entry) /*!< in: secondary index entry */ +bool row_purge_poss_sec(purge_node_t *node, /*!< in/out: row purge node */ + dict_index_t *index, /*!< in: secondary index */ + const dtuple_t *entry) /*!< in: secondary index entry */ { bool can_delete; mtr_t mtr; @@ -287,7 +277,6 @@ index tree. Does not try to buffer the delete. @return true if success or if not found */ static MY_ATTRIBUTE((warn_unused_result)) ibool row_purge_remove_sec_if_poss_tree( - /*==============================*/ purge_node_t *node, /*!< in: row purge node */ dict_index_t *index, /*!< in: index */ const dtuple_t *entry) /*!< in: index entry */ @@ -400,7 +389,6 @@ if possible. @retval true if success or if not found @retval false if row_purge_remove_sec_if_poss_tree() should be invoked */ static MY_ATTRIBUTE((warn_unused_result)) bool row_purge_remove_sec_if_poss_leaf( - /*==============================*/ purge_node_t *node, /*!< in: row purge node */ dict_index_t *index, /*!< in: index */ const dtuple_t *entry) /*!< in: index entry */ @@ -545,14 +533,11 @@ static MY_ATTRIBUTE((warn_unused_result)) bool row_purge_remove_sec_if_poss_leaf return (false); } -/***********************************************************/ /** - Removes a secondary index entry if possible. */ +/** Removes a secondary index entry if possible. */ UNIV_INLINE -void row_purge_remove_sec_if_poss( - /*=========================*/ - purge_node_t *node, /*!< in: row purge node */ - dict_index_t *index, /*!< in: index */ - const dtuple_t *entry) /*!< in: index entry */ +void row_purge_remove_sec_if_poss(purge_node_t *node, /*!< in: row purge node */ + dict_index_t *index, /*!< in: index */ + const dtuple_t *entry) /*!< in: index entry */ { ibool success; ulint n_tries = 0; @@ -601,13 +586,11 @@ static inline void row_purge_skip_uncommitted_virtual_index( } } -/***********************************************************/ /** - Purges a delete marking of a record. +/** Purges a delete marking of a record. @retval true if the row was not found, or it was successfully removed @retval false the purge needs to be suspended because of running out of file space */ static MY_ATTRIBUTE((warn_unused_result)) bool row_purge_del_mark( - /*===============*/ purge_node_t *node) /*!< in/out: row purge node */ { mem_heap_t *heap; @@ -639,11 +622,9 @@ static MY_ATTRIBUTE((warn_unused_result)) bool row_purge_del_mark( return (row_purge_remove_clust_if_poss(node)); } -/***********************************************************/ /** - Purges an update of an existing record. Also purges an update of a delete +/** Purges an update of an existing record. Also purges an update of a delete marked record if that record contained an externally stored field. */ static void row_purge_upd_exist_or_extern_func( -/*===============================*/ #ifdef UNIV_DEBUG const que_thr_t *thr, /*!< in: query thread */ #endif /* UNIV_DEBUG */ @@ -776,8 +757,7 @@ static void row_purge_upd_exist_or_extern_func( row_purge_upd_exist_or_extern_func(node, undo_rec) #endif /* UNIV_DEBUG */ -/***********************************************************/ /** - Parses the row reference and other info in a modify undo log record. +/** Parses the row reference and other info in a modify undo log record. @param[in,out] node row undo node @param[in] undo_rec undo record to purge @param[out] updated_extern whether an externally stored @@ -1091,15 +1071,12 @@ static MY_ATTRIBUTE((warn_unused_result)) bool row_purge_record_func( row_purge_record_func(node, undo_rec, updated_extern, thd) #endif /* UNIV_DEBUG */ -/***********************************************************/ /** - Fetches an undo log record and does the purge for the recorded operation. +/** Fetches an undo log record and does the purge for the recorded operation. If none left, or the current purge completed, returns the control to the parent node, which is always a query thread node. */ -static void row_purge( - /*======*/ - purge_node_t *node, /*!< in: row purge node */ - trx_undo_rec_t *undo_rec, /*!< in: record to purge */ - que_thr_t *thr) /*!< in: query thread */ +static void row_purge(purge_node_t *node, /*!< in: row purge node */ + trx_undo_rec_t *undo_rec, /*!< in: record to purge */ + que_thr_t *thr) /*!< in: query thread */ { bool updated_extern; THD *thd = current_thd; @@ -1200,8 +1177,7 @@ que_thr_t *row_purge_step(que_thr_t *thr) { } #ifdef UNIV_DEBUG -/***********************************************************/ /** - Validate the persisent cursor. The purge node has two references +/** Validate the persisent cursor. The purge node has two references to the clustered index record - one via the ref member, and the other via the persistent cursor. These two references must match each other if the found_clust flag is set. diff --git a/storage/innobase/row/row0quiesce.cc b/storage/innobase/row/row0quiesce.cc index b09c955e2411..b3e2d9c421c3 100644 --- a/storage/innobase/row/row0quiesce.cc +++ b/storage/innobase/row/row0quiesce.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2012, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2012, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file row/row0quiesce.cc +/** @file row/row0quiesce.cc Quiesce a tablespace. Created 2012-02-08 by Sunny Bains. @@ -44,12 +43,10 @@ this program; if not, write to the Free Software Foundation, Inc., #include "srv0start.h" #include "trx0purge.h" -/*********************************************************************/ /** - Write the meta data (index user fields) config file. +/** Write the meta data (index user fields) config file. @return DB_SUCCESS or error code. */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_quiesce_write_index_fields( - /*===========================*/ const dict_index_t *index, /*!< in: write the meta data for this index */ FILE *file, /*!< in: file to write to */ @@ -165,12 +162,10 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t return (err); } -/*********************************************************************/ /** - Write the meta data config file index information. +/** Write the meta data config file index information. @return DB_SUCCESS or error code. */ static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t row_quiesce_write_indexes( - /*======================*/ const dict_table_t *table, /*!< in: write the meta data for this table */ FILE *file, /*!< in: file to write to */ @@ -229,13 +224,11 @@ static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t return (err); } -/*********************************************************************/ /** - Write the meta data (table columns) config file. Serialise the contents of +/** Write the meta data (table columns) config file. Serialise the contents of dict_col_t structure, along with the column name. All fields are serialized as ib_uint32_t. @return DB_SUCCESS or error code. */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_quiesce_write_table( - /*====================*/ const dict_table_t *table, /*!< in: write the meta data for this table */ FILE *file, /*!< in: file to write to */ @@ -305,11 +298,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_quiesce_write_table( return (DB_SUCCESS); } -/*********************************************************************/ /** - Write the meta data config file header. +/** Write the meta data config file header. @return DB_SUCCESS or error code. */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_quiesce_write_header( - /*=====================*/ const dict_table_t *table, /*!< in: write the meta data for this table */ FILE *file, /*!< in: file to write to */ @@ -424,14 +415,12 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_quiesce_write_header( return (DB_SUCCESS); } -/*********************************************************************/ /** - Write the table meta data after quiesce. +/** Write the table meta data after quiesce. @return DB_SUCCESS or error code */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_quiesce_write_cfg( - /*==================*/ - dict_table_t *table, /*!< in: write the meta data for - this table */ - THD *thd) /*!< in/out: session */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + row_quiesce_write_cfg(dict_table_t *table, /*!< in: write the meta data for + this table */ + THD *thd) /*!< in/out: session */ { dberr_t err; char name[OS_FILE_MAX_PATH]; @@ -642,11 +631,9 @@ static MY_ATTRIBUTE((nonnull, warn_unused_result)) dberr_t return (err); } -/*********************************************************************/ /** - Check whether a table has an FTS index defined on it. +/** Check whether a table has an FTS index defined on it. @return true if an FTS index exists on the table */ static bool row_quiesce_table_has_fts_index( - /*============================*/ const dict_table_t *table) /*!< in: quiesce this table */ { bool exists = false; @@ -666,12 +653,9 @@ static bool row_quiesce_table_has_fts_index( return (exists); } -/*********************************************************************/ /** - Quiesce the tablespace that the table resides in. */ -void row_quiesce_table_start( - /*====================*/ - dict_table_t *table, /*!< in: quiesce this table */ - trx_t *trx) /*!< in/out: transaction/session */ +/** Quiesce the tablespace that the table resides in. */ +void row_quiesce_table_start(dict_table_t *table, /*!< in: quiesce this table */ + trx_t *trx) /*!< in/out: transaction/session */ { ut_a(trx->mysql_thd != 0); ut_a(srv_n_purge_threads > 0); @@ -729,10 +713,8 @@ void row_quiesce_table_start( ut_a(err == DB_SUCCESS); } -/*********************************************************************/ /** - Cleanup after table quiesce. */ +/** Cleanup after table quiesce. */ void row_quiesce_table_complete( - /*=======================*/ dict_table_t *table, /*!< in: quiesce this table */ trx_t *trx) /*!< in/out: transaction/session */ { @@ -784,11 +766,9 @@ void row_quiesce_table_complete( ut_a(err == DB_SUCCESS); } -/*********************************************************************/ /** - Set a table's quiesce state. +/** Set a table's quiesce state. @return DB_SUCCESS or error code. */ dberr_t row_quiesce_set_state( - /*==================*/ dict_table_t *table, /*!< in: quiesce this table */ ib_quiesce_t state, /*!< in: quiesce state to set */ trx_t *trx) /*!< in/out: transaction */ diff --git a/storage/innobase/row/row0row.cc b/storage/innobase/row/row0row.cc index d02eda791156..fc18d6fb24e7 100644 --- a/storage/innobase/row/row0row.cc +++ b/storage/innobase/row/row0row.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file row/row0row.cc +/** @file row/row0row.cc General row routines Created 4/20/1996 Heikki Tuuri @@ -57,14 +56,12 @@ this program; if not, write to the Free Software Foundation, Inc., #include "trx0undo.h" #include "ut0mem.h" -/*****************************************************************/ /** - When an insert or purge to a table is performed, this function builds +/** When an insert or purge to a table is performed, this function builds the entry to be inserted into or purged from an index on the table. @return index entry which should be inserted or purged @retval NULL if the externally stored columns in the clustered index record are unavailable and ext != NULL, or row is missing some needed columns. */ dtuple_t *row_build_index_entry_low( - /*======================*/ const dtuple_t *row, /*!< in: row which should be inserted or purged */ const row_ext_t *ext, /*!< in: externally stored column @@ -516,49 +513,46 @@ static inline dtuple_t *row_build_low(ulint type, const dict_index_t *index, return (row); } -/*******************************************************************/ /** - An inverse function to row_build_index_entry. Builds a row from a +/** An inverse function to row_build_index_entry. Builds a row from a record in a clustered index. @return own: row built; see the NOTE below! */ -dtuple_t *row_build( - /*======*/ - ulint type, /*!< in: ROW_COPY_POINTERS or - ROW_COPY_DATA; the latter - copies also the data fields to - heap while the first only - places pointers to data fields - on the index page, and thus is - more efficient */ - const dict_index_t *index, /*!< in: clustered index */ - const rec_t *rec, /*!< in: record in the clustered - index; NOTE: in the case - ROW_COPY_POINTERS the data - fields in the row will point - directly into this record, - therefore, the buffer page of - this record must be at least - s-latched and the latch held - as long as the row dtuple is used! */ - const ulint *offsets, /*!< in: rec_get_offsets(rec,index) - or NULL, in which case this function - will invoke rec_get_offsets() */ - const dict_table_t *col_table, - /*!< in: table, to check which - externally stored columns - occur in the ordering columns - of an index, or NULL if - index->table should be - consulted instead */ - const dtuple_t *add_cols, - /*!< in: default values of - added columns, or NULL */ - const ulint *col_map, /*!< in: mapping of old column - numbers to new ones, or NULL */ - row_ext_t **ext, /*!< out, own: cache of - externally stored column - prefixes, or NULL */ - mem_heap_t *heap) /*!< in: memory heap from which - the memory needed is allocated */ +dtuple_t *row_build(ulint type, /*!< in: ROW_COPY_POINTERS or + ROW_COPY_DATA; the latter + copies also the data fields to + heap while the first only + places pointers to data fields + on the index page, and thus is + more efficient */ + const dict_index_t *index, /*!< in: clustered index */ + const rec_t *rec, /*!< in: record in the clustered + index; NOTE: in the case + ROW_COPY_POINTERS the data + fields in the row will point + directly into this record, + therefore, the buffer page of + this record must be at least + s-latched and the latch held + as long as the row dtuple is used! */ + const ulint *offsets, /*!< in: rec_get_offsets(rec,index) + or NULL, in which case this function + will invoke rec_get_offsets() */ + const dict_table_t *col_table, + /*!< in: table, to check which + externally stored columns + occur in the ordering columns + of an index, or NULL if + index->table should be + consulted instead */ + const dtuple_t *add_cols, + /*!< in: default values of + added columns, or NULL */ + const ulint *col_map, /*!< in: mapping of old column + numbers to new ones, or NULL */ + row_ext_t **ext, /*!< out, own: cache of + externally stored column + prefixes, or NULL */ + mem_heap_t *heap) /*!< in: memory heap from which + the memory needed is allocated */ { return (row_build_low(type, index, rec, offsets, col_table, add_cols, NULL, col_map, ext, heap)); @@ -598,12 +592,10 @@ dtuple_t *row_build_w_add_vcol(ulint type, const dict_index_t *index, col_map, ext, heap)); } -/*******************************************************************/ /** - Converts an index record to a typed data tuple. +/** Converts an index record to a typed data tuple. @return index entry built; does not set info_bits, and the data fields in the entry will point directly to rec */ dtuple_t *row_rec_to_index_entry_low( - /*=======================*/ const rec_t *rec, /*!< in: record in the index */ const dict_index_t *index, /*!< in: index */ const ulint *offsets, /*!< in: rec_get_offsets(rec, index) */ @@ -659,12 +651,10 @@ dtuple_t *row_rec_to_index_entry_low( return (entry); } -/*******************************************************************/ /** - Converts an index record to a typed data tuple. NOTE that externally +/** Converts an index record to a typed data tuple. NOTE that externally stored (often big) fields are NOT copied to heap. @return own: index entry built */ dtuple_t *row_rec_to_index_entry( - /*===================*/ const rec_t *rec, /*!< in: record in the index */ const dict_index_t *index, /*!< in: index */ const ulint *offsets, /*!< in: rec_get_offsets(rec) */ @@ -697,12 +687,10 @@ dtuple_t *row_rec_to_index_entry( DBUG_RETURN(entry); } -/*******************************************************************/ /** - Builds from a secondary index record a row reference with which we can +/** Builds from a secondary index record a row reference with which we can search the clustered index record. @return own: row reference built; see the NOTE below! */ dtuple_t *row_build_row_ref( - /*==============*/ ulint type, /*!< in: ROW_COPY_DATA, or ROW_COPY_POINTERS: the former copies also the data fields to heap, whereas the latter only places pointers @@ -800,11 +788,9 @@ dtuple_t *row_build_row_ref( return (ref); } -/*******************************************************************/ /** - Builds from a secondary index record a row reference with which we can +/** Builds from a secondary index record a row reference with which we can search the clustered index record. */ void row_build_row_ref_in_tuple( - /*=======================*/ dtuple_t *ref, /*!< in/out: row reference built; see the NOTE below! */ const rec_t *rec, /*!< in: record in the index; @@ -890,11 +876,9 @@ void row_build_row_ref_in_tuple( } } -/***************************************************************/ /** - Searches the clustered index record for a row, if we have the row reference. +/** Searches the clustered index record for a row, if we have the row reference. @return true if found */ ibool row_search_on_row_ref( - /*==================*/ btr_pcur_t *pcur, /*!< out: persistent cursor, which must be closed by the caller */ ulint mode, /*!< in: BTR_MODIFY_LEAF, ... */ @@ -929,12 +913,10 @@ ibool row_search_on_row_ref( return (TRUE); } -/*********************************************************************/ /** - Fetches the clustered index record for a secondary index record. The latches +/** Fetches the clustered index record for a secondary index record. The latches on the secondary index record are preserved. @return record or NULL, if no record found */ rec_t *row_get_clust_rec( - /*==============*/ ulint mode, /*!< in: BTR_MODIFY_LEAF, ... */ const rec_t *rec, /*!< in: record in a secondary index */ dict_index_t *index, /*!< in: secondary index */ @@ -1000,11 +982,9 @@ ib_uint64_t row_get_autoinc_counter(const dtuple_t *row, ulint n) { return (row_parse_int_from_field(field)); } -/***************************************************************/ /** - Searches an index record. +/** Searches an index record. @return whether the record was found or buffered */ enum row_search_result row_search_index_entry( - /*===================*/ dict_index_t *index, /*!< in: index */ const dtuple_t *entry, /*!< in: index entry */ ulint mode, /*!< in: BTR_MODIFY_LEAF, ... */ @@ -1060,8 +1040,7 @@ enum row_search_result row_search_index_entry( return (ROW_FOUND); } -/*******************************************************************/ /** - Formats the raw data in "data" (in InnoDB on-disk format) that is of +/** Formats the raw data in "data" (in InnoDB on-disk format) that is of type DATA_INT using "prtype" and writes the result to "buf". If the data is in unknown format, then nothing is written to "buf", 0 is returned and "format_in_hex" is set to TRUE, otherwise @@ -1072,7 +1051,6 @@ enum row_search_result row_search_index_entry( terminating '\0'). @return number of bytes that were written */ static ulint row_raw_format_int( - /*===============*/ const char *data, /*!< in: raw data */ ulint data_len, /*!< in: raw data length in bytes */ @@ -1102,8 +1080,7 @@ static ulint row_raw_format_int( return (ut_min(ret, buf_size)); } -/*******************************************************************/ /** - Formats the raw data in "data" (in InnoDB on-disk format) that is of +/** Formats the raw data in "data" (in InnoDB on-disk format) that is of type DATA_(CHAR|VARCHAR|MYSQL|VARMYSQL) using "prtype" and writes the result to "buf". If the data is in binary format, then nothing is written to "buf", @@ -1115,7 +1092,6 @@ static ulint row_raw_format_int( terminating '\0'). @return number of bytes that were written */ static ulint row_raw_format_str( - /*===============*/ const char *data, /*!< in: raw data */ ulint data_len, /*!< in: raw data length in bytes */ @@ -1150,23 +1126,20 @@ static ulint row_raw_format_str( return (innobase_raw_format(data, data_len, charset_coll, buf, buf_size)); } -/*******************************************************************/ /** - Formats the raw data in "data" (in InnoDB on-disk format) using +/** Formats the raw data in "data" (in InnoDB on-disk format) using "dict_field" and writes the result to "buf". Not more than "buf_size" bytes are written to "buf". The result is always NUL-terminated (provided buf_size is positive) and the number of bytes that were written to "buf" is returned (including the terminating NUL). @return number of bytes that were written */ -ulint row_raw_format( - /*===========*/ - const char *data, /*!< in: raw data */ - ulint data_len, /*!< in: raw data length - in bytes */ - const dict_field_t *dict_field, /*!< in: index field */ - char *buf, /*!< out: output buffer */ - ulint buf_size) /*!< in: output buffer size - in bytes */ +ulint row_raw_format(const char *data, /*!< in: raw data */ + ulint data_len, /*!< in: raw data length + in bytes */ + const dict_field_t *dict_field, /*!< in: index field */ + char *buf, /*!< out: output buffer */ + ulint buf_size) /*!< in: output buffer size + in bytes */ { ulint mtype; ulint prtype; diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc index b78ae97c3a5f..34f942eb9f70 100644 --- a/storage/innobase/row/row0sel.cc +++ b/storage/innobase/row/row0sel.cc @@ -31,8 +31,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/***************************************************/ /** - @file row/row0sel.cc +/** @file row/row0sel.cc Select Created 12/19/1997 Heikki Tuuri @@ -91,15 +90,13 @@ to que_run_threads: this is to allow canceling runaway queries */ #define SEL_EXHAUSTED 1 #define SEL_RETRY 2 -/********************************************************************/ /** - Returns TRUE if the user-defined column in a secondary index record +/** Returns TRUE if the user-defined column in a secondary index record is alphabetically the same as the corresponding BLOB column in the clustered index record. NOTE: the comparison is NOT done as a binary comparison, but character fields are compared with collation! @return true if the columns are equal */ static ibool row_sel_sec_rec_is_for_blob( - /*========================*/ trx_t *trx, /*!< in: the operating transaction */ ulint mtype, /*!< in: main type */ ulint prtype, /*!< in: precise type */ @@ -340,11 +337,9 @@ static dberr_t row_sel_sec_rec_is_for_clust_rec( return (err); } -/*********************************************************************/ /** - Creates a select node struct. +/** Creates a select node struct. @return own: select node struct */ sel_node_t *sel_node_create( - /*============*/ mem_heap_t *heap) /*!< in: memory heap where created */ { sel_node_t *node; @@ -359,12 +354,9 @@ sel_node_t *sel_node_create( return (node); } -/*********************************************************************/ /** - Frees the memory private to a select node when a query graph is freed, +/** Frees the memory private to a select node when a query graph is freed, does not free the heap where the node was originally created. */ -void sel_node_free_private( - /*==================*/ - sel_node_t *node) /*!< in: select node struct */ +void sel_node_free_private(sel_node_t *node) /*!< in: select node struct */ { ulint i; plan_t *plan; @@ -383,13 +375,10 @@ void sel_node_free_private( } } -/*********************************************************************/ /** - Evaluates the values in a select list. If there are aggregate functions, +/** Evaluates the values in a select list. If there are aggregate functions, their argument value is added to the aggregate total. */ UNIV_INLINE -void sel_eval_select_list( - /*=================*/ - sel_node_t *node) /*!< in: select node */ +void sel_eval_select_list(sel_node_t *node) /*!< in: select node */ { que_node_t *exp; @@ -402,12 +391,10 @@ void sel_eval_select_list( } } -/*********************************************************************/ /** - Assigns the values in the select list to the possible into-variables in +/** Assigns the values in the select list to the possible into-variables in SELECT ... INTO ... */ UNIV_INLINE void sel_assign_into_var_values( - /*=======================*/ sym_node_t *var, /*!< in: first variable in a list of variables */ sel_node_t *node) /*!< in: select node */ @@ -428,13 +415,10 @@ void sel_assign_into_var_values( } } -/*********************************************************************/ /** - Resets the aggregate value totals in the select list of an aggregate type +/** Resets the aggregate value totals in the select list of an aggregate type query. */ UNIV_INLINE -void sel_reset_aggregate_vals( - /*=====================*/ - sel_node_t *node) /*!< in: select node */ +void sel_reset_aggregate_vals(sel_node_t *node) /*!< in: select node */ { func_node_t *func_node; @@ -449,12 +433,9 @@ void sel_reset_aggregate_vals( node->aggregate_already_fetched = FALSE; } -/*********************************************************************/ /** - Copies the input variable values when an explicit cursor is opened. */ +/** Copies the input variable values when an explicit cursor is opened. */ UNIV_INLINE -void row_sel_copy_input_variable_vals( - /*=============================*/ - sel_node_t *node) /*!< in: select node */ +void row_sel_copy_input_variable_vals(sel_node_t *node) /*!< in: select node */ { sym_node_t *var; @@ -469,10 +450,8 @@ void row_sel_copy_input_variable_vals( } } -/*********************************************************************/ /** - Fetches the column values from a record. */ +/** Fetches the column values from a record. */ static void row_sel_fetch_columns( - /*==================*/ trx_t *trx, /*!< in: the current transaction or nullptr */ dict_index_t *index, /*!< in: record index */ const rec_t *rec, /*!< in: record in a clustered or non-clustered @@ -548,10 +527,9 @@ static void row_sel_fetch_columns( } } -/*********************************************************************/ /** - Allocates a prefetch buffer for a column when prefetch is first time done. */ +/** Allocates a prefetch buffer for a column when prefetch is first time done. + */ static void sel_col_prefetch_buf_alloc( - /*=======================*/ sym_node_t *column) /*!< in: symbol table node for a column */ { sel_buf_t *sel_buf; @@ -571,11 +549,9 @@ static void sel_col_prefetch_buf_alloc( } } -/*********************************************************************/ /** - Frees a prefetch buffer for a column, including the dynamically allocated +/** Frees a prefetch buffer for a column, including the dynamically allocated memory for data stored there. */ void sel_col_prefetch_buf_free( - /*======================*/ sel_buf_t *prefetch_buf) /*!< in, own: prefetch buffer */ { sel_buf_t *sel_buf; @@ -592,11 +568,9 @@ void sel_col_prefetch_buf_free( ut_free(prefetch_buf); } -/*********************************************************************/ /** - Pops the column values for a prefetched, cached row from the column prefetch +/** Pops the column values for a prefetched, cached row from the column prefetch buffers and places them to the val fields in the column nodes. */ static void sel_dequeue_prefetched_row( - /*=======================*/ plan_t *plan) /*!< in: plan node for a table */ { sym_node_t *column; @@ -652,13 +626,10 @@ static void sel_dequeue_prefetched_row( plan->first_prefetched++; } -/*********************************************************************/ /** - Pushes the column values for a prefetched, cached row to the column prefetch +/** Pushes the column values for a prefetched, cached row to the column prefetch buffers from the val fields in the column nodes. */ UNIV_INLINE -void sel_enqueue_prefetched_row( - /*=======================*/ - plan_t *plan) /*!< in: plan node for a table */ +void sel_enqueue_prefetched_row(plan_t *plan) /*!< in: plan node for a table */ { sym_node_t *column; sel_buf_t *sel_buf; @@ -719,11 +690,9 @@ void sel_enqueue_prefetched_row( } } -/*********************************************************************/ /** - Builds a previous version of a clustered index record for a consistent read +/** Builds a previous version of a clustered index record for a consistent read @return DB_SUCCESS or error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_sel_build_prev_vers( - /*====================*/ ReadView *read_view, /*!< in: read view */ dict_index_t *index, /*!< in: plan node for table */ rec_t *rec, /*!< in: record in a clustered index */ @@ -752,11 +721,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_sel_build_prev_vers( return (err); } -/*********************************************************************/ /** - Builds the last committed version of a clustered index record for a +/** Builds the last committed version of a clustered index record for a semi-consistent read. */ static void row_sel_build_committed_vers_for_mysql( - /*===================================*/ dict_index_t *clust_index, /*!< in: clustered index */ row_prebuilt_t *prebuilt, /*!< in: prebuilt struct */ const rec_t *rec, /*!< in: record in a clustered index */ @@ -783,13 +750,11 @@ static void row_sel_build_committed_vers_for_mysql( old_vers, vrow); } -/*********************************************************************/ /** - Tests the conditions which determine when the index segment we are searching +/** Tests the conditions which determine when the index segment we are searching through has been exhausted. @return true if row passed the tests */ UNIV_INLINE ibool row_sel_test_end_conds( - /*===================*/ plan_t *plan) /*!< in: plan for the table; the column values must already have been retrieved and the right sides of comparisons evaluated */ @@ -816,12 +781,10 @@ ibool row_sel_test_end_conds( return (TRUE); } -/*********************************************************************/ /** - Tests the other conditions. +/** Tests the other conditions. @return true if row passed the tests */ UNIV_INLINE ibool row_sel_test_other_conds( - /*=====================*/ plan_t *plan) /*!< in: plan for the table; the column values must already have been retrieved */ { @@ -842,12 +805,10 @@ ibool row_sel_test_other_conds( return (TRUE); } -/*********************************************************************/ /** - Retrieves the clustered index record corresponding to a record in a +/** Retrieves the clustered index record corresponding to a record in a non-clustered index. Does the necessary locking. @return DB_SUCCESS or error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_sel_get_clust_rec( - /*==================*/ sel_node_t *node, /*!< in: select_node */ plan_t *plan, /*!< in: plan node for table */ rec_t *rec, /*!< in: record in a non-clustered index */ @@ -1232,16 +1193,13 @@ dberr_t sel_set_rec_lock(btr_pcur_t *pcur, const rec_t *rec, return (err); } -/*********************************************************************/ /** - Opens a pcur to a table index. */ -static void row_sel_open_pcur( - /*==============*/ - plan_t *plan, /*!< in: table plan */ - ibool search_latch_locked, - /*!< in: TRUE if the thread currently - has the search latch locked in - s-mode */ - mtr_t *mtr) /*!< in: mtr */ +/** Opens a pcur to a table index. */ +static void row_sel_open_pcur(plan_t *plan, /*!< in: table plan */ + ibool search_latch_locked, + /*!< in: TRUE if the thread currently + has the search latch locked in + s-mode */ + mtr_t *mtr) /*!< in: mtr */ { dict_index_t *index; func_node_t *cond; @@ -1304,16 +1262,13 @@ static void row_sel_open_pcur( plan->pcur_is_open = TRUE; } -/*********************************************************************/ /** - Restores a stored pcur position to a table index. +/** Restores a stored pcur position to a table index. @return true if the cursor should be moved to the next record after we return from this function (moved to the previous, in the case of a descending cursor) without processing again the current cursor record */ -static ibool row_sel_restore_pcur_pos( - /*=====================*/ - plan_t *plan, /*!< in: table plan */ - mtr_t *mtr) /*!< in: mtr */ +static ibool row_sel_restore_pcur_pos(plan_t *plan, /*!< in: table plan */ + mtr_t *mtr) /*!< in: mtr */ { ibool equal_position; ulint relative_position; @@ -1392,12 +1347,9 @@ static ibool row_sel_restore_pcur_pos( return (TRUE); } -/*********************************************************************/ /** - Resets a plan cursor to a closed state. */ +/** Resets a plan cursor to a closed state. */ UNIV_INLINE -void plan_reset_cursor( - /*==============*/ - plan_t *plan) /*!< in: plan */ +void plan_reset_cursor(plan_t *plan) /*!< in: plan */ { plan->pcur_is_open = FALSE; plan->cursor_at_end = FALSE; @@ -1405,12 +1357,10 @@ void plan_reset_cursor( plan->n_rows_prefetched = 0; } -/*********************************************************************/ /** - Tries to do a shortcut to fetch a clustered index record with a unique key, +/** Tries to do a shortcut to fetch a clustered index record with a unique key, using the hash index if possible (not always). @return SEL_FOUND, SEL_EXHAUSTED, SEL_RETRY */ static ulint row_sel_try_search_shortcut( - /*========================*/ trx_t *trx, /*!< in: trx doing the operation. */ sel_node_t *node, /*!< in: select node for a consistent read */ plan_t *plan, /*!< in: plan for a unique search in clustered @@ -1506,13 +1456,11 @@ static ulint row_sel_try_search_shortcut( return (ret); } -/*********************************************************************/ /** - Performs a select step. +/** Performs a select step. @return DB_SUCCESS or error code */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_sel( - /*====*/ - sel_node_t *node, /*!< in: select node */ - que_thr_t *thr) /*!< in: query thread */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + row_sel(sel_node_t *node, /*!< in: select node */ + que_thr_t *thr) /*!< in: query thread */ { dict_index_t *index; plan_t *plan; @@ -2177,13 +2125,10 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_sel( return (err); } -/**********************************************************************/ /** - Performs a select step. This is a high-level function used in SQL execution +/** Performs a select step. This is a high-level function used in SQL execution graphs. @return query thread to run next or NULL */ -que_thr_t *row_sel_step( - /*=========*/ - que_thr_t *thr) /*!< in: query thread */ +que_thr_t *row_sel_step(que_thr_t *thr) /*!< in: query thread */ { sel_node_t *node; @@ -2280,12 +2225,9 @@ que_thr_t *row_sel_step( return (thr); } -/**********************************************************************/ /** - Performs a fetch for a cursor. +/** Performs a fetch for a cursor. @return query thread to run next or NULL */ -que_thr_t *fetch_step( - /*=======*/ - que_thr_t *thr) /*!< in: query thread */ +que_thr_t *fetch_step(que_thr_t *thr) /*!< in: query thread */ { sel_node_t *sel_node; fetch_node_t *node; @@ -2335,15 +2277,13 @@ que_thr_t *fetch_step( return (thr); } -/****************************************************************/ /** - Converts a key value stored in MySQL format to an Innobase dtuple. The last +/** Converts a key value stored in MySQL format to an Innobase dtuple. The last field of the key value may be just a prefix of a fixed length field: hence the parameter key_len. But currently we do not allow search keys where the last field is only a prefix of the full key field len and print a warning if such appears. A counterpart of this function is ha_innobase::store_key_val_for_row() in ha_innodb.cc. */ void row_sel_convert_mysql_key_to_innobase( - /*==================================*/ dtuple_t *tuple, /*!< in/out: tuple where to build; NOTE: we assume that the type info in the tuple is already according @@ -2548,10 +2488,8 @@ void row_sel_convert_mysql_key_to_innobase( dtuple_set_n_fields(tuple, n_fields); } -/**************************************************************/ /** - Stores the row id to the prebuilt struct. */ +/** Stores the row id to the prebuilt struct. */ static void row_sel_store_row_id_to_prebuilt( - /*=============================*/ row_prebuilt_t *prebuilt, /*!< in/out: prebuilt */ const rec_t *index_rec, /*!< in: record */ const dict_index_t *index, /*!< in: index of the record */ @@ -3132,12 +3070,10 @@ static MY_ATTRIBUTE((warn_unused_result)) ibool DBUG_RETURN(TRUE); } -/*********************************************************************/ /** - Builds a previous version of a clustered index record for a consistent read +/** Builds a previous version of a clustered index record for a consistent read @return DB_SUCCESS or error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_sel_build_prev_vers_for_mysql( - /*==============================*/ ReadView *read_view, /*!< in: read view */ dict_index_t *clust_index, /*!< in: clustered index */ row_prebuilt_t *prebuilt, /*!< in: prebuilt struct */ @@ -3168,14 +3104,12 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t return (err); } -/*********************************************************************/ /** - Retrieves the clustered index record corresponding to a record in a +/** Retrieves the clustered index record corresponding to a record in a non-clustered index. Does the necessary locking. Used in the MySQL interface. @return DB_SUCCESS, DB_SUCCESS_LOCKED_REC, or error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_sel_get_clust_rec_for_mysql( - /*============================*/ row_prebuilt_t *prebuilt, /*!< in: prebuilt struct in the handle */ dict_index_t *sec_index, /*!< in: secondary index where rec resides */ const rec_t *rec, /*!< in: record in a non-clustered index; if @@ -3421,14 +3355,12 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t return (err); } -/********************************************************************/ /** - Restores cursor position after it has been stored. We have to take into +/** Restores cursor position after it has been stored. We have to take into account that the record cursor was positioned on may have been deleted. Then we may have to move the cursor one step up or down. @return true if we may need to process the record the cursor is now positioned on (i.e. we should not go to the next record yet) */ static ibool sel_restore_position_for_mysql( - /*===========================*/ ibool *same_user_rec, /*!< out: TRUE if we were able to restore the cursor on a user record with the same ordering prefix in in the @@ -3518,10 +3450,8 @@ static ibool sel_restore_position_for_mysql( return (TRUE); } -/********************************************************************/ /** - Copies a cached field for MySQL from the fetch cache. */ +/** Copies a cached field for MySQL from the fetch cache. */ static void row_sel_copy_cached_field_for_mysql( - /*================================*/ byte *buf, /*!< in/out: row buffer */ const byte *cache, /*!< in: cached row */ const mysql_row_templ_t *templ) /*!< in: column template */ @@ -3589,11 +3519,9 @@ static Record_buffer *row_sel_get_record_buffer( return prebuilt->m_mysql_handler->ha_get_record_buffer(); } -/********************************************************************/ /** - Pops a cached row for MySQL from the fetch cache. */ +/** Pops a cached row for MySQL from the fetch cache. */ UNIV_INLINE void row_sel_dequeue_cached_row_for_mysql( - /*=================================*/ byte *buf, /*!< in/out: buffer where to copy the row */ row_prebuilt_t *prebuilt) /*!< in: prebuilt struct */ @@ -3654,11 +3582,9 @@ void row_sel_dequeue_cached_row_for_mysql( } } -/********************************************************************/ /** - Initialise the prefetch cache. */ +/** Initialise the prefetch cache. */ UNIV_INLINE void row_sel_prefetch_cache_init( - /*========================*/ row_prebuilt_t *prebuilt) /*!< in/out: prebuilt struct */ { ulint i; @@ -3689,12 +3615,10 @@ void row_sel_prefetch_cache_init( } } -/********************************************************************/ /** - Get the last fetch cache buffer from the queue. +/** Get the last fetch cache buffer from the queue. @return pointer to buffer. */ UNIV_INLINE byte *row_sel_fetch_last_buf( - /*===================*/ row_prebuilt_t *prebuilt) /*!< in/out: prebuilt struct */ { const auto record_buffer = row_sel_get_record_buffer(prebuilt); @@ -3726,11 +3650,9 @@ byte *row_sel_fetch_last_buf( return (buf); } -/********************************************************************/ /** - Pushes a row for MySQL to the fetch cache. */ +/** Pushes a row for MySQL to the fetch cache. */ UNIV_INLINE void row_sel_enqueue_cache_row_for_mysql( - /*================================*/ byte *mysql_rec, /*!< in/out: MySQL record */ row_prebuilt_t *prebuilt) /*!< in/out: prebuilt struct */ { @@ -3746,14 +3668,12 @@ void row_sel_enqueue_cache_row_for_mysql( ++prebuilt->n_fetch_cached; } -/*********************************************************************/ /** - Tries to do a shortcut to fetch a clustered index record with a unique key, +/** Tries to do a shortcut to fetch a clustered index record with a unique key, using the hash index if possible (not always). We assume that the search mode is PAGE_CUR_GE, it is a consistent read, there is a read view in trx, btr search latch has been locked in S-mode if AHI is enabled. @return SEL_FOUND, SEL_EXHAUSTED, SEL_RETRY */ static ulint row_sel_try_search_shortcut_for_mysql( - /*==================================*/ const rec_t **out_rec, /*!< out: record if found */ row_prebuilt_t *prebuilt, /*!< in: prebuilt struct */ ulint **offsets, /*!< in/out: for rec_get_offsets(*out_rec) */ @@ -3805,11 +3725,9 @@ static ulint row_sel_try_search_shortcut_for_mysql( return (SEL_FOUND); } -/*********************************************************************/ /** - Check a pushed-down index condition. +/** Check a pushed-down index condition. @return ICP_NO_MATCH, ICP_MATCH, or ICP_OUT_OF_RANGE */ static ICP_RESULT row_search_idx_cond_check( - /*======================*/ byte *mysql_rec, /*!< out: record in MySQL format (invalid unless prebuilt->idx_cond == true and @@ -4887,6 +4805,7 @@ dberr_t row_search_mvcc(byte *buf, page_cur_mode_t mode, default: goto lock_wait_or_error; } + DEBUG_SYNC_C("allow_insert"); } /* A page supremum record cannot be in the result set: skip @@ -5843,11 +5762,9 @@ dberr_t row_search_mvcc(byte *buf, page_cur_mode_t mode, DBUG_RETURN(err); } -/********************************************************************/ /** - Count rows in a R-Tree leaf level. +/** Count rows in a R-Tree leaf level. @return DB_SUCCESS if successful */ dberr_t row_count_rtree_recs( - /*=================*/ row_prebuilt_t *prebuilt, /*!< in: prebuilt struct for the table handle; this contains the info of search_tuple, index; if search @@ -5953,12 +5870,10 @@ dberr_t row_count_rtree_recs( goto loop; } -/*******************************************************************/ /** - Read the AUTOINC column from the current row. If the value is less than +/** Read the AUTOINC column from the current row. If the value is less than 0 and the type is not unsigned then we reset the value to 0. @return value read from the column */ static ib_uint64_t row_search_autoinc_read_column( - /*===========================*/ dict_index_t *index, /*!< in: index to read from */ const rec_t *rec, /*!< in: current rec */ ulint col_no, /*!< in: column number */ @@ -6026,12 +5941,10 @@ static const rec_t *row_search_get_max_rec(dict_index_t *index, mtr_t *mtr) { return (rec); } -/*******************************************************************/ /** - Read the max AUTOINC value from an index. +/** Read the max AUTOINC value from an index. @return DB_SUCCESS if all OK else error code, DB_RECORD_NOT_FOUND if column name can't be found in index */ dberr_t row_search_max_autoinc( - /*===================*/ dict_index_t *index, /*!< in: index to search */ const char *col_name, /*!< in: name of autoinc column */ ib_uint64_t *value) /*!< out: AUTOINC value read */ diff --git a/storage/innobase/row/row0uins.cc b/storage/innobase/row/row0uins.cc index 9d0421dc2de6..0487945ea00b 100644 --- a/storage/innobase/row/row0uins.cc +++ b/storage/innobase/row/row0uins.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file row/row0uins.cc +/** @file row/row0uins.cc Fresh insert undo Created 2/25/1997 Heikki Tuuri @@ -65,13 +64,11 @@ check. If you make a change in this module make sure that no codepath is introduced where a call to log_free_check() is bypassed. */ -/***************************************************************/ /** - Removes a clustered index record. The pcur in node was positioned on the +/** Removes a clustered index record. The pcur in node was positioned on the record, now it is detached. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo_ins_remove_clust_rec( - /*==========================*/ - undo_node_t *node) /*!< in: undo node */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + row_undo_ins_remove_clust_rec(undo_node_t *node) /*!< in: undo node */ { btr_cur_t *btr_cur; ibool success; @@ -161,11 +158,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo_ins_remove_clust_rec( return (err); } -/***************************************************************/ /** - Removes a secondary index entry if found. +/** Removes a secondary index entry if found. @return DB_SUCCESS, DB_FAIL, or DB_OUT_OF_FILE_SPACE */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo_ins_remove_sec_low( - /*========================*/ ulint mode, /*!< in: BTR_MODIFY_LEAF or BTR_MODIFY_TREE, depending on whether we wish optimistic or pessimistic descent down the index tree */ @@ -251,15 +246,13 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo_ins_remove_sec_low( return (err); } -/***************************************************************/ /** - Removes a secondary index entry from the index if found. Tries first +/** Removes a secondary index entry from the index if found. Tries first optimistic, then pessimistic descent down the tree. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo_ins_remove_sec( - /*====================*/ - dict_index_t *index, /*!< in: index */ - dtuple_t *entry, /*!< in: index entry to insert */ - que_thr_t *thr) /*!< in: query thread */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + row_undo_ins_remove_sec(dict_index_t *index, /*!< in: index */ + dtuple_t *entry, /*!< in: index entry to insert */ + que_thr_t *thr) /*!< in: query thread */ { dberr_t err; ulint n_tries = 0; @@ -347,13 +340,11 @@ static void row_undo_ins_parse_undo_rec(undo_node_t *node, MDL_ticket **mdl) { } } -/***************************************************************/ /** - Removes secondary index records. +/** Removes secondary index records. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo_ins_remove_sec_rec( - /*========================*/ - undo_node_t *node, /*!< in/out: row undo node */ - que_thr_t *thr) /*!< in: query thread */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + row_undo_ins_remove_sec_rec(undo_node_t *node, /*!< in/out: row undo node */ + que_thr_t *thr) /*!< in: query thread */ { dberr_t err = DB_SUCCESS; dict_index_t *index = node->index; @@ -404,17 +395,14 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo_ins_remove_sec_rec( return (err); } -/***********************************************************/ /** - Undoes a fresh insert of a row to a table. A fresh insert means that +/** Undoes a fresh insert of a row to a table. A fresh insert means that the same clustered index unique key did not have any record, even delete marked, at the time of the insert. InnoDB is eager in a rollback: if it figures out that an index record will be removed in the purge anyway, it will remove it in the rollback. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -dberr_t row_undo_ins( - /*=========*/ - undo_node_t *node, /*!< in: row undo node */ - que_thr_t *thr) /*!< in: query thread */ +dberr_t row_undo_ins(undo_node_t *node, /*!< in: row undo node */ + que_thr_t *thr) /*!< in: query thread */ { dberr_t err; MDL_ticket *mdl = nullptr; diff --git a/storage/innobase/row/row0umod.cc b/storage/innobase/row/row0umod.cc index 5b8b84d7b20e..16256c24c9de 100644 --- a/storage/innobase/row/row0umod.cc +++ b/storage/innobase/row/row0umod.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file row/row0umod.cc +/** @file row/row0umod.cc Undo modify of a row Created 2/27/1997 Heikki Tuuri @@ -81,11 +80,9 @@ check. If you make a change in this module make sure that no codepath is introduced where a call to log_free_check() is bypassed. */ -/***********************************************************/ /** - Undoes a modify in a clustered index record. +/** Undoes a modify in a clustered index record. @return DB_SUCCESS, DB_FAIL, or error code: we may run out of file space */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo_mod_clust_low( - /*===================*/ undo_node_t *node, /*!< in: row undo node */ ulint **offsets, /*!< out: rec_get_offsets() on the record */ mem_heap_t **offsets_heap, @@ -157,15 +154,13 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo_mod_clust_low( DBUG_RETURN(err); } -/***********************************************************/ /** - Purges a clustered index record after undo if possible. +/** Purges a clustered index record after undo if possible. This is attempted when the record was inserted by updating a delete-marked record and there no longer exist transactions that would see the delete-marked record. @return DB_SUCCESS, DB_FAIL, or error code: we may run out of file space */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo_mod_remove_clust_low( - /*==========================*/ undo_node_t *node, /*!< in: row undo node */ mtr_t *mtr, /*!< in/out: mini-transaction */ ulint mode) /*!< in: BTR_MODIFY_LEAF or BTR_MODIFY_TREE */ @@ -244,14 +239,12 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo_mod_remove_clust_low( return (err); } -/***********************************************************/ /** - Undoes a modify in a clustered index record. Sets also the node state for the - next round of undo. +/** Undoes a modify in a clustered index record. Sets also the node state for + the next round of undo. @return DB_SUCCESS or error code: we may run out of file space */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo_mod_clust( - /*===============*/ - undo_node_t *node, /*!< in: row undo node */ - que_thr_t *thr) /*!< in: query thread */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + row_undo_mod_clust(undo_node_t *node, /*!< in: row undo node */ + que_thr_t *thr) /*!< in: query thread */ { btr_pcur_t *pcur; mtr_t mtr; @@ -373,12 +366,10 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo_mod_clust( return (err); } -/***********************************************************/ /** - Delete marks or removes a secondary index entry if found. +/** Delete marks or removes a secondary index entry if found. @return DB_SUCCESS, DB_FAIL, or DB_OUT_OF_FILE_SPACE */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo_mod_del_mark_or_remove_sec_low( - /*====================================*/ undo_node_t *node, /*!< in: row undo node */ que_thr_t *thr, /*!< in: query thread */ dict_index_t *index, /*!< in: index */ @@ -521,8 +512,7 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t return (err); } -/***********************************************************/ /** - Delete marks or removes a secondary index entry if found. +/** Delete marks or removes a secondary index entry if found. NOTE that if we updated the fields of a delete-marked secondary index record so that alphabetically they stayed the same, e.g., 'abc' -> 'aBc', we cannot return to the original values because we do not know them. But this should @@ -532,7 +522,6 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo_mod_del_mark_or_remove_sec( - /*================================*/ undo_node_t *node, /*!< in: row undo node */ que_thr_t *thr, /*!< in: query thread */ dict_index_t *index, /*!< in: index */ @@ -551,8 +540,7 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t return (err); } -/***********************************************************/ /** - Delete unmarks a secondary index entry which must be found. It might not be +/** Delete unmarks a secondary index entry which must be found. It might not be delete-marked at the moment, but it does not harm to unmark it anyway. We also need to update the fields of the secondary index record if we updated its fields but alphabetically they stayed the same, e.g., 'abc' -> 'aBc'. @@ -563,7 +551,6 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t and an insert would lead to a duplicate exists */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo_mod_del_unmark_sec_and_undo_update( - /*========================================*/ ulint mode, /*!< in: search mode: BTR_MODIFY_LEAF or BTR_MODIFY_TREE */ que_thr_t *thr, /*!< in: query thread */ @@ -757,10 +744,8 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t return (err); } -/***********************************************************/ /** - Flags a secondary index corrupted. */ +/** Flags a secondary index corrupted. */ static void row_undo_mod_sec_flag_corrupted( - /*============================*/ trx_t *trx, /*!< in/out: transaction */ dict_index_t *index) /*!< in: secondary index */ { @@ -780,13 +765,11 @@ static void row_undo_mod_sec_flag_corrupted( } } -/***********************************************************/ /** - Undoes a modify in secondary indexes when undo record type is UPD_DEL. +/** Undoes a modify in secondary indexes when undo record type is UPD_DEL. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo_mod_upd_del_sec( - /*=====================*/ - undo_node_t *node, /*!< in: row undo node */ - que_thr_t *thr) /*!< in: query thread */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + row_undo_mod_upd_del_sec(undo_node_t *node, /*!< in: row undo node */ + que_thr_t *thr) /*!< in: query thread */ { mem_heap_t *heap; dberr_t err = DB_SUCCESS; @@ -842,13 +825,11 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo_mod_upd_del_sec( return (err); } -/***********************************************************/ /** - Undoes a modify in secondary indexes when undo record type is DEL_MARK. +/** Undoes a modify in secondary indexes when undo record type is DEL_MARK. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo_mod_del_mark_sec( - /*======================*/ - undo_node_t *node, /*!< in: row undo node */ - que_thr_t *thr) /*!< in: query thread */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + row_undo_mod_del_mark_sec(undo_node_t *node, /*!< in: row undo node */ + que_thr_t *thr) /*!< in: query thread */ { mem_heap_t *heap; dberr_t err = DB_SUCCESS; @@ -906,13 +887,11 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo_mod_del_mark_sec( return (err); } -/***********************************************************/ /** - Undoes a modify in secondary indexes when undo record type is UPD_EXIST. +/** Undoes a modify in secondary indexes when undo record type is UPD_EXIST. @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo_mod_upd_exist_sec( - /*=======================*/ - undo_node_t *node, /*!< in: row undo node */ - que_thr_t *thr) /*!< in: query thread */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + row_undo_mod_upd_exist_sec(undo_node_t *node, /*!< in: row undo node */ + que_thr_t *thr) /*!< in: query thread */ { mem_heap_t *heap; dberr_t err = DB_SUCCESS; @@ -1101,13 +1080,10 @@ static void row_undo_mod_parse_undo_rec(undo_node_t *node, MDL_ticket **mdl) { } } -/***********************************************************/ /** - Undoes a modify operation on a row of a table. +/** Undoes a modify operation on a row of a table. @return DB_SUCCESS or error code */ -dberr_t row_undo_mod( - /*=========*/ - undo_node_t *node, /*!< in: row undo node */ - que_thr_t *thr) /*!< in: query thread */ +dberr_t row_undo_mod(undo_node_t *node, /*!< in: row undo node */ + que_thr_t *thr) /*!< in: query thread */ { dberr_t err; MDL_ticket *mdl = nullptr; diff --git a/storage/innobase/row/row0undo.cc b/storage/innobase/row/row0undo.cc index 2d00f6dfe155..205c69a236a5 100644 --- a/storage/innobase/row/row0undo.cc +++ b/storage/innobase/row/row0undo.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file row/row0undo.cc +/** @file row/row0undo.cc Row undo Created 1/8/1997 Heikki Tuuri @@ -127,11 +126,9 @@ doing the purge. Similarly, during a rollback, a record can be removed if the stored roll ptr in the undo log points to a trx already (being) purged, or if the roll ptr is NULL, i.e., it was a fresh insert. */ -/********************************************************************/ /** - Creates a row undo node to a query graph. +/** Creates a row undo node to a query graph. @return own: undo node */ undo_node_t *row_undo_node_create( - /*=================*/ trx_t *trx, /*!< in/out: transaction */ que_thr_t *parent, /*!< in: parent node, i.e., a thr node */ mem_heap_t *heap) /*!< in: memory heap where created */ @@ -157,15 +154,13 @@ undo_node_t *row_undo_node_create( return (undo); } -/***********************************************************/ /** - Looks for the clustered index record when node has the row reference. +/** Looks for the clustered index record when node has the row reference. The pcur in node is used in the search. If found, stores the row to node, and stores the position of pcur, and detaches it. The pcur must be closed by the caller in any case. @return true if found; NOTE the node->pcur must be closed by the caller, regardless of the return value */ bool row_undo_search_clust_to_pcur( - /*==========================*/ undo_node_t *node) /*!< in/out: row undo node */ { dict_index_t *clust_index; @@ -249,15 +244,13 @@ bool row_undo_search_clust_to_pcur( return (found); } -/***********************************************************/ /** - Fetches an undo log record and does the undo for the recorded operation. +/** Fetches an undo log record and does the undo for the recorded operation. If none left, or a partial rollback completed, returns control to the parent node, which is always a query thread node. @return DB_SUCCESS if operation successfully completed, else error code */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo( - /*=====*/ - undo_node_t *node, /*!< in: row undo node */ - que_thr_t *thr) /*!< in: query thread */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + row_undo(undo_node_t *node, /*!< in: row undo node */ + que_thr_t *thr) /*!< in: query thread */ { dberr_t err; trx_t *trx; @@ -322,13 +315,10 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_undo( return (err); } -/***********************************************************/ /** - Undoes a row operation in a table. This is a high-level function used +/** Undoes a row operation in a table. This is a high-level function used in SQL execution graphs. @return query thread to run next or NULL */ -que_thr_t *row_undo_step( - /*==========*/ - que_thr_t *thr) /*!< in: query thread */ +que_thr_t *row_undo_step(que_thr_t *thr) /*!< in: query thread */ { dberr_t err; undo_node_t *node; diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index 2d02c2475636..54ec2abd53ab 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file row/row0upd.cc +/** @file row/row0upd.cc Update of a row Created 12/27/1996 Heikki Tuuri @@ -131,20 +130,17 @@ check. If you make a change in this module make sure that no codepath is introduced where a call to log_free_check() is bypassed. */ -/***********************************************************/ /** - Checks if an update vector changes some of the first ordering fields of an +/** Checks if an update vector changes some of the first ordering fields of an index record. This is only used in foreign key checks and we can assume that index does not contain column prefixes. @return true if changes */ static ibool row_upd_changes_first_fields_binary( - /*================================*/ dtuple_t *entry, /*!< in: old value of index entry */ dict_index_t *index, /*!< in: index of entry */ const upd_t *update, /*!< in: update vector for the row */ ulint n); /*!< in: how many first fields to check */ -/*********************************************************************/ /** - Checks if index currently is mentioned as a referenced index in a foreign +/** Checks if index currently is mentioned as a referenced index in a foreign key constraint. NOTE that since we do not hold dict_operation_lock when leaving the @@ -152,10 +148,8 @@ static ibool row_upd_changes_first_fields_binary( we leave this function: this function is only for heuristic use! @return true if referenced */ -static ibool row_upd_index_is_referenced( - /*========================*/ - dict_index_t *index, /*!< in: index */ - trx_t *trx) /*!< in: transaction */ +static ibool row_upd_index_is_referenced(dict_index_t *index, /*!< in: index */ + trx_t *trx) /*!< in: transaction */ { dict_table_t *table = index->table; ibool is_referenced = FALSE; @@ -173,8 +167,7 @@ static ibool row_upd_index_is_referenced( return (is_referenced); } -/*********************************************************************/ /** - Checks if possible foreign key constraints hold after a delete of the record +/** Checks if possible foreign key constraints hold after a delete of the record under pcur. NOTE that this function will temporarily commit mtr and lose the @@ -183,7 +176,6 @@ static ibool row_upd_index_is_referenced( @return DB_SUCCESS or an error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_upd_check_references_constraints( - /*=================================*/ upd_node_t *node, /*!< in: row update node */ btr_pcur_t *pcur, /*!< in: cursor positioned on a record; NOTE: the cursor position is lost in this function! */ @@ -287,12 +279,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t DBUG_RETURN(err); } -/*********************************************************************/ /** - Creates an update node for a query graph. +/** Creates an update node for a query graph. @return own: update node */ -upd_node_t *upd_node_create( - /*============*/ - mem_heap_t *heap) /*!< in: mem heap where created */ +upd_node_t *upd_node_create(mem_heap_t *heap) /*!< in: mem heap where created */ { upd_node_t *node; @@ -307,11 +296,9 @@ upd_node_t *upd_node_create( } #endif /* !UNIV_HOTBACKUP */ -/*********************************************************************/ /** - Updates the trx id and roll ptr field in a clustered index record in database - recovery. */ +/** Updates the trx id and roll ptr field in a clustered index record in + database recovery. */ void row_upd_rec_sys_fields_in_recovery( - /*===============================*/ rec_t *rec, /*!< in/out: record */ page_zip_des_t *page_zip, /*!< in/out: compressed page, or NULL */ const ulint *offsets, /*!< in: array returned by rec_get_offsets() */ @@ -339,10 +326,8 @@ void row_upd_rec_sys_fields_in_recovery( } #ifndef UNIV_HOTBACKUP -/*********************************************************************/ /** - Sets the trx id or roll ptr field of a clustered index entry. */ +/** Sets the trx id or roll ptr field of a clustered index entry. */ void row_upd_index_entry_sys_field( - /*==========================*/ dtuple_t *entry, /*!< in/out: index entry, where the memory buffers for sys fields are already allocated: the function just copies the new values to @@ -371,13 +356,11 @@ void row_upd_index_entry_sys_field( } } -/***********************************************************/ /** - Returns TRUE if row update changes size of some field in index or if some +/** Returns TRUE if row update changes size of some field in index or if some field to be updated is stored externally in rec or update. @return true if the update changes the size of some field in index or the field is external in rec or update */ ibool row_upd_changes_field_size_or_external( - /*===================================*/ dict_index_t *index, /*!< in: index */ const ulint *offsets, /*!< in: rec_get_offsets(rec, index) */ const upd_t *update) /*!< in: update vector */ @@ -439,11 +422,9 @@ ibool row_upd_changes_field_size_or_external( return (FALSE); } -/***********************************************************/ /** - Returns true if row update contains disowned external fields. +/** Returns true if row update contains disowned external fields. @return true if the update contains disowned external fields. */ bool row_upd_changes_disowned_external( - /*==============================*/ const upd_t *update) /*!< in: update vector */ { const upd_field_t *upd_field; @@ -474,14 +455,12 @@ bool row_upd_changes_disowned_external( } #endif /* !UNIV_HOTBACKUP */ -/***********************************************************/ /** - Replaces the new column values stored in the update vector to the +/** Replaces the new column values stored in the update vector to the record given. No field size changes are allowed. This function is usually invoked on a clustered index. The only use case for a secondary index is row_ins_sec_index_entry_by_modify() or its counterpart in ibuf_insert_to_index_page(). */ void row_upd_rec_in_place( - /*=================*/ rec_t *rec, /*!< in/out: record where replaced */ dict_index_t *index, /*!< in: the index the record belongs to */ const ulint *offsets, /*!< in: array returned by rec_get_offsets() */ @@ -527,12 +506,10 @@ void row_upd_rec_in_place( } #ifndef UNIV_HOTBACKUP -/*********************************************************************/ /** - Writes into the redo log the values of trx id and roll ptr and enough info +/** Writes into the redo log the values of trx id and roll ptr and enough info to determine their positions within a clustered index record. @return new pointer to mlog */ byte *row_upd_write_sys_vals_to_log( - /*==========================*/ dict_index_t *index, /*!< in: clustered index */ trx_id_t trx_id, /*!< in: transaction id */ roll_ptr_t roll_ptr, /*!< in: roll ptr of the undo log record */ @@ -555,16 +532,13 @@ byte *row_upd_write_sys_vals_to_log( } #endif /* !UNIV_HOTBACKUP */ -/*********************************************************************/ /** - Parses the log data of system field values. +/** Parses the log data of system field values. @return log data end or NULL */ -byte *row_upd_parse_sys_vals( - /*===================*/ - const byte *ptr, /*!< in: buffer */ - const byte *end_ptr, /*!< in: buffer end */ - ulint *pos, /*!< out: TRX_ID position in record */ - trx_id_t *trx_id, /*!< out: trx id */ - roll_ptr_t *roll_ptr) /*!< out: roll ptr */ +byte *row_upd_parse_sys_vals(const byte *ptr, /*!< in: buffer */ + const byte *end_ptr, /*!< in: buffer end */ + ulint *pos, /*!< out: TRX_ID position in record */ + trx_id_t *trx_id, /*!< out: trx id */ + roll_ptr_t *roll_ptr) /*!< out: roll ptr */ { *pos = mach_parse_compressed(&ptr, end_ptr); @@ -585,10 +559,9 @@ byte *row_upd_parse_sys_vals( } #ifndef UNIV_HOTBACKUP -/***********************************************************/ /** - Writes to the redo log the new values of the fields occurring in the index. */ +/** Writes to the redo log the new values of the fields occurring in the index. + */ void row_upd_index_write_log( - /*====================*/ const upd_t *update, /*!< in: update vector */ byte *log_ptr, /*!< in: pointer to mlog buffer: must contain at least MLOG_BUF_MARGIN bytes @@ -659,11 +632,9 @@ void row_upd_index_write_log( } #endif /* !UNIV_HOTBACKUP */ -/*********************************************************************/ /** - Parses the log data written by row_upd_index_write_log. +/** Parses the log data written by row_upd_index_write_log. @return log data end or NULL */ byte *row_upd_index_parse( - /*================*/ const byte *ptr, /*!< in: buffer */ const byte *end_ptr, /*!< in: buffer end */ mem_heap_t *heap, /*!< in: memory heap where update vector is @@ -753,13 +724,11 @@ upd_field_t *upd_t::get_upd_field(ulint field_no) const { } #ifndef UNIV_HOTBACKUP -/***************************************************************/ /** - Builds an update vector from those fields which in a secondary index entry +/** Builds an update vector from those fields which in a secondary index entry differ from a record that has the equal ordering fields. NOTE: we compare the fields as binary strings! @return own: update vector of differing fields */ upd_t *row_upd_build_sec_rec_difference_binary( - /*====================================*/ const rec_t *rec, /*!< in: secondary index record */ dict_index_t *index, /*!< in: index */ const ulint *offsets, /*!< in: rec_get_offsets(rec, index) */ @@ -1112,11 +1081,9 @@ static void row_upd_index_replace_new_col_val_func( DBUG_VOID_RETURN; } -/***********************************************************/ /** - Replaces the new column values stored in the update vector to the index entry - given. */ +/** Replaces the new column values stored in the update vector to the index + entry given. */ void row_upd_index_replace_new_col_vals_index_pos( - /*=========================================*/ dtuple_t *entry, /*!< in/out: index entry where replaced; the clustered index record must be covered by a lock or a page latch to @@ -1186,11 +1153,9 @@ void row_upd_index_replace_new_col_vals_index_pos( DBUG_VOID_RETURN; } -/***********************************************************/ /** - Replaces the new column values stored in the update vector to the index entry - given. */ +/** Replaces the new column values stored in the update vector to the index + entry given. */ void row_upd_index_replace_new_col_vals( - /*===============================*/ dtuple_t *entry, /*!< in/out: index entry where replaced; the clustered index record must be covered by a lock or a page latch to @@ -1359,10 +1324,8 @@ void row_upd_replace_vcol(dtuple_t *row, const dict_table_t *table, } } -/***********************************************************/ /** - Replaces the new column values stored in the update vector. */ +/** Replaces the new column values stored in the update vector. */ void row_upd_replace( - /*============*/ trx_t *trx, /*!< in: transaction object. */ dtuple_t *row, /*!< in/out: row where replaced, indexed by col_no; @@ -1441,15 +1404,13 @@ void row_upd_replace( row_upd_replace_vcol(row, table, update, true, NULL, NULL); } -/***********************************************************/ /** - Checks if an update vector changes an ordering field of an index record. +/** Checks if an update vector changes an ordering field of an index record. This function is fast if the update vector is short or the number of ordering fields in the index is small. Otherwise, this can be quadratic. NOTE: we compare the fields as binary strings! @return true if update vector changes an ordering field in the index record */ ibool row_upd_changes_ord_field_binary_func( - /*==================================*/ dict_index_t *index, /*!< in: index of the record */ const upd_t *update, /*!< in: update vector for the row; NOTE: the field numbers in this MUST be clustered index @@ -1666,13 +1627,11 @@ ibool row_upd_changes_ord_field_binary_func( return (FALSE); } -/***********************************************************/ /** - Checks if an update vector changes an ordering field of an index record. +/** Checks if an update vector changes an ordering field of an index record. NOTE: we compare the fields as binary strings! @return true if update vector may change an ordering field in an index record */ ibool row_upd_changes_some_index_ord_field_binary( - /*========================================*/ const dict_table_t *table, /*!< in: table */ const upd_t *update) /*!< in: update vector for the row */ { @@ -1700,13 +1659,10 @@ ibool row_upd_changes_some_index_ord_field_binary( return (FALSE); } -/***********************************************************/ /** - Checks if an FTS Doc ID column is affected by an UPDATE. +/** Checks if an FTS Doc ID column is affected by an UPDATE. @return whether the Doc ID column is changed */ -bool row_upd_changes_doc_id( - /*===================*/ - dict_table_t *table, /*!< in: table */ - upd_field_t *upd_field) /*!< in: field to check */ +bool row_upd_changes_doc_id(dict_table_t *table, /*!< in: table */ + upd_field_t *upd_field) /*!< in: field to check */ { ulint col_no; dict_index_t *clust_index; @@ -1722,12 +1678,10 @@ bool row_upd_changes_doc_id( return (col_no == fts->doc_col); } -/***********************************************************/ /** - Checks if an FTS indexed column is affected by an UPDATE. +/** Checks if an FTS indexed column is affected by an UPDATE. @return offset within fts_t::indexes if FTS indexed column updated else ULINT_UNDEFINED */ ulint row_upd_changes_fts_column( - /*=======================*/ dict_table_t *table, /*!< in: table */ upd_field_t *upd_field) /*!< in: field to check */ { @@ -1750,13 +1704,11 @@ ulint row_upd_changes_fts_column( } } -/***********************************************************/ /** - Checks if an update vector changes some of the first ordering fields of an +/** Checks if an update vector changes some of the first ordering fields of an index record. This is only used in foreign key checks and we can assume that index does not contain column prefixes. @return true if changes */ static ibool row_upd_changes_first_fields_binary( - /*================================*/ dtuple_t *entry, /*!< in: index entry */ dict_index_t *index, /*!< in: index of entry */ const upd_t *update, /*!< in: update vector for the row */ @@ -1797,11 +1749,9 @@ static ibool row_upd_changes_first_fields_binary( return (FALSE); } -/*********************************************************************/ /** - Copies the column values from a record. */ +/** Copies the column values from a record. */ UNIV_INLINE void row_upd_copy_columns( - /*=================*/ rec_t *rec, /*!< in: record in a clustered index */ const ulint *offsets, /*!< in: array returned by rec_get_offsets() */ sym_node_t *column) /*!< in: first column in a column list, or @@ -1819,13 +1769,10 @@ void row_upd_copy_columns( } } -/*********************************************************************/ /** - Calculates the new values for fields to update. Note that row_upd_copy_columns - must have been called first. */ +/** Calculates the new values for fields to update. Note that + row_upd_copy_columns must have been called first. */ UNIV_INLINE -void row_upd_eval_new_vals( - /*==================*/ - upd_t *update) /*!< in/out: update vector */ +void row_upd_eval_new_vals(upd_t *update) /*!< in/out: update vector */ { que_node_t *exp; upd_field_t *upd_field; @@ -1969,8 +1916,7 @@ void row_upd_store_row(trx_t *trx, upd_node_t *node, THD *thd, } } -/***********************************************************/ /** - Print a MBR data from disk */ +/** Print a MBR data from disk */ static void srv_mbr_print(const byte *data) { double a, b, c, d; a = mach_double_read(data); @@ -1985,14 +1931,12 @@ static void srv_mbr_print(const byte *data) { << "\n"; } -/***********************************************************/ /** - Updates a secondary index entry of a row. +/** Updates a secondary index entry of a row. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_upd_sec_index_entry( - /*====================*/ - upd_node_t *node, /*!< in: row update node */ - que_thr_t *thr) /*!< in: query thread */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + row_upd_sec_index_entry(upd_node_t *node, /*!< in: row update node */ + que_thr_t *thr) /*!< in: query thread */ { mtr_t mtr; const rec_t *rec; @@ -2211,15 +2155,13 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_upd_sec_index_entry( return (err); } -/***********************************************************/ /** - Updates the secondary index record if it is changed in the row update or +/** Updates the secondary index record if it is changed in the row update or deletes it if this is a delete. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_upd_sec_step( - /*=============*/ - upd_node_t *node, /*!< in: row update node */ - que_thr_t *thr) /*!< in: query thread */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + row_upd_sec_step(upd_node_t *node, /*!< in: row update node */ + que_thr_t *thr) /*!< in: query thread */ { ut_ad((node->state == UPD_NODE_UPDATE_ALL_SEC) || (node->state == UPD_NODE_UPDATE_SOME_SEC)); @@ -2241,14 +2183,12 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_upd_sec_step( #define row_upd_clust_rec_by_insert_inherit(rec, offsets, entry, update) \ row_upd_clust_rec_by_insert_inherit_func(rec, entry, update) #endif /* UNIV_DEBUG */ -/*******************************************************************/ /** - Mark non-updated off-page columns inherited when the primary key is +/** Mark non-updated off-page columns inherited when the primary key is updated. We must mark them as inherited in entry, so that they are not freed in a rollback. A limited version of this function used to be called btr_cur_mark_dtuple_inherited_extern(). @return whether any columns were inherited */ static bool row_upd_clust_rec_by_insert_inherit_func( - /*=====================================*/ const rec_t *rec, /*!< in: old record, or NULL */ #ifdef UNIV_DEBUG const ulint *offsets, /*!< in: rec_get_offsets(rec), or NULL */ @@ -2318,15 +2258,13 @@ static bool row_upd_clust_rec_by_insert_inherit_func( return (inherit); } -/***********************************************************/ /** - Marks the clustered index record deleted and inserts the updated version +/** Marks the clustered index record deleted and inserts the updated version of the record to the index. This function should be used when the ordering fields of the clustered index record change. This should be quite rare in database applications. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_upd_clust_rec_by_insert( - /*========================*/ ulint flags, /*!< in: undo logging and locking flags */ upd_node_t *node, /*!< in/out: row update node */ dict_index_t *index, /*!< in: clustered index of the record */ @@ -2521,13 +2459,11 @@ static void row_upd_check_autoinc_counter(const upd_node_t *node, } } -/***********************************************************/ /** - Updates a clustered index record of a row when the ordering fields do +/** Updates a clustered index record of a row when the ordering fields do not change. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_upd_clust_rec( - /*==============*/ ulint flags, /*!< in: undo logging and locking flags */ upd_node_t *node, /*!< in: row update node */ dict_index_t *index, /*!< in: clustered index */ @@ -2670,11 +2606,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_upd_clust_rec( return (err); } -/***********************************************************/ /** - Delete marks a clustered index record. +/** Delete marks a clustered index record. @return DB_SUCCESS if operation successfully completed, else error code */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_upd_del_mark_clust_rec( - /*=======================*/ ulint flags, /*!< in: undo logging and locking flags */ upd_node_t *node, /*!< in: row update node */ dict_index_t *index, /*!< in: clustered index */ @@ -2722,14 +2656,12 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_upd_del_mark_clust_rec( return (err); } -/***********************************************************/ /** - Updates the clustered index record. +/** Updates the clustered index record. @return DB_SUCCESS if operation successfully completed, DB_LOCK_WAIT in case of a lock wait, else error code */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_upd_clust_step( - /*===============*/ - upd_node_t *node, /*!< in: row update node */ - que_thr_t *thr) /*!< in: query thread */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + row_upd_clust_step(upd_node_t *node, /*!< in: row update node */ + que_thr_t *thr) /*!< in: query thread */ { dict_index_t *index; btr_pcur_t *pcur; @@ -2889,16 +2821,13 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t row_upd_clust_step( return (err); } -/***********************************************************/ /** - Updates the affected index records of a row. When the control is transferred +/** Updates the affected index records of a row. When the control is transferred to this node, we assume that we have a persistent cursor which was on a record, and the position of the cursor is stored in the cursor. @return DB_SUCCESS if operation successfully completed, else error code or DB_LOCK_WAIT */ -static dberr_t row_upd( - /*====*/ - upd_node_t *node, /*!< in: row update node */ - que_thr_t *thr) /*!< in: query thread */ +static dberr_t row_upd(upd_node_t *node, /*!< in: row update node */ + que_thr_t *thr) /*!< in: query thread */ { dberr_t err = DB_SUCCESS; DBUG_ENTER("row_upd"); @@ -2984,13 +2913,10 @@ static dberr_t row_upd( DBUG_RETURN(err); } -/***********************************************************/ /** - Updates a row in a table. This is a high-level function used in SQL execution - graphs. +/** Updates a row in a table. This is a high-level function used in SQL + execution graphs. @return query thread to run next or NULL */ -que_thr_t *row_upd_step( - /*=========*/ - que_thr_t *thr) /*!< in: query thread */ +que_thr_t *row_upd_step(que_thr_t *thr) /*!< in: query thread */ { upd_node_t *node; sel_node_t *sel_node; diff --git a/storage/innobase/row/row0vers.cc b/storage/innobase/row/row0vers.cc index 076e568d8f2b..349df0d7f075 100644 --- a/storage/innobase/row/row0vers.cc +++ b/storage/innobase/row/row0vers.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1997, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file row/row0vers.cc +/** @file row/row0vers.cc Row versions Created 2/6/1997 Heikki Tuuri @@ -69,8 +68,7 @@ static bool row_vers_non_vc_index_entry_match(dict_index_t *index, const dtuple_t *ientry2, ulint *n_non_v_col); -/*****************************************************************/ /** - Finds out if an active transaction has inserted or modified a secondary +/** Finds out if an active transaction has inserted or modified a secondary index record. @return 0 if committed, else the active transaction id; NOTE that this function can return false positives but never false @@ -78,7 +76,6 @@ static bool row_vers_non_vc_index_entry_match(dict_index_t *index, trx_is_active() while holding lock_sys->mutex. */ UNIV_INLINE trx_t *row_vers_impl_x_locked_low( - /*=======================*/ const rec_t *clust_rec, /*!< in: clustered index record */ dict_index_t *clust_index, /*!< in: the clustered index */ const rec_t *rec, /*!< in: secondary index record */ @@ -328,15 +325,13 @@ trx_t *row_vers_impl_x_locked_low( DBUG_RETURN(trx); } -/*****************************************************************/ /** - Finds out if an active transaction has inserted or modified a secondary +/** Finds out if an active transaction has inserted or modified a secondary index record. @return 0 if committed, else the active transaction id; NOTE that this function can return false positives but never false negatives. The caller must confirm all positive results by calling trx_is_active() while holding lock_sys->mutex. */ trx_t *row_vers_impl_x_locked( - /*===================*/ const rec_t *rec, /*!< in: record in a secondary index */ dict_index_t *index, /*!< in: the secondary index */ const ulint *offsets) /*!< in: rec_get_offsets(rec, index) */ @@ -387,8 +382,7 @@ trx_t *row_vers_impl_x_locked( return (trx); } -/*****************************************************************/ /** - Finds out if we must preserve a delete marked earlier version of a clustered +/** Finds out if we must preserve a delete marked earlier version of a clustered index record, because it is >= the purge view. @param[in] trx_id transaction id in the version @param[in] name table name @@ -396,9 +390,8 @@ trx_t *row_vers_impl_x_locked( clustered index record; it will also hold the latch on purge_view @return true if earlier version should be preserved */ -ibool row_vers_must_preserve_del_marked( - /*==============================*/ - trx_id_t trx_id, const table_name_t &name, mtr_t *mtr) { +ibool row_vers_must_preserve_del_marked(trx_id_t trx_id, + const table_name_t &name, mtr_t *mtr) { ut_ad(!rw_lock_own(&(purge_sys->latch), RW_LOCK_S)); mtr_s_lock(&purge_sys->latch, mtr); @@ -777,15 +770,13 @@ static const dtuple_t *row_vers_build_cur_vrow( return (cur_vrow); } -/*****************************************************************/ /** - Finds out if a version of the record, where the version >= the current +/** Finds out if a version of the record, where the version >= the current purge view, should have ientry as its secondary index entry. We check if there is any not delete marked version of the record where the trx id >= purge view, and the secondary index entry and ientry are identified in the alphabetical ordering; exactly in this case we return TRUE. @return true if earlier version should have */ ibool row_vers_old_has_index_entry( - /*=========================*/ ibool also_curr, /*!< in: TRUE if also rec is included in the versions to search; otherwise only versions prior to it are searched */ @@ -1037,13 +1028,11 @@ ibool row_vers_old_has_index_entry( } } -/*****************************************************************/ /** - Constructs the version of a clustered index record which a consistent +/** Constructs the version of a clustered index record which a consistent read should see. We assume that the trx id stored in rec is such that the consistent read should not see rec in its present version. @return DB_SUCCESS or DB_MISSING_HISTORY */ dberr_t row_vers_build_for_consistent_read( - /*===============================*/ const rec_t *rec, /*!< in: record in a clustered index; the caller must have a latch on the page; this latch locks the top of the stack of versions @@ -1149,11 +1138,9 @@ dberr_t row_vers_build_for_consistent_read( return (err); } -/*****************************************************************/ /** - Constructs the last committed version of a clustered index record, +/** Constructs the last committed version of a clustered index record, which should be seen by a semi-consistent read. */ void row_vers_build_for_semi_consistent_read( - /*====================================*/ const rec_t *rec, /*!< in: record in a clustered index; the caller must have a latch on the page; this latch locks the top of the stack of versions diff --git a/storage/innobase/srv/srv0conc.cc b/storage/innobase/srv/srv0conc.cc index 5654fb9d3f2a..493464947ac6 100644 --- a/storage/innobase/srv/srv0conc.cc +++ b/storage/innobase/srv/srv0conc.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2011, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -37,8 +37,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file srv/srv0conc.cc +/** @file srv/srv0conc.cc InnoDB concurrency manager @@ -90,10 +89,8 @@ struct srv_conc_t { /* Control variables for tracking concurrency. */ static srv_conc_t srv_conc; -/*********************************************************************/ /** - Note that a user thread is entering InnoDB. */ +/** Note that a user thread is entering InnoDB. */ static void srv_enter_innodb_with_tickets( - /*==========================*/ trx_t *trx) /*!< in/out: transaction that wants to enter InnoDB */ { @@ -101,8 +98,7 @@ static void srv_enter_innodb_with_tickets( trx->n_tickets_to_enter_innodb = srv_n_free_tickets_to_enter; } -/*********************************************************************/ /** - Handle the scheduling of a user thread that wants to enter InnoDB. Setting +/** Handle the scheduling of a user thread that wants to enter InnoDB. Setting srv_adaptive_max_sleep_delay > 0 switches the adaptive sleep calibration to ON. When set, we want to wait in the queue for as little time as possible. However, very short waits will result in a lot of context switches and that @@ -114,7 +110,6 @@ static void srv_enter_innodb_with_tickets( decrement it by one. This is to try and keep the sleep time stable around the "optimum" sleep time. */ static void srv_conc_enter_innodb_with_atomics( - /*===============================*/ trx_t *trx) /*!< in/out: transaction that wants to enter InnoDB */ { @@ -203,10 +198,8 @@ static void srv_conc_enter_innodb_with_atomics( } } -/*********************************************************************/ /** - Note that a user thread is leaving InnoDB code. */ +/** Note that a user thread is leaving InnoDB code. */ static void srv_conc_exit_innodb_with_atomics( - /*==============================*/ trx_t *trx) /*!< in/out: transaction */ { trx->n_tickets_to_enter_innodb = 0; @@ -215,8 +208,7 @@ static void srv_conc_exit_innodb_with_atomics( (void)os_atomic_decrement_lint(&srv_conc.n_active, 1); } -/*********************************************************************/ /** - Puts an OS thread to wait if there are too many concurrent threads +/** Puts an OS thread to wait if there are too many concurrent threads (>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. @param[in,out] prebuilt row prebuilt handler */ void srv_conc_enter_innodb(row_prebuilt_t *prebuilt) { @@ -233,11 +225,9 @@ void srv_conc_enter_innodb(row_prebuilt_t *prebuilt) { srv_conc_enter_innodb_with_atomics(trx); } -/*********************************************************************/ /** - This lets a thread enter InnoDB regardless of the number of threads inside +/** This lets a thread enter InnoDB regardless of the number of threads inside InnoDB. This must be called when a thread ends a lock wait. */ void srv_conc_force_enter_innodb( - /*========================*/ trx_t *trx) /*!< in: transaction object associated with the thread */ { @@ -261,11 +251,9 @@ void srv_conc_force_enter_innodb( trx->declared_to_be_inside_innodb = TRUE; } -/*********************************************************************/ /** - This must be called when a thread exits InnoDB in a lock wait or at the +/** This must be called when a thread exits InnoDB in a lock wait or at the end of an SQL statement. */ void srv_conc_force_exit_innodb( - /*=======================*/ trx_t *trx) /*!< in: transaction object associated with the thread */ { @@ -286,18 +274,8 @@ void srv_conc_force_exit_innodb( #endif /* UNIV_DEBUG */ } -/*********************************************************************/ /** - Get the count of threads waiting inside InnoDB. */ -ulint srv_conc_get_waiting_threads(void) -/*==============================*/ -{ - return (srv_conc.n_waiting); -} +/** Get the count of threads waiting inside InnoDB. */ +ulint srv_conc_get_waiting_threads(void) { return (srv_conc.n_waiting); } -/*********************************************************************/ /** - Get the count of threads active inside InnoDB. */ -ulint srv_conc_get_active_threads(void) -/*==============================*/ -{ - return (srv_conc.n_active); -} +/** Get the count of threads active inside InnoDB. */ +ulint srv_conc_get_active_threads(void) { return (srv_conc.n_active); } diff --git a/storage/innobase/srv/srv0mon.cc b/storage/innobase/srv/srv0mon.cc index 2ea3996b6d38..0396319047e1 100644 --- a/storage/innobase/srv/srv0mon.cc +++ b/storage/innobase/srv/srv0mon.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2010, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2010, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under @@ -25,8 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file srv/srv0mon.cc +/** @file srv/srv0mon.cc Database monitor counter interfaces Created 12/9/2009 Jimmy Yang @@ -1160,13 +1159,11 @@ monitor_value_t innodb_counter_value[NUM_MONITOR]; has been turned on/off. */ ulint monitor_set_tbl[(NUM_MONITOR + NUM_BITS_ULINT - 1) / NUM_BITS_ULINT]; -/****************************************************************/ /** - Get a monitor's "monitor_info" by its monitor id (index into the +/** Get a monitor's "monitor_info" by its monitor id (index into the innodb_counter_info array. @return Point to corresponding monitor_info_t, or NULL if no such monitor */ monitor_info_t *srv_mon_get_info( - /*=============*/ monitor_id_t monitor_id) /*!< id indexing into the innodb_counter_info array */ { @@ -1175,13 +1172,11 @@ monitor_info_t *srv_mon_get_info( return ((monitor_id < NUM_MONITOR) ? &innodb_counter_info[monitor_id] : NULL); } -/****************************************************************/ /** - Get monitor's name by its monitor id (indexing into the +/** Get monitor's name by its monitor id (indexing into the innodb_counter_info array. @return corresponding monitor name, or NULL if no such monitor */ const char *srv_mon_get_name( - /*=============*/ monitor_id_t monitor_id) /*!< id index into the innodb_counter_info array */ { @@ -1192,12 +1187,10 @@ const char *srv_mon_get_name( : NULL); } -/****************************************************************/ /** - Turn on/off, reset monitor counters in a module. If module_id +/** Turn on/off, reset monitor counters in a module. If module_id is MONITOR_ALL_COUNTER then turn on all monitor counters. turned on because it has already been turned on. */ void srv_mon_set_module_control( - /*=======================*/ monitor_id_t module_id, /*!< in: Module ID as in monitor_counter_id. If it is set to MONITOR_ALL_COUNTER, this means @@ -1330,8 +1323,7 @@ static ulint srv_mon_get_rseg_size(void) { return (value); } -/****************************************************************/ /** - This function consolidates some existing server counters used +/** This function consolidates some existing server counters used by "system status variables". These existing system variables do not have mechanism to start/stop and reset the counters, so we simulate these controls by remembering the corresponding counter values when the @@ -1340,7 +1332,6 @@ static ulint srv_mon_get_rseg_size(void) { srv_export_innodb_status() for related global counters used by the existing status variables.*/ void srv_mon_process_existing_counter( - /*=============================*/ monitor_id_t monitor_id, /*!< in: the monitor's ID as in monitor_counter_id */ mon_option_t set_option) /*!< in: Turn on/off reset the @@ -1769,12 +1760,9 @@ void srv_mon_process_existing_counter( } } -/*************************************************************/ /** - Reset a monitor, create a new base line with the current monitor +/** Reset a monitor, create a new base line with the current monitor value. This baseline is recorded by MONITOR_VALUE_RESET(monitor) */ -void srv_mon_reset( - /*==========*/ - monitor_id_t monitor) /*!< in: monitor id */ +void srv_mon_reset(monitor_id_t monitor) /*!< in: monitor id */ { ibool monitor_was_on; @@ -1815,11 +1803,8 @@ void srv_mon_reset( } } -/*************************************************************/ /** - Turn on monitor counters that are marked as default ON. */ -void srv_mon_default_on(void) -/*====================*/ -{ +/** Turn on monitor counters that are marked as default ON. */ +void srv_mon_default_on(void) { ulint ix; for (ix = 0; ix < NUM_MONITOR; ix++) { diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index e572b92309c6..2ab0ca5dfec1 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. @@ -39,8 +39,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file srv/srv0srv.cc +/** @file srv/srv0srv.cc The database server main program Created 10/8/1995 Heikki Tuuri @@ -687,11 +686,8 @@ PSI_stage_info srv_stage_clone_page_copy = { 0, "clone (page copy)", PSI_FLAG_STAGE_PROGRESS, PSI_DOCUMENT_ME}; #endif /* HAVE_PSI_STAGE_INTERFACE */ -/*********************************************************************/ /** - Prints counters for work done by srv_master_thread. */ -static void srv_print_master_thread_info( - /*=========================*/ - FILE *file) /* in: output stream */ +/** Prints counters for work done by srv_master_thread. */ +static void srv_print_master_thread_info(FILE *file) /* in: output stream */ { fprintf(file, "srv_master_thread loops: " ULINTPF " srv_active, " ULINTPF @@ -702,10 +698,8 @@ static void srv_print_master_thread_info( } #endif /* !UNIV_HOTBACKUP */ -/*********************************************************************/ /** - Sets the info describing an i/o thread current state. */ +/** Sets the info describing an i/o thread current state. */ void srv_set_io_thread_op_info( - /*======================*/ ulint i, /*!< in: the 'segment' of the i/o thread */ const char *str) /*!< in: constant char string describing the state */ @@ -715,11 +709,8 @@ void srv_set_io_thread_op_info( srv_io_thread_op_info[i] = str; } -/*********************************************************************/ /** - Resets the info describing an i/o thread current state. */ -void srv_reset_io_thread_op_info() -/*=========================*/ -{ +/** Resets the info describing an i/o thread current state. */ +void srv_reset_io_thread_op_info() { for (ulint i = 0; i < UT_ARR_SIZE(srv_io_thread_op_info); ++i) { srv_io_thread_op_info[i] = "not started yet"; } @@ -727,11 +718,9 @@ void srv_reset_io_thread_op_info() #ifndef UNIV_HOTBACKUP #ifdef UNIV_DEBUG -/*********************************************************************/ /** - Validates the type of a thread table slot. +/** Validates the type of a thread table slot. @return true if ok */ static ibool srv_thread_type_validate( - /*=====================*/ srv_thread_type type) /*!< in: thread type */ { switch (type) { @@ -747,11 +736,9 @@ static ibool srv_thread_type_validate( } #endif /* UNIV_DEBUG */ -/*********************************************************************/ /** - Gets the type of a thread table slot. +/** Gets the type of a thread table slot. @return thread type */ static srv_thread_type srv_slot_get_type( - /*==============*/ const srv_slot_t *slot) /*!< in: thread slot */ { srv_thread_type type = slot->type; @@ -759,11 +746,9 @@ static srv_thread_type srv_slot_get_type( return (type); } -/*********************************************************************/ /** - Reserves a slot in the thread table for the current thread. +/** Reserves a slot in the thread table for the current thread. @return reserved slot */ static srv_slot_t *srv_reserve_slot( - /*=============*/ srv_thread_type type) /*!< in: type of the thread */ { srv_slot_t *slot = 0; @@ -807,11 +792,9 @@ static srv_slot_t *srv_reserve_slot( return (slot); } -/*********************************************************************/ /** - Suspends the calling thread to wait for the event in its thread slot. +/** Suspends the calling thread to wait for the event in its thread slot. @return the current signal count of the event. */ static int64_t srv_suspend_thread_low( - /*===================*/ srv_slot_t *slot) /*!< in/out: thread slot */ { ut_ad(!srv_read_only_mode); @@ -853,12 +836,9 @@ static int64_t srv_suspend_thread_low( return (os_event_reset(slot->event)); } -/*********************************************************************/ /** - Suspends the calling thread to wait for the event in its thread slot. +/** Suspends the calling thread to wait for the event in its thread slot. @return the current signal count of the event. */ -static int64_t srv_suspend_thread( - /*===============*/ - srv_slot_t *slot) /*!< in/out: thread slot */ +static int64_t srv_suspend_thread(srv_slot_t *slot) /*!< in/out: thread slot */ { srv_sys_mutex_enter(); @@ -869,15 +849,12 @@ static int64_t srv_suspend_thread( return (sig_count); } -/*********************************************************************/ /** - Releases threads of the type given from suspension in the thread table. +/** Releases threads of the type given from suspension in the thread table. NOTE! The server mutex has to be reserved by the caller! @return number of threads released: this may be less than n if not enough threads were suspended at the moment. */ -ulint srv_release_threads( - /*================*/ - srv_thread_type type, /*!< in: thread type */ - ulint n) /*!< in: number of threads to release */ +ulint srv_release_threads(srv_thread_type type, /*!< in: thread type */ + ulint n) /*!< in: number of threads to release */ { ulint i; ulint count = 0; @@ -937,11 +914,8 @@ ulint srv_release_threads( return (count); } -/*********************************************************************/ /** - Release a thread's slot. */ -static void srv_free_slot( - /*==========*/ - srv_slot_t *slot) /*!< in/out: thread slot */ +/** Release a thread's slot. */ +static void srv_free_slot(srv_slot_t *slot) /*!< in/out: thread slot */ { srv_sys_mutex_enter(); @@ -957,11 +931,8 @@ static void srv_free_slot( srv_sys_mutex_exit(); } -/*********************************************************************/ /** - Initializes the server. */ -static void srv_init(void) -/*==========*/ -{ +/** Initializes the server. */ +static void srv_init(void) { ulint n_sys_threads = 0; ulint srv_sys_sz = sizeof(*srv_sys); @@ -1034,11 +1005,8 @@ static void srv_init(void) dict_mem_init(); } -/*********************************************************************/ /** - Frees the data structures created in srv_init(). */ -void srv_free(void) -/*==========*/ -{ +/** Frees the data structures created in srv_init(). */ +void srv_free(void) { mutex_free(&srv_innodb_monitor_mutex); mutex_free(&page_zip_stat_per_index_mutex); @@ -1072,12 +1040,9 @@ void srv_free(void) srv_sys = 0; } -/*********************************************************************/ /** - Initializes the synchronization primitives, memory system, and the thread +/** Initializes the synchronization primitives, memory system, and the thread local storage. */ -static void srv_general_init(void) -/*==================*/ -{ +static void srv_general_init(void) { sync_check_init(); /* Reset the system variables in the recovery module. */ recv_sys_var_init(); @@ -1087,11 +1052,8 @@ static void srv_general_init(void) row_mysql_init(); } -/*********************************************************************/ /** - Boots the InnoDB server. */ -void srv_boot(void) -/*==========*/ -{ +/** Boots the InnoDB server. */ +void srv_boot(void) { /* Initialize synchronization primitives, memory management, and thread local storage */ @@ -1102,11 +1064,8 @@ void srv_boot(void) srv_init(); } -/******************************************************************/ /** - Refreshes the values used to calculate per-second averages. */ -static void srv_refresh_innodb_monitor_stats(void) -/*==================================*/ -{ +/** Refreshes the values used to calculate per-second averages. */ +static void srv_refresh_innodb_monitor_stats(void) { mutex_enter(&srv_innodb_monitor_mutex); srv_last_monitor_time = time(NULL); @@ -1128,12 +1087,10 @@ static void srv_refresh_innodb_monitor_stats(void) mutex_exit(&srv_innodb_monitor_mutex); } -/******************************************************************/ /** - Outputs to a file the output of the InnoDB Monitor. +/** Outputs to a file the output of the InnoDB Monitor. @return false if not all information printed due to failure to obtain necessary mutex */ ibool srv_printf_innodb_monitor( - /*======================*/ FILE *file, /*!< in: output stream */ ibool nowait, /*!< in: whether to wait for the lock_sys_t:: mutex */ @@ -1340,11 +1297,8 @@ ibool srv_printf_innodb_monitor( return (ret); } -/******************************************************************/ /** - Function to pass InnoDB status variables to MySQL */ -void srv_export_innodb_status(void) -/*==========================*/ -{ +/** Function to pass InnoDB status variables to MySQL */ +void srv_export_innodb_status(void) { buf_pool_stat_t stat; buf_pools_list_size_t buf_pools_list_size; ulint LRU_len; @@ -1666,13 +1620,8 @@ void srv_error_monitor_thread() { srv_error_monitor_active = FALSE; } -/******************************************************************/ /** - Increment the server activity count. */ -void srv_inc_activity_count(void) -/*========================*/ -{ - srv_sys->activity_count.inc(); -} +/** Increment the server activity count. */ +void srv_inc_activity_count(void) { srv_sys->activity_count.inc(); } /** Check whether any background thread (except the master thread) is active. Send the threads wakeup signal. @@ -1738,15 +1687,12 @@ bool srv_master_thread_active() { return (active); } -/*******************************************************************/ /** - Tells the InnoDB server that there has been activity in the database +/** Tells the InnoDB server that there has been activity in the database and wakes up the master thread if it is suspended (not sleeping). Used in the MySQL interface. Note that there is a small chance that the master thread stays suspended (we do not protect our operation with the srv_sys_t->mutex, for performance reasons). */ -void srv_active_wake_master_thread_low() -/*===============================*/ -{ +void srv_active_wake_master_thread_low() { ut_ad(!srv_read_only_mode); ut_ad(!srv_sys_mutex_own()); @@ -1777,15 +1723,12 @@ void srv_active_wake_master_thread_low() } } -/*******************************************************************/ /** - Tells the purge thread that there has been activity in the database +/** Tells the purge thread that there has been activity in the database and wakes up the purge thread if it is suspended (not sleeping). Note that there is a small chance that the purge thread stays suspended (we do not protect our check with the srv_sys_t:mutex and the purge_sys->latch, for performance reasons). */ -void srv_wake_purge_thread_if_not_active(void) -/*=====================================*/ -{ +void srv_wake_purge_thread_if_not_active(void) { ut_ad(!srv_sys_mutex_own()); if (purge_sys->state == PURGE_STATE_RUN && @@ -1794,11 +1737,8 @@ void srv_wake_purge_thread_if_not_active(void) } } -/*******************************************************************/ /** - Wakes up the master thread if it is suspended or being suspended. */ -void srv_wake_master_thread(void) -/*========================*/ -{ +/** Wakes up the master thread if it is suspended or being suspended. */ +void srv_wake_master_thread(void) { ut_ad(!srv_sys_mutex_own()); srv_inc_activity_count(); @@ -1806,34 +1746,24 @@ void srv_wake_master_thread(void) srv_release_threads(SRV_MASTER, 1); } -/*******************************************************************/ /** - Get current server activity count. We don't hold srv_sys::mutex while +/** Get current server activity count. We don't hold srv_sys::mutex while reading this value as it is only used in heuristics. @return activity count. */ -ulint srv_get_activity_count(void) -/*========================*/ -{ - return (srv_sys->activity_count); -} +ulint srv_get_activity_count(void) { return (srv_sys->activity_count); } -/*******************************************************************/ /** - Check if there has been any activity. +/** Check if there has been any activity. @return false if no change in activity counter. */ ibool srv_check_activity( - /*===============*/ ulint old_activity_count) /*!< in: old activity count */ { return (srv_sys->activity_count != old_activity_count); } -/********************************************************************/ /** - The master thread is tasked to ensure that flush of log file happens +/** The master thread is tasked to ensure that flush of log file happens once every second in the background. This is to ensure that not more than one second of trxs are lost in case of crash when innodb_flush_logs_at_trx_commit != 1 */ -static void srv_sync_log_buffer_in_background(void) -/*===================================*/ -{ +static void srv_sync_log_buffer_in_background(void) { time_t current_time = time(NULL); srv_main_thread_op_info = "flushing log"; @@ -1845,11 +1775,9 @@ static void srv_sync_log_buffer_in_background(void) } } -/********************************************************************/ /** - Make room in the table cache by evicting an unused table. +/** Make room in the table cache by evicting an unused table. @return number of tables evicted. */ static ulint srv_master_evict_from_table_cache( - /*==============================*/ ulint pct_check) /*!< in: max percent to check */ { ulint n_tables_evicted = 0; @@ -1868,11 +1796,9 @@ static ulint srv_master_evict_from_table_cache( return (n_tables_evicted); } -/*********************************************************************/ /** - This function prints progress message every 60 seconds during server +/** This function prints progress message every 60 seconds during server shutdown, for any activities that master thread is pending on. */ static void srv_shutdown_print_master_pending( - /*==============================*/ ib_time_t *last_print_time, /*!< last time the function print the message */ ulint n_tables_to_drop, /*!< number of tables to @@ -1949,16 +1875,13 @@ void srv_master_thread_disabled_debug_update(THD *thd, SYS_VAR *var, } #endif /* UNIV_DEBUG */ -/*********************************************************************/ /** - Perform the tasks that the master thread is supposed to do when the +/** Perform the tasks that the master thread is supposed to do when the server is active. There are two types of tasks. The first category is of such tasks which are performed at each inovcation of this function. We assume that this function is called roughly every second when the server is active. The second category is of such tasks which are performed at some interval e.g.: purge, dict_LRU cleanup etc. */ -static void srv_master_do_active_tasks(void) -/*============================*/ -{ +static void srv_master_do_active_tasks(void) { ib_time_t cur_time = ut_time(); uintmax_t counter_time = ut_time_us(NULL); @@ -2035,17 +1958,14 @@ static void srv_master_do_active_tasks(void) } } -/*********************************************************************/ /** - Perform the tasks that the master thread is supposed to do whenever the +/** Perform the tasks that the master thread is supposed to do whenever the server is idle. We do check for the server state during this function and if the server has entered the shutdown phase we may return from the function without completing the required tasks. Note that the server can move to active state when we are executing this function but we don't check for that as we are suppose to perform more or less same tasks when server is active. */ -static void srv_master_do_idle_tasks(void) -/*==========================*/ -{ +static void srv_master_do_idle_tasks(void) { uintmax_t counter_time; ++srv_main_idle_loops; @@ -2107,8 +2027,7 @@ static void srv_master_do_idle_tasks(void) counter_time); } -/*********************************************************************/ /** - Perform the tasks during shutdown. The tasks that we do at shutdown +/** Perform the tasks during shutdown. The tasks that we do at shutdown depend on srv_fast_shutdown: 2 => very fast shutdown => do no book keeping 1 => normal shutdown => clear drop table queue and make checkpoint @@ -2116,7 +2035,6 @@ static void srv_master_do_idle_tasks(void) merge @return true if some work was done. false otherwise */ static ibool srv_master_do_shutdown_tasks( - /*=========================*/ ib_time_t *last_print_time) /*!< last time the function print the message */ { @@ -2326,13 +2244,10 @@ static void srv_enable_undo_encryption_if_set() { undo::spaces->s_unlock(); } -/*********************************************************************/ /** - Puts master thread to sleep. At this point we are using polling to +/** Puts master thread to sleep. At this point we are using polling to service various activities. Master thread sleeps for one second before checking the state of the server again */ -static void srv_master_sleep(void) -/*==================*/ -{ +static void srv_master_sleep(void) { srv_main_thread_op_info = "sleeping"; os_thread_sleep(1000000); srv_main_thread_op_info = ""; @@ -2434,12 +2349,9 @@ static bool srv_purge_should_exit( return (false); } -/*********************************************************************/ /** - Fetch and execute a task from the work queue. +/** Fetch and execute a task from the work queue. @return true if a task was executed */ -static bool srv_task_execute(void) -/*==================*/ -{ +static bool srv_task_execute(void) { que_thr_t *thr = NULL; ut_ad(!srv_read_only_mode); @@ -2525,11 +2437,9 @@ void srv_worker_thread() { my_thread_end(); } -/*********************************************************************/ /** - Do the actual purge operation. +/** Do the actual purge operation. @return length of history list before the last purge batch. */ static ulint srv_do_purge( - /*=========*/ ulint n_threads, /*!< in: number of threads to use */ ulint *n_total_purged) /*!< in/out: total pages purged */ { @@ -2599,10 +2509,8 @@ static ulint srv_do_purge( return (rseg_history_len); } -/*********************************************************************/ /** - Suspend the purge coordinator thread. */ +/** Suspend the purge coordinator thread. */ static void srv_purge_coordinator_suspend( - /*==========================*/ srv_slot_t *slot, /*!< in/out: Purge coordinator thread slot */ ulint rseg_history_len) /*!< in: history list length @@ -2823,12 +2731,9 @@ void srv_purge_coordinator_thread() { my_thread_end(); } -/**********************************************************************/ /** - Enqueues a task to server task queue and releases a worker thread, if there +/** Enqueues a task to server task queue and releases a worker thread, if there is a suspended one. */ -void srv_que_task_enqueue_low( - /*=====================*/ - que_thr_t *thr) /*!< in: query thread */ +void srv_que_task_enqueue_low(que_thr_t *thr) /*!< in: query thread */ { ut_ad(!srv_read_only_mode); mutex_enter(&srv_sys->tasks_mutex); @@ -2840,12 +2745,9 @@ void srv_que_task_enqueue_low( srv_release_threads(SRV_WORKER, 1); } -/**********************************************************************/ /** - Get count of tasks in the queue. +/** Get count of tasks in the queue. @return number of tasks in queue */ -ulint srv_get_task_queue_length(void) -/*===========================*/ -{ +ulint srv_get_task_queue_length(void) { ulint n_tasks; ut_ad(!srv_read_only_mode); @@ -2859,11 +2761,8 @@ ulint srv_get_task_queue_length(void) return (n_tasks); } -/**********************************************************************/ /** - Wakeup the purge threads. */ -void srv_purge_wakeup(void) -/*==================*/ -{ +/** Wakeup the purge threads. */ +void srv_purge_wakeup(void) { ut_ad(!srv_read_only_mode); if (srv_force_recovery < SRV_FORCE_NO_BACKGROUND) { diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index ad1111993b53..92cbea98ee1c 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2008, Google Inc. Copyright (c) 2009, Percona Inc. @@ -39,8 +39,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file srv/srv0start.cc +/** @file srv/srv0start.cc Starts the InnoDB database server Created 2/16/1996 Heikki Tuuri @@ -222,12 +221,9 @@ static PSI_stage_info *srv_stages[] = { }; #endif /* HAVE_PSI_STAGE_INTERFACE */ -/*********************************************************************/ /** - Check if a file can be opened in read-write mode. +/** Check if a file can be opened in read-write mode. @return true if it doesn't exist or can be opened in rw mode. */ -static bool srv_file_check_mode( - /*================*/ - const char *name) /*!< in: filename to check */ +static bool srv_file_check_mode(const char *name) /*!< in: filename to check */ { os_file_stat_t stat; @@ -276,13 +272,11 @@ static void io_handler_thread(ulint segment) { } } -/*********************************************************************/ /** - Creates a log file. +/** Creates a log file. @return DB_SUCCESS or error code */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t create_log_file( - /*============*/ - pfs_os_file_t *file, /*!< out: file handle */ - const char *name) /*!< in: log file name */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + create_log_file(pfs_os_file_t *file, /*!< out: file handle */ + const char *name) /*!< in: log file name */ { bool ret; @@ -323,11 +317,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t create_log_file( /** Initial number of the first redo log file */ #define INIT_LOG_FILE0 (SRV_N_LOG_FILES_MAX + 1) -/*********************************************************************/ /** - Creates all log files. +/** Creates all log files. @return DB_SUCCESS or error code */ static dberr_t create_log_files( - /*=============*/ char *logfilename, /*!< in/out: buffer for log file name */ size_t dirnamelen, /*!< in: length of the directory path */ lsn_t lsn, /*!< in: FIL_PAGE_FILE_FLUSH_LSN value */ @@ -445,10 +437,8 @@ static dberr_t create_log_files( return (DB_SUCCESS); } -/*********************************************************************/ /** - Renames the first log file. */ +/** Renames the first log file. */ static void create_log_files_rename( - /*====================*/ char *logfilename, /*!< in/out: buffer for log file name */ size_t dirnamelen, /*!< in: length of the directory path */ lsn_t lsn, /*!< in: FIL_PAGE_FILE_FLUSH_LSN value */ @@ -486,14 +476,12 @@ static void create_log_files_rename( ib::info() << "New log files created, LSN=" << lsn; } -/*********************************************************************/ /** - Opens a log file. +/** Opens a log file. @return DB_SUCCESS or error code */ -static MY_ATTRIBUTE((warn_unused_result)) dberr_t open_log_file( - /*==========*/ - pfs_os_file_t *file, /*!< out: file handle */ - const char *name, /*!< in: log file name */ - os_offset_t *size) /*!< out: file size */ +static MY_ATTRIBUTE((warn_unused_result)) dberr_t + open_log_file(pfs_os_file_t *file, /*!< out: file handle */ + const char *name, /*!< in: log file name */ + os_offset_t *size) /*!< out: file size */ { bool ret; @@ -1291,9 +1279,7 @@ static dberr_t srv_undo_tablespaces_init(bool create_new_db) { /******************************************************************** Wait for the purge thread(s) to start up. */ -static void srv_start_wait_for_purge_to_start() -/*===============================*/ -{ +static void srv_start_wait_for_purge_to_start() { /* Wait for the purge coordinator and master thread to startup. */ purge_state_t state = trx_purge_state(); @@ -1392,23 +1378,19 @@ static void srv_create_sdi_indexes() { btr_sdi_create_index(SYSTEM_TABLE_SPACE, false); } -/****************************************************************/ /** - Set state to indicate start of particular group of threads in InnoDB. */ +/** Set state to indicate start of particular group of threads in InnoDB. */ UNIV_INLINE void srv_start_state_set( - /*================*/ srv_start_state_t state) /*!< in: indicate current state of thread startup */ { srv_start_state |= state; } -/****************************************************************/ /** - Check if following group of threads is started. +/** Check if following group of threads is started. @return true if started */ UNIV_INLINE bool srv_start_state_is_set( - /*===================*/ srv_start_state_t state) /*!< in: state to check for */ { return (srv_start_state & state); @@ -2682,7 +2664,6 @@ Sync all FTS cache before shutdown */ static void srv_fts_close(void) -/*===============*/ { dict_table_t* table; @@ -2894,7 +2875,6 @@ so. */ static void srv_shutdown_table_bg_threads(void) -/*===============================*/ { dict_table_t* table; dict_table_t* first; diff --git a/storage/innobase/sync/sync0arr.cc b/storage/innobase/sync/sync0arr.cc index c09615c35903..1ef36adc5312 100644 --- a/storage/innobase/sync/sync0arr.cc +++ b/storage/innobase/sync/sync0arr.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -31,8 +31,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file sync/sync0arr.cc +/** @file sync/sync0arr.cc The wait array used in synchronization primitives Created 9/5/1995 Heikki Tuuri @@ -178,24 +177,19 @@ static ulint sg_count; #define sync_array_enter(a) mutex_enter(&(a)->mutex) #ifdef UNIV_DEBUG -/******************************************************************/ /** - This function is called only in the debug version. Detects a deadlock +/** This function is called only in the debug version. Detects a deadlock of one or more threads because of waits of semaphores. @return true if deadlock detected */ static bool sync_array_detect_deadlock( - /*=======================*/ sync_array_t *arr, /*!< in: wait array; NOTE! the caller must own the mutex to array */ sync_cell_t *start, /*!< in: cell where recursive search started */ sync_cell_t *cell, /*!< in: cell to search */ ulint depth); /*!< in: recursion depth */ -/********************************************************************/ /** - Validates the integrity of the wait array. Checks +/** Validates the integrity of the wait array. Checks that the number of reserved cells equals the count variable. */ -static void sync_array_validate( - /*================*/ - sync_array_t *arr) /*!< in: sync wait array */ +static void sync_array_validate(sync_array_t *arr) /*!< in: sync wait array */ { ulint count = 0; @@ -258,11 +252,9 @@ sync_array_t::~sync_array_t() UNIV_NOTHROW { UT_DELETE_ARRAY(cells); } -/*****************************************************************/ /** - Gets the nth cell in array. +/** Gets the nth cell in array. @return cell */ static sync_cell_t *sync_array_get_nth_cell( - /*====================*/ sync_array_t *arr, /*!< in: sync array */ ulint n) /*!< in: index */ { @@ -271,19 +263,14 @@ static sync_cell_t *sync_array_get_nth_cell( return (&arr->cells[n]); } -/******************************************************************/ /** - Frees the resources in a wait array. */ -static void sync_array_free( - /*============*/ - sync_array_t *arr) /*!< in, own: sync wait array */ +/** Frees the resources in a wait array. */ +static void sync_array_free(sync_array_t *arr) /*!< in, own: sync wait array */ { UT_DELETE(arr); } -/*******************************************************************/ /** - Returns the event that the thread owning the cell waits for. */ +/** Returns the event that the thread owning the cell waits for. */ static os_event_t sync_cell_get_event( - /*================*/ sync_cell_t *cell) /*!< in: non-empty sync array cell */ { ulint type = cell->request_type; @@ -303,12 +290,10 @@ static os_event_t sync_cell_get_event( } } -/******************************************************************/ /** - Reserves a wait array cell for waiting for an object. +/** Reserves a wait array cell for waiting for an object. The event of the cell is reset to nonsignalled state. @return sync cell to wait on */ sync_cell_t *sync_array_reserve_cell( - /*====================*/ sync_array_t *arr, /*!< in: wait array */ void *object, /*!< in: pointer to the object to wait for */ ulint type, /*!< in: lock request type */ @@ -375,11 +360,9 @@ sync_cell_t *sync_array_reserve_cell( return (cell); } -/******************************************************************/ /** - Frees the cell. NOTE! sync_array_wait_event frees the cell +/** Frees the cell. NOTE! sync_array_wait_event frees the cell automatically! */ void sync_array_free_cell( - /*=================*/ sync_array_t *arr, /*!< in: wait array */ sync_cell_t *&cell) /*!< in/out: the cell in the array */ { @@ -417,13 +400,11 @@ void sync_array_free_cell( cell = 0; } -/******************************************************************/ /** - This function should be called when a thread starts to wait on +/** This function should be called when a thread starts to wait on a wait array cell. In the debug version this function checks if the wait for a semaphore will result in a deadlock, in which case prints info and asserts. */ void sync_array_wait_event( - /*==================*/ sync_array_t *arr, /*!< in: wait array */ sync_cell_t *&cell) /*!< in: index of the reserved cell */ { @@ -460,12 +441,9 @@ void sync_array_wait_event( cell = 0; } -/******************************************************************/ /** - Reports info of a wait array cell. */ -static void sync_array_cell_print( - /*==================*/ - FILE *file, /*!< in: file where to print */ - sync_cell_t *cell) /*!< in: sync cell */ +/** Reports info of a wait array cell. */ +static void sync_array_cell_print(FILE *file, /*!< in: file where to print */ + sync_cell_t *cell) /*!< in: sync cell */ { rw_lock_t *rwlock; ulint type; @@ -574,11 +552,9 @@ static void sync_array_cell_print( } #ifdef UNIV_DEBUG -/******************************************************************/ /** - Looks for a cell with the given thread id. +/** Looks for a cell with the given thread id. @return pointer to cell or NULL if not found */ static sync_cell_t *sync_array_find_thread( - /*===================*/ sync_array_t *arr, /*!< in: wait array */ os_thread_id_t thread) /*!< in: thread id */ { @@ -597,11 +573,9 @@ static sync_cell_t *sync_array_find_thread( return (NULL); /* Not found */ } -/******************************************************************/ /** - Recursion step for deadlock detection. +/** Recursion step for deadlock detection. @return true if deadlock detected */ static ibool sync_array_deadlock_step( - /*=====================*/ sync_array_t *arr, /*!< in: wait array; NOTE! the caller must own the mutex to array */ sync_cell_t *start, /*!< in: cell where recursive search @@ -649,12 +623,10 @@ static void sync_array_report_error(rw_lock_t *lock, rw_lock_debug_t *debug, rw_lock_debug_print(stderr, debug); } -/******************************************************************/ /** - This function is called only in the debug version. Detects a deadlock +/** This function is called only in the debug version. Detects a deadlock of one or more threads because of waits of semaphores. @return true if deadlock detected */ static bool sync_array_detect_deadlock( - /*=======================*/ sync_array_t *arr, /*!< in: wait array; NOTE! the caller must own the mutex to array */ sync_cell_t *start, /*!< in: cell where recursive search started */ @@ -874,10 +846,8 @@ static bool sync_array_detect_deadlock( } #endif /* UNIV_DEBUG */ -/******************************************************************/ /** - Determines if we can wake up the thread waiting for a sempahore. */ +/** Determines if we can wake up the thread waiting for a sempahore. */ static bool sync_arr_cell_can_wake_up( - /*======================*/ sync_cell_t *cell) /*!< in: cell to search */ { rw_lock_t *lock; @@ -943,16 +913,10 @@ static bool sync_arr_cell_can_wake_up( return (false); } -/**********************************************************************/ /** - Increments the signalled count. */ -void sync_array_object_signalled() -/*=========================*/ -{ - ++sg_count; -} +/** Increments the signalled count. */ +void sync_array_object_signalled() { ++sg_count; } -/**********************************************************************/ /** - If the wakeup algorithm does not work perfectly at semaphore relases, +/** If the wakeup algorithm does not work perfectly at semaphore relases, this function will do the waking (see the comment in mutex_exit). This function should be called about every 1 second in the server. @@ -960,7 +924,6 @@ void sync_array_object_signalled() changing the lock_word and calling signal_object, so sometimes this finds threads to wake up even when nothing has gone wrong. */ static void sync_array_wake_threads_if_sema_free_low( - /*=====================================*/ sync_array_t *arr) /* in/out: wait array */ { sync_array_enter(arr); @@ -982,27 +945,22 @@ static void sync_array_wake_threads_if_sema_free_low( sync_array_exit(arr); } -/**********************************************************************/ /** - If the wakeup algorithm does not work perfectly at semaphore relases, +/** If the wakeup algorithm does not work perfectly at semaphore relases, this function will do the waking (see the comment in mutex_exit). This function should be called about every 1 second in the server. Note that there's a race condition between this thread and mutex_exit changing the lock_word and calling signal_object, so sometimes this finds threads to wake up even when nothing has gone wrong. */ -void sync_arr_wake_threads_if_sema_free(void) -/*====================================*/ -{ +void sync_arr_wake_threads_if_sema_free(void) { for (ulint i = 0; i < sync_array_size; ++i) { sync_array_wake_threads_if_sema_free_low(sync_wait_array[i]); } } -/**********************************************************************/ /** - Prints warnings of long semaphore waits to stderr. +/** Prints warnings of long semaphore waits to stderr. @return true if fatal semaphore wait threshold was exceeded */ static bool sync_array_print_long_waits_low( - /*============================*/ sync_array_t *arr, /*!< in: sync array instance */ os_thread_id_t *waiter, /*!< out: longest waiting thread */ const void **sema, /*!< out: longest-waited-for semaphore */ @@ -1065,11 +1023,9 @@ static bool sync_array_print_long_waits_low( return (fatal); } -/**********************************************************************/ /** - Prints warnings of long semaphore waits to stderr. +/** Prints warnings of long semaphore waits to stderr. @return true if fatal semaphore wait threshold was exceeded */ ibool sync_array_print_long_waits( - /*========================*/ os_thread_id_t *waiter, /*!< out: longest waiting thread */ const void **sema) /*!< out: longest-waited-for semaphore */ { @@ -1122,10 +1078,8 @@ ibool sync_array_print_long_waits( return (fatal); } -/**********************************************************************/ /** - Prints info of the wait array. */ +/** Prints info of the wait array. */ static void sync_array_print_info_low( - /*======================*/ FILE *file, /*!< in: file where to print */ sync_array_t *arr) /*!< in: wait array */ { @@ -1147,12 +1101,9 @@ static void sync_array_print_info_low( } } -/**********************************************************************/ /** - Prints info of the wait array. */ -static void sync_array_print_info( - /*==================*/ - FILE *file, /*!< in: file where to print */ - sync_array_t *arr) /*!< in: wait array */ +/** Prints info of the wait array. */ +static void sync_array_print_info(FILE *file, /*!< in: file where to print */ + sync_array_t *arr) /*!< in: wait array */ { sync_array_enter(arr); @@ -1161,12 +1112,10 @@ static void sync_array_print_info( sync_array_exit(arr); } -/**********************************************************************/ /** - Create the primary system wait array(s), they are protected by an OS mutex */ -void sync_array_init( - /*============*/ - ulint n_threads) /*!< in: Number of slots to - create in all arrays */ +/** Create the primary system wait array(s), they are protected by an OS mutex + */ +void sync_array_init(ulint n_threads) /*!< in: Number of slots to + create in all arrays */ { ut_a(sync_wait_array == NULL); ut_a(srv_sync_array_size > 0); @@ -1183,11 +1132,8 @@ void sync_array_init( } } -/**********************************************************************/ /** - Close sync array wait sub-system. */ -void sync_array_close(void) -/*==================*/ -{ +/** Close sync array wait sub-system. */ +void sync_array_close(void) { for (ulint i = 0; i < sync_array_size; ++i) { sync_array_free(sync_wait_array[i]); } @@ -1196,11 +1142,8 @@ void sync_array_close(void) sync_wait_array = NULL; } -/**********************************************************************/ /** - Print info about the sync array(s). */ -void sync_array_print( - /*=============*/ - FILE *file) /*!< in/out: Print to this stream */ +/** Print info about the sync array(s). */ +void sync_array_print(FILE *file) /*!< in/out: Print to this stream */ { for (ulint i = 0; i < sync_array_size; ++i) { sync_array_print_info(file, sync_wait_array[i]); diff --git a/storage/innobase/sync/sync0debug.cc b/storage/innobase/sync/sync0debug.cc index e3e8d02e3dc1..d0c1c4ed42f5 100644 --- a/storage/innobase/sync/sync0debug.cc +++ b/storage/innobase/sync/sync0debug.cc @@ -30,8 +30,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file sync/sync0debug.cc +/** @file sync/sync0debug.cc Debug checks for latches. Created 2012-08-21 Sunny Bains diff --git a/storage/innobase/sync/sync0rw.cc b/storage/innobase/sync/sync0rw.cc index 20fd70be2db8..039deda246ee 100644 --- a/storage/innobase/sync/sync0rw.cc +++ b/storage/innobase/sync/sync0rw.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -31,8 +31,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file sync/sync0rw.cc +/** @file sync/sync0rw.cc The read-write lock (for thread synchronization) Created 9/11/1995 Heikki Tuuri @@ -176,41 +175,26 @@ rw_lock_list_t rw_lock_list; ib_mutex_t rw_lock_list_mutex; #ifdef UNIV_DEBUG -/******************************************************************/ /** - Creates a debug info struct. */ +/** Creates a debug info struct. */ static rw_lock_debug_t *rw_lock_debug_create(void); -/*======================*/ -/******************************************************************/ /** - Frees a debug info struct. */ -static void rw_lock_debug_free( - /*===============*/ - rw_lock_debug_t *info); - -/******************************************************************/ /** - Creates a debug info struct. +/** Frees a debug info struct. */ +static void rw_lock_debug_free(rw_lock_debug_t *info); + +/** Creates a debug info struct. @return own: debug info struct */ -static rw_lock_debug_t *rw_lock_debug_create(void) -/*======================*/ -{ +static rw_lock_debug_t *rw_lock_debug_create(void) { return ((rw_lock_debug_t *)ut_malloc_nokey(sizeof(rw_lock_debug_t))); } -/******************************************************************/ /** - Frees a debug info struct. */ -static void rw_lock_debug_free( - /*===============*/ - rw_lock_debug_t *info) { - ut_free(info); -} +/** Frees a debug info struct. */ +static void rw_lock_debug_free(rw_lock_debug_t *info) { ut_free(info); } #endif /* UNIV_DEBUG */ -/******************************************************************/ /** - Creates, or rather, initializes an rw-lock object in a specified memory +/** Creates, or rather, initializes an rw-lock object in a specified memory location (which must be appropriately aligned). The rw-lock is initialized to the non-locked state. Explicit freeing of the rw-lock with rw_lock_free is necessary only if the memory block containing it is freed. */ void rw_lock_create_func( - /*================*/ rw_lock_t *lock, /*!< in: pointer to memory */ #ifdef UNIV_DEBUG latch_level_t level, /*!< in: level */ @@ -289,13 +273,10 @@ void rw_lock_create_func( mutex_exit(&rw_lock_list_mutex); } -/******************************************************************/ /** - Calling this function is obligatory only if the memory buffer containing +/** Calling this function is obligatory only if the memory buffer containing the rw-lock is freed. Removes an rw-lock object from the global list. The rw-lock is checked to be in the non-locked state. */ -void rw_lock_free_func( - /*==============*/ - rw_lock_t *lock) /*!< in/out: rw-lock */ +void rw_lock_free_func(rw_lock_t *lock) /*!< in/out: rw-lock */ { os_rmb; ut_ad(rw_lock_validate(lock)); @@ -319,13 +300,11 @@ void rw_lock_free_func( ut_d(lock->~rw_lock_t()); } -/******************************************************************/ /** - Lock an rw-lock in shared mode for the current thread. If the rw-lock is +/** Lock an rw-lock in shared mode for the current thread. If the rw-lock is locked in exclusive mode, or there is an exclusive lock request waiting, the function spins a preset time (controlled by srv_n_spin_wait_rounds), waiting for the lock, before suspending the thread. */ void rw_lock_s_lock_spin( - /*================*/ rw_lock_t *lock, /*!< in: pointer to rw-lock */ ulint pass, /*!< in: pass value; != 0, if the lock will be passed to another thread to unlock */ @@ -417,8 +396,7 @@ void rw_lock_s_lock_spin( } } -/******************************************************************/ /** - This function is used in the insert buffer to move the ownership of an +/** This function is used in the insert buffer to move the ownership of an x-latch on a buffer frame to the current thread. The x-latch was set by the buffer read operation and it protected the buffer frame while the read was done. The ownership is moved because we want that the current @@ -426,7 +404,6 @@ void rw_lock_s_lock_spin( This, in turn, is needed to pass the debug checks of index page operations. */ void rw_lock_x_lock_move_ownership( - /*==========================*/ rw_lock_t *lock) /*!< in: lock which was x-locked in the buffer read */ { @@ -435,12 +412,10 @@ void rw_lock_x_lock_move_ownership( rw_lock_set_writer_id_and_recursion_flag(lock, true); } -/******************************************************************/ /** - Function for the next writer to call. Waits for readers to exit. +/** Function for the next writer to call. Waits for readers to exit. The caller must have already decremented lock_word by X_LOCK_DECR. */ UNIV_INLINE void rw_lock_x_lock_wait_func( - /*=====================*/ rw_lock_t *lock, /*!< in: pointer to rw-lock */ #ifdef UNIV_DEBUG ulint pass, /*!< in: pass value; != 0, if the lock will @@ -516,12 +491,10 @@ void rw_lock_x_lock_wait_func( #define rw_lock_x_lock_wait(L, P, T, F, O) rw_lock_x_lock_wait_func(L, T, F, O) #endif /* UNIV_DBEUG */ -/******************************************************************/ /** - Low-level function for acquiring an exclusive lock. +/** Low-level function for acquiring an exclusive lock. @return false if did not succeed, true if success. */ UNIV_INLINE ibool rw_lock_x_lock_low( - /*===============*/ rw_lock_t *lock, /*!< in: pointer to rw-lock */ ulint pass, /*!< in: pass value; != 0, if the lock will be passed to another thread to unlock */ @@ -589,11 +562,9 @@ ibool rw_lock_x_lock_low( return (TRUE); } -/******************************************************************/ /** - Low-level function for acquiring an sx lock. +/** Low-level function for acquiring an sx lock. @return false if did not succeed, true if success. */ ibool rw_lock_sx_lock_low( - /*================*/ rw_lock_t *lock, /*!< in: pointer to rw-lock */ ulint pass, /*!< in: pass value; != 0, if the lock will be passed to another thread to unlock */ @@ -664,8 +635,7 @@ ibool rw_lock_sx_lock_low( return (TRUE); } -/******************************************************************/ /** - NOTE! Use the corresponding macro, not directly this function! Lock an +/** NOTE! Use the corresponding macro, not directly this function! Lock an rw-lock in exclusive mode for the current thread. If the rw-lock is locked in shared or exclusive mode, or there is an exclusive lock request waiting, the function spins a preset time (controlled by srv_n_spin_wait_rounds), @@ -674,7 +644,6 @@ ibool rw_lock_sx_lock_low( != 0, only a single x-lock may be taken on the lock. NOTE: If the same thread has an s-lock, locking does not succeed! */ void rw_lock_x_lock_func( - /*================*/ rw_lock_t *lock, /*!< in: pointer to rw-lock */ ulint pass, /*!< in: pass value; != 0, if the lock will be passed to another thread to unlock */ @@ -761,8 +730,7 @@ void rw_lock_x_lock_func( goto lock_loop; } -/******************************************************************/ /** - NOTE! Use the corresponding macro, not directly this function! Lock an +/** NOTE! Use the corresponding macro, not directly this function! Lock an rw-lock in SX mode for the current thread. If the rw-lock is locked in exclusive mode, or there is an exclusive lock request waiting, the function spins a preset time (controlled by SYNC_SPIN_ROUNDS), waiting @@ -771,7 +739,6 @@ void rw_lock_x_lock_func( only a single sx-lock may be taken on the lock. NOTE: If the same thread has an s-lock, locking does not succeed! */ void rw_lock_sx_lock_func( - /*=================*/ rw_lock_t *lock, /*!< in: pointer to rw-lock */ ulint pass, /*!< in: pass value; != 0, if the lock will be passed to another thread to unlock */ @@ -860,13 +827,10 @@ void rw_lock_sx_lock_func( #ifdef UNIV_DEBUG -/******************************************************************/ /** - Checks that the rw-lock has been initialized and that there are no +/** Checks that the rw-lock has been initialized and that there are no simultaneous shared and exclusive locks. @return true */ -bool rw_lock_validate( - /*=============*/ - const rw_lock_t *lock) /*!< in: rw-lock */ +bool rw_lock_validate(const rw_lock_t *lock) /*!< in: rw-lock */ { ulint waiters; lint lock_word; @@ -884,14 +848,11 @@ bool rw_lock_validate( return (true); } -/******************************************************************/ /** - Checks if somebody has locked the rw-lock in the specified mode. +/** Checks if somebody has locked the rw-lock in the specified mode. @return true if locked */ -bool rw_lock_is_locked( - /*==============*/ - rw_lock_t *lock, /*!< in: rw-lock */ - ulint lock_type) /*!< in: lock type: RW_LOCK_S, - RW_LOCK_X or RW_LOCK_SX */ +bool rw_lock_is_locked(rw_lock_t *lock, /*!< in: rw-lock */ + ulint lock_type) /*!< in: lock type: RW_LOCK_S, + RW_LOCK_X or RW_LOCK_SX */ { ut_ad(rw_lock_validate(lock)); @@ -911,10 +872,8 @@ bool rw_lock_is_locked( return (false); /* avoid compiler warnings */ } -/******************************************************************/ /** - Inserts the debug information for an rw-lock. */ +/** Inserts the debug information for an rw-lock. */ void rw_lock_add_debug_info( - /*===================*/ rw_lock_t *lock, /*!< in: rw-lock */ ulint pass, /*!< in: pass value */ ulint lock_type, /*!< in: lock type */ @@ -953,13 +912,10 @@ void rw_lock_add_debug_info( } } -/******************************************************************/ /** - Removes a debug information struct for an rw-lock. */ -void rw_lock_remove_debug_info( - /*======================*/ - rw_lock_t *lock, /*!< in: rw-lock */ - ulint pass, /*!< in: pass value */ - ulint lock_type) /*!< in: lock type */ +/** Removes a debug information struct for an rw-lock. */ +void rw_lock_remove_debug_info(rw_lock_t *lock, /*!< in: rw-lock */ + ulint pass, /*!< in: pass value */ + ulint lock_type) /*!< in: lock type */ { rw_lock_debug_t *info; @@ -990,15 +946,12 @@ void rw_lock_remove_debug_info( ut_error; } -/******************************************************************/ /** - Checks if the thread has locked the rw-lock in the specified mode, with +/** Checks if the thread has locked the rw-lock in the specified mode, with the pass value == 0. @return true if locked */ -ibool rw_lock_own( - /*========*/ - rw_lock_t *lock, /*!< in: rw-lock */ - ulint lock_type) /*!< in: lock type: RW_LOCK_S, - RW_LOCK_X */ +ibool rw_lock_own(rw_lock_t *lock, /*!< in: rw-lock */ + ulint lock_type) /*!< in: lock type: RW_LOCK_S, + RW_LOCK_X */ { ut_ad(lock); ut_ad(rw_lock_validate(lock)); @@ -1092,11 +1045,8 @@ bool rw_lock_own_flagged(const rw_lock_t *lock, rw_lock_flags_t flags) { return (false); } -/***************************************************************/ /** - Prints debug info of currently locked rw-locks. */ -void rw_lock_list_print_info( - /*====================*/ - FILE *file) /*!< in: file where to print */ +/** Prints debug info of currently locked rw-locks. */ +void rw_lock_list_print_info(FILE *file) /*!< in: file where to print */ { ulint count = 0; @@ -1146,12 +1096,9 @@ void rw_lock_list_print_info( mutex_exit(&rw_lock_list_mutex); } -/*********************************************************************/ /** - Prints info of a debug struct. */ -void rw_lock_debug_print( - /*================*/ - FILE *f, /*!< in: output stream */ - const rw_lock_debug_t *info) /*!< in: debug struct */ +/** Prints info of a debug struct. */ +void rw_lock_debug_print(FILE *f, /*!< in: output stream */ + const rw_lock_debug_t *info) /*!< in: debug struct */ { ulint rwt = info->lock_type; diff --git a/storage/innobase/sync/sync0sync.cc b/storage/innobase/sync/sync0sync.cc index 145fe9c5c9ea..18f995672059 100644 --- a/storage/innobase/sync/sync0sync.cc +++ b/storage/innobase/sync/sync0sync.cc @@ -31,8 +31,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file sync/sync0sync.cc +/** @file sync/sync0sync.cc Mutex, the basic synchronization primitive Created 9/5/1995 Heikki Tuuri diff --git a/storage/innobase/trx/trx0i_s.cc b/storage/innobase/trx/trx0i_s.cc index c05764026c96..41492ded9a2e 100644 --- a/storage/innobase/trx/trx0i_s.cc +++ b/storage/innobase/trx/trx0i_s.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2007, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file trx/trx0i_s.cc +/** @file trx/trx0i_s.cc INFORMATION SCHEMA innodb_trx, innodb_locks and innodb_lock_waits tables fetch code. @@ -196,13 +195,10 @@ INFORMATION SCHEMA tables is fetched and later retrieved by the C++ code in handler/i_s.cc. */ trx_i_s_cache_t *trx_i_s_cache = &trx_i_s_cache_static; -/*******************************************************************/ /** - For a record lock that is in waiting state retrieves the only bit that +/** For a record lock that is in waiting state retrieves the only bit that is set, for a table lock returns ULINT_UNDEFINED. @return record number within the heap */ -static ulint wait_lock_get_heap_no( - /*==================*/ - const lock_t *lock) /*!< in: lock */ +static ulint wait_lock_get_heap_no(const lock_t *lock) /*!< in: lock */ { ulint ret; @@ -221,10 +217,8 @@ static ulint wait_lock_get_heap_no( return (ret); } -/*******************************************************************/ /** - Initializes the members of a table cache. */ +/** Initializes the members of a table cache. */ static void table_cache_init( - /*=============*/ i_s_table_cache_t *table_cache, /*!< out: table cache */ size_t row_size) /*!< in: the size of a row */ @@ -242,10 +236,8 @@ static void table_cache_init( } } -/*******************************************************************/ /** - Frees a table cache. */ +/** Frees a table cache. */ static void table_cache_free( - /*=============*/ i_s_table_cache_t *table_cache) /*!< in/out: table cache */ { ulint i; @@ -260,14 +252,12 @@ static void table_cache_free( } } -/*******************************************************************/ /** - Returns an empty row from a table cache. The row is allocated if no more +/** Returns an empty row from a table cache. The row is allocated if no more empty rows are available. The number of used rows is incremented. If the memory limit is hit then NULL is returned and nothing is allocated. @return empty row, or NULL if out of memory */ static void *table_cache_create_empty_row( - /*=========================*/ i_s_table_cache_t *table_cache, /*!< in/out: table cache */ trx_i_s_cache_t *cache) /*!< in/out: cache to record how many bytes are @@ -390,11 +380,9 @@ static void *table_cache_create_empty_row( } #ifdef UNIV_DEBUG -/*******************************************************************/ /** - Validates a row in the locks cache. +/** Validates a row in the locks cache. @return true if valid */ static ibool i_s_locks_row_validate( - /*===================*/ const i_s_locks_row_t *row) /*!< in: row to validate */ { ut_ad(row->lock_table_id != 0); @@ -411,12 +399,10 @@ static ibool i_s_locks_row_validate( } #endif /* UNIV_DEBUG */ -/*******************************************************************/ /** - Fills i_s_trx_row_t object. +/** Fills i_s_trx_row_t object. If memory can not be allocated then FALSE is returned. @return false if allocation fails */ static ibool fill_trx_row( - /*=========*/ i_s_trx_row_t *row, /*!< out: result object that's filled */ const trx_t *trx, /*!< in: transaction to @@ -555,13 +541,11 @@ static ibool fill_trx_row( return (TRUE); } -/*******************************************************************/ /** - Format the nth field of "rec" and put it in "buf". The result is always +/** Format the nth field of "rec" and put it in "buf". The result is always NUL-terminated. Returns the number of bytes that were written to "buf" (including the terminating NUL). @return end of the result */ static ulint put_nth_field( - /*==========*/ char *buf, /*!< out: buffer */ ulint buf_size, /*!< in: buffer size in bytes */ ulint n, /*!< in: number of field */ @@ -697,12 +681,10 @@ void p_s_fill_lock_data(const char **lock_data, const lock_t *lock, mtr_commit(&mtr); } -/*******************************************************************/ /** - Fills i_s_locks_row_t object. Returns its first argument. +/** Fills i_s_locks_row_t object. Returns its first argument. If memory can not be allocated then FALSE is returned. @return false if allocation fails */ static ibool fill_locks_row( - /*===========*/ i_s_locks_row_t *row, /*!< out: result object that's filled */ const lock_t *lock, /*!< in: lock to get data from */ ulint heap_no, /*!< in: lock's record number @@ -739,14 +721,12 @@ static ibool fill_locks_row( return (TRUE); } -/*******************************************************************/ /** - Adds new element to the locks cache, enlarging it if necessary. +/** Adds new element to the locks cache, enlarging it if necessary. Returns a pointer to the added row. If the row is already present then no row is added and a pointer to the existing row is returned. If row can not be allocated then NULL is returned. @return row */ static i_s_locks_row_t *add_lock_to_cache( - /*==============*/ trx_i_s_cache_t *cache, /*!< in/out: cache */ const lock_t *lock, /*!< in: the element to add */ ulint heap_no) /*!< in: lock's record number @@ -773,8 +753,7 @@ static i_s_locks_row_t *add_lock_to_cache( return (dst_row); } -/*******************************************************************/ /** - Adds transaction's relevant (important) locks to cache. +/** Adds transaction's relevant (important) locks to cache. If the transaction is waiting, then the wait lock is added to innodb_locks and a pointer to the added row is returned in requested_lock_row, otherwise requested_lock_row is set to NULL. @@ -782,7 +761,6 @@ static i_s_locks_row_t *add_lock_to_cache( requested_lock_row is undefined. @return false if allocation fails */ static ibool add_trx_relevant_locks_to_cache( - /*============================*/ trx_i_s_cache_t *cache, /*!< in/out: cache */ const trx_t *trx, /*!< in: transaction */ i_s_locks_row_t **requested_lock_row) /*!< out: pointer to the @@ -847,12 +825,9 @@ to ensure that SELECTs which join several INFORMATION SCHEMA tables read the same version of the cache. */ #define CACHE_MIN_IDLE_TIME_US 100000 /* 0.1 sec */ -/*******************************************************************/ /** - Checks if the cache can safely be updated. +/** Checks if the cache can safely be updated. @return true if can be updated */ -static ibool can_cache_be_updated( - /*=================*/ - trx_i_s_cache_t *cache) /*!< in: cache */ +static ibool can_cache_be_updated(trx_i_s_cache_t *cache) /*!< in: cache */ { uintmax_t now; @@ -873,11 +848,9 @@ static ibool can_cache_be_updated( return (FALSE); } -/*******************************************************************/ /** - Declare a cache empty, preparing it to be filled up. Not all resources +/** Declare a cache empty, preparing it to be filled up. Not all resources are freed because they can be reused. */ static void trx_i_s_cache_clear( - /*================*/ trx_i_s_cache_t *cache) /*!< out: cache to clear */ { cache->innodb_trx.rows_used = 0; @@ -888,11 +861,9 @@ static void trx_i_s_cache_clear( ha_storage_empty(&cache->storage); } -/*******************************************************************/ /** - Fetches the data needed to fill the 3 INFORMATION SCHEMA tables into the +/** Fetches the data needed to fill the 3 INFORMATION SCHEMA tables into the table cache buffer. Cache must be locked for write. */ static void fetch_data_into_cache_low( - /*======================*/ trx_i_s_cache_t *cache, /*!< in/out: cache */ bool read_write, /*!< in: only read-write transactions */ @@ -956,12 +927,9 @@ static void fetch_data_into_cache_low( } } -/*******************************************************************/ /** - Fetches the data needed to fill the 3 INFORMATION SCHEMA tables into the +/** Fetches the data needed to fill the 3 INFORMATION SCHEMA tables into the table cache buffer. Cache must be locked for write. */ -static void fetch_data_into_cache( - /*==================*/ - trx_i_s_cache_t *cache) /*!< in/out: cache */ +static void fetch_data_into_cache(trx_i_s_cache_t *cache) /*!< in/out: cache */ { ut_ad(lock_mutex_own()); ut_ad(trx_sys_mutex_own()); @@ -978,12 +946,10 @@ static void fetch_data_into_cache( cache->is_truncated = FALSE; } -/*******************************************************************/ /** - Update the transactions cache if it has not been read for some time. +/** Update the transactions cache if it has not been read for some time. Called from handler/i_s.cc. @return 0 - fetched, 1 - not */ int trx_i_s_possibly_fetch_data_into_cache( - /*===================================*/ trx_i_s_cache_t *cache) /*!< in/out: cache */ { if (!can_cache_be_updated(cache)) { @@ -1005,22 +971,16 @@ int trx_i_s_possibly_fetch_data_into_cache( return (0); } -/*******************************************************************/ /** - Returns TRUE if the data in the cache is truncated due to the memory +/** Returns TRUE if the data in the cache is truncated due to the memory limit posed by TRX_I_S_MEM_LIMIT. @return true if truncated */ -ibool trx_i_s_cache_is_truncated( - /*=======================*/ - trx_i_s_cache_t *cache) /*!< in: cache */ +ibool trx_i_s_cache_is_truncated(trx_i_s_cache_t *cache) /*!< in: cache */ { return (cache->is_truncated); } -/*******************************************************************/ /** - Initialize INFORMATION SCHEMA trx related cache. */ -void trx_i_s_cache_init( - /*===============*/ - trx_i_s_cache_t *cache) /*!< out: cache to init */ +/** Initialize INFORMATION SCHEMA trx related cache. */ +void trx_i_s_cache_init(trx_i_s_cache_t *cache) /*!< out: cache to init */ { /* The latching is done in the following order: acquire trx_i_s_cache_t::rw_lock, X @@ -1054,11 +1014,8 @@ void trx_i_s_cache_init( cache->is_truncated = FALSE; } -/*******************************************************************/ /** - Free the INFORMATION SCHEMA trx related cache. */ -void trx_i_s_cache_free( - /*===============*/ - trx_i_s_cache_t *cache) /*!< in, own: cache to free */ +/** Free the INFORMATION SCHEMA trx related cache. */ +void trx_i_s_cache_free(trx_i_s_cache_t *cache) /*!< in, own: cache to free */ { rw_lock_free(cache->rw_lock); ut_free(cache->rw_lock); @@ -1072,20 +1029,14 @@ void trx_i_s_cache_free( table_cache_free(&cache->innodb_locks); } -/*******************************************************************/ /** - Issue a shared/read lock on the tables cache. */ -void trx_i_s_cache_start_read( - /*=====================*/ - trx_i_s_cache_t *cache) /*!< in: cache */ +/** Issue a shared/read lock on the tables cache. */ +void trx_i_s_cache_start_read(trx_i_s_cache_t *cache) /*!< in: cache */ { rw_lock_s_lock(cache->rw_lock); } -/*******************************************************************/ /** - Release a shared/read lock on the tables cache. */ -void trx_i_s_cache_end_read( - /*===================*/ - trx_i_s_cache_t *cache) /*!< in: cache */ +/** Release a shared/read lock on the tables cache. */ +void trx_i_s_cache_end_read(trx_i_s_cache_t *cache) /*!< in: cache */ { uintmax_t now; @@ -1100,31 +1051,23 @@ void trx_i_s_cache_end_read( rw_lock_s_unlock(cache->rw_lock); } -/*******************************************************************/ /** - Issue an exclusive/write lock on the tables cache. */ -void trx_i_s_cache_start_write( - /*======================*/ - trx_i_s_cache_t *cache) /*!< in: cache */ +/** Issue an exclusive/write lock on the tables cache. */ +void trx_i_s_cache_start_write(trx_i_s_cache_t *cache) /*!< in: cache */ { rw_lock_x_lock(cache->rw_lock); } -/*******************************************************************/ /** - Release an exclusive/write lock on the tables cache. */ -void trx_i_s_cache_end_write( - /*====================*/ - trx_i_s_cache_t *cache) /*!< in: cache */ +/** Release an exclusive/write lock on the tables cache. */ +void trx_i_s_cache_end_write(trx_i_s_cache_t *cache) /*!< in: cache */ { ut_ad(rw_lock_own(cache->rw_lock, RW_LOCK_X)); rw_lock_x_unlock(cache->rw_lock); } -/*******************************************************************/ /** - Selects a INFORMATION SCHEMA table cache from the whole cache. +/** Selects a INFORMATION SCHEMA table cache from the whole cache. @return table cache */ static i_s_table_cache_t *cache_select_table( - /*===============*/ trx_i_s_cache_t *cache, /*!< in: whole cache */ enum i_s_table table) /*!< in: which table */ { @@ -1144,14 +1087,11 @@ static i_s_table_cache_t *cache_select_table( return (table_cache); } -/*******************************************************************/ /** - Retrieves the number of used rows in the cache for a given +/** Retrieves the number of used rows in the cache for a given INFORMATION SCHEMA table. @return number of rows */ -ulint trx_i_s_cache_get_rows_used( - /*========================*/ - trx_i_s_cache_t *cache, /*!< in: cache */ - enum i_s_table table) /*!< in: which table */ +ulint trx_i_s_cache_get_rows_used(trx_i_s_cache_t *cache, /*!< in: cache */ + enum i_s_table table) /*!< in: which table */ { i_s_table_cache_t *table_cache; @@ -1160,15 +1100,12 @@ ulint trx_i_s_cache_get_rows_used( return (table_cache->rows_used); } -/*******************************************************************/ /** - Retrieves the nth row (zero-based) in the cache for a given +/** Retrieves the nth row (zero-based) in the cache for a given INFORMATION SCHEMA table. @return row */ -void *trx_i_s_cache_get_nth_row( - /*======================*/ - trx_i_s_cache_t *cache, /*!< in: cache */ - enum i_s_table table, /*!< in: which table */ - ulint n) /*!< in: row number */ +void *trx_i_s_cache_get_nth_row(trx_i_s_cache_t *cache, /*!< in: cache */ + enum i_s_table table, /*!< in: which table */ + ulint n) /*!< in: row number */ { i_s_table_cache_t *table_cache; ulint i; @@ -1194,14 +1131,12 @@ void *trx_i_s_cache_get_nth_row( return (row); } -/*******************************************************************/ /** - Crafts a lock id string from a i_s_locks_row_t object. Returns its +/** Crafts a lock id string from a i_s_locks_row_t object. Returns its second argument. This function aborts if there is not enough space in lock_id. Be sure to provide at least TRX_I_S_LOCK_ID_MAX_LEN + 1 if you want to be 100% sure that it will not abort. @return resulting lock id */ char *trx_i_s_create_lock_id( - /*===================*/ const i_s_locks_row_t *row, /*!< in: innodb_locks row */ char *lock_id, /*!< out: resulting lock_id */ ulint lock_id_size) /*!< in: size of the lock id diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 226fe94e9816..4f0dca41360f 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file trx/trx0purge.cc +/** @file trx/trx0purge.cc Purge old versions Created 3/26/1996 Heikki Tuuri @@ -174,12 +173,10 @@ const page_size_t TrxUndoRsegsIterator::set_next() { return (page_size); } -/****************************************************************/ /** - Builds a purge 'query' graph. The actual purge is performed by executing +/** Builds a purge 'query' graph. The actual purge is performed by executing this query graph. @return own: the query graph */ static que_t *trx_purge_graph_build( - /*==================*/ trx_t *trx, /*!< in: transaction */ ulint n_purge_threads) /*!< in: number of purge threads */ @@ -203,15 +200,12 @@ static que_t *trx_purge_graph_build( return (fork); } -/********************************************************************/ /** - Creates the global purge system control structure and inits the history +/** Creates the global purge system control structure and inits the history mutex. */ -void trx_purge_sys_create( - /*=================*/ - ulint n_purge_threads, /*!< in: number of purge - threads */ - purge_pq_t *purge_queue) /*!< in, own: UNDO log min - binary heap */ +void trx_purge_sys_create(ulint n_purge_threads, /*!< in: number of purge + threads */ + purge_pq_t *purge_queue) /*!< in, own: UNDO log min + binary heap */ { purge_sys = static_cast(ut_zalloc_nokey(sizeof(*purge_sys))); @@ -264,9 +258,7 @@ void trx_purge_sys_create( /************************************************************************ Frees the global purge system control structure. */ -void trx_purge_sys_close(void) -/*======================*/ -{ +void trx_purge_sys_close(void) { que_graph_free(purge_sys->query); ut_a(purge_sys->trx->id == 0); @@ -306,11 +298,9 @@ void trx_purge_sys_close(void) /*================ UNDO LOG HISTORY LIST =============================*/ -/********************************************************************/ /** - Adds the update undo log as the first log in the history list. Removes the +/** Adds the update undo log as the first log in the history list. Removes the update undo log segment from the rseg slot if it is too big for reuse. */ void trx_purge_add_update_undo_to_history( - /*=================================*/ trx_t *trx, /*!< in: transaction */ trx_undo_ptr_t *undo_ptr, /*!< in/out: update undo log. */ page_t *undo_page, /*!< in: update undo log header page, @@ -492,10 +482,8 @@ static void trx_purge_free_segment(trx_rseg_t *rseg, fil_addr_t hdr_addr, mtr_commit(&mtr); } -/********************************************************************/ /** - Removes unnecessary history data from a rollback segment. */ +/** Removes unnecessary history data from a rollback segment. */ static void trx_purge_truncate_rseg_history( - /*============================*/ trx_rseg_t *rseg, /*!< in: rollback segment */ const purge_iter_t *limit) /*!< in: truncate offset */ { @@ -1164,11 +1152,9 @@ static void trx_purge_initiate_truncate(purge_iter_t *limit, DBUG_SUICIDE();); } -/********************************************************************/ /** - Removes unnecessary history data from rollback segments. NOTE that when this +/** Removes unnecessary history data from rollback segments. NOTE that when this function is called, the caller must not have any latches on undo log pages! */ static void trx_purge_truncate_history( - /*========================*/ purge_iter_t *limit, /*!< in: truncate limit */ const ReadView *view) /*!< in: purge view */ { @@ -1256,11 +1242,9 @@ static void trx_purge_truncate_history( } } -/***********************************************************************/ /** - Updates the last not yet purged history log info in rseg when we have purged +/** Updates the last not yet purged history log info in rseg when we have purged a whole undo log. Advances also purge_sys->purge_trx_no past the purged log. */ static void trx_purge_rseg_get_next_history_log( - /*================================*/ trx_rseg_t *rseg, /*!< in: rollback segment */ ulint *n_pages_handled) /*!< in/out: number of UNDO pages handled */ @@ -1428,14 +1412,11 @@ static void trx_purge_read_undo_rec(trx_purge_t *purge_sys, purge_sys->next_stored = TRUE; } -/***********************************************************************/ /** - Chooses the next undo log to purge and updates the info in purge_sys. This +/** Chooses the next undo log to purge and updates the info in purge_sys. This function is used to initialize purge_sys when the next record to purge is not known, and also to update the purge system info on the next record when purge has handled the whole undo log for a transaction. */ -static void trx_purge_choose_next_log(void) -/*===========================*/ -{ +static void trx_purge_choose_next_log(void) { ut_ad(purge_sys->next_stored == FALSE); const page_size_t &page_size = purge_sys->rseg_iter->set_next(); @@ -1448,11 +1429,9 @@ static void trx_purge_choose_next_log(void) } } -/***********************************************************************/ /** - Gets the next record to purge and updates the info in the purge system. +/** Gets the next record to purge and updates the info in the purge system. @return copy of an undo log record or pointer to the dummy undo log record */ static trx_undo_rec_t *trx_purge_get_next_rec( - /*===================*/ ulint *n_pages_handled, /*!< in/out: number of UNDO pages handled */ mem_heap_t *heap) /*!< in: memory heap where copied */ @@ -1571,14 +1550,12 @@ static trx_undo_rec_t *trx_purge_get_next_rec( return (rec_copy); } -/********************************************************************/ /** - Fetches the next undo log record from the history list to purge. It must be +/** Fetches the next undo log record from the history list to purge. It must be released with the corresponding release function. @return copy of an undo log record or pointer to trx_purge_ignore_rec, if the whole undo log can skipped in purge; NULL if none left */ static MY_ATTRIBUTE((warn_unused_result)) trx_undo_rec_t *trx_purge_fetch_next_rec( - /*=====================*/ trx_id_t *modifier_trx_id, /*!< out: modifier trx id. this is the trx that created the undo record. */ @@ -1748,12 +1725,9 @@ static ulint trx_purge_attach_undo_recs(const ulint n_purge_threads, return (n_pages_handled); } -/*******************************************************************/ /** - Calculate the DML delay required. +/** Calculate the DML delay required. @return delay in microseconds or ULINT_MAX */ -static ulint trx_purge_dml_delay(void) -/*=====================*/ -{ +static ulint trx_purge_dml_delay(void) { /* Determine how much data manipulation language (DML) statements need to be delayed in order to reduce the lagging of the purge thread. */ @@ -1786,10 +1760,8 @@ static ulint trx_purge_dml_delay(void) return (delay); } -/*******************************************************************/ /** - Wait for pending purge jobs to complete. */ +/** Wait for pending purge jobs to complete. */ static void trx_purge_wait_for_workers_to_complete( - /*===================================*/ trx_purge_t *purge_sys) /*!< in: purge instance */ { ulint i = 0; @@ -1818,11 +1790,8 @@ static void trx_purge_wait_for_workers_to_complete( ut_a(srv_get_task_queue_length() == 0); } -/******************************************************************/ /** - Remove old historical changes from the rollback segments. */ -static void trx_purge_truncate(void) -/*====================*/ -{ +/** Remove old historical changes from the rollback segments. */ +static void trx_purge_truncate(void) { ut_ad(trx_purge_check_limit()); if (purge_sys->limit.trx_no == 0) { @@ -1832,16 +1801,13 @@ static void trx_purge_truncate(void) } } -/*******************************************************************/ /** - This function runs a purge batch. +/** This function runs a purge batch. @return number of undo log pages handled in the batch */ -ulint trx_purge( - /*======*/ - ulint n_purge_threads, /*!< in: number of purge tasks - to submit to the work queue */ - ulint batch_size, /*!< in: the maximum number of records - to purge in one batch */ - bool truncate) /*!< in: truncate history if true */ +ulint trx_purge(ulint n_purge_threads, /*!< in: number of purge tasks + to submit to the work queue */ + ulint batch_size, /*!< in: the maximum number of records + to purge in one batch */ + bool truncate) /*!< in: truncate history if true */ { que_thr_t *thr = NULL; ulint n_pages_handled; @@ -1934,12 +1900,9 @@ ulint trx_purge( return (n_pages_handled); } -/*******************************************************************/ /** - Get the purge state. +/** Get the purge state. @return purge state. */ -purge_state_t trx_purge_state(void) -/*=================*/ -{ +purge_state_t trx_purge_state(void) { purge_state_t state; rw_lock_x_lock(&purge_sys->latch); @@ -1951,11 +1914,8 @@ purge_state_t trx_purge_state(void) return (state); } -/*******************************************************************/ /** - Stop purge and wait for it to stop, move to PURGE_STATE_STOP. */ -void trx_purge_stop(void) -/*================*/ -{ +/** Stop purge and wait for it to stop, move to PURGE_STATE_STOP. */ +void trx_purge_stop(void) { purge_state_t state; int64_t sig_count = os_event_reset(purge_sys->event); @@ -2013,11 +1973,8 @@ void trx_purge_stop(void) MONITOR_INC_VALUE(MONITOR_PURGE_STOP_COUNT, 1); } -/*******************************************************************/ /** - Resume purge, move to PURGE_STATE_RUN. */ -void trx_purge_run(void) -/*===============*/ -{ +/** Resume purge, move to PURGE_STATE_RUN. */ +void trx_purge_run(void) { rw_lock_x_lock(&purge_sys->latch); switch (purge_sys->state) { diff --git a/storage/innobase/trx/trx0rec.cc b/storage/innobase/trx/trx0rec.cc index 96892106facc..71bf269a2884 100644 --- a/storage/innobase/trx/trx0rec.cc +++ b/storage/innobase/trx/trx0rec.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file trx/trx0rec.cc +/** @file trx/trx0rec.cc Transaction undo log record Created 3/26/1996 Heikki Tuuri @@ -61,12 +60,10 @@ class Spatial_reference_system; /*=========== UNDO LOG RECORD CREATION AND DECODING ====================*/ -/**********************************************************************/ /** - Writes the mtr log entry of the inserted undo log record on the undo log +/** Writes the mtr log entry of the inserted undo log record on the undo log page. */ UNIV_INLINE void trx_undof_page_add_undo_rec_log( - /*============================*/ page_t *undo_page, /*!< in: undo log page */ ulint old_free, /*!< in: start offset of the inserted entry */ ulint new_free, /*!< in: end offset of the entry */ @@ -100,14 +97,11 @@ void trx_undof_page_add_undo_rec_log( } #endif /* !UNIV_HOTBACKUP */ -/***********************************************************/ /** - Parses a redo log record of adding an undo log record. +/** Parses a redo log record of adding an undo log record. @return end of log record or NULL */ -byte *trx_undo_parse_add_undo_rec( - /*========================*/ - byte *ptr, /*!< in: buffer */ - byte *end_ptr, /*!< in: buffer end */ - page_t *page) /*!< in: page or NULL */ +byte *trx_undo_parse_add_undo_rec(byte *ptr, /*!< in: buffer */ + byte *end_ptr, /*!< in: buffer end */ + page_t *page) /*!< in: page or NULL */ { ulint len; byte *rec; @@ -142,14 +136,11 @@ byte *trx_undo_parse_add_undo_rec( } #ifndef UNIV_HOTBACKUP -/**********************************************************************/ /** - Calculates the free space left for extending an undo log record. +/** Calculates the free space left for extending an undo log record. @return bytes left */ UNIV_INLINE -ulint trx_undo_left( - /*==========*/ - const page_t *page, /*!< in: undo log page */ - const byte *ptr) /*!< in: pointer to page */ +ulint trx_undo_left(const page_t *page, /*!< in: undo log page */ + const byte *ptr) /*!< in: pointer to page */ { /* The '- 10' is a safety margin, in case we have some small calculation error below */ @@ -157,13 +148,11 @@ ulint trx_undo_left( return (UNIV_PAGE_SIZE - (ptr - page) - 10 - FIL_PAGE_DATA_END); } -/**********************************************************************/ /** - Set the next and previous pointers in the undo page for the undo record +/** Set the next and previous pointers in the undo page for the undo record that was written to ptr. Update the first free value by the number of bytes written for this undo record. @return offset of the inserted entry on the page if succeeded, 0 if fail */ static ulint trx_undo_page_set_next_prev_and_add( - /*================================*/ page_t *undo_page, /*!< in/out: undo log page */ byte *ptr, /*!< in: ptr up to where data has been written on this undo page. */ @@ -423,11 +412,9 @@ static bool trx_undo_report_insert_virtual(page_t *undo_page, return (true); } -/**********************************************************************/ /** - Reports in the undo log of an insert of a clustered index record. +/** Reports in the undo log of an insert of a clustered index record. @return offset of the inserted entry on the page if succeed, 0 if fail */ static ulint trx_undo_page_report_insert( - /*========================*/ page_t *undo_page, /*!< in: undo log page */ trx_t *trx, /*!< in: transaction */ dict_index_t *index, /*!< in: clustered index */ @@ -496,11 +483,9 @@ static ulint trx_undo_page_report_insert( return (trx_undo_page_set_next_prev_and_add(undo_page, ptr, mtr)); } -/**********************************************************************/ /** - Reads from an undo log record the general parameters. +/** Reads from an undo log record the general parameters. @return remaining part of undo log record after reading these values */ byte *trx_undo_rec_get_pars( - /*==================*/ trx_undo_rec_t *undo_rec, /*!< in: undo log record */ ulint *type, /*!< out: undo record type: TRX_UNDO_INSERT_REC, ... */ @@ -591,11 +576,9 @@ byte *trx_undo_rec_get_col_val(const byte *ptr, const byte **field, ulint *len, return (const_cast(ptr)); } -/*******************************************************************/ /** - Builds a row reference from an undo log record. +/** Builds a row reference from an undo log record. @return pointer to remaining part of undo record */ byte *trx_undo_rec_get_row_ref( - /*=====================*/ byte *ptr, /*!< in: remaining part of a copy of an undo log record, at the start of the row reference; NOTE that this copy of the undo log record must @@ -635,11 +618,9 @@ byte *trx_undo_rec_get_row_ref( return (ptr); } -/*******************************************************************/ /** - Skips a row reference from an undo log record. +/** Skips a row reference from an undo log record. @return pointer to remaining part of undo record */ static byte *trx_undo_rec_skip_row_ref( - /*======================*/ byte *ptr, /*!< in: remaining part in update undo log record, at the start of the row reference */ dict_index_t *index) /*!< in: clustered index */ @@ -811,10 +792,10 @@ static byte *trx_undo_page_report_modify_ext_func( @param[in,out] len length of field, in bytes @param[in] srs Spatial reference system of R-tree. */ -static void trx_undo_get_mbr_from_ext( - /*======================*/ - trx_t *trx, dict_index_t *index, double *mbr, const page_size_t &page_size, - const byte *field, ulint *len, const dd::Spatial_reference_system *srs) { +static void trx_undo_get_mbr_from_ext(trx_t *trx, dict_index_t *index, + double *mbr, const page_size_t &page_size, + const byte *field, ulint *len, + const dd::Spatial_reference_system *srs) { uchar *dptr = NULL; ulint dlen; mem_heap_t *heap = mem_heap_create(100); @@ -835,13 +816,11 @@ static void trx_undo_get_mbr_from_ext( mem_heap_free(heap); } -/**********************************************************************/ /** - Reports in the undo log of an update or delete marking of a clustered index +/** Reports in the undo log of an update or delete marking of a clustered index record. @return byte offset of the inserted undo log entry on the page if succeed, 0 if fail */ static ulint trx_undo_page_report_modify( - /*========================*/ page_t *undo_page, /*!< in: undo log page */ trx_t *trx, /*!< in: transaction */ dict_index_t *index, /*!< in: clustered index where update or @@ -1320,12 +1299,10 @@ static ulint trx_undo_page_report_modify( return (first_free); } -/**********************************************************************/ /** - Reads from an undo log update record the system field values of the old +/** Reads from an undo log update record the system field values of the old version. @return remaining part of undo log record after reading these values */ byte *trx_undo_update_rec_get_sys_cols( - /*=============================*/ const byte *ptr, /*!< in: remaining part of undo log record after reading general parameters */ @@ -1345,12 +1322,10 @@ byte *trx_undo_update_rec_get_sys_cols( return (const_cast(ptr)); } -/*******************************************************************/ /** - Builds an update vector based on a remaining part of an undo log record. +/** Builds an update vector based on a remaining part of an undo log record. @return remaining part of the record, NULL if an error detected, which means that the record is corrupted */ byte *trx_undo_update_rec_get_update( - /*===========================*/ const byte *ptr, /*!< in: remaining part in update undo log record, after reading the row reference NOTE that this copy of the undo log record must @@ -1526,13 +1501,11 @@ byte *trx_undo_update_rec_get_update( return (const_cast(ptr)); } -/*******************************************************************/ /** - Builds a partial row from an update undo log record, for purge. +/** Builds a partial row from an update undo log record, for purge. It contains the columns which occur as ordering in any index of the table. Any missing columns are indicated by col->mtype == DATA_MISSING. @return pointer to remaining part of undo record */ byte *trx_undo_rec_get_partial_row( - /*=========================*/ const byte *ptr, /*!< in: remaining part in update undo log record of a suitable type, at the start of the stored index columns; @@ -1667,11 +1640,9 @@ byte *trx_undo_rec_get_partial_row( } #endif /* !UNIV_HOTBACKUP */ -/***********************************************************************/ /** - Erases the unused undo log page end. +/** Erases the unused undo log page end. @return true if the page contained something, false if it was empty */ static ibool trx_undo_erase_page_end( - /*====================*/ page_t *undo_page, /*!< in/out: undo page whose end to erase */ mtr_t *mtr) /*!< in/out: mini-transaction */ { @@ -1686,11 +1657,9 @@ static ibool trx_undo_erase_page_end( return (first_free != TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE); } -/***********************************************************/ /** - Parses a redo log record of erasing of an undo page end. +/** Parses a redo log record of erasing of an undo page end. @return end of log record or NULL */ byte *trx_undo_parse_erase_page_end( - /*==========================*/ byte *ptr, /*!< in: buffer */ byte *end_ptr MY_ATTRIBUTE((unused)), /*!< in: buffer end */ page_t *page, /*!< in: page or NULL */ @@ -1709,14 +1678,12 @@ byte *trx_undo_parse_erase_page_end( } #ifndef UNIV_HOTBACKUP -/***********************************************************************/ /** - Writes information to an undo log about an insert, update, or a delete marking - of a clustered index record. This information is used in a rollback of the - transaction and in consistent reads that must look to the history of this +/** Writes information to an undo log about an insert, update, or a delete + marking of a clustered index record. This information is used in a rollback of + the transaction and in consistent reads that must look to the history of this transaction. @return DB_SUCCESS or error code */ dberr_t trx_undo_report_row_operation( - /*==========================*/ ulint flags, /*!< in: if BTR_NO_UNDO_LOG_FLAG bit is set, does nothing */ ulint op_type, /*!< in: TRX_UNDO_INSERT_OP or @@ -1967,13 +1934,11 @@ dberr_t trx_undo_report_row_operation( /*============== BUILDING PREVIOUS VERSION OF A RECORD ===============*/ -/******************************************************************/ /** - Copies an undo record to heap. This function can be called if we know that +/** Copies an undo record to heap. This function can be called if we know that the undo log record exists. @return own: copy of the record */ static MY_ATTRIBUTE((warn_unused_result)) trx_undo_rec_t *trx_undo_get_undo_rec_low( - /*======================*/ roll_ptr_t roll_ptr, /*!< in: roll pointer to record */ mem_heap_t *heap, /*!< in: memory heap where copied */ bool is_temp) /*!< in: true if temp undo rec. */ @@ -2006,8 +1971,7 @@ static MY_ATTRIBUTE((warn_unused_result)) return (undo_rec); } -/******************************************************************/ /** - Copies an undo record to heap. +/** Copies an undo record to heap. @param[in] roll_ptr roll pointer to record @param[in] trx_id id of the trx that generated the roll pointer: it points to an @@ -2021,7 +1985,6 @@ static MY_ATTRIBUTE((warn_unused_result)) @retval false if the undo log record is available NOTE: the caller must have latches on the clustered index page. */ static MY_ATTRIBUTE((warn_unused_result)) bool trx_undo_get_undo_rec( - /*==================*/ roll_ptr_t roll_ptr, trx_id_t trx_id, mem_heap_t *heap, bool is_temp, const table_name_t &name, trx_undo_rec_t **undo_rec) { bool missing_history; diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc index e85b129f3585..8f7baaeefd1a 100644 --- a/storage/innobase/trx/trx0roll.cc +++ b/storage/innobase/trx/trx0roll.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file trx/trx0roll.cc +/** @file trx/trx0roll.cc Transaction rollback Created 3/26/1996 Heikki Tuuri @@ -75,16 +74,11 @@ static undo_no_t trx_roll_max_undo_no; /** Auxiliary variable which tells the previous progress % we printed */ static ulint trx_roll_progress_printed_pct; -/****************************************************************/ /** - Finishes a transaction rollback. */ -static void trx_rollback_finish( - /*================*/ - trx_t *trx); /*!< in: transaction */ +/** Finishes a transaction rollback. */ +static void trx_rollback_finish(trx_t *trx); /*!< in: transaction */ -/*******************************************************************/ /** - Rollback a transaction used in MySQL. */ +/** Rollback a transaction used in MySQL. */ static void trx_rollback_to_savepoint_low( - /*==========================*/ trx_t *trx, /*!< in: transaction handle */ trx_savept_t *savept) /*!< in: pointer to savepoint undo number, if partial rollback requested, or NULL for @@ -144,11 +138,9 @@ static void trx_rollback_to_savepoint_low( MONITOR_DEC(MONITOR_TRX_ACTIVE); } -/*******************************************************************/ /** - Rollback a transaction to a given savepoint or do a complete rollback. +/** Rollback a transaction to a given savepoint or do a complete rollback. @return error code or DB_SUCCESS */ dberr_t trx_rollback_to_savepoint( - /*======================*/ trx_t *trx, /*!< in: transaction handle */ trx_savept_t *savept) /*!< in: pointer to savepoint undo number, if partial rollback requested, or NULL for @@ -163,11 +155,9 @@ dberr_t trx_rollback_to_savepoint( return (trx->error_state); } -/*******************************************************************/ /** - Rollback a transaction used in MySQL. +/** Rollback a transaction used in MySQL. @return error code or DB_SUCCESS */ static dberr_t trx_rollback_for_mysql_low( - /*=======================*/ trx_t *trx) /*!< in/out: transaction */ { trx->op_info = "rollback"; @@ -263,12 +253,9 @@ static dberr_t trx_rollback_low(trx_t *trx) { return (DB_CORRUPTION); } -/*******************************************************************/ /** - Rollback a transaction used in MySQL. +/** Rollback a transaction used in MySQL. @return error code or DB_SUCCESS */ -dberr_t trx_rollback_for_mysql( - /*===================*/ - trx_t *trx) /*!< in/out: transaction */ +dberr_t trx_rollback_for_mysql(trx_t *trx) /*!< in/out: transaction */ { /* Avoid the tracking of async rollback killer thread to enter into InnoDB. */ @@ -282,11 +269,9 @@ dberr_t trx_rollback_for_mysql( } } -/*******************************************************************/ /** - Rollback the latest SQL statement for MySQL. +/** Rollback the latest SQL statement for MySQL. @return error code or DB_SUCCESS */ dberr_t trx_rollback_last_sql_stat_for_mysql( - /*=================================*/ trx_t *trx) /*!< in/out: transaction */ { dberr_t err; @@ -332,11 +317,9 @@ dberr_t trx_rollback_last_sql_stat_for_mysql( return (DB_CORRUPTION); } -/*******************************************************************/ /** - Search for a savepoint using name. +/** Search for a savepoint using name. @return savepoint if found else NULL */ static trx_named_savept_t *trx_savepoint_find( - /*===============*/ trx_t *trx, /*!< in: transaction */ const char *name) /*!< in: savepoint name */ { @@ -352,10 +335,8 @@ static trx_named_savept_t *trx_savepoint_find( return (NULL); } -/*******************************************************************/ /** - Frees a single savepoint struct. */ +/** Frees a single savepoint struct. */ static void trx_roll_savepoint_free( - /*=====================*/ trx_t *trx, /*!< in: transaction handle */ trx_named_savept_t *savep) /*!< in: savepoint to free */ { @@ -365,10 +346,8 @@ static void trx_roll_savepoint_free( ut_free(savep); } -/*******************************************************************/ /** - Frees savepoint structs starting from savep. */ +/** Frees savepoint structs starting from savep. */ void trx_roll_savepoints_free( - /*=====================*/ trx_t *trx, /*!< in: transaction handle */ trx_named_savept_t *savep) /*!< in: free all savepoints starting with this savepoint i*/ @@ -384,8 +363,7 @@ void trx_roll_savepoints_free( } } -/*******************************************************************/ /** - Rolls back a transaction back to a named savepoint. Modifications after the +/** Rolls back a transaction back to a named savepoint. Modifications after the savepoint are undone but InnoDB does NOT release the corresponding locks which are stored in memory. If a lock is 'implicit', that is, a new inserted row holds a lock where the lock information is carried by the trx id stored in @@ -395,7 +373,6 @@ void trx_roll_savepoints_free( otherwise DB_SUCCESS */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t trx_rollback_to_savepoint_for_mysql_low( - /*====================================*/ trx_t *trx, /*!< in/out: transaction */ trx_named_savept_t *savep, /*!< in/out: savepoint */ int64_t *mysql_binlog_cache_pos) @@ -432,8 +409,7 @@ executed after the savepoint */ return (err); } -/*******************************************************************/ /** - Rolls back a transaction back to a named savepoint. Modifications after the +/** Rolls back a transaction back to a named savepoint. Modifications after the savepoint are undone but InnoDB does NOT release the corresponding locks which are stored in memory. If a lock is 'implicit', that is, a new inserted row holds a lock where the lock information is carried by the trx id stored in @@ -442,7 +418,6 @@ executed after the savepoint */ @return if no savepoint of the name found then DB_NO_SAVEPOINT, otherwise DB_SUCCESS */ dberr_t trx_rollback_to_savepoint_for_mysql( - /*================================*/ trx_t *trx, /*!< in: transaction handle */ const char *savepoint_name, /*!< in: savepoint name */ int64_t *mysql_binlog_cache_pos) /*!< out: the MySQL binlog cache @@ -491,14 +466,12 @@ dberr_t trx_rollback_to_savepoint_for_mysql( return (DB_CORRUPTION); } -/*******************************************************************/ /** - Creates a named savepoint. If the transaction is not yet started, starts it. +/** Creates a named savepoint. If the transaction is not yet started, starts it. If there is already a savepoint of the same name, this call erases that old savepoint and replaces it with a new. Savepoints are deleted in a transaction commit or rollback. @return always DB_SUCCESS */ dberr_t trx_savepoint_for_mysql( - /*====================*/ trx_t *trx, /*!< in: transaction handle */ const char *savepoint_name, /*!< in: savepoint name */ int64_t binlog_cache_pos) /*!< in: MySQL binlog cache @@ -536,13 +509,11 @@ dberr_t trx_savepoint_for_mysql( return (DB_SUCCESS); } -/*******************************************************************/ /** - Releases only the named savepoint. Savepoints which were set after this +/** Releases only the named savepoint. Savepoints which were set after this savepoint are left as is. @return if no savepoint of the name found then DB_NO_SAVEPOINT, otherwise DB_SUCCESS */ dberr_t trx_release_savepoint_for_mysql( - /*============================*/ trx_t *trx, /*!< in: transaction handle */ const char *savepoint_name) /*!< in: savepoint name */ { @@ -560,24 +531,18 @@ dberr_t trx_release_savepoint_for_mysql( return (savep != NULL ? DB_SUCCESS : DB_NO_SAVEPOINT); } -/*******************************************************************/ /** - Determines if this transaction is rolling back an incomplete transaction +/** Determines if this transaction is rolling back an incomplete transaction in crash recovery. @return true if trx is an incomplete transaction that is being rolled back in crash recovery */ -ibool trx_is_recv( - /*========*/ - const trx_t *trx) /*!< in: transaction */ +ibool trx_is_recv(const trx_t *trx) /*!< in: transaction */ { return (trx == trx_roll_crash_recv_trx); } -/*******************************************************************/ /** - Returns a transaction savepoint taken at this point in time. +/** Returns a transaction savepoint taken at this point in time. @return savepoint */ -trx_savept_t trx_savept_take( - /*============*/ - trx_t *trx) /*!< in: transaction */ +trx_savept_t trx_savept_take(trx_t *trx) /*!< in: transaction */ { trx_savept_t savept; @@ -586,11 +551,8 @@ trx_savept_t trx_savept_take( return (savept); } -/*******************************************************************/ /** - Roll back an active transaction. */ -static void trx_rollback_active( - /*================*/ - trx_t *trx) /*!< in/out: transaction */ +/** Roll back an active transaction. */ +static void trx_rollback_active(trx_t *trx) /*!< in/out: transaction */ { mem_heap_t *heap; que_fork_t *fork; @@ -656,14 +618,12 @@ static void trx_rollback_active( trx_roll_crash_recv_trx = NULL; } -/*******************************************************************/ /** - Rollback or clean up any resurrected incomplete transactions. It assumes +/** Rollback or clean up any resurrected incomplete transactions. It assumes that the caller holds the trx_sys_t::mutex and it will release the lock if it does a clean up or rollback. @return true if the transaction was cleaned up or rolled back and trx_sys->mutex was released. */ static ibool trx_rollback_resurrected( - /*=====================*/ trx_t *trx, /*!< in: transaction to rollback or clean */ ibool all) /*!< in: FALSE=roll back dictionary transactions; TRUE=roll back all non-PREPARED transactions */ @@ -711,13 +671,11 @@ static ibool trx_rollback_resurrected( return (FALSE); } -/*******************************************************************/ /** - Rollback or clean up any incomplete transactions which were +/** Rollback or clean up any incomplete transactions which were encountered in crash recovery. If the transaction already was committed, then we clean up a possible insert undo log. If the transaction was not yet committed, then we roll it back. */ void trx_rollback_or_clean_recovered( - /*============================*/ ibool all) /*!< in: FALSE=roll back dictionary transactions; TRUE=roll back all non-PREPARED transactions */ { @@ -793,10 +751,8 @@ void trx_recovery_rollback_thread() { my_thread_end(); } -/***********************************************************************/ /** - Tries truncate the undo logs. */ +/** Tries truncate the undo logs. */ static void trx_roll_try_truncate( - /*==================*/ trx_t *trx, /*!< in/out: transaction */ trx_undo_ptr_t *undo_ptr) /*!< in: rollback segment to look for next undo log record. */ @@ -815,12 +771,10 @@ static void trx_roll_try_truncate( } } -/***********************************************************************/ /** - Pops the topmost undo log record in a single undo log and updates the info +/** Pops the topmost undo log record in a single undo log and updates the info about the topmost record in the undo log memory struct. @return undo log record, the page s-latched */ static trx_undo_rec_t *trx_roll_pop_top_rec( - /*=================*/ trx_t *trx, /*!< in: transaction */ trx_undo_t *undo, /*!< in: undo log */ mtr_t *mtr) /*!< in: mtr */ @@ -852,13 +806,11 @@ static trx_undo_rec_t *trx_roll_pop_top_rec( return (undo_page + offset); } -/********************************************************************/ /** - Pops the topmost record when the two undo logs of a transaction are seen +/** Pops the topmost record when the two undo logs of a transaction are seen as a single stack of records ordered by their undo numbers. @return undo log record copied to heap, NULL if none left, or if the undo number of the top record would be less than the limit */ static trx_undo_rec_t *trx_roll_pop_top_rec_of_trx_low( - /*============================*/ trx_t *trx, /*!< in/out: transaction */ trx_undo_ptr_t *undo_ptr, /*!< in: rollback segment to look for next undo log record. */ @@ -953,12 +905,10 @@ static trx_undo_rec_t *trx_roll_pop_top_rec_of_trx_low( return (undo_rec_copy); } -/********************************************************************/ /** - Get next undo log record from redo and noredo rollback segments. +/** Get next undo log record from redo and noredo rollback segments. @return undo log record copied to heap, NULL if none left, or if the undo number of the top record would be less than the limit */ trx_undo_rec_t *trx_roll_pop_top_rec_of_trx( - /*========================*/ trx_t *trx, /*!< in: transaction */ undo_no_t limit, /*!< in: least undo number we need */ roll_ptr_t *roll_ptr, /*!< out: roll pointer to undo record */ @@ -979,15 +929,12 @@ trx_undo_rec_t *trx_roll_pop_top_rec_of_trx( return (undo_rec); } -/****************************************************************/ /** - Builds an undo 'query' graph for a transaction. The actual rollback is +/** Builds an undo 'query' graph for a transaction. The actual rollback is performed by executing this query graph like a query subprocedure call. The reply about the completion of the rollback will be sent by this graph. @return own: the query graph */ -static que_t *trx_roll_graph_build( - /*=================*/ - trx_t *trx) /*!< in/out: transaction */ +static que_t *trx_roll_graph_build(trx_t *trx) /*!< in/out: transaction */ { mem_heap_t *heap; que_fork_t *fork; @@ -1006,12 +953,10 @@ static que_t *trx_roll_graph_build( return (fork); } -/*********************************************************************/ /** - Starts a rollback operation, creates the UNDO graph that will do the +/** Starts a rollback operation, creates the UNDO graph that will do the actual undo operation. @return query graph thread that will perform the UNDO operations. */ static que_thr_t *trx_rollback_start( - /*===============*/ trx_t *trx, /*!< in: transaction */ ib_id_t roll_limit) /*!< in: rollback to undo no (for partial undo), 0 if we are rolling back @@ -1042,11 +987,8 @@ static que_thr_t *trx_rollback_start( return (que_fork_start_command(roll_graph)); } -/****************************************************************/ /** - Finishes a transaction rollback. */ -static void trx_rollback_finish( - /*================*/ - trx_t *trx) /*!< in: transaction */ +/** Finishes a transaction rollback. */ +static void trx_rollback_finish(trx_t *trx) /*!< in: transaction */ { trx_commit(trx); @@ -1055,11 +997,9 @@ static void trx_rollback_finish( trx->lock.que_state = TRX_QUE_RUNNING; } -/*********************************************************************/ /** - Creates a rollback command node struct. +/** Creates a rollback command node struct. @return own: rollback node struct */ roll_node_t *roll_node_create( - /*=============*/ mem_heap_t *heap) /*!< in: mem heap where created */ { roll_node_t *node; @@ -1073,12 +1013,9 @@ roll_node_t *roll_node_create( return (node); } -/***********************************************************/ /** - Performs an execution step for a rollback command node in a query graph. +/** Performs an execution step for a rollback command node in a query graph. @return query thread to run next, or NULL */ -que_thr_t *trx_rollback_step( - /*==============*/ - que_thr_t *thr) /*!< in: query thread */ +que_thr_t *trx_rollback_step(que_thr_t *thr) /*!< in: query thread */ { roll_node_t *node; diff --git a/storage/innobase/trx/trx0rseg.cc b/storage/innobase/trx/trx0rseg.cc index cbeac00c38ab..ae42c2ba5083 100644 --- a/storage/innobase/trx/trx0rseg.cc +++ b/storage/innobase/trx/trx0rseg.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file trx/trx0rseg.cc +/** @file trx/trx0rseg.cc Rollback segment Created 3/26/1996 Heikki Tuuri diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc index 6ea165e15761..a0b89f5bf19b 100644 --- a/storage/innobase/trx/trx0sys.cc +++ b/storage/innobase/trx/trx0sys.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file trx/trx0sys.cc +/** @file trx/trx0sys.cc Transaction system Created 3/26/1996 Heikki Tuuri @@ -94,11 +93,8 @@ void ReadView::check_trx_id_sanity(trx_id_t id, const table_name_t &name) { uint trx_rseg_n_slots_debug = 0; #endif /* UNIV_DEBUG */ -/*****************************************************************/ /** - Writes the value of max_trx_id to the file based trx system header. */ -void trx_sys_flush_max_trx_id(void) -/*==========================*/ -{ +/** Writes the value of max_trx_id to the file based trx system header. */ +void trx_sys_flush_max_trx_id(void) { mtr_t mtr; trx_sysf_t *sys_header; @@ -116,13 +112,11 @@ void trx_sys_flush_max_trx_id(void) } } -/*****************************************************************/ /** - Updates the offset information about the end of the MySQL binlog entry +/** Updates the offset information about the end of the MySQL binlog entry which corresponds to the transaction just being committed. In a MySQL replication slave updates the latest master binlog position up to which replication has proceeded. */ void trx_sys_update_mysql_binlog_offset( - /*===============================*/ const char *file_name, /*!< in: MySQL log file name */ int64_t offset, /*!< in: position in that log file */ ulint field, /*!< in: offset of the MySQL log info field in @@ -162,12 +156,9 @@ void trx_sys_update_mysql_binlog_offset( (ulint)(offset & 0xFFFFFFFFUL), MLOG_4BYTES, mtr); } -/*****************************************************************/ /** - Stores the MySQL binlog offset info in the trx system header if +/** Stores the MySQL binlog offset info in the trx system header if the magic number shows it valid, and print the info to stderr */ -void trx_sys_print_mysql_binlog_offset(void) -/*===================================*/ -{ +void trx_sys_print_mysql_binlog_offset(void) { trx_sysf_t *sys_header; mtr_t mtr; ulint trx_sys_mysql_bin_log_pos_high; @@ -232,12 +223,9 @@ ulint trx_sysf_rseg_find_free(mtr_t *mtr) { return (ULINT_UNDEFINED); } -/*****************************************************************/ /** - Creates the file page for the transaction system. This function is called only - at the database creation, before trx_sys_init. */ -static void trx_sysf_create( - /*============*/ - mtr_t *mtr) /*!< in: mtr */ +/** Creates the file page for the transaction system. This function is called + only at the database creation, before trx_sys_init. */ +static void trx_sysf_create(mtr_t *mtr) /*!< in: mtr */ { trx_sysf_t *sys_header; ulint slot_no; @@ -302,13 +290,10 @@ static void trx_sysf_create( ut_a(page_no == FSP_FIRST_RSEG_PAGE_NO); } -/*****************************************************************/ /** - Creates and initializes the central memory structures for the transaction +/** Creates and initializes the central memory structures for the transaction system. This is called when the database is started. @return min binary heap of rsegs to purge */ -purge_pq_t *trx_sys_init_at_db_start(void) -/*==========================*/ -{ +purge_pq_t *trx_sys_init_at_db_start(void) { purge_pq_t *purge_queue; trx_sysf_t *sys_header; ib_uint64_t rows_to_undo = 0; @@ -390,11 +375,8 @@ purge_pq_t *trx_sys_init_at_db_start(void) return (purge_queue); } -/*****************************************************************/ /** - Creates the trx_sys instance and initializes purge_queue and mutex. */ -void trx_sys_create(void) -/*================*/ -{ +/** Creates the trx_sys instance and initializes purge_queue and mutex. */ +void trx_sys_create(void) { ut_ad(trx_sys == NULL); trx_sys = static_cast(ut_zalloc_nokey(sizeof(*trx_sys))); @@ -419,11 +401,8 @@ void trx_sys_create(void) new (&trx_sys->tmp_rsegs) Rsegs(); } -/*****************************************************************/ /** - Creates and initializes the transaction system at the database creation. */ -void trx_sys_create_sys_pages(void) -/*==========================*/ -{ +/** Creates and initializes the transaction system at the database creation. */ +void trx_sys_create_sys_pages(void) { mtr_t mtr; mtr_start(&mtr); @@ -434,11 +413,9 @@ void trx_sys_create_sys_pages(void) } #else /* !UNIV_HOTBACKUP */ -/*****************************************************************/ /** - Prints to stderr the MySQL binlog info in the system header if the +/** Prints to stderr the MySQL binlog info in the system header if the magic number shows it valid. */ void trx_sys_print_mysql_binlog_offset_from_page( - /*========================================*/ const byte *page) /*!< in: buffer containing the trx system header page, i.e., page number TRX_SYS_PAGE_NO in the tablespace */ @@ -465,9 +442,7 @@ void trx_sys_print_mysql_binlog_offset_from_page( #ifndef UNIV_HOTBACKUP /********************************************************************* Shutdown/Close the transaction system. */ -void trx_sys_close(void) -/*===============*/ -{ +void trx_sys_close(void) { ut_ad(srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS); if (trx_sys == NULL) { @@ -548,9 +523,7 @@ static void trx_undo_fake_prepared(const trx_t *trx, trx_undo_t *undo) { /********************************************************************* Check if there are any active (non-prepared) transactions. @return total number of active transactions or 0 if none */ -ulint trx_sys_any_active_transactions(void) -/*=================================*/ -{ +ulint trx_sys_any_active_transactions(void) { trx_sys_mutex_enter(); ulint total_trx = UT_LIST_GET_LEN(trx_sys->mysql_trx_list); @@ -590,11 +563,9 @@ ulint trx_sys_any_active_transactions(void) } #ifdef UNIV_DEBUG -/*************************************************************/ /** - Validate the trx_ut_list_t. +/** Validate the trx_ut_list_t. @return true if valid. */ static bool trx_sys_validate_trx_list_low( - /*===========================*/ trx_ut_list_t *trx_list) /*!< in: &trx_sys->rw_trx_list */ { const trx_t *trx; @@ -613,12 +584,9 @@ static bool trx_sys_validate_trx_list_low( return (true); } -/*************************************************************/ /** - Validate the trx_sys_t::rw_trx_list. +/** Validate the trx_sys_t::rw_trx_list. @return true if the list is valid. */ -bool trx_sys_validate_trx_list() -/*=======================*/ -{ +bool trx_sys_validate_trx_list() { ut_ad(trx_sys_mutex_own()); ut_a(trx_sys_validate_trx_list_low(&trx_sys->rw_trx_list)); diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 6065110023de..32a6ed42f629 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file trx/trx0trx.cc +/** @file trx/trx0trx.cc The transaction Created 3/26/1996 Heikki Tuuri @@ -95,33 +94,25 @@ void trx_set_flush_observer(trx_t *trx, FlushObserver *observer) { trx->flush_observer = observer; } -/*************************************************************/ /** - Set detailed error message for the transaction. */ -void trx_set_detailed_error( - /*===================*/ - trx_t *trx, /*!< in: transaction struct */ - const char *msg) /*!< in: detailed error message */ +/** Set detailed error message for the transaction. */ +void trx_set_detailed_error(trx_t *trx, /*!< in: transaction struct */ + const char *msg) /*!< in: detailed error message */ { ut_strlcpy(trx->detailed_error, msg, MAX_DETAILED_ERROR_LEN); } -/*************************************************************/ /** - Set detailed error message for the transaction from a file. Note that the +/** Set detailed error message for the transaction from a file. Note that the file is rewinded before reading from it. */ void trx_set_detailed_error_from_file( - /*=============================*/ trx_t *trx, /*!< in: transaction struct */ FILE *file) /*!< in: file to read message from */ { os_file_read_string(file, trx->detailed_error, MAX_DETAILED_ERROR_LEN); } -/********************************************************************/ /** - Initialize transaction object. +/** Initialize transaction object. @param trx trx to initialize */ -static void trx_init( - /*=====*/ - trx_t *trx) { +static void trx_init(trx_t *trx) { /* This is called at the end of commit, do not reset the trx_t::state here to NOT_STARTED. The FORCED_ROLLBACK status is required for asynchronous handling. */ @@ -490,12 +481,9 @@ static void trx_free(trx_t *&trx) { trx = NULL; } -/********************************************************************/ /** - Creates a transaction object for background operations by the master thread. +/** Creates a transaction object for background operations by the master thread. @return own: transaction object */ -trx_t *trx_allocate_for_background(void) -/*=============================*/ -{ +trx_t *trx_allocate_for_background(void) { trx_t *trx; trx = trx_create_low(); @@ -505,12 +493,9 @@ trx_t *trx_allocate_for_background(void) return (trx); } -/********************************************************************/ /** - Creates a transaction object for MySQL. +/** Creates a transaction object for MySQL. @return own: transaction object */ -trx_t *trx_allocate_for_mysql(void) -/*========================*/ -{ +trx_t *trx_allocate_for_mysql(void) { trx_t *trx; trx = trx_allocate_for_background(); @@ -575,11 +560,8 @@ void trx_free_for_background(trx_t *trx) { trx_free(trx); } -/********************************************************************/ /** - At shutdown, frees a transaction object that is in the PREPARED state. */ -void trx_free_prepared( - /*==============*/ - trx_t *trx) /*!< in, own: trx object */ +/** At shutdown, frees a transaction object that is in the PREPARED state. */ +void trx_free_prepared(trx_t *trx) /*!< in, own: trx object */ { ut_a(trx_state_eq(trx, TRX_STATE_PREPARED)); ut_a(trx->magic_n == TRX_MAGIC_N); @@ -754,12 +736,10 @@ void trx_resurrect_locks() { resurrected_trx_tables.clear(); } -/****************************************************************/ /** - Resurrect the transactions that were doing inserts at the time of the +/** Resurrect the transactions that were doing inserts at the time of the crash, they need to be undone. @return trx_t instance */ static trx_t *trx_resurrect_insert( - /*=================*/ trx_undo_t *undo, /*!< in: entry to UNDO */ trx_rseg_t *rseg) /*!< in: rollback segment */ { @@ -838,11 +818,9 @@ static trx_t *trx_resurrect_insert( return (trx); } -/****************************************************************/ /** - Prepared transactions are left in the prepared state waiting for a +/** Prepared transactions are left in the prepared state waiting for a commit or abort decision from MySQL */ static void trx_resurrect_update_in_prepared_state( - /*===================================*/ trx_t *trx, /*!< in,out: transaction */ const trx_undo_t *undo) /*!< in: update UNDO record */ { @@ -867,11 +845,9 @@ static void trx_resurrect_update_in_prepared_state( } } -/****************************************************************/ /** - Resurrect the transactions that were doing updates the time of the +/** Resurrect the transactions that were doing updates the time of the crash, they need to be undone. */ static void trx_resurrect_update( - /*=================*/ trx_t *trx, /*!< in/out: transaction */ trx_undo_t *undo, /*!< in/out: update UNDO record */ trx_rseg_t *rseg) /*!< in/out: rollback segment */ @@ -958,15 +934,12 @@ static void trx_resurrect(trx_rseg_t *rseg) { } } -/****************************************************************/ /** - Creates trx objects for transactions and initializes the trx list of +/** Creates trx objects for transactions and initializes the trx list of trx_sys at database start. Rollback segments and undo log lists must already exist when this function is called, because the lists of transactions to be rolled back or cleaned up are built based on the undo log lists. */ -void trx_lists_init_at_db_start(void) -/*============================*/ -{ +void trx_lists_init_at_db_start(void) { ut_a(srv_is_being_started); /* Look through the rollback segments in the TRX_SYS for @@ -1191,10 +1164,8 @@ void trx_assign_rseg_temp(trx_t *trx) { } } -/****************************************************************/ /** - Starts a transaction. */ +/** Starts a transaction. */ static void trx_start_low( - /*==========*/ trx_t *trx, /*!< in: transaction */ bool read_write) /*!< in: true if read-write transaction */ { @@ -1347,11 +1318,9 @@ static void trx_start_low( MONITOR_INC(MONITOR_TRX_ACTIVE); } -/****************************************************************/ /** - Set the transaction serialisation number. +/** Set the transaction serialisation number. @return true if the transaction number was added to the serialisation_list. */ static bool trx_serialisation_number_get( - /*=========================*/ trx_t *trx, /*!< in/out: transaction */ trx_undo_ptr_t *redo_rseg_undo_ptr, /*!< in/out: Set trx serialisation number in @@ -1421,12 +1390,10 @@ static bool trx_serialisation_number_get( return (added_trx_no); } -/****************************************************************/ /** - Assign the transaction its history serialisation number and write the +/** Assign the transaction its history serialisation number and write the update UNDO log record to the assigned rollback segment. @return true if a serialisation log was written */ static bool trx_write_serialisation_history( - /*============================*/ trx_t *trx, /*!< in/out: transaction */ mtr_t *mtr) /*!< in/out: mini-transaction */ { @@ -1553,7 +1520,6 @@ static bool trx_write_serialisation_history( /******************************************************************** Finalize a transaction containing updates for a FTS table. */ static void trx_finalize_for_fts_table( - /*=======================*/ fts_trx_table_t *ftt) /* in: FTS trx table */ { fts_t *fts = ftt->table->fts; @@ -1581,10 +1547,8 @@ static void trx_finalize_for_fts_table( } } -/******************************************************************/ /** - Finalize a transaction containing updates to FTS tables. */ +/** Finalize a transaction containing updates to FTS tables. */ static void trx_finalize_for_fts( - /*=================*/ trx_t *trx, /*!< in/out: transaction */ bool is_commit) /*!< in: true if the transaction was committed, false if it was rolled back. */ @@ -1614,11 +1578,9 @@ static void trx_finalize_for_fts( trx->fts_trx = NULL; } -/**********************************************************************/ /** - If required, flushes the log to disk based on the value of +/** If required, flushes the log to disk based on the value of innodb_flush_log_at_trx_commit. */ static void trx_flush_log_if_needed_low( - /*========================*/ lsn_t lsn) /*!< in: lsn up to which logs are to be flushed. */ { @@ -1645,11 +1607,9 @@ static void trx_flush_log_if_needed_low( ut_error; } -/**********************************************************************/ /** - If required, flushes the log to disk based on the value of +/** If required, flushes the log to disk based on the value of innodb_flush_log_at_trx_commit. */ static void trx_flush_log_if_needed( - /*====================*/ lsn_t lsn, /*!< in: lsn up to which logs are to be flushed. */ trx_t *trx) /*!< in/out: transaction */ @@ -1665,13 +1625,10 @@ static void trx_flush_log_if_needed( trx->op_info = ""; } -/**********************************************************************/ /** - For each table that has been modified by the given transaction: update +/** For each table that has been modified by the given transaction: update its dict_table_t::update_time with the current timestamp. Clear the list of the modified tables at the end. */ -static void trx_update_mod_tables_timestamp( - /*============================*/ - trx_t *trx) /*!< in: transaction */ +static void trx_update_mod_tables_timestamp(trx_t *trx) /*!< in: transaction */ { ut_ad(trx->id != 0); @@ -1740,10 +1697,8 @@ static void trx_erase_lists(trx_t *trx, bool serialised) { trx_sys_mutex_exit(); } -/****************************************************************/ /** - Commits a transaction in memory. */ +/** Commits a transaction in memory. */ static void trx_commit_in_memory( - /*=================*/ trx_t *trx, /*!< in/out: transaction */ const mtr_t *mtr, /*!< in: mini-transaction of trx_write_serialisation_history(), or NULL if @@ -1930,10 +1885,8 @@ written */ ut_a(trx->error_state == DB_SUCCESS); } -/****************************************************************/ /** - Commits a transaction and a mini-transaction. */ +/** Commits a transaction and a mini-transaction. */ void trx_commit_low( - /*===========*/ trx_t *trx, /*!< in/out: transaction */ mtr_t *mtr) /*!< in/out: mini-transaction (will be committed), or NULL if trx made no modifications */ @@ -2018,11 +1971,8 @@ void trx_commit_low( trx_commit_in_memory(trx, mtr, serialised); } -/****************************************************************/ /** - Commits a transaction. */ -void trx_commit( - /*=======*/ - trx_t *trx) /*!< in/out: transaction */ +/** Commits a transaction. */ +void trx_commit(trx_t *trx) /*!< in/out: transaction */ { mtr_t *mtr; mtr_t local_mtr; @@ -2043,13 +1993,10 @@ void trx_commit( trx_commit_low(trx, mtr); } -/****************************************************************/ /** - Cleans up a transaction at database startup. The cleanup is needed if +/** Cleans up a transaction at database startup. The cleanup is needed if the transaction already got to the middle of a commit when the database crashed, and we cannot roll it back. */ -void trx_cleanup_at_db_startup( - /*======================*/ - trx_t *trx) /*!< in: transaction */ +void trx_cleanup_at_db_startup(trx_t *trx) /*!< in: transaction */ { ut_ad(trx->is_recovered); @@ -2085,14 +2032,11 @@ void trx_cleanup_at_db_startup( trx->state = TRX_STATE_NOT_STARTED; } -/********************************************************************/ /** - Assigns a read view for a consistent read query. All the consistent reads +/** Assigns a read view for a consistent read query. All the consistent reads within the same transaction will get the same read view, which is created when this function is first called for a new started transaction. @return consistent read view */ -ReadView *trx_assign_read_view( - /*=================*/ - trx_t *trx) /*!< in/out: active transaction */ +ReadView *trx_assign_read_view(trx_t *trx) /*!< in/out: active transaction */ { ut_ad(trx->state == TRX_STATE_ACTIVE); @@ -2107,11 +2051,8 @@ ReadView *trx_assign_read_view( return (trx->read_view); } -/****************************************************************/ /** - Prepares a transaction for commit/rollback. */ -void trx_commit_or_rollback_prepare( - /*===========================*/ - trx_t *trx) /*!< in/out: transaction */ +/** Prepares a transaction for commit/rollback. */ +void trx_commit_or_rollback_prepare(trx_t *trx) /*!< in/out: transaction */ { /* We are reading trx->state without holding trx_sys->mutex here, because the commit or rollback should be invoked for a @@ -2149,11 +2090,9 @@ void trx_commit_or_rollback_prepare( ut_error; } -/*********************************************************************/ /** - Creates a commit command node struct. +/** Creates a commit command node struct. @return own: commit node struct */ commit_node_t *trx_commit_node_create( - /*===================*/ mem_heap_t *heap) /*!< in: mem heap where created */ { commit_node_t *node; @@ -2165,12 +2104,9 @@ commit_node_t *trx_commit_node_create( return (node); } -/***********************************************************/ /** - Performs an execution step for a commit type node in a query graph. +/** Performs an execution step for a commit type node in a query graph. @return query thread to run next, or NULL */ -que_thr_t *trx_commit_step( - /*============*/ - que_thr_t *thr) /*!< in: query thread */ +que_thr_t *trx_commit_step(que_thr_t *thr) /*!< in: query thread */ { commit_node_t *node; @@ -2214,12 +2150,9 @@ que_thr_t *trx_commit_step( return (thr); } -/**********************************************************************/ /** - Does the transaction commit for MySQL. +/** Does the transaction commit for MySQL. @return DB_SUCCESS or error number */ -dberr_t trx_commit_for_mysql( - /*=================*/ - trx_t *trx) /*!< in/out: transaction */ +dberr_t trx_commit_for_mysql(trx_t *trx) /*!< in/out: transaction */ { TrxInInnoDB trx_in_innodb(trx, true); @@ -2261,12 +2194,9 @@ dberr_t trx_commit_for_mysql( return (DB_CORRUPTION); } -/**********************************************************************/ /** - If required, flushes the log to disk if we called trx_commit_for_mysql() +/** If required, flushes the log to disk if we called trx_commit_for_mysql() with trx->flush_log_later == TRUE. */ -void trx_commit_complete_for_mysql( - /*==========================*/ - trx_t *trx) /*!< in/out: transaction */ +void trx_commit_complete_for_mysql(trx_t *trx) /*!< in/out: transaction */ { if (trx->id != 0 || !trx->must_flush_log_later || thd_requested_durability(trx->mysql_thd) == HA_IGNORE_DURABILITY) { @@ -2279,11 +2209,8 @@ void trx_commit_complete_for_mysql( trx->ddl_must_flush = false; } -/**********************************************************************/ /** - Marks the latest SQL statement ended. */ -void trx_mark_sql_stat_end( - /*==================*/ - trx_t *trx) /*!< in: trx handle */ +/** Marks the latest SQL statement ended. */ +void trx_mark_sql_stat_end(trx_t *trx) /*!< in: trx handle */ { ut_a(trx); @@ -2309,23 +2236,20 @@ void trx_mark_sql_stat_end( ut_error; } -/**********************************************************************/ /** - Prints info about a transaction. +/** Prints info about a transaction. Caller must hold trx_sys->mutex. */ -void trx_print_low( - /*==========*/ - FILE *f, - /*!< in: output stream */ - const trx_t *trx, - /*!< in: transaction */ - ulint max_query_len, - /*!< in: max query length to print, - or 0 to use the default max length */ - ulint n_rec_locks, - /*!< in: lock_number_of_rows_locked(&trx->lock) */ - ulint n_trx_locks, - /*!< in: length of trx->lock.trx_locks */ - ulint heap_size) +void trx_print_low(FILE *f, + /*!< in: output stream */ + const trx_t *trx, + /*!< in: transaction */ + ulint max_query_len, + /*!< in: max query length to print, + or 0 to use the default max length */ + ulint n_rec_locks, + /*!< in: lock_number_of_rows_locked(&trx->lock) */ + ulint n_trx_locks, + /*!< in: length of trx->lock.trx_locks */ + ulint heap_size) /*!< in: mem_heap_get_size(trx->lock.lock_heap) */ { ibool newline; @@ -2438,12 +2362,10 @@ void trx_print_low( } } -/**********************************************************************/ /** - Prints info about a transaction. +/** Prints info about a transaction. The caller must hold lock_sys->mutex and trx_sys->mutex. When possible, use trx_print() instead. */ void trx_print_latched( - /*==============*/ FILE *f, /*!< in: output stream */ const trx_t *trx, /*!< in: transaction */ ulint max_query_len) /*!< in: max query length to print, @@ -2457,15 +2379,12 @@ void trx_print_latched( mem_heap_get_size(trx->lock.lock_heap)); } -/**********************************************************************/ /** - Prints info about a transaction. +/** Prints info about a transaction. Acquires and releases lock_sys->mutex and trx_sys->mutex. */ -void trx_print( - /*======*/ - FILE *f, /*!< in: output stream */ - const trx_t *trx, /*!< in: transaction */ - ulint max_query_len) /*!< in: max query length to print, - or 0 to use the default max length */ +void trx_print(FILE *f, /*!< in: output stream */ + const trx_t *trx, /*!< in: transaction */ + ulint max_query_len) /*!< in: max query length to print, + or 0 to use the default max length */ { ulint n_rec_locks; ulint n_trx_locks; @@ -2485,13 +2404,10 @@ void trx_print( } #ifdef UNIV_DEBUG -/**********************************************************************/ /** - Asserts that a transaction has been started. +/** Asserts that a transaction has been started. The caller must hold trx_sys->mutex. @return true if started */ -ibool trx_assert_started( - /*===============*/ - const trx_t *trx) /*!< in: transaction */ +ibool trx_assert_started(const trx_t *trx) /*!< in: transaction */ { ut_ad(trx_sys_mutex_own()); @@ -2522,15 +2438,12 @@ ibool trx_assert_started( } #endif /* UNIV_DEBUG */ -/*******************************************************************/ /** - Compares the "weight" (or size) of two transactions. Transactions that +/** Compares the "weight" (or size) of two transactions. Transactions that have edited non-transactional tables are considered heavier than ones that have not. @return true if weight(a) >= weight(b) */ -bool trx_weight_ge( - /*==========*/ - const trx_t *a, /*!< in: transaction to be compared */ - const trx_t *b) /*!< in: transaction to be compared */ +bool trx_weight_ge(const trx_t *a, /*!< in: transaction to be compared */ + const trx_t *b) /*!< in: transaction to be compared */ { ibool a_notrans_edit; ibool b_notrans_edit; @@ -2555,11 +2468,9 @@ bool trx_weight_ge( return (TRX_WEIGHT(a) >= TRX_WEIGHT(b)); } -/****************************************************************/ /** - Prepares a transaction for given rollback segment. +/** Prepares a transaction for given rollback segment. @return lsn_t: lsn assigned for commit of scheduled rollback segment */ static lsn_t trx_prepare_low( - /*============*/ trx_t *trx, /*!< in/out: transaction */ trx_undo_ptr_t *undo_ptr, /*!< in/out: pointer to rollback segment scheduled for prepare. */ @@ -2612,11 +2523,8 @@ static lsn_t trx_prepare_low( return (lsn); } -/****************************************************************/ /** - Prepares a transaction. */ -static void trx_prepare( - /*========*/ - trx_t *trx) /*!< in/out: transaction */ +/** Prepares a transaction. */ +static void trx_prepare(trx_t *trx) /*!< in/out: transaction */ { /* This transaction has crossed the point of no return and cannot be rolled back asynchronously now. It must commit or rollback @@ -2717,14 +2625,11 @@ dberr_t trx_prepare_for_mysql(trx_t *trx) { return (DB_SUCCESS); } -/**********************************************************************/ /** - This function is used to find number of prepared transactions and +/** This function is used to find number of prepared transactions and their transaction objects for a recovery. @return number of prepared transactions stored in xid_list */ -int trx_recover_for_mysql( - /*==================*/ - XID *xid_list, /*!< in/out: prepared transactions */ - ulint len) /*!< in: number of slots in xid_list */ +int trx_recover_for_mysql(XID *xid_list, /*!< in/out: prepared transactions */ + ulint len) /*!< in: number of slots in xid_list */ { const trx_t *trx; ulint count = 0; @@ -2778,14 +2683,12 @@ int trx_recover_for_mysql( return (int(count)); } -/*******************************************************************/ /** - This function is used to find one X/Open XA distributed transaction +/** This function is used to find one X/Open XA distributed transaction which is in the prepared state @return trx on match, the trx->xid will be invalidated; note that the trx may have been committed, unless the caller is holding lock_sys->mutex */ static MY_ATTRIBUTE((warn_unused_result)) trx_t *trx_get_trx_by_xid_low( - /*===================*/ const XID *xid) /*!< in: X/Open XA transaction identifier */ { @@ -2814,14 +2717,12 @@ static MY_ATTRIBUTE((warn_unused_result)) trx_t *trx_get_trx_by_xid_low( return (trx); } -/*******************************************************************/ /** - This function is used to find one X/Open XA distributed transaction +/** This function is used to find one X/Open XA distributed transaction which is in the prepared state @return trx or NULL; on match, the trx->xid will be invalidated; note that the trx may have been committed, unless the caller is holding lock_sys->mutex */ trx_t *trx_get_trx_by_xid( - /*===============*/ const XID *xid) /*!< in: X/Open XA transaction identifier */ { trx_t *trx; @@ -2841,10 +2742,8 @@ trx_t *trx_get_trx_by_xid( return (trx); } -/*************************************************************/ /** - Starts the transaction if it is not yet started. */ +/** Starts the transaction if it is not yet started. */ void trx_start_if_not_started_xa_low( - /*============================*/ trx_t *trx, /*!< in/out: transaction */ bool read_write) /*!< in: true if read write transaction */ { @@ -2875,10 +2774,8 @@ void trx_start_if_not_started_xa_low( ut_error; } -/*************************************************************/ /** - Starts the transaction if it is not yet started. */ +/** Starts the transaction if it is not yet started. */ void trx_start_if_not_started_low( - /*==========================*/ trx_t *trx, /*!< in: transaction */ bool read_write) /*!< in: true if read write transaction */ { @@ -2904,11 +2801,8 @@ void trx_start_if_not_started_low( ut_error; } -/*************************************************************/ /** - Starts a transaction for internal processing. */ -void trx_start_internal_low( - /*===================*/ - trx_t *trx) /*!< in/out: transaction */ +/** Starts a transaction for internal processing. */ +void trx_start_internal_low(trx_t *trx) /*!< in/out: transaction */ { /* Ensure it is not flagged as an auto-commit-non-locking transaction. */ @@ -2933,16 +2827,13 @@ void trx_start_internal_read_only_low(trx_t *trx) { trx_start_low(trx, false); } -/*************************************************************/ /** - Set the transaction as a read-write transaction if it is not already +/** Set the transaction as a read-write transaction if it is not already tagged as such. Read-only transactions that are writing to temporary tables are assigned an ID and a rollback segment but are not added to the trx read-write list because their updates should not be visible to other transactions and therefore their changes can be ignored by by MVCC. */ -void trx_set_rw_mode( - /*============*/ - trx_t *trx) /*!< in/out: transaction that is RW */ +void trx_set_rw_mode(trx_t *trx) /*!< in/out: transaction that is RW */ { ut_ad(trx->rsegs.m_redo.rseg == 0); ut_ad(!trx->in_rw_trx_list); diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc index f7574cb98a8e..719dcd7d56d1 100644 --- a/storage/innobase/trx/trx0undo.cc +++ b/storage/innobase/trx/trx0undo.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file trx/trx0undo.cc +/** @file trx/trx0undo.cc Transaction undo log Created 3/26/1996 Heikki Tuuri @@ -108,20 +107,16 @@ s-latches on the undo log pages are enough, but in a truncate, x-latches must be obtained on the rollback segment and individual pages. */ #endif /* !UNIV_HOTBACKUP */ -/********************************************************************/ /** - Initializes the fields in an undo log segment page. */ +/** Initializes the fields in an undo log segment page. */ static void trx_undo_page_init( - /*===============*/ page_t *undo_page, /*!< in: undo log segment page */ ulint type, /*!< in: undo log segment type */ mtr_t *mtr); /*!< in: mtr */ #ifndef UNIV_HOTBACKUP -/********************************************************************/ /** - Creates and initializes an undo log memory object. +/** Creates and initializes an undo log memory object. @return own: the undo log memory object */ static trx_undo_t *trx_undo_mem_create( - /*================*/ trx_rseg_t *rseg, /*!< in: rollback segment memory object */ ulint id, /*!< in: slot index within rseg */ ulint type, /*!< in: type of the log: TRX_UNDO_INSERT or @@ -132,24 +127,20 @@ static trx_undo_t *trx_undo_mem_create( page_no_t page_no, /*!< in: undo log header page number */ ulint offset); /*!< in: undo log header byte offset on page */ #endif /* !UNIV_HOTBACKUP */ -/***************************************************************/ /** - Initializes a cached insert undo log header page for new use. NOTE that this +/** Initializes a cached insert undo log header page for new use. NOTE that this function has its own log record type MLOG_UNDO_HDR_REUSE. You must NOT change the operation of this function! @return undo log header byte offset on page */ static ulint trx_undo_insert_header_reuse( - /*=========================*/ page_t *undo_page, /*!< in/out: insert undo log segment header page, x-latched */ trx_id_t trx_id, /*!< in: transaction id */ mtr_t *mtr); /*!< in: mtr */ #ifndef UNIV_HOTBACKUP -/***********************************************************************/ /** - Gets the previous record in an undo log from the previous page. +/** Gets the previous record in an undo log from the previous page. @return undo log record, the page s-latched, NULL if none */ static trx_undo_rec_t *trx_undo_get_prev_rec_from_prev_page( - /*=================================*/ trx_undo_rec_t *rec, /*!< in: undo record */ page_no_t page_no, /*!< in: undo log header page number */ ulint offset, /*!< in: undo log header offset on page */ @@ -188,11 +179,9 @@ static trx_undo_rec_t *trx_undo_get_prev_rec_from_prev_page( return (trx_undo_page_get_last_rec(prev_page, page_no, offset)); } -/***********************************************************************/ /** - Gets the previous record in an undo log. +/** Gets the previous record in an undo log. @return undo log record, the page s-latched, NULL if none */ trx_undo_rec_t *trx_undo_get_prev_rec( - /*==================*/ trx_undo_rec_t *rec, /*!< in: undo record */ page_no_t page_no, /*!< in: undo log header page number */ ulint offset, /*!< in: undo log header offset on page */ @@ -259,11 +248,9 @@ static trx_undo_rec_t *trx_undo_get_next_rec_from_next_page( return (trx_undo_page_get_first_rec(next_page, page_no, offset)); } -/***********************************************************************/ /** - Gets the next record in an undo log. +/** Gets the next record in an undo log. @return undo log record, the page s-latched, NULL if none */ trx_undo_rec_t *trx_undo_get_next_rec( - /*==================*/ trx_undo_rec_t *rec, /*!< in: undo record */ page_no_t page_no, /*!< in: undo log header page number */ ulint offset, /*!< in: undo log header offset on page */ @@ -331,14 +318,11 @@ trx_undo_rec_t *trx_undo_get_first_rec(trx_id_t *modifier_trx_id, /*============== UNDO LOG FILE COPY CREATION AND FREEING ==================*/ -/**********************************************************************/ /** - Writes the mtr log entry of an undo log page initialization. */ +/** Writes the mtr log entry of an undo log page initialization. */ UNIV_INLINE -void trx_undo_page_init_log( - /*===================*/ - page_t *undo_page, /*!< in: undo log page */ - ulint type, /*!< in: undo log type */ - mtr_t *mtr) /*!< in: mtr */ +void trx_undo_page_init_log(page_t *undo_page, /*!< in: undo log page */ + ulint type, /*!< in: undo log type */ + mtr_t *mtr) /*!< in: mtr */ { mlog_write_initial_log_record(undo_page, MLOG_UNDO_INIT, mtr); @@ -348,15 +332,12 @@ void trx_undo_page_init_log( #define trx_undo_page_init_log(undo_page, type, mtr) ((void)0) #endif /* !UNIV_HOTBACKUP */ -/***********************************************************/ /** - Parses the redo log entry of an undo log page initialization. +/** Parses the redo log entry of an undo log page initialization. @return end of log record or NULL */ -byte *trx_undo_parse_page_init( - /*=====================*/ - const byte *ptr, /*!< in: buffer */ - const byte *end_ptr, /*!< in: buffer end */ - page_t *page, /*!< in: page or NULL */ - mtr_t *mtr) /*!< in: mtr or NULL */ +byte *trx_undo_parse_page_init(const byte *ptr, /*!< in: buffer */ + const byte *end_ptr, /*!< in: buffer end */ + page_t *page, /*!< in: page or NULL */ + mtr_t *mtr) /*!< in: mtr or NULL */ { ulint type; @@ -373,10 +354,8 @@ byte *trx_undo_parse_page_init( return (const_cast(ptr)); } -/********************************************************************/ /** - Initializes the fields in an undo log segment page. */ +/** Initializes the fields in an undo log segment page. */ static void trx_undo_page_init( - /*===============*/ page_t *undo_page, /*!< in: undo log segment page */ ulint type, /*!< in: undo log segment type */ mtr_t *mtr) /*!< in: mtr */ @@ -398,12 +377,10 @@ static void trx_undo_page_init( } #ifndef UNIV_HOTBACKUP -/***************************************************************/ /** - Creates a new undo log segment in file. +/** Creates a new undo log segment in file. @return DB_SUCCESS if page creation OK possible error codes are: DB_TOO_MANY_CONCURRENT_TRXS DB_OUT_OF_FILE_SPACE */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t trx_undo_seg_create( - /*================*/ trx_rseg_t *rseg MY_ATTRIBUTE((unused)), /*!< in: rollback segment */ trx_rsegf_t *rseg_hdr, /*!< in: rollback segment header, page x-latched */ @@ -488,11 +465,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t trx_undo_seg_create( return (err); } -/**********************************************************************/ /** - Writes the mtr log entry of an undo log header initialization. */ +/** Writes the mtr log entry of an undo log header initialization. */ UNIV_INLINE void trx_undo_header_create_log( - /*=======================*/ const page_t *undo_page, /*!< in: undo log header page */ trx_id_t trx_id, /*!< in: transaction id */ mtr_t *mtr) /*!< in: mtr */ @@ -505,13 +480,11 @@ void trx_undo_header_create_log( #define trx_undo_header_create_log(undo_page, trx_id, mtr) ((void)0) #endif /* !UNIV_HOTBACKUP */ -/***************************************************************/ /** - Creates a new undo log header in file. NOTE that this function has its own +/** Creates a new undo log header in file. NOTE that this function has its own log record type MLOG_UNDO_HDR_CREATE. You must NOT change the operation of this function! @return header byte offset on page */ static ulint trx_undo_header_create( - /*===================*/ page_t *undo_page, /*!< in/out: undo log segment header page, x-latched; it is assumed that there is @@ -578,10 +551,8 @@ static ulint trx_undo_header_create( } #ifndef UNIV_HOTBACKUP -/********************************************************************/ /** - Write X/Open XA Transaction Identification (XID) to undo log header */ +/** Write X/Open XA Transaction Identification (XID) to undo log header */ static void trx_undo_write_xid( - /*===============*/ trx_ulogf_t *log_hdr, /*!< in: undo log header */ const XID *xid, /*!< in: X/Open XA Transaction Identification */ mtr_t *mtr) /*!< in: mtr */ @@ -602,10 +573,8 @@ static void trx_undo_write_xid( XIDDATASIZE, mtr); } -/********************************************************************/ /** - Read X/Open XA Transaction Identification (XID) from undo log header */ +/** Read X/Open XA Transaction Identification (XID) from undo log header */ static void trx_undo_read_xid( - /*==============*/ trx_ulogf_t *log_hdr, /*!< in: undo log header */ XID *xid) /*!< out: X/Open XA Transaction Identification */ { @@ -621,10 +590,8 @@ static void trx_undo_read_xid( xid->set_data(log_hdr + TRX_UNDO_XA_XID, XIDDATASIZE); } -/***************************************************************/ /** - Adds space for the XA XID after an undo log old-style header. */ +/** Adds space for the XA XID after an undo log old-style header. */ static void trx_undo_header_add_space_for_xid( - /*==============================*/ page_t *undo_page, /*!< in: undo log segment header page */ trx_ulogf_t *log_hdr, /*!< in: undo log header */ mtr_t *mtr) /*!< in: mtr */ @@ -653,11 +620,9 @@ static void trx_undo_header_add_space_for_xid( mlog_write_ulint(log_hdr + TRX_UNDO_LOG_START, new_free, MLOG_2BYTES, mtr); } -/**********************************************************************/ /** - Writes the mtr log entry of an undo log header reuse. */ +/** Writes the mtr log entry of an undo log header reuse. */ UNIV_INLINE void trx_undo_insert_header_reuse_log( - /*=============================*/ const page_t *undo_page, /*!< in: undo log header page */ trx_id_t trx_id, /*!< in: transaction id */ mtr_t *mtr) /*!< in: mtr */ @@ -699,13 +664,11 @@ byte *trx_undo_parse_page_header(mlog_id_t type, const byte *ptr, return (const_cast(ptr)); } -/***************************************************************/ /** - Initializes a cached insert undo log header page for new use. NOTE that this +/** Initializes a cached insert undo log header page for new use. NOTE that this function has its own log record type MLOG_UNDO_HDR_REUSE. You must NOT change the operation of this function! @return undo log header byte offset on page */ static ulint trx_undo_insert_header_reuse( - /*=========================*/ page_t *undo_page, /*!< in/out: insert undo log segment header page, x-latched */ trx_id_t trx_id, /*!< in: transaction id */ @@ -757,11 +720,9 @@ static ulint trx_undo_insert_header_reuse( } #ifndef UNIV_HOTBACKUP -/********************************************************************/ /** - Tries to add a page to the undo log segment where the undo log is placed. +/** Tries to add a page to the undo log segment where the undo log is placed. @return X-latched block if success, else NULL */ buf_block_t *trx_undo_add_page( - /*==============*/ trx_t *trx, /*!< in: transaction */ trx_undo_t *undo, /*!< in: undo log memory object */ trx_undo_ptr_t *undo_ptr, /*!< in: assign undo log from @@ -821,11 +782,9 @@ buf_block_t *trx_undo_add_page( return (new_block); } -/********************************************************************/ /** - Frees an undo log page that is not the header page. +/** Frees an undo log page that is not the header page. @return last page number in remaining log */ static page_no_t trx_undo_free_page( - /*===============*/ trx_rseg_t *rseg, /*!< in: rollback segment */ ibool in_history, /*!< in: TRUE if the undo log is in the history list */ @@ -875,11 +834,9 @@ static page_no_t trx_undo_free_page( return (last_addr.page); } -/********************************************************************/ /** - Frees the last undo log page. +/** Frees the last undo log page. The caller must hold the rollback segment mutex. */ void trx_undo_free_last_page_func( -/*==========================*/ #ifdef UNIV_DEBUG const trx_t *trx, /*!< in: transaction */ #endif /* UNIV_DEBUG */ @@ -925,11 +882,9 @@ static void trx_undo_empty_header_page(space_id_t space, mlog_write_ulint(log_hdr + TRX_UNDO_LOG_START, end, MLOG_2BYTES, mtr); } -/***********************************************************************/ /** - Truncates an undo log from the end. This function is used during a rollback +/** Truncates an undo log from the end. This function is used during a rollback to free space from an undo log. */ void trx_undo_truncate_end_func( -/*=======================*/ #ifdef UNIV_DEBUG const trx_t *trx, /*!< in: transaction whose undo log it is */ #endif /* UNIV_DEBUG */ @@ -1104,13 +1059,11 @@ static void trx_undo_seg_free(const trx_undo_t *undo, bool noredo) { /*========== UNDO LOG MEMORY COPY INITIALIZATION =====================*/ -/********************************************************************/ /** - Creates and initializes an undo log memory object according to the values +/** Creates and initializes an undo log memory object according to the values in the header in file, when the database is started. The memory object is inserted in the appropriate list of rseg. @return own: the undo log memory object */ static trx_undo_t *trx_undo_mem_create_at_db_start( - /*============================*/ trx_rseg_t *rseg, /*!< in: rollback segment memory object */ ulint id, /*!< in: slot index within rseg */ page_no_t page_no, /*!< in: undo log segment page number */ @@ -1216,13 +1169,11 @@ static trx_undo_t *trx_undo_mem_create_at_db_start( return (undo); } -/********************************************************************/ /** - Initializes the undo log lists for a rollback segment memory copy. This +/** Initializes the undo log lists for a rollback segment memory copy. This function is only called when the database is started or a new rollback segment is created. @return the combined size of undo log segments in pages */ ulint trx_undo_lists_init( - /*================*/ trx_rseg_t *rseg) /*!< in: rollback segment memory object */ { ulint size = 0; @@ -1270,11 +1221,9 @@ ulint trx_undo_lists_init( return (size); } -/********************************************************************/ /** - Creates and initializes an undo log memory object. +/** Creates and initializes an undo log memory object. @return own: the undo log memory object */ static trx_undo_t *trx_undo_mem_create( - /*================*/ trx_rseg_t *rseg, /*!< in: rollback segment memory object */ ulint id, /*!< in: slot index within rseg */ ulint type, /*!< in: type of the log: TRX_UNDO_INSERT or @@ -1323,10 +1272,8 @@ static trx_undo_t *trx_undo_mem_create( return (undo); } -/********************************************************************/ /** - Initializes a cached undo log object for new use. */ +/** Initializes a cached undo log object for new use. */ static void trx_undo_mem_init_for_reuse( - /*========================*/ trx_undo_t *undo, /*!< in: undo log to init */ trx_id_t trx_id, /*!< in: id of the trx for which the undo log is created */ @@ -1348,24 +1295,19 @@ static void trx_undo_mem_init_for_reuse( undo->empty = TRUE; } -/********************************************************************/ /** - Frees an undo log memory copy. */ -void trx_undo_mem_free( - /*==============*/ - trx_undo_t *undo) /*!< in: the undo object to be freed */ +/** Frees an undo log memory copy. */ +void trx_undo_mem_free(trx_undo_t *undo) /*!< in: the undo object to be freed */ { ut_a(undo->id < TRX_RSEG_N_SLOTS); ut_free(undo); } -/**********************************************************************/ /** - Creates a new undo log. +/** Creates a new undo log. @return DB_SUCCESS if successful in creating the new undo lob object, possible error codes are: DB_TOO_MANY_CONCURRENT_TRXS DB_OUT_OF_FILE_SPACE DB_OUT_OF_MEMORY */ static MY_ATTRIBUTE((warn_unused_result)) dberr_t trx_undo_create( - /*============*/ trx_t *trx, /*!< in: transaction */ trx_rseg_t *rseg, /*!< in: rollback segment memory copy */ ulint type, /*!< in: type of the log: TRX_UNDO_INSERT or @@ -1421,11 +1363,9 @@ static MY_ATTRIBUTE((warn_unused_result)) dberr_t trx_undo_create( /*================ UNDO LOG ASSIGNMENT AND CLEANUP =====================*/ -/********************************************************************/ /** - Reuses a cached undo log. +/** Reuses a cached undo log. @return the undo log memory object, NULL if none cached */ static trx_undo_t *trx_undo_reuse_cached( - /*==================*/ trx_t *trx, /*!< in: transaction */ trx_rseg_t *rseg, /*!< in: rollback segment memory object */ ulint type, /*!< in: type of the log: TRX_UNDO_INSERT or @@ -1487,11 +1427,9 @@ static trx_undo_t *trx_undo_reuse_cached( return (undo); } -/**********************************************************************/ /** - Marks an undo log header as a header of a data dictionary operation +/** Marks an undo log header as a header of a data dictionary operation transaction. */ static void trx_undo_mark_as_dict_operation( - /*============================*/ trx_t *trx, /*!< in: dict op transaction */ trx_undo_t *undo, /*!< in: assigned undo log */ mtr_t *mtr) /*!< in: mtr */ @@ -1507,14 +1445,12 @@ static void trx_undo_mark_as_dict_operation( undo->dict_operation = TRUE; } -/**********************************************************************/ /** - Assigns an undo log for a transaction. A new undo log is created or a cached +/** Assigns an undo log for a transaction. A new undo log is created or a cached undo log reused. @return DB_SUCCESS if undo log assign successful, possible error codes are: DB_TOO_MANY_CONCURRENT_TRXS DB_OUT_OF_FILE_SPACE DB_READ_ONLY DB_OUT_OF_MEMORY */ dberr_t trx_undo_assign_undo( - /*=================*/ trx_t *trx, /*!< in: transaction */ trx_undo_ptr_t *undo_ptr, /*!< in: assign undo log from referred rollback segment. */ @@ -1587,11 +1523,9 @@ dberr_t trx_undo_assign_undo( return (err); } -/******************************************************************/ /** - Sets the state of the undo log segment at a transaction finish. +/** Sets the state of the undo log segment at a transaction finish. @return undo log segment header page, x-latched */ page_t *trx_undo_set_state_at_finish( - /*=========================*/ trx_undo_t *undo, /*!< in: undo log memory copy */ mtr_t *mtr) /*!< in: mtr */ { @@ -1672,12 +1606,10 @@ page_t *trx_undo_set_state_at_prepare(trx_t *trx, trx_undo_t *undo, return (undo_page); } -/**********************************************************************/ /** - Adds the update undo log header as the first in the history list, and +/** Adds the update undo log header as the first in the history list, and frees the memory object, or puts it to the list of cached update undo log segments. */ void trx_undo_update_cleanup( - /*====================*/ trx_t *trx, /*!< in: trx owning the update undo log */ trx_undo_ptr_t *undo_ptr, /*!< in: update undo log. */ @@ -1761,11 +1693,8 @@ void trx_undo_insert_cleanup(trx_undo_ptr_t *undo_ptr, bool noredo) { mutex_exit(&(rseg->mutex)); } -/********************************************************************/ /** - At shutdown, frees the undo logs of a PREPARED transaction. */ -void trx_undo_free_prepared( - /*===================*/ - trx_t *trx) /*!< in/out: PREPARED transaction */ +/** At shutdown, frees the undo logs of a PREPARED transaction. */ +void trx_undo_free_prepared(trx_t *trx) /*!< in/out: PREPARED transaction */ { ut_ad(srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS); diff --git a/storage/innobase/usr/usr0sess.cc b/storage/innobase/usr/usr0sess.cc index d1bd9328a10e..b8c5e005e7d8 100644 --- a/storage/innobase/usr/usr0sess.cc +++ b/storage/innobase/usr/usr0sess.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file usr/usr0sess.cc +/** @file usr/usr0sess.cc Sessions Created 6/25/1996 Heikki Tuuri @@ -34,12 +33,9 @@ this program; if not, write to the Free Software Foundation, Inc., #include "usr0sess.h" #include "trx0trx.h" -/*********************************************************************/ /** - Opens a session. +/** Opens a session. @return own: session object */ -sess_t *sess_open(void) -/*===========*/ -{ +sess_t *sess_open(void) { sess_t *sess; sess = static_cast(ut_zalloc_nokey(sizeof(*sess))); @@ -52,11 +48,8 @@ sess_t *sess_open(void) return (sess); } -/*********************************************************************/ /** - Closes a session, freeing the memory occupied by it. */ -void sess_close( - /*=======*/ - sess_t *sess) /*!< in, own: session object */ +/** Closes a session, freeing the memory occupied by it. */ +void sess_close(sess_t *sess) /*!< in, own: session object */ { trx_free_for_background(sess->trx); ut_free(sess); diff --git a/storage/innobase/ut/crc32.cc b/storage/innobase/ut/crc32.cc index d366a4953c64..ed3c6f5bc4f8 100644 --- a/storage/innobase/ut/crc32.cc +++ b/storage/innobase/ut/crc32.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2009, 2010 Facebook, Inc. All Rights Reserved. -Copyright (c) 2011, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, @@ -25,8 +25,7 @@ Copyright (c) 2011, 2017, Oracle and/or its affiliates. All Rights Reserved. *****************************************************************************/ -/***************************************************************/ /** - @file ut/crc32.cc +/** @file ut/crc32.cc CRC32 implementation from Facebook, based on the zlib implementation. Created Aug 8, 2011, Vasil Dimov, based on mysys/my_crc32.c and @@ -442,12 +441,9 @@ have support for it */ static uint32_t ut_crc32_slice8_table[8][256]; static bool ut_crc32_slice8_table_initialized = false; -/********************************************************************/ /** - Initializes the table that is used to generate the CRC32 if the CPU does +/** Initializes the table that is used to generate the CRC32 if the CPU does not have support for it. */ -static void ut_crc32_slice8_table_init() -/*========================*/ -{ +static void ut_crc32_slice8_table_init() { /* bit-reversed poly 0x1EDC6F41 (from SSE42 crc32 instruction) */ static const uint32_t poly = 0x82f63b78; uint32_t n; @@ -657,12 +653,9 @@ static uint32_t ut_crc32_byte_by_byte_sw(const byte *buf, ulint len) { return (~crc); } -/********************************************************************/ /** - Initializes the data structures used by ut_crc32*(). Does not do any +/** Initializes the data structures used by ut_crc32*(). Does not do any allocations, would not hurt if called twice, but would be pointless. */ -void ut_crc32_init() -/*===========*/ -{ +void ut_crc32_init() { #if defined(gnuc64) || defined(_WIN32) ut_crc32_cpu_enabled = ut_crc32_check_cpu(); diff --git a/storage/innobase/ut/ut.cc b/storage/innobase/ut/ut.cc index b0bb64403022..379d42b5d589 100644 --- a/storage/innobase/ut/ut.cc +++ b/storage/innobase/ut/ut.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/***************************************************************/ /** - @file ut/ut.cc +/** @file ut/ut.cc Various utilities for Innobase. Created 5/11/1994 Heikki Tuuri @@ -42,13 +41,10 @@ external tools. */ #include "univ.i" #include "ut/ut.h" -/*************************************************************/ /** - Prints the contents of a memory buffer in hex and ascii. */ -void ut_print_buf( - /*=========*/ - FILE *file, /*!< in: file where to print */ - const void *buf, /*!< in: memory buffer */ - ulint len) /*!< in: length of the buffer */ +/** Prints the contents of a memory buffer in hex and ascii. */ +void ut_print_buf(FILE *file, /*!< in: file where to print */ + const void *buf, /*!< in: memory buffer */ + ulint len) /*!< in: length of the buffer */ { const byte *data; ulint i; @@ -73,13 +69,10 @@ void ut_print_buf( putc(';', file); } -/*************************************************************/ /** - Prints the contents of a memory buffer in hex. */ -void ut_print_buf_hex( - /*=============*/ - std::ostream &o, /*!< in/out: output stream */ - const void *buf, /*!< in: memory buffer */ - ulint len) /*!< in: length of the buffer */ +/** Prints the contents of a memory buffer in hex. */ +void ut_print_buf_hex(std::ostream &o, /*!< in/out: output stream */ + const void *buf, /*!< in: memory buffer */ + ulint len) /*!< in: length of the buffer */ { const byte *data; ulint i; @@ -99,13 +92,10 @@ void ut_print_buf_hex( o << ")"; } -/*************************************************************/ /** - Prints the contents of a memory buffer in hex and ascii. */ -void ut_print_buf( - /*=========*/ - std::ostream &o, /*!< in/out: output stream */ - const void *buf, /*!< in: memory buffer */ - ulint len) /*!< in: length of the buffer */ +/** Prints the contents of a memory buffer in hex and ascii. */ +void ut_print_buf(std::ostream &o, /*!< in/out: output stream */ + const void *buf, /*!< in: memory buffer */ + ulint len) /*!< in: length of the buffer */ { const byte *data; ulint i; @@ -120,11 +110,8 @@ void ut_print_buf( ut_print_buf_hex(o, buf, len); } -/**********************************************************/ /** - Prints a timestamp to a file. */ -void ut_print_timestamp( - /*===============*/ - FILE *file) /*!< in: file where to print */ +/** Prints a timestamp to a file. */ +void ut_print_timestamp(FILE *file) /*!< in: file where to print */ { auto thread_id = os_thread_handle(); @@ -150,11 +137,8 @@ void ut_print_timestamp( #endif /* _WIN32 */ } -/**********************************************************/ /** - Sprintfs a timestamp to a buffer, 13..14 chars plus terminating NUL. */ -void ut_sprintf_timestamp( - /*=================*/ - char *buf) /*!< in: buffer where to sprintf */ +/** Sprintfs a timestamp to a buffer, 13..14 chars plus terminating NUL. */ +void ut_sprintf_timestamp(char *buf) /*!< in: buffer where to sprintf */ { #ifdef _WIN32 SYSTEMTIME cal_tm; @@ -178,15 +162,12 @@ void ut_sprintf_timestamp( #endif } -/**********************************************************************/ /** - Like ut_strlcpy, but if src doesn't fit in dst completely, copies the last +/** Like ut_strlcpy, but if src doesn't fit in dst completely, copies the last (size - 1) bytes of src, not the first. @return strlen(src) */ -ulint ut_strlcpy_rev( - /*===========*/ - char *dst, /*!< in: destination buffer */ - const char *src, /*!< in: source buffer */ - ulint size) /*!< in: size of destination buffer */ +ulint ut_strlcpy_rev(char *dst, /*!< in: destination buffer */ + const char *src, /*!< in: source buffer */ + ulint size) /*!< in: size of destination buffer */ { ulint src_size = strlen(src); diff --git a/storage/innobase/ut/ut.h b/storage/innobase/ut/ut.h index 30296387b4a8..558f944df0fb 100644 --- a/storage/innobase/ut/ut.h +++ b/storage/innobase/ut/ut.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/******************************************************************/ /** - @file ut/ut.h +/** @file ut/ut.h Various utilities Created 1/20/1994 Heikki Tuuri @@ -39,48 +38,30 @@ external tools. */ #define ut_ut_h #include "univ.i" -/*************************************************************/ /** - Prints the contents of a memory buffer in hex and ascii. */ -void ut_print_buf( - /*=========*/ - FILE *file, /*!< in: file where to print */ - const void *buf, /*!< in: memory buffer */ - ulint len); /*!< in: length of the buffer */ - -/**********************************************************/ /** - Prints a timestamp to a file. */ -void ut_print_timestamp( - /*===============*/ - FILE *file) /*!< in: file where to print */ +/** Prints the contents of a memory buffer in hex and ascii. */ +void ut_print_buf(FILE *file, /*!< in: file where to print */ + const void *buf, /*!< in: memory buffer */ + ulint len); /*!< in: length of the buffer */ + +/** Prints a timestamp to a file. */ +void ut_print_timestamp(FILE *file) /*!< in: file where to print */ UNIV_COLD; -/**********************************************************/ /** - Sprintfs a timestamp to a buffer, 13..14 chars plus terminating NUL. */ -void ut_sprintf_timestamp( - /*=================*/ - char *buf); /*!< in: buffer where to sprintf */ -/*************************************************************/ /** - Prints the contents of a memory buffer in hex. */ -void ut_print_buf_hex( - /*=============*/ - std::ostream &o, /*!< in/out: output stream */ - const void *buf, /*!< in: memory buffer */ - ulint len); /*!< in: length of the buffer */ -/*************************************************************/ /** - Prints the contents of a memory buffer in hex and ascii. */ -void ut_print_buf( - /*=========*/ - std::ostream &o, /*!< in/out: output stream */ - const void *buf, /*!< in: memory buffer */ - ulint len); /*!< in: length of the buffer */ -/**********************************************************************/ /** - Like ut_strlcpy, but if src doesn't fit in dst completely, copies the last +/** Sprintfs a timestamp to a buffer, 13..14 chars plus terminating NUL. */ +void ut_sprintf_timestamp(char *buf); /*!< in: buffer where to sprintf */ +/** Prints the contents of a memory buffer in hex. */ +void ut_print_buf_hex(std::ostream &o, /*!< in/out: output stream */ + const void *buf, /*!< in: memory buffer */ + ulint len); /*!< in: length of the buffer */ +/** Prints the contents of a memory buffer in hex and ascii. */ +void ut_print_buf(std::ostream &o, /*!< in/out: output stream */ + const void *buf, /*!< in: memory buffer */ + ulint len); /*!< in: length of the buffer */ +/** Like ut_strlcpy, but if src doesn't fit in dst completely, copies the last (size - 1) bytes of src, not the first. @return strlen(src) */ -ulint ut_strlcpy_rev( - /*===========*/ - char *dst, /*!< in: destination buffer */ - const char *src, /*!< in: source buffer */ - ulint size); /*!< in: size of destination buffer */ +ulint ut_strlcpy_rev(char *dst, /*!< in: destination buffer */ + const char *src, /*!< in: source buffer */ + ulint size); /*!< in: size of destination buffer */ struct PrintBuffer { PrintBuffer(const void *buf, ulint len) : m_buf(buf), m_len(len) {} diff --git a/storage/innobase/ut/ut0dbg.cc b/storage/innobase/ut/ut0dbg.cc index b2f7eac91d42..291c54d53acd 100644 --- a/storage/innobase/ut/ut0dbg.cc +++ b/storage/innobase/ut/ut0dbg.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/*****************************************************************/ /** - @file ut/ut0dbg.cc +/** @file ut/ut0dbg.cc Debug utilities for Innobase. Created 1/30/1994 Heikki Tuuri @@ -37,10 +36,8 @@ this program; if not, write to the Free Software Foundation, Inc., #include "sql/log.h" #include "ut0dbg.h" -/*************************************************************/ /** - Report a failed assertion. */ +/** Report a failed assertion. */ void ut_dbg_assertion_failed( - /*====================*/ const char *expr, /*!< in: the failed assertion (optional) */ const char *file, /*!< in: source file containing the assertion */ ulint line) /*!< in: line number of the assertion */ diff --git a/storage/innobase/ut/ut0list.cc b/storage/innobase/ut/ut0list.cc index 9c7a092fec0d..855b49a47560 100644 --- a/storage/innobase/ut/ut0list.cc +++ b/storage/innobase/ut/ut0list.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/*******************************************************************/ /** - @file ut/ut0list.cc +/** @file ut/ut0list.cc A double-linked list Created 4/26/2006 Osku Salerma @@ -35,20 +34,14 @@ this program; if not, write to the Free Software Foundation, Inc., #include -/****************************************************************/ /** - Create a new list. +/** Create a new list. @return list */ -ib_list_t *ib_list_create(void) -/*=================*/ -{ +ib_list_t *ib_list_create(void) { return (static_cast(ut_zalloc_nokey(sizeof(ib_list_t)))); } -/****************************************************************/ /** - Free a list. */ -void ib_list_free( - /*=========*/ - ib_list_t *list) /*!< in: list */ +/** Free a list. */ +void ib_list_free(ib_list_t *list) /*!< in: list */ { /* We don't check that the list is empty because it's entirely valid to e.g. have all the nodes allocated from a single heap that is then @@ -57,11 +50,9 @@ void ib_list_free( ut_free(list); } -/****************************************************************/ /** - Add the data after the indicated node. +/** Add the data after the indicated node. @return new list node */ static ib_list_node_t *ib_list_add_after( - /*==============*/ ib_list_t *list, /*!< in: list */ ib_list_node_t *prev_node, /*!< in: node preceding new node (can be NULL) */ @@ -111,11 +102,9 @@ static ib_list_node_t *ib_list_add_after( return (node); } -/****************************************************************/ /** - Add the data to the end of the list. +/** Add the data to the end of the list. @return new list node */ ib_list_node_t *ib_list_add_last( - /*=============*/ ib_list_t *list, /*!< in: list */ void *data, /*!< in: data */ mem_heap_t *heap) /*!< in: memory heap to use */ @@ -123,12 +112,9 @@ ib_list_node_t *ib_list_add_last( return (ib_list_add_after(list, ib_list_get_last(list), data, heap)); } -/****************************************************************/ /** - Remove the node from the list. */ -void ib_list_remove( - /*===========*/ - ib_list_t *list, /*!< in: list */ - ib_list_node_t *node) /*!< in: node to remove */ +/** Remove the node from the list. */ +void ib_list_remove(ib_list_t *list, /*!< in: list */ + ib_list_node_t *node) /*!< in: node to remove */ { if (node->prev) { node->prev->next = node->next; diff --git a/storage/innobase/ut/ut0mem.cc b/storage/innobase/ut/ut0mem.cc index e5b0081ee272..dd7b30946aca 100644 --- a/storage/innobase/ut/ut0mem.cc +++ b/storage/innobase/ut/ut0mem.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/********************************************************************/ /** - @file ut/ut0mem.cc +/** @file ut/ut0mem.cc Memory primitives Created 5/11/1994 Heikki Tuuri @@ -36,16 +35,13 @@ this program; if not, write to the Free Software Foundation, Inc., #include "os0thread.h" #include "srv0srv.h" -/**********************************************************************/ /** - Copies up to size - 1 characters from the NUL-terminated string src to +/** Copies up to size - 1 characters from the NUL-terminated string src to dst, NUL-terminating the result. Returns strlen(src), so truncation occurred if the return value >= size. @return strlen(src) */ -ulint ut_strlcpy( - /*=======*/ - char *dst, /*!< in: destination buffer */ - const char *src, /*!< in: source buffer */ - ulint size) /*!< in: size of destination buffer */ +ulint ut_strlcpy(char *dst, /*!< in: destination buffer */ + const char *src, /*!< in: source buffer */ + ulint size) /*!< in: size of destination buffer */ { ulint src_size = strlen(src); @@ -62,7 +58,6 @@ ulint ut_strlcpy( /******************************************************************** Concatenate 3 strings.*/ char *ut_str3cat( - /*=======*/ /* out, own: concatenated string, must be freed with ut_free() */ const char *s1, /* in: string 1 */ diff --git a/storage/innobase/ut/ut0new.cc b/storage/innobase/ut/ut0new.cc index 6a9f733aed21..8eb0bb2de156 100644 --- a/storage/innobase/ut/ut0new.cc +++ b/storage/innobase/ut/ut0new.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/**************************************************/ /** - @file ut/ut0new.cc +/** @file ut/ut0new.cc Instrumented memory allocator. Created May 26, 2014 Vasil Dimov diff --git a/storage/innobase/ut/ut0rbt.cc b/storage/innobase/ut/ut0rbt.cc index 04604204ba9e..dff1f8167895 100644 --- a/storage/innobase/ut/ut0rbt.cc +++ b/storage/innobase/ut/ut0rbt.cc @@ -1,6 +1,5 @@ -/***************************************************************************/ /** - - Copyright (c) 2007, 2017, Oracle and/or its affiliates. All Rights Reserved. +/** + Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -23,8 +22,7 @@ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *****************************************************************************/ -/********************************************************************/ /** - Red-Black tree implementation +/** Red-Black tree implementation (c) 2007 Oracle/Innobase Oy @@ -36,8 +34,7 @@ #include "univ.i" #include "ut0new.h" -/**********************************************************************/ /** - Definition of a red-black tree +/** Definition of a red-black tree ============================== A red-black tree is a binary search tree which has the following @@ -63,11 +60,9 @@ #define SIZEOF_NODE(t) ((sizeof(ib_rbt_node_t) + t->sizeof_value) - 1) #if defined UNIV_DEBUG || defined IB_RBT_TESTING -/**********************************************************************/ /** - Verify that the keys are in order. +/** Verify that the keys are in order. @return true of OK. false if not ordered */ static ibool rbt_check_ordering( - /*===============*/ const ib_rbt_t *tree) /*!< in: tree to verfify */ { const ib_rbt_node_t *node; @@ -96,12 +91,10 @@ static ibool rbt_check_ordering( return (TRUE); } -/**********************************************************************/ /** - Check that every path from the root to the leaves has the same count. +/** Check that every path from the root to the leaves has the same count. Count is expressed in the number of black nodes. @return 0 on failure else black height of the subtree */ static ibool rbt_count_black_nodes( - /*==================*/ const ib_rbt_t *tree, /*!< in: tree to verify */ const ib_rbt_node_t *node) /*!< in: start of sub-tree */ { @@ -136,11 +129,9 @@ static ibool rbt_count_black_nodes( } #endif /* UNIV_DEBUG || IB_RBT_TESTING */ -/**********************************************************************/ /** - Turn the node's right child's left sub-tree into node's right sub-tree. +/** Turn the node's right child's left sub-tree into node's right sub-tree. This will also make node's right child it's parent. */ static void rbt_rotate_left( - /*============*/ const ib_rbt_node_t *nil, /*!< in: nil node of the tree */ ib_rbt_node_t *node) /*!< in: node to rotate */ { @@ -170,11 +161,9 @@ static void rbt_rotate_left( node->parent = right; } -/**********************************************************************/ /** - Turn the node's left child's right sub-tree into node's left sub-tree. +/** Turn the node's left child's right sub-tree into node's left sub-tree. This also make node's left child it's parent. */ static void rbt_rotate_right( - /*=============*/ const ib_rbt_node_t *nil, /*!< in: nil node of tree */ ib_rbt_node_t *node) /*!< in: node to rotate */ { @@ -204,11 +193,10 @@ static void rbt_rotate_right( node->parent = left; } -/**********************************************************************/ /** - Append a node to the tree. */ -static ib_rbt_node_t *rbt_tree_add_child( - /*===============*/ - const ib_rbt_t *tree, ib_rbt_bound_t *parent, ib_rbt_node_t *node) { +/** Append a node to the tree. */ +static ib_rbt_node_t *rbt_tree_add_child(const ib_rbt_t *tree, + ib_rbt_bound_t *parent, + ib_rbt_node_t *node) { /* Cast away the const. */ ib_rbt_node_t *last = (ib_rbt_node_t *)parent->last; @@ -226,11 +214,9 @@ static ib_rbt_node_t *rbt_tree_add_child( return (node); } -/**********************************************************************/ /** - Generic binary tree insert */ -static ib_rbt_node_t *rbt_tree_insert( - /*============*/ - ib_rbt_t *tree, const void *key, ib_rbt_node_t *node) { +/** Generic binary tree insert */ +static ib_rbt_node_t *rbt_tree_insert(ib_rbt_t *tree, const void *key, + ib_rbt_node_t *node) { ib_rbt_bound_t parent; ib_rbt_node_t *current = ROOT(tree); @@ -262,10 +248,8 @@ static ib_rbt_node_t *rbt_tree_insert( return (node); } -/**********************************************************************/ /** - Balance a tree after inserting a node. */ +/** Balance a tree after inserting a node. */ static void rbt_balance_tree( - /*=============*/ const ib_rbt_t *tree, /*!< in: tree to balance */ ib_rbt_node_t *node) /*!< in: node that was inserted */ { @@ -346,11 +330,9 @@ static void rbt_balance_tree( ROOT(tree)->color = IB_RBT_BLACK; } -/**********************************************************************/ /** - Find the given node's successor. +/** Find the given node's successor. @return successor node or NULL if no successor */ static ib_rbt_node_t *rbt_find_successor( - /*===============*/ const ib_rbt_t *tree, /*!< in: rb tree */ const ib_rbt_node_t *current) /*!< in: this is declared const because it can be called via @@ -383,11 +365,9 @@ static ib_rbt_node_t *rbt_find_successor( return (next); } -/**********************************************************************/ /** - Find the given node's precedecessor. +/** Find the given node's precedecessor. @return predecessor node or NULL if no predecesor */ static ib_rbt_node_t *rbt_find_predecessor( - /*=================*/ const ib_rbt_t *tree, /*!< in: rb tree */ const ib_rbt_node_t *current) /*!< in: this is declared const because it can be called via @@ -420,13 +400,10 @@ static ib_rbt_node_t *rbt_find_predecessor( return (prev); } -/**********************************************************************/ /** - Replace node with child. After applying transformations eject becomes +/** Replace node with child. After applying transformations eject becomes an orphan. */ -static void rbt_eject_node( - /*===========*/ - ib_rbt_node_t *eject, /*!< in: node to eject */ - ib_rbt_node_t *node) /*!< in: node to replace with */ +static void rbt_eject_node(ib_rbt_node_t *eject, /*!< in: node to eject */ + ib_rbt_node_t *node) /*!< in: node to replace with */ { /* Update the to be ejected node's parent's child pointers. */ if (eject->parent->left == eject) { @@ -442,10 +419,8 @@ static void rbt_eject_node( node->parent = eject->parent; } -/**********************************************************************/ /** - Replace a node with another node. */ +/** Replace a node with another node. */ static void rbt_replace_node( - /*=============*/ ib_rbt_node_t *replace, /*!< in: node to replace */ ib_rbt_node_t *node) /*!< in: node to replace with */ { @@ -467,11 +442,9 @@ static void rbt_replace_node( replace->color = color; } -/**********************************************************************/ /** - Detach node from the tree replacing it with one of it's children. +/** Detach node from the tree replacing it with one of it's children. @return the child node that now occupies the position of the detached node */ static ib_rbt_node_t *rbt_detach_node( - /*============*/ const ib_rbt_t *tree, /*!< in: rb tree */ ib_rbt_node_t *node) /*!< in: node to detach */ { @@ -508,11 +481,9 @@ static ib_rbt_node_t *rbt_detach_node( return (child); } -/**********************************************************************/ /** - Rebalance the right sub-tree after deletion. +/** Rebalance the right sub-tree after deletion. @return node to rebalance if more rebalancing required else NULL */ static ib_rbt_node_t *rbt_balance_right( - /*==============*/ const ib_rbt_node_t *nil, /*!< in: rb tree nil node */ ib_rbt_node_t *parent, /*!< in: parent node */ ib_rbt_node_t *sibling) /*!< in: sibling node */ @@ -563,11 +534,9 @@ static ib_rbt_node_t *rbt_balance_right( return (node); } -/**********************************************************************/ /** - Rebalance the left sub-tree after deletion. +/** Rebalance the left sub-tree after deletion. @return node to rebalance if more rebalancing required else NULL */ static ib_rbt_node_t *rbt_balance_left( - /*=============*/ const ib_rbt_node_t *nil, /*!< in: rb tree nil node */ ib_rbt_node_t *parent, /*!< in: parent node */ ib_rbt_node_t *sibling) /*!< in: sibling node */ @@ -618,10 +587,8 @@ static ib_rbt_node_t *rbt_balance_left( return (node); } -/**********************************************************************/ /** - Delete the node and rebalance the tree if necessary */ +/** Delete the node and rebalance the tree if necessary */ static void rbt_remove_node_and_rebalance( - /*==========================*/ ib_rbt_t *tree, /*!< in: rb tree */ ib_rbt_node_t *node) /*!< in: node to remove */ { @@ -664,12 +631,9 @@ static void rbt_remove_node_and_rebalance( --tree->n_nodes; } -/**********************************************************************/ /** - Recursively free the nodes. */ -static void rbt_free_node( - /*==========*/ - ib_rbt_node_t *node, /*!< in: node to free */ - ib_rbt_node_t *nil) /*!< in: rb tree nil node */ +/** Recursively free the nodes. */ +static void rbt_free_node(ib_rbt_node_t *node, /*!< in: node to free */ + ib_rbt_node_t *nil) /*!< in: rb tree nil node */ { if (node != nil) { rbt_free_node(node->left, nil); @@ -679,23 +643,18 @@ static void rbt_free_node( } } -/**********************************************************************/ /** - Free all the nodes and free the tree. */ -void rbt_free( - /*=====*/ - ib_rbt_t *tree) /*!< in: rb tree to free */ +/** Free all the nodes and free the tree. */ +void rbt_free(ib_rbt_t *tree) /*!< in: rb tree to free */ { rbt_free_node(tree->root, tree->nil); ut_free(tree->nil); ut_free(tree); } -/**********************************************************************/ /** - Create an instance of a red black tree, whose comparison function takes +/** Create an instance of a red black tree, whose comparison function takes an argument @return an empty rb tree */ ib_rbt_t *rbt_create_arg_cmp( - /*===============*/ size_t sizeof_value, /*!< in: sizeof data item */ ib_rbt_arg_compare compare, /*!< in: fn to compare items */ void *cmp_arg) /*!< in: compare fn arg */ @@ -711,13 +670,10 @@ ib_rbt_t *rbt_create_arg_cmp( return (tree); } -/**********************************************************************/ /** - Create an instance of a red black tree. +/** Create an instance of a red black tree. @return an empty rb tree */ -ib_rbt_t *rbt_create( - /*=======*/ - size_t sizeof_value, /*!< in: sizeof data item */ - ib_rbt_compare compare) /*!< in: fn to compare items */ +ib_rbt_t *rbt_create(size_t sizeof_value, /*!< in: sizeof data item */ + ib_rbt_compare compare) /*!< in: fn to compare items */ { ib_rbt_t *tree; ib_rbt_node_t *node; @@ -744,11 +700,9 @@ ib_rbt_t *rbt_create( return (tree); } -/**********************************************************************/ /** - Generic insert of a value in the rb tree. +/** Generic insert of a value in the rb tree. @return inserted node */ const ib_rbt_node_t *rbt_insert( - /*=======*/ ib_rbt_t *tree, /*!< in: rb tree */ const void *key, /*!< in: key for ordering */ const void *value) /*!< in: value of key, this value @@ -771,11 +725,9 @@ const ib_rbt_node_t *rbt_insert( return (node); } -/**********************************************************************/ /** - Add a new node to the tree, useful for data that is pre-sorted. +/** Add a new node to the tree, useful for data that is pre-sorted. @return appended node */ const ib_rbt_node_t *rbt_add_node( - /*=========*/ ib_rbt_t *tree, /*!< in: rb tree */ ib_rbt_bound_t *parent, /*!< in: bounds */ const void *value) /*!< in: this value is copied @@ -807,11 +759,9 @@ const ib_rbt_node_t *rbt_add_node( return (node); } -/**********************************************************************/ /** - Find a matching node in the rb tree. +/** Find a matching node in the rb tree. @return NULL if not found else the node where key was found */ static const ib_rbt_node_t *rbt_lookup( - /*=======*/ const ib_rbt_t *tree, /*!< in: rb tree */ const void *key) /*!< in: key to use for search */ { @@ -839,13 +789,10 @@ static const ib_rbt_node_t *rbt_lookup( return (current != tree->nil ? current : NULL); } -/**********************************************************************/ /** - Delete a node indentified by key. +/** Delete a node indentified by key. @return true if success false if not found */ -ibool rbt_delete( - /*=======*/ - ib_rbt_t *tree, /*!< in: rb tree */ - const void *key) /*!< in: key to delete */ +ibool rbt_delete(ib_rbt_t *tree, /*!< in: rb tree */ + const void *key) /*!< in: key to delete */ { ibool deleted = FALSE; ib_rbt_node_t *node = (ib_rbt_node_t *)rbt_lookup(tree, key); @@ -860,12 +807,10 @@ ibool rbt_delete( return (deleted); } -/**********************************************************************/ /** - Remove a node from the rb tree, the node is not free'd, that is the +/** Remove a node from the rb tree, the node is not free'd, that is the callers responsibility. @return deleted node but without the const */ ib_rbt_node_t *rbt_remove_node( - /*============*/ ib_rbt_t *tree, /*!< in: rb tree */ const ib_rbt_node_t *const_node) /*!< in: node to delete, this is a fudge and declared const @@ -882,14 +827,11 @@ ib_rbt_node_t *rbt_remove_node( return ((ib_rbt_node_t *)const_node); } -/**********************************************************************/ /** - Find the node that has the greatest key that is <= key. +/** Find the node that has the greatest key that is <= key. @return value of result */ -int rbt_search( - /*=======*/ - const ib_rbt_t *tree, /*!< in: rb tree */ - ib_rbt_bound_t *parent, /*!< in: search bounds */ - const void *key) /*!< in: key to search */ +int rbt_search(const ib_rbt_t *tree, /*!< in: rb tree */ + ib_rbt_bound_t *parent, /*!< in: search bounds */ + const void *key) /*!< in: key to search */ { ib_rbt_node_t *current = ROOT(tree); @@ -919,18 +861,15 @@ int rbt_search( return (parent->result); } -/**********************************************************************/ /** - Find the node that has the greatest key that is <= key. But use the +/** Find the node that has the greatest key that is <= key. But use the supplied comparison function. @return value of result */ -int rbt_search_cmp( - /*===========*/ - const ib_rbt_t *tree, /*!< in: rb tree */ - ib_rbt_bound_t *parent, /*!< in: search bounds */ - const void *key, /*!< in: key to search */ - ib_rbt_compare compare, /*!< in: fn to compare items */ - ib_rbt_arg_compare arg_compare) /*!< in: fn to compare items - with argument */ +int rbt_search_cmp(const ib_rbt_t *tree, /*!< in: rb tree */ + ib_rbt_bound_t *parent, /*!< in: search bounds */ + const void *key, /*!< in: key to search */ + ib_rbt_compare compare, /*!< in: fn to compare items */ + ib_rbt_arg_compare arg_compare) /*!< in: fn to compare items + with argument */ { ib_rbt_node_t *current = ROOT(tree); @@ -960,10 +899,8 @@ int rbt_search_cmp( return (parent->result); } -/**********************************************************************/ /** - Return the left most node in the tree. */ +/** Return the left most node in the tree. */ const ib_rbt_node_t *rbt_first( - /*======*/ /* out leftmost node or NULL */ const ib_rbt_t *tree) /* in: rb tree */ { @@ -978,12 +915,9 @@ const ib_rbt_node_t *rbt_first( return (first); } -/**********************************************************************/ /** - Return the right most node in the tree. +/** Return the right most node in the tree. @return the rightmost node or NULL */ -const ib_rbt_node_t *rbt_last( - /*=====*/ - const ib_rbt_t *tree) /*!< in: rb tree */ +const ib_rbt_node_t *rbt_last(const ib_rbt_t *tree) /*!< in: rb tree */ { ib_rbt_node_t *last = NULL; ib_rbt_node_t *current = ROOT(tree); @@ -996,35 +930,28 @@ const ib_rbt_node_t *rbt_last( return (last); } -/**********************************************************************/ /** - Return the next node. +/** Return the next node. @return node next from current */ const ib_rbt_node_t *rbt_next( - /*=====*/ const ib_rbt_t *tree, /*!< in: rb tree */ const ib_rbt_node_t *current) /*!< in: current node */ { return (current ? rbt_find_successor(tree, current) : NULL); } -/**********************************************************************/ /** - Return the previous node. +/** Return the previous node. @return node prev from current */ const ib_rbt_node_t *rbt_prev( - /*=====*/ const ib_rbt_t *tree, /*!< in: rb tree */ const ib_rbt_node_t *current) /*!< in: current node */ { return (current ? rbt_find_predecessor(tree, current) : NULL); } -/**********************************************************************/ /** - Merge the node from dst into src. Return the number of nodes merged. +/** Merge the node from dst into src. Return the number of nodes merged. @return no. of recs merged */ -ulint rbt_merge_uniq( - /*===========*/ - ib_rbt_t *dst, /*!< in: dst rb tree */ - const ib_rbt_t *src) /*!< in: src rb tree */ +ulint rbt_merge_uniq(ib_rbt_t *dst, /*!< in: dst rb tree */ + const ib_rbt_t *src) /*!< in: src rb tree */ { ib_rbt_bound_t parent; ulint n_merged = 0; @@ -1045,13 +972,10 @@ ulint rbt_merge_uniq( } #if defined UNIV_DEBUG || defined IB_RBT_TESTING -/**********************************************************************/ /** - Check that every path from the root to the leaves has the same count and +/** Check that every path from the root to the leaves has the same count and the tree nodes are in order. @return true if OK false otherwise */ -ibool rbt_validate( - /*=========*/ - const ib_rbt_t *tree) /*!< in: RB tree to validate */ +ibool rbt_validate(const ib_rbt_t *tree) /*!< in: RB tree to validate */ { if (rbt_count_black_nodes(tree, ROOT(tree)) > 0) { return (rbt_check_ordering(tree)); diff --git a/storage/innobase/ut/ut0rnd.cc b/storage/innobase/ut/ut0rnd.cc index a271093ecfa0..4a0414c050b8 100644 --- a/storage/innobase/ut/ut0rnd.cc +++ b/storage/innobase/ut/ut0rnd.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1994, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/***************************************************************/ /** - @file ut/ut0rnd.cc +/** @file ut/ut0rnd.cc Random numbers and hashing Created 5/11/1994 Heikki Tuuri @@ -42,13 +41,10 @@ this program; if not, write to the Free Software Foundation, Inc., thread_local ulint ut_rnd_ulint_counter = 0; -/***********************************************************/ /** - Looks for a prime number slightly greater than the given argument. +/** Looks for a prime number slightly greater than the given argument. The prime is chosen so that it is not near any power of 2. @return prime */ -ulint ut_find_prime( - /*==========*/ - ulint n) /*!< in: positive number > 100 */ +ulint ut_find_prime(ulint n) /*!< in: positive number > 100 */ { ulint pow2; ulint i; diff --git a/storage/innobase/ut/ut0ut.cc b/storage/innobase/ut/ut0ut.cc index 0942352a5111..0b60d3533dc7 100644 --- a/storage/innobase/ut/ut0ut.cc +++ b/storage/innobase/ut/ut0ut.cc @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/***************************************************************/ /** - @file ut/ut0ut.cc +/** @file ut/ut0ut.cc Various utilities for Innobase. Created 5/11/1994 Heikki Tuuri @@ -60,8 +59,7 @@ this program; if not, write to the Free Software Foundation, Inc., using time_fn = VOID(WINAPI *)(_Out_ LPFILETIME); static time_fn ut_get_system_time_as_file_time = GetSystemTimeAsFileTime; -/*****************************************************************/ /** - NOTE: The Windows epoch starts from 1601/01/01 whereas the Unix +/** NOTE: The Windows epoch starts from 1601/01/01 whereas the Unix epoch starts from 1970/1/1. For selection of constant see: http://support.microsoft.com/kb/167296/ */ #define WIN_TO_UNIX_DELTA_USEC 11644473600000000LL @@ -91,11 +89,9 @@ bool ut_win_init_time() { return (true); } -/*****************************************************************/ /** - This is the Windows version of gettimeofday(2). +/** This is the Windows version of gettimeofday(2). @return 0 if all OK else -1 */ static int ut_gettimeofday( - /*============*/ struct timeval *tv, /*!< out: Values are relative to Unix epoch */ void *tz) /*!< in: not used */ { @@ -132,26 +128,18 @@ reimplement this function. */ #define ut_gettimeofday gettimeofday #endif -/**********************************************************/ /** - Returns system time. We do not specify the format of the time returned: +/** Returns system time. We do not specify the format of the time returned: the only way to manipulate it is to use the function ut_difftime. @return system time */ -ib_time_t ut_time(void) -/*=========*/ -{ - return (time(NULL)); -} +ib_time_t ut_time(void) { return (time(NULL)); } -/**********************************************************/ /** - Returns system time. +/** Returns system time. Upon successful completion, the value 0 is returned; otherwise the value -1 is returned and the global variable errno is set to indicate the error. @return 0 on success, -1 otherwise */ -int ut_usectime( - /*========*/ - ulint *sec, /*!< out: seconds since the Epoch */ - ulint *ms) /*!< out: microseconds since the Epoch+*sec */ +int ut_usectime(ulint *sec, /*!< out: seconds since the Epoch */ + ulint *ms) /*!< out: microseconds since the Epoch+*sec */ { struct timeval tv; int ret = 0; @@ -179,14 +167,11 @@ int ut_usectime( return (ret); } -/**********************************************************/ /** - Returns the number of microseconds since epoch. Similar to +/** Returns the number of microseconds since epoch. Similar to time(3), the return value is also stored in *tloc, provided that tloc is non-NULL. @return us since epoch */ -uintmax_t ut_time_us( - /*=======*/ - uintmax_t *tloc) /*!< out: us since epoch, if non-NULL */ +uintmax_t ut_time_us(uintmax_t *tloc) /*!< out: us since epoch, if non-NULL */ { struct timeval tv; uintmax_t us; @@ -202,14 +187,11 @@ uintmax_t ut_time_us( return (us); } -/**********************************************************/ /** - Returns the number of milliseconds since some epoch. The +/** Returns the number of milliseconds since some epoch. The value may wrap around. It should only be used for heuristic purposes. @return ms since epoch */ -ulint ut_time_ms(void) -/*============*/ -{ +ulint ut_time_ms(void) { struct timeval tv; ut_gettimeofday(&tv, NULL); @@ -217,13 +199,10 @@ ulint ut_time_ms(void) return ((ulint)tv.tv_sec * 1000 + tv.tv_usec / 1000); } -/**********************************************************/ /** - Returns the difference of two times in seconds. +/** Returns the difference of two times in seconds. @return time2 - time1 expressed in seconds */ -double ut_difftime( - /*========*/ - ib_time_t time2, /*!< in: time */ - ib_time_t time1) /*!< in: time */ +double ut_difftime(ib_time_t time2, /*!< in: time */ + ib_time_t time1) /*!< in: time */ { return (difftime(time2, time1)); } @@ -259,13 +238,10 @@ void meb_sprintf_timestamp_without_extra_chars( #else /* UNIV_HOTBACKUP */ -/*************************************************************/ /** - Runs an idle loop on CPU. The argument gives the desired delay +/** Runs an idle loop on CPU. The argument gives the desired delay in microseconds on 100 MHz Pentium + Visual C++. @return dummy value */ -ulint ut_delay( - /*=====*/ - ulint delay) /*!< in: delay in microseconds on 100 MHz Pentium */ +ulint ut_delay(ulint delay) /*!< in: delay in microseconds on 100 MHz Pentium */ { ulint i, j; @@ -284,12 +260,9 @@ ulint ut_delay( } #endif /* UNIV_HOTBACKUP */ -/*************************************************************/ /** - Calculates fast the number rounded up to the nearest power of 2. +/** Calculates fast the number rounded up to the nearest power of 2. @return first power of 2 which is >= n */ -ulint ut_2_power_up( - /*==========*/ - ulint n) /*!< in: number != 0 */ +ulint ut_2_power_up(ulint n) /*!< in: number != 0 */ { ulint res; @@ -325,16 +298,13 @@ std::string ut_get_name(const trx_t *trx, const char *name) { return (std::string(buf, 0, bufend - buf)); } -/**********************************************************************/ /** - Outputs a fixed-length string, quoted as an SQL identifier. +/** Outputs a fixed-length string, quoted as an SQL identifier. If the string contains a slash '/', the string will be output as two identifiers separated by a period (.), as in SQL database_name.identifier. */ -void ut_print_name( - /*==========*/ - FILE *f, /*!< in: output stream */ - const trx_t *trx, /*!< in: transaction */ - const char *name) /*!< in: name to print */ +void ut_print_name(FILE *f, /*!< in: output stream */ + const trx_t *trx, /*!< in: transaction */ + const char *name) /*!< in: name to print */ { /* 2 * NAME_LEN for database and table name, and some slack for the #mysql50# prefix and quotes */ @@ -385,12 +355,9 @@ char *ut_format_name(const char *name, char *formatted, ulint formatted_size) { return (formatted); } -/**********************************************************************/ /** - Catenate files. */ -void ut_copy_file( - /*=========*/ - FILE *dest, /*!< in: output file */ - FILE *src) /*!< in: input file to be appended to output */ +/** Catenate files. */ +void ut_copy_file(FILE *dest, /*!< in: output file */ + FILE *src) /*!< in: input file to be appended to output */ { long len = ftell(src); char buf[4096]; @@ -413,19 +380,16 @@ void ut_copy_file( #ifdef _WIN32 #include -/**********************************************************************/ /** - A substitute for vsnprintf(3), formatted output conversion into +/** A substitute for vsnprintf(3), formatted output conversion into a limited buffer. Note: this function DOES NOT return the number of characters that would have been printed if the buffer was unlimited because VC's _vsnprintf() returns -1 in this case and we would need to call _vscprintf() in addition to estimate that but we would need another copy of "ap" for that and VC does not provide va_copy(). */ -void ut_vsnprintf( - /*=========*/ - char *str, /*!< out: string */ - size_t size, /*!< in: str size */ - const char *fmt, /*!< in: format */ - va_list ap) /*!< in: format values */ +void ut_vsnprintf(char *str, /*!< out: string */ + size_t size, /*!< in: str size */ + const char *fmt, /*!< in: format */ + va_list ap) /*!< in: format values */ { _vsnprintf(str, size, fmt, ap); str[size - 1] = '\0'; diff --git a/storage/innobase/ut/ut0vec.cc b/storage/innobase/ut/ut0vec.cc index 04eb5f79e0d1..6b8d1f34fb2a 100644 --- a/storage/innobase/ut/ut0vec.cc +++ b/storage/innobase/ut/ut0vec.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -24,8 +24,7 @@ this program; if not, write to the Free Software Foundation, Inc., *****************************************************************************/ -/*******************************************************************/ /** - @file ut/ut0vec.cc +/** @file ut/ut0vec.cc A vector of pointers to data items Created 4/6/2006 Osku Salerma @@ -37,7 +36,6 @@ this program; if not, write to the Free Software Foundation, Inc., /******************************************************************** Create a new vector with the given initial size. */ ib_vector_t *ib_vector_create( - /*=============*/ /* out: vector */ ib_alloc_t *allocator, /* in: vector allocator */ ulint sizeof_value, /* in: size of data item */ @@ -64,9 +62,7 @@ ib_vector_t *ib_vector_create( /******************************************************************** Resize the vector, currently the vector can only grow and we expand the number of elements it can hold by 2 times. */ -void ib_vector_resize( - /*=============*/ - ib_vector_t *vec) /* in: vector */ +void ib_vector_resize(ib_vector_t *vec) /* in: vector */ { ulint new_total = vec->total * 2; ulint old_size = vec->used * vec->sizeof_value; diff --git a/storage/innobase/ut/ut0wqueue.cc b/storage/innobase/ut/ut0wqueue.cc index 42c5998c5272..0d04a7152a6b 100644 --- a/storage/innobase/ut/ut0wqueue.cc +++ b/storage/innobase/ut/ut0wqueue.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2006, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2006, 2018, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the @@ -32,8 +32,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "mem0mem.h" #include "ut0list.h" -/*******************************************************************/ /** - @file ut/ut0wqueue.cc +/** @file ut/ut0wqueue.cc A work queue Created 4/26/2006 Osku Salerma @@ -46,12 +45,9 @@ struct ib_wqueue_t { os_event_t event; /*!< event we use to signal additions to list */ }; -/****************************************************************/ /** - Create a new work queue. +/** Create a new work queue. @return work queue */ -ib_wqueue_t *ib_wqueue_create(void) -/*===================*/ -{ +ib_wqueue_t *ib_wqueue_create(void) { ib_wqueue_t *wq = static_cast(ut_malloc_nokey(sizeof(*wq))); /* Function ib_wqueue_create() has not been used anywhere, @@ -65,11 +61,8 @@ ib_wqueue_t *ib_wqueue_create(void) return (wq); } -/****************************************************************/ /** - Free a work queue. */ -void ib_wqueue_free( - /*===========*/ - ib_wqueue_t *wq) /*!< in: work queue */ +/** Free a work queue. */ +void ib_wqueue_free(ib_wqueue_t *wq) /*!< in: work queue */ { mutex_free(&wq->mutex); ib_list_free(wq->items); @@ -78,10 +71,8 @@ void ib_wqueue_free( ut_free(wq); } -/****************************************************************/ /** - Add a work item to the queue. */ +/** Add a work item to the queue. */ void ib_wqueue_add( - /*==========*/ ib_wqueue_t *wq, /*!< in: work queue */ void *item, /*!< in: work item */ mem_heap_t *heap) /*!< in: memory heap to use for allocating the @@ -98,7 +89,6 @@ void ib_wqueue_add( /******************************************************************** Wait for a work item to appear in the queue for specified time. */ void *ib_wqueue_timedwait( - /*================*/ /* out: work item or NULL on timeout*/ ib_wqueue_t *wq, /* in: work queue */ ib_time_t wait_in_usecs) /* in: wait time in micro seconds */ @@ -137,7 +127,6 @@ void *ib_wqueue_timedwait( /******************************************************************** Check if queue is empty. */ ibool ib_wqueue_is_empty( - /*===============*/ /* out: TRUE if queue empty else FALSE */ const ib_wqueue_t *wq) /* in: work queue */