1
/* Copyright (C) 2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
2
Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License
6
as published by the Free Software Foundation; version 2 of
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16
19
#ifdef USE_PRAGMA_IMPLEMENTATION
17
20
#pragma implementation // gcc: Class implementation
865
869
azflush(&(share->archive_write), Z_SYNC_FLUSH);
867
Set the position of the local read thread to the beginning postion.
871
Set the position of the local read thread to the beginning position.
869
873
if (read_data_header(&archive))
1108
1112
/* Copy null bits */
1109
1113
const uchar *ptr= record_buffer->buffer;
1115
Field::unpack() is not called when field is NULL. For VARCHAR
1116
Field::unpack() only unpacks as much bytes as occupied by field
1117
value. In these cases respective memory area on record buffer is
1120
These uninitialized areas may be accessed by CHECKSUM TABLE or
1121
by optimizer using temporary table (BUG#12997905). We may remove
1122
this memset() when they're fixed.
1124
memset(record, 0, table->s->reclength);
1110
1125
memcpy(record, ptr, table->s->null_bytes);
1111
1126
ptr+= table->s->null_bytes;
1112
1127
for (Field **field=table->field ; *field ; field++)
1114
if (!((*field)->is_null()))
1129
if (!((*field)->is_null_in_record(record)))
1116
1131
ptr= (*field)->unpack(record + (*field)->offset(table->record[0]), ptr);
1577
1592
const char *old_proc_info;
1578
ha_rows count= share->rows_recorded;
1579
1594
DBUG_ENTER("ha_archive::check");
1581
1596
old_proc_info= thd_proc_info(thd, "Checking table");
1597
pthread_mutex_lock(&share->mutex);
1598
count= share->rows_recorded;
1582
1599
/* Flush any waiting data */
1583
pthread_mutex_lock(&share->mutex);
1584
azflush(&(share->archive_write), Z_SYNC_FLUSH);
1600
if (share->archive_write_open)
1601
azflush(&(share->archive_write), Z_SYNC_FLUSH);
1585
1602
pthread_mutex_unlock(&share->mutex);
1604
if (init_archive_reader())
1605
DBUG_RETURN(HA_ADMIN_CORRUPT);
1588
1607
Now we will rewind the archive file so that we are positioned at the
1589
1608
start of the file.
1591
init_archive_reader();
1592
1610
read_data_header(&archive);
1611
for (ha_rows cur_count= count; cur_count; cur_count--)
1613
if ((rc= get_row(&archive, table->record[0])))
1617
Now read records that may have been inserted concurrently.
1618
Acquire share->mutex so tail of the table is not modified by
1621
pthread_mutex_lock(&share->mutex);
1622
count= share->rows_recorded - count;
1623
if (share->archive_write_open)
1624
azflush(&(share->archive_write), Z_SYNC_FLUSH);
1593
1625
while (!(rc= get_row(&archive, table->record[0])))
1596
thd_proc_info(thd, old_proc_info);
1627
pthread_mutex_unlock(&share->mutex);
1598
1629
if ((rc && rc != HA_ERR_END_OF_FILE) || count)
1600
share->crashed= FALSE;
1601
DBUG_RETURN(HA_ADMIN_CORRUPT);
1632
thd_proc_info(thd, old_proc_info);
1604
1633
DBUG_RETURN(HA_ADMIN_OK);
1636
thd_proc_info(thd, old_proc_info);
1637
share->crashed= FALSE;
1638
DBUG_RETURN(HA_ADMIN_CORRUPT);