21 #include "myisamdef.h"
27 #define GETPID() (log_type == 1 ? (long) myisam_pid : (long) my_thread_dbug_id())
31 static int log_type=0;
34 int mi_log(
int activate_log)
40 log_type=activate_log;
44 myisam_pid=(ulong) getpid();
45 if (myisam_log_file < 0)
52 (O_RDWR | O_BINARY | O_APPEND),
54 DBUG_RETURN(my_errno);
57 else if (myisam_log_file >= 0)
69 void _myisam_log(
enum myisam_log_commands command,
MI_INFO *info,
70 const uchar *buffert, uint length)
74 ulong pid=(ulong) GETPID();
76 memset(buff, 0,
sizeof(buff));
77 buff[0]=(char) command;
78 mi_int2store(buff+1,info->dfile);
79 mi_int4store(buff+3,pid);
80 mi_int2store(buff+9,length);
83 error=my_lock(myisam_log_file,F_WRLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE));
87 error=my_lock(myisam_log_file,F_UNLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE));
93 void _myisam_log_command(
enum myisam_log_commands command,
MI_INFO *info,
94 const uchar *buffert, uint length,
int result)
98 ulong pid=(ulong) GETPID();
101 buff[0]=(char) command;
102 mi_int2store(buff+1,info->dfile);
103 mi_int4store(buff+3,pid);
104 mi_int2store(buff+7,result);
106 error=my_lock(myisam_log_file,F_WRLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE));
111 error=my_lock(myisam_log_file,F_UNLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE));
117 void _myisam_log_record(
enum myisam_log_commands command,
MI_INFO *info,
118 const uchar *
record, my_off_t filepos,
int result)
123 ulong pid=(ulong) GETPID();
126 if (!info->s->base.blobs)
127 length=info->s->base.reclength;
129 length=info->s->base.reclength+ _my_calc_total_blob_length(info,record);
130 buff[0]=(uchar) command;
131 mi_int2store(buff+1,info->dfile);
132 mi_int4store(buff+3,pid);
133 mi_int2store(buff+7,result);
134 mi_sizestore(buff+9,filepos);
135 mi_int4store(buff+17,length);
137 error=my_lock(myisam_log_file,F_WRLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE));
139 (void)
mysql_file_write(myisam_log_file, record, info->s->base.reclength, MYF(0));
140 if (info->s->base.blobs)
144 for (end=info->blobs+info->s->base.blobs, blob= info->blobs;
148 memcpy(&pos, record+blob->offset+blob->pack_length,
154 error=my_lock(myisam_log_file,F_UNLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE));