Server IP : 104.21.38.3 / Your IP : 104.23.175.113 Web Server : Apache System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /www/server/mysql/src/storage/myisam/ |
Upload File : |
/* Copyright (c) 2000, 2023, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the Free Software Foundation. This program is also distributed with certain software (including but not limited to OpenSSL) that is licensed under separate terms, as designated in a particular file or component or in included license documentation. The authors of MySQL hereby grant you an additional permission to link the program and your derivative works with the separately licensed software that they have included with MySQL. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* Logging of MyISAM commands and records on logfile for debugging The log can be examined with help of the myisamlog command. */ #include "myisamdef.h" #ifdef _WIN32 #include <fcntl.h> #include <process.h> #endif #define GETPID() (log_type == 1 ? (long) myisam_pid : (long) my_thread_self()) /* Activate logging if flag is 1 and reset logging if flag is 0 */ static int log_type=0; ulong myisam_pid=0; int mi_log(int activate_log) { int error=0; char buff[FN_REFLEN]; DBUG_ENTER("mi_log"); log_type=activate_log; if (activate_log) { if (!myisam_pid) myisam_pid=(ulong) getpid(); if (myisam_log_file < 0) { if ((myisam_log_file= mysql_file_create(mi_key_file_log, fn_format(buff, myisam_log_filename, "", ".log", 4), 0, (O_RDWR | O_BINARY | O_APPEND), MYF(0))) < 0) DBUG_RETURN(my_errno()); } } else if (myisam_log_file >= 0) { error= mysql_file_close(myisam_log_file, MYF(0)) ? my_errno() : 0 ; myisam_log_file= -1; } DBUG_RETURN(error); } /* Logging of records and commands on logfile */ /* All logs starts with command(1) dfile(2) process(4) result(2) */ void _myisam_log(enum myisam_log_commands command, MI_INFO *info, const uchar *buffert, uint length) { uchar buff[11]; int error,old_errno; ulong pid=(ulong) GETPID(); old_errno=my_errno(); memset(buff, 0, sizeof(buff)); buff[0]=(char) command; mi_int2store(buff+1,info->dfile); mi_int4store(buff+3,pid); mi_int2store(buff+9,length); mysql_mutex_lock(&THR_LOCK_myisam); error=my_lock(myisam_log_file,F_WRLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE)); (void) mysql_file_write(myisam_log_file, buff, sizeof(buff), MYF(0)); (void) mysql_file_write(myisam_log_file, buffert, length, MYF(0)); if (!error) error=my_lock(myisam_log_file,F_UNLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE)); mysql_mutex_unlock(&THR_LOCK_myisam); set_my_errno(old_errno); } void _myisam_log_command(enum myisam_log_commands command, MI_INFO *info, const uchar *buffert, uint length, int result) { uchar buff[9]; int error,old_errno; ulong pid=(ulong) GETPID(); old_errno=my_errno(); buff[0]=(char) command; mi_int2store(buff+1,info->dfile); mi_int4store(buff+3,pid); mi_int2store(buff+7,result); mysql_mutex_lock(&THR_LOCK_myisam); error=my_lock(myisam_log_file,F_WRLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE)); (void) mysql_file_write(myisam_log_file, buff, sizeof(buff), MYF(0)); if (buffert) (void) mysql_file_write(myisam_log_file, buffert, length, MYF(0)); if (!error) error=my_lock(myisam_log_file,F_UNLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE)); mysql_mutex_unlock(&THR_LOCK_myisam); set_my_errno(old_errno); } void _myisam_log_record(enum myisam_log_commands command, MI_INFO *info, const uchar *record, my_off_t filepos, int result) { uchar buff[21],*pos; int error,old_errno; uint length; ulong pid=(ulong) GETPID(); old_errno=my_errno(); if (!info->s->base.blobs) length=info->s->base.reclength; else length=info->s->base.reclength+ _my_calc_total_blob_length(info,record); buff[0]=(uchar) command; mi_int2store(buff+1,info->dfile); mi_int4store(buff+3,pid); mi_int2store(buff+7,result); mi_sizestore(buff+9,filepos); mi_int4store(buff+17,length); mysql_mutex_lock(&THR_LOCK_myisam); error=my_lock(myisam_log_file,F_WRLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE)); (void) mysql_file_write(myisam_log_file, buff, sizeof(buff), MYF(0)); (void) mysql_file_write(myisam_log_file, record, info->s->base.reclength, MYF(0)); if (info->s->base.blobs) { MI_BLOB *blob,*end; for (end=info->blobs+info->s->base.blobs, blob= info->blobs; blob != end ; blob++) { memcpy(&pos, record+blob->offset+blob->pack_length, sizeof(char*)); (void) mysql_file_write(myisam_log_file, pos, blob->length, MYF(0)); } } if (!error) error=my_lock(myisam_log_file,F_UNLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE)); mysql_mutex_unlock(&THR_LOCK_myisam); set_my_errno(old_errno); }