;;; my-mariadb.el -- Customization for mariadb development-branch -*- lexical-binding: t -*- ;; Copyright (C) 2023 Free Software Foundation. ;; Author: Yuchen Pei ;; Package-Requires: ((emacs "28.2")) ;; This file is part of dotted. ;; dotted is free software: you can redistribute it and/or modify it under ;; the terms of the GNU Affero General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; dotted is distributed in the hope that it will be useful, but WITHOUT ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General ;; Public License for more details. ;; You should have received a copy of the GNU Affero General Public ;; License along with dotted. If not, see . ;;; Commentary: ;; Customization for mariadb development-branch. ;;; Code: (require 'my-prog) (require 'sql) (defun my-sql-maybe-mtrr () (interactive) (if (equal (file-name-extension (buffer-file-name)) "test") (call-interactively 'project-compile) (sql-send-buffer))) (defun my-gdb-maria () (interactive) (when (and (buffer-live-p gud-comint-buffer) (get-buffer-process gud-comint-buffer)) (my-gdb-quit)) (sleep-for 1) (my-gdb (format "rr replay %s -d %s" (expand-file-name (replace-regexp-in-string "/src" "/build/mysql-test/var/log/mysqld.1.rr/latest-trace" (project-root (project-current t)))) (expand-file-name "~/bin/gdb-mi.sh")))) (defun my-gdb-maria-spider () (interactive) (when (and (buffer-live-p gud-comint-buffer) (get-buffer-process gud-comint-buffer)) (my-gdb-quit)) (sleep-for 1) (my-gdb (format "rr replay %s -d %s" (expand-file-name (replace-regexp-in-string "/src" "/build/mysql-test/var/log/mysqld.1.1.rr/latest-trace" (project-root (project-current t)))) (expand-file-name "~/bin/gdb-mi.sh")))) (defvar my-c-style-maria-spider '("maria-spider" (c-basic-offset . 2) (c-offsets-alist . (;; no indentation when opening an brace (substatement-open . 0) ;; no extra space when aligning continued lines of block comments (c . +) (arglist-intro . +) (arglist-close . 0) (arglist-cont-nonempty c-lineup-gcc-asm-reg c-lineup-arglist) (arglist-cont . 0) (statement-block-intro . +) )) ;; empty comment start on block comment continuation refill (c-block-comment-prefix . "") )) (defun my-mdev-22979 (beg end) (interactive "r") (save-excursion (goto-char end) (insert " )}, ") (goto-char beg) (insert " {C_STRING_WITH_LEN( "))) (defun my-gdb-mysql-parse-frame () (interactive) (let ((old-frame) (level)) (with-current-buffer (gdb-stack-buffer-name) (save-excursion (beginning-of-buffer) (setq old-frame (point)) (text-property-search-forward 'gdb-frame "mysql_parse" (lambda (val prop) (equal (alist-get 'func prop) val))) (beginning-of-line) (setq level (alist-get 'level (get-text-property (point) 'gdb-frame))))) (with-current-buffer gud-comint-buffer (insert "f " level) (comint-send-input)) (with-current-buffer (gdb-stack-buffer-name) (save-excursion (goto-char old-frame) (gdb-select-frame))))) (defun my-mdev-29502-seek-next () (save-excursion (while (re-search-forward "\\(\\ *\\)SPIDER_CLEAR_FILE_POS(&\\(.*\\)->mta_conn_mutex_file_pos); \\ *pthread_mutex_unlock(&\\2->mta_conn_mutex);" nil t) (replace-match "\\1spider_conn_mutex_unlock(\\2);"))) (save-excursion (while (re-search-forward "\\(\\ *\\)DBUG_ASSERT(!\\(.*\\)->mta_conn_mutex_lock_already); \\ *DBUG_ASSERT(!\\2->mta_conn_mutex_unlock_later); \\ *\\2->mta_conn_mutex_lock_already = TRUE; \\ *\\2->mta_conn_mutex_unlock_later = TRUE;" nil t) (replace-match "\\1spider_conn_mutex_locked(\\2);"))) (save-excursion (while (re-search-forward "\\(\\ *\\)DBUG_ASSERT(\\(.*\\)->mta_conn_mutex_lock_already); \\ *DBUG_ASSERT(\\2->mta_conn_mutex_unlock_later); \\ *\\2->mta_conn_mutex_lock_already = FALSE; \\ *\\2->mta_conn_mutex_unlock_later = FALSE;" nil t) (replace-match "\\1spider_conn_mutex_unlocking(\\2);"))) (save-excursion (while (re-search-forward "\\(\\ *\\)pthread_mutex_lock(&\\(.*\\)->mta_conn_mutex); \\ *SPIDER_SET_FILE_POS(&\\2->mta_conn_mutex_file_pos);" nil t) (replace-match "\\1spider_conn_mutex_lock(\\2);"))) ) (defun my-mdev-29502-need-lock () (save-excursion (while (re-search-forward "\\(\\ *\\)if ([^!].*need_lock_before_set_sql_for_exec(.*" nil t) (beginning-of-line) (kill-sexp 3) (kill-line))) (save-excursion (while (re-search-forward "\\(\\ *\\)if (!.*need_lock_before_set_sql_for_exec(.*" nil t) (beginning-of-line) (kill-sexp 2) (kill-line 2) (c-indent-line-or-region) (beginning-of-line 3) (kill-line 1) ))) (provide 'my-mariadb) ;;; my-mariadb.el ends here