您好,欢迎来到339美食。
搜索
您的当前位置:首页TransactionsonInnoDB_MySQL

TransactionsonInnoDB_MySQL

来源:339美食


GNU Emacs Function to Traverse Rows in Page

If we dump a single InnoDB index page into a file, we can open it in GNU Emacs hexl-mode and use the following elisp function to traverse from infimum record to the supremum record. First place the cursor on the 'i' of the infimum record and then call this function to reach the next record origin. I am not an expert in writing elisp functions. If you can improve on this and write a better one, kindly share it with me.

(defun ib-next-red-row () "Go to the origin of the next record in ROW_FORMAT=REDUNDANT.The cursor must be positioned at the origin of a record. This is for the GNU Emacs hexl-mode. " (interactive) (setq rec-origin (point)) (setq rec-origin-offset (hexl-current-address)) ;; The next-rec pointer is stored in 2 bytes before the ;; record origin (hexl-backward-char 2) (setq next-rec (string (char-after))) (forward-char 1) (setq next-rec 	(concat next-rec (string (char-after)))) (hexl-forward-char 1) (setq next-rec 	(concat next-rec (string (char-after)))) (forward-char 1) (setq next-rec 	(concat next-rec (string (char-after)))) ;; Next record is next-rec-off bytes away from page origin (setq next-rec-off (hexl-hex-string-to-integer next-rec)) ;; Assuming that there is only one page in dump (hexl-goto-address 0) (hexl-forward-char next-rec-off))

Conclusion

In this article, the format of the redundant row was explained. A gdb session was used to demonstrate how to access a page and the rows within that page. The infimum record was accessed, printed and analysed. Using its next record pointer, the first user record was accessed. The reader can use the next record pointer of the first user record to access the next user record and so on till the supremum record is reached. I leave that as an exercise for the readers.

Thanks to Marko Makela for his useful tips on debugging at our yearly InnoDB Team Meeting 2013 held at Shanghai, China. This article derives from his ideas.

Copyright © 2019- 3391111.com 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务