mirror of
https://github.com/MariaDB/server.git
synced 2025-06-15 00:02:46 +03:00
merged
This commit is contained in:
0
INSTALL-WIN-SOURCE
Executable file → Normal file
0
INSTALL-WIN-SOURCE
Executable file → Normal file
@ -507,6 +507,8 @@ typedef struct st_keycache
|
||||
ulonglong size;
|
||||
} KEY_CACHE;
|
||||
|
||||
typedef uint32 ha_checksum;
|
||||
|
||||
#include <my_alloc.h>
|
||||
|
||||
/* Prototypes for mysys and my_func functions */
|
||||
@ -749,10 +751,11 @@ extern void print_defaults(const char *conf_file, const char **groups);
|
||||
extern my_bool my_compress(byte *, ulong *, ulong *);
|
||||
extern my_bool my_uncompress(byte *, ulong *, ulong *);
|
||||
extern byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen);
|
||||
extern ulong checksum(const byte *mem, uint count);
|
||||
extern ha_checksum my_checksum(ha_checksum crc, const byte *mem, uint count);
|
||||
extern uint my_bit_log2(ulong value);
|
||||
uint my_count_bits(ulonglong v);
|
||||
extern uint my_count_bits(ulonglong v);
|
||||
extern void my_sleep(ulong m_seconds);
|
||||
extern ulong crc32(ulong crc, const uchar *buf, uint len);
|
||||
|
||||
#ifdef __WIN__
|
||||
extern my_bool have_tcpip; /* Is set if tcpip is used */
|
||||
|
@ -53,8 +53,6 @@ extern "C" {
|
||||
|
||||
#define mi_portable_sizeof_char_ptr 8
|
||||
|
||||
typedef uint32 ha_checksum;
|
||||
|
||||
/* Param to/from mi_info */
|
||||
|
||||
typedef struct st_mi_isaminfo /* Struct from h_info */
|
||||
|
@ -1328,7 +1328,7 @@ int extend;
|
||||
print_error("Found wrong record at %lu",(ulong) start_recpos);
|
||||
got_error=1;
|
||||
}
|
||||
crc^=checksum(record,info->s->base.reclength);
|
||||
crc^=_nisam_checksum(record,info->s->base.reclength);
|
||||
link_used+=info->s->pack.ref_length;
|
||||
used+=block_info.rec_len+info->s->pack.ref_length;
|
||||
}
|
||||
|
@ -358,6 +358,7 @@ extern int _nisam_read_pack_record(N_INFO *info,ulong filepos,byte *buf);
|
||||
extern int _nisam_read_rnd_pack_record(N_INFO*, byte *,ulong, int);
|
||||
extern int _nisam_pack_rec_unpack(N_INFO *info,byte *to,byte *from,
|
||||
uint reclength);
|
||||
extern ulong _nisam_checksum(const byte *mem, uint count);
|
||||
|
||||
typedef struct st_sortinfo {
|
||||
uint key_length;
|
||||
|
19
isam/open.c
19
isam/open.c
@ -453,3 +453,22 @@ static void setup_key_functions(register N_KEYDEF *keyinfo)
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
Calculate a long checksum for a memoryblock. Used to verify pack_isam
|
||||
|
||||
SYNOPSIS
|
||||
checksum()
|
||||
mem Pointer to memory block
|
||||
count Count of bytes
|
||||
*/
|
||||
|
||||
ulong _nisam_checksum(const byte *mem, uint count)
|
||||
{
|
||||
ulong crc;
|
||||
for (crc= 0; count-- ; mem++)
|
||||
crc= ((crc << 1) + *((uchar*) mem)) +
|
||||
test(crc & ((ulong) 1L << (8*sizeof(ulong)-1)));
|
||||
return crc;
|
||||
}
|
||||
|
||||
|
@ -738,7 +738,7 @@ static int get_statistic(MRG_INFO *mrg,HUFF_COUNTS *huff_counts)
|
||||
{
|
||||
if (! error)
|
||||
{
|
||||
crc^=checksum(record,reclength);
|
||||
crc^=_nisam_checksum(record,reclength);
|
||||
for (pos=record,count=huff_counts ;
|
||||
count < end_count ;
|
||||
count++,
|
||||
|
@ -28,30 +28,29 @@ ha_checksum mi_checksum(MI_INFO *info, const byte *buf)
|
||||
{
|
||||
const byte *pos;
|
||||
const byte *end;
|
||||
ulong length;
|
||||
switch (rec->type) {
|
||||
case FIELD_BLOB:
|
||||
{
|
||||
ulong length=_mi_calc_blob_length(rec->length-
|
||||
length=_mi_calc_blob_length(rec->length-
|
||||
mi_portable_sizeof_char_ptr,
|
||||
buf);
|
||||
memcpy((char*) &pos, buf+rec->length- mi_portable_sizeof_char_ptr,
|
||||
sizeof(char*));
|
||||
end=pos+length;
|
||||
break;
|
||||
}
|
||||
case FIELD_VARCHAR:
|
||||
{
|
||||
uint length;
|
||||
length=uint2korr(buf);
|
||||
pos=buf+2; end=pos+length;
|
||||
pos=buf+2;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
pos=buf; end=buf+rec->length;
|
||||
length=rec->length;
|
||||
pos=buf;
|
||||
break;
|
||||
}
|
||||
for ( ; pos != end ; pos++)
|
||||
crc=((crc << 8) + *((uchar*) pos)) + (crc >> (8*sizeof(ha_checksum)-8));
|
||||
crc=my_checksum(crc, pos ? pos : "", length);
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
@ -59,9 +58,5 @@ ha_checksum mi_checksum(MI_INFO *info, const byte *buf)
|
||||
|
||||
ha_checksum mi_static_checksum(MI_INFO *info, const byte *pos)
|
||||
{
|
||||
ha_checksum crc;
|
||||
const byte *end=pos+info->s->base.reclength;
|
||||
for (crc=0; pos != end; pos++)
|
||||
crc=((crc << 8) + *((uchar*) pos)) + (crc >> (8*sizeof(ha_checksum)-8));
|
||||
return crc;
|
||||
return my_checksum(0, pos, info->s->base.reclength);
|
||||
}
|
||||
|
@ -1354,3 +1354,40 @@ id label
|
||||
3524 Societe Test
|
||||
3525 Fournisseur Test
|
||||
drop table t1,t2;
|
||||
create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) type=innodb;
|
||||
select * from t1;
|
||||
c1 c2 stamp
|
||||
replace delayed into t1 (c1, c2) values ( "text1","11"),( "text2","12");
|
||||
ERROR HY000: Table storage engine for 't1' doesn't have this option
|
||||
select * from t1;
|
||||
c1 c2 stamp
|
||||
replace delayed into t1 (c1, c2) values ( "text1","12"),( "text2","13"),( "text3","14", "a" ),( "text4","15", "b" );
|
||||
ERROR HY000: Table storage engine for 't1' doesn't have this option
|
||||
select * from t1;
|
||||
c1 c2 stamp
|
||||
drop table t1;
|
||||
create table t1 (a int, b varchar(200), c text not null) checksum=1 type=myisam;
|
||||
create table t2 (a int, b varchar(200), c text not null) checksum=0 type=innodb;
|
||||
create table t3 (a int, b varchar(200), c text not null) checksum=1 type=innodb;
|
||||
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
|
||||
insert t2 select * from t1;
|
||||
insert t3 select * from t1;
|
||||
checksum table t1, t2, t3, t4 quick;
|
||||
Table Checksum
|
||||
test.t1 968604391
|
||||
test.t2 NULL
|
||||
test.t3 NULL
|
||||
test.t4 NULL
|
||||
checksum table t1, t2, t3, t4;
|
||||
Table Checksum
|
||||
test.t1 968604391
|
||||
test.t2 968604391
|
||||
test.t3 968604391
|
||||
test.t4 NULL
|
||||
checksum table t1, t2, t3, t4 extended;
|
||||
Table Checksum
|
||||
test.t1 968604391
|
||||
test.t2 968604391
|
||||
test.t3 968604391
|
||||
test.t4 NULL
|
||||
drop table t1,t2,t3;
|
||||
|
@ -367,6 +367,23 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) TYPE=MyISAM;
|
||||
ERROR 42000: This version of MySQL doesn't yet support 'RTREE INDEX'
|
||||
DROP TABLE IF EXISTS t1;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 't1'
|
||||
create table t1 (a int, b varchar(200), c text not null) checksum=1;
|
||||
create table t2 (a int, b varchar(200), c text not null) checksum=0;
|
||||
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
|
||||
insert t2 select * from t1;
|
||||
checksum table t1, t2, t3 quick;
|
||||
Table Checksum
|
||||
test.t1 968604391
|
||||
test.t2 NULL
|
||||
test.t3 NULL
|
||||
checksum table t1, t2, t3;
|
||||
Table Checksum
|
||||
test.t1 968604391
|
||||
test.t2 968604391
|
||||
test.t3 NULL
|
||||
checksum table t1, t2, t3 extended;
|
||||
Table Checksum
|
||||
test.t1 968604391
|
||||
test.t2 968604391
|
||||
test.t3 NULL
|
||||
drop table t1,t2;
|
||||
|
@ -43,7 +43,7 @@ wait_timeout 28800
|
||||
show variables like "this_doesn't_exists%";
|
||||
Variable_name Value
|
||||
show table status from test like "this_doesn't_exists%";
|
||||
Name Type Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Charset Create_options Comment
|
||||
Name Type Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Charset Checksum Create_options Comment
|
||||
show databases;
|
||||
Database
|
||||
mysql
|
||||
|
@ -940,3 +940,29 @@ SELECT t2.id, t1.label FROM t2 INNER JOIN
|
||||
(SELECT t1.id_object as id_object FROM t1 WHERE t1.label LIKE '%test%') AS lbl
|
||||
ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object);
|
||||
drop table t1,t2;
|
||||
|
||||
#
|
||||
# Bug #1078
|
||||
#
|
||||
create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) type=innodb;
|
||||
select * from t1;
|
||||
--error 1031
|
||||
replace delayed into t1 (c1, c2) values ( "text1","11"),( "text2","12");
|
||||
select * from t1;
|
||||
--error 1031
|
||||
replace delayed into t1 (c1, c2) values ( "text1","12"),( "text2","13"),( "text3","14", "a" ),( "text4","15", "b" );
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
create table t1 (a int, b varchar(200), c text not null) checksum=1 type=myisam;
|
||||
create table t2 (a int, b varchar(200), c text not null) checksum=0 type=innodb;
|
||||
create table t3 (a int, b varchar(200), c text not null) checksum=1 type=innodb;
|
||||
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
|
||||
insert t2 select * from t1;
|
||||
insert t3 select * from t1;
|
||||
checksum table t1, t2, t3, t4 quick;
|
||||
checksum table t1, t2, t3, t4;
|
||||
checksum table t1, t2, t3, t4 extended;
|
||||
#show table status;
|
||||
drop table t1,t2,t3;
|
||||
|
||||
|
@ -363,4 +363,15 @@ drop table t1,t2;
|
||||
CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) TYPE=MyISAM;
|
||||
# INSERT INTO t1 VALUES (1,1),(1,1);
|
||||
# DELETE FROM rt WHERE a<1;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
# DROP TABLE IF EXISTS t1;
|
||||
|
||||
create table t1 (a int, b varchar(200), c text not null) checksum=1;
|
||||
create table t2 (a int, b varchar(200), c text not null) checksum=0;
|
||||
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
|
||||
insert t2 select * from t1;
|
||||
checksum table t1, t2, t3 quick;
|
||||
checksum table t1, t2, t3;
|
||||
checksum table t1, t2, t3 extended;
|
||||
#show table status;
|
||||
drop table t1,t2;
|
||||
|
||||
|
@ -29,7 +29,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\
|
||||
mf_path.c mf_loadpath.c\
|
||||
my_open.c my_create.c my_dup.c my_seek.c my_read.c \
|
||||
my_pread.c my_write.c \
|
||||
mf_keycache.c \
|
||||
mf_keycache.c my_crc32.c \
|
||||
mf_iocache.c mf_iocache2.c mf_cache.c mf_tempfile.c \
|
||||
mf_tempdir.c my_lock.c mf_brkhant.c my_alarm.c \
|
||||
my_malloc.c my_realloc.c my_once.c mulalloc.c \
|
||||
|
@ -19,19 +19,22 @@
|
||||
#include "my_sys.h"
|
||||
|
||||
/*
|
||||
Calculate a long checksum for a memoryblock. Used to verify pack_isam
|
||||
Calculate a long checksum for a memoryblock.
|
||||
|
||||
SYNOPSIS
|
||||
checksum()
|
||||
mem Pointer to memory block
|
||||
count Count of bytes
|
||||
my_checksum()
|
||||
crc start value for crc
|
||||
pos pointer to memory block
|
||||
length length of the block
|
||||
*/
|
||||
|
||||
ulong checksum(const byte *mem, uint count)
|
||||
ha_checksum my_checksum(ha_checksum crc, const byte *pos, uint length)
|
||||
{
|
||||
ulong crc;
|
||||
for (crc= 0; count-- ; mem++)
|
||||
crc= ((crc << 1) + *((uchar*) mem)) +
|
||||
test(crc & ((ulong) 1L << (8*sizeof(ulong)-1)));
|
||||
/* const byte *end=pos+length;
|
||||
for ( ; pos != end ; pos++)
|
||||
crc=((crc << 8) + *((uchar*) pos)) + (crc >> (8*sizeof(ha_checksum)-8));
|
||||
return crc;
|
||||
*/
|
||||
return (ha_checksum)crc32((uint)crc, (const uchar *)pos, length);
|
||||
}
|
||||
|
||||
|
36
mysys/my_crc32.c
Normal file
36
mysys/my_crc32.c
Normal file
@ -0,0 +1,36 @@
|
||||
/* Copyright (C) 2003 MySQL AB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include "mysys_priv.h"
|
||||
|
||||
#ifndef HAVE_COMPRESS
|
||||
|
||||
/* minimal set of defines for using crc32() from zlib codebase */
|
||||
#define _ZLIB_H
|
||||
#define ZEXPORT
|
||||
#define Z_NULL 0
|
||||
#define OF(args) args
|
||||
#undef DYNAMIC_CRC_TABLE
|
||||
typedef uchar Byte;
|
||||
typedef uchar Bytef;
|
||||
typedef uint uInt;
|
||||
typedef ulong uLong;
|
||||
typedef ulong uLongf;
|
||||
|
||||
#include "../zlib/crc32.c"
|
||||
|
||||
#endif
|
||||
|
@ -86,6 +86,8 @@ client_libs='@CLIENT_LIBS@'
|
||||
|
||||
libs="$ldflags -L'$pkglibdir' -lmysqlclient $client_libs"
|
||||
libs=`echo $libs | sed -e 's; +;;'`
|
||||
libs_r="$ldflags -L'$pkglibdir' -lmysqlclient_r $client_libs"
|
||||
libs_r=`echo $libs_r | sed -e 's; +;;'`
|
||||
cflags="-I'$pkgincludedir'"
|
||||
embedded_libs="$ldflags -L'$pkglibdir' -lmysqld @LIBS@ @innodb_system_libs@"
|
||||
|
||||
@ -95,6 +97,7 @@ Usage: $0 [OPTIONS]
|
||||
Options:
|
||||
--cflags [$cflags]
|
||||
--libs [$libs]
|
||||
--libs_r [$libs_r]
|
||||
--socket [$socket]
|
||||
--port [$port]
|
||||
--version [$version]
|
||||
@ -109,6 +112,7 @@ while test $# -gt 0; do
|
||||
case $1 in
|
||||
--cflags) echo "$cflags" ;;
|
||||
--libs) echo "$libs" ;;
|
||||
--libs_r) echo "$libs_r" ;;
|
||||
--socket) echo "$socket" ;;
|
||||
--port) echo "$port" ;;
|
||||
--version) echo "$version" ;;
|
||||
|
@ -236,6 +236,8 @@ int ha_myisam::open(const char *name, int mode, uint test_if_locked)
|
||||
VOID(mi_extra(file, HA_EXTRA_WAIT_LOCK, 0));
|
||||
if (!table->db_record_offset)
|
||||
int_table_flags|=HA_REC_NOT_IN_SEQ;
|
||||
if (file->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD))
|
||||
int_table_flags|=HA_HAS_CHECKSUM;
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -1414,3 +1416,9 @@ int ha_myisam::ft_read(byte * buf)
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
return error;
|
||||
}
|
||||
|
||||
uint ha_myisam::checksum() const
|
||||
{
|
||||
return (uint)file->s->state.checksum;
|
||||
}
|
||||
|
||||
|
@ -64,6 +64,7 @@ class ha_myisam: public handler
|
||||
uint max_keys() const { return MI_MAX_KEY; }
|
||||
uint max_key_parts() const { return MAX_REF_PARTS; }
|
||||
uint max_key_length() const { return MI_MAX_KEY_LENGTH; }
|
||||
uint checksum() const;
|
||||
|
||||
int open(const char *name, int mode, uint test_if_locked);
|
||||
int close(void);
|
||||
|
@ -48,32 +48,33 @@
|
||||
#define HA_TABLE_SCAN_ON_INDEX 4 /* No separate data/index file */
|
||||
#define HA_REC_NOT_IN_SEQ 8 /* ha_info don't return recnumber;
|
||||
It returns a position to ha_r_rnd */
|
||||
#define HA_HAS_GEOMETRY 16
|
||||
#define HA_NO_INDEX 32 /* No index needed for next/prev */
|
||||
#define HA_KEY_READ_WRONG_STR 64 /* keyread returns converted strings */
|
||||
#define HA_NULL_KEY 128 /* One can have keys with NULL */
|
||||
#define HA_DUPP_POS 256 /* ha_position() gives dupp row */
|
||||
#define HA_NO_BLOBS 512 /* Doesn't support blobs */
|
||||
#define HA_BLOB_KEY (HA_NO_BLOBS*2) /* key on blob */
|
||||
#define HA_AUTO_PART_KEY (HA_BLOB_KEY*2)
|
||||
#define HA_REQUIRE_PRIMARY_KEY (HA_AUTO_PART_KEY*2)
|
||||
#define HA_NOT_EXACT_COUNT (HA_REQUIRE_PRIMARY_KEY*2)
|
||||
#define HA_NO_WRITE_DELAYED (HA_NOT_EXACT_COUNT*2)
|
||||
#define HA_PRIMARY_KEY_IN_READ_INDEX (HA_NO_WRITE_DELAYED*2)
|
||||
#define HA_DROP_BEFORE_CREATE (HA_PRIMARY_KEY_IN_READ_INDEX*2)
|
||||
#define HA_NOT_READ_AFTER_KEY (HA_DROP_BEFORE_CREATE*2)
|
||||
#define HA_NOT_DELETE_WITH_CACHE (HA_NOT_READ_AFTER_KEY*2)
|
||||
#define HA_NO_TEMP_TABLES (HA_NOT_DELETE_WITH_CACHE*2)
|
||||
#define HA_NO_PREFIX_CHAR_KEYS (HA_NO_TEMP_TABLES*2)
|
||||
#define HA_CAN_FULLTEXT (HA_NO_PREFIX_CHAR_KEYS*2)
|
||||
#define HA_CAN_SQL_HANDLER (HA_CAN_FULLTEXT*2)
|
||||
#define HA_NO_AUTO_INCREMENT (HA_CAN_SQL_HANDLER*2)
|
||||
#define HA_HAS_GEOMETRY (1 << 4)
|
||||
#define HA_NO_INDEX (1 << 5) /* No index needed for next/prev */
|
||||
#define HA_KEY_READ_WRONG_STR (1 << 6) /* keyread returns converted strings */
|
||||
#define HA_NULL_KEY (1 << 7) /* One can have keys with NULL */
|
||||
#define HA_DUPP_POS (1 << 8) /* ha_position() gives dupp row */
|
||||
#define HA_NO_BLOBS (1 << 9) /* Doesn't support blobs */
|
||||
#define HA_BLOB_KEY (1 << 10) /* key on blob */
|
||||
#define HA_AUTO_PART_KEY (1 << 11)
|
||||
#define HA_REQUIRE_PRIMARY_KEY (1 << 12)
|
||||
#define HA_NOT_EXACT_COUNT (1 << 13)
|
||||
#define HA_NO_WRITE_DELAYED (1 << 14)
|
||||
#define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15)
|
||||
#define HA_DROP_BEFORE_CREATE (1 << 16)
|
||||
#define HA_NOT_READ_AFTER_KEY (1 << 17)
|
||||
#define HA_NOT_DELETE_WITH_CACHE (1 << 18)
|
||||
#define HA_NO_TEMP_TABLES (1 << 19)
|
||||
#define HA_NO_PREFIX_CHAR_KEYS (1 << 20)
|
||||
#define HA_CAN_FULLTEXT (1 << 21)
|
||||
#define HA_CAN_SQL_HANDLER (1 << 22)
|
||||
#define HA_NO_AUTO_INCREMENT (1 << 23)
|
||||
#define HA_HAS_CHECKSUM (1 << 24)
|
||||
|
||||
/*
|
||||
Next record gives next record according last record read (even
|
||||
if database is updated after read). Not used at this point.
|
||||
*/
|
||||
#define HA_LASTKEY_ORDER (HA_NO_AUTO_INCREMENT*2)
|
||||
#define HA_LASTKEY_ORDER (1 << 25)
|
||||
|
||||
|
||||
/* bits in index_flags(index_number) for what you can do with index */
|
||||
@ -306,8 +307,8 @@ public:
|
||||
virtual bool check_and_repair(THD *thd) {return 1;}
|
||||
virtual int optimize(THD* thd,HA_CHECK_OPT* check_opt);
|
||||
virtual int analyze(THD* thd, HA_CHECK_OPT* check_opt);
|
||||
virtual int backup(THD* thd, HA_CHECK_OPT* check_opt);
|
||||
virtual int preload_keys(THD* thd, HA_CHECK_OPT* check_opt);
|
||||
virtual int backup(THD* thd, HA_CHECK_OPT* check_opt);
|
||||
/*
|
||||
restore assumes .frm file must exist, and that generate_table() has been
|
||||
called; It will just copy the data file and run repair.
|
||||
@ -342,6 +343,7 @@ public:
|
||||
virtual uint max_key_part_length() { return 255; }
|
||||
virtual uint min_record_length(uint options) const { return 1; }
|
||||
virtual bool low_byte_first() const { return 1; }
|
||||
virtual uint checksum() const { return 0; }
|
||||
virtual bool is_crashed() const { return 0; }
|
||||
virtual bool auto_repair() const { return 0; }
|
||||
|
||||
@ -356,12 +358,11 @@ public:
|
||||
/* Type of table for caching query */
|
||||
virtual uint8 table_cache_type() { return HA_CACHE_TBL_NONTRANSACT; }
|
||||
/*
|
||||
Is query with this cable cachable (have sense only for ASKTRANSACT
|
||||
Is query with this table cachable (have sense only for ASKTRANSACT
|
||||
tables)
|
||||
*/
|
||||
static bool caching_allowed(THD* thd, char* table_key,
|
||||
uint key_length, uint8 cahe_type);
|
||||
|
||||
};
|
||||
|
||||
/* Some extern variables used with handlers */
|
||||
|
@ -107,14 +107,6 @@ Item *create_func_cot(Item* a)
|
||||
new Item_func_tan(a));
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_COMPRESS
|
||||
Item *create_func_crc32(Item* a)
|
||||
{
|
||||
return new Item_func_crc32(a);
|
||||
}
|
||||
#endif
|
||||
|
||||
Item *create_func_date_format(Item* a,Item *b)
|
||||
{
|
||||
return new Item_func_date_format(a,b,0);
|
||||
@ -666,13 +658,10 @@ Item *create_func_point(Item *a, Item *b)
|
||||
return new Item_func_point(a, b);
|
||||
}
|
||||
|
||||
#if !defined(HAVE_COMPRESS)
|
||||
|
||||
Item *create_func_compress (Item*a __attribute__((unused))){return 0;}
|
||||
Item *create_func_uncompress (Item*a __attribute__((unused))){return 0;}
|
||||
Item *create_func_uncompressed_length(Item*a __attribute__((unused))){return 0;}
|
||||
|
||||
#else
|
||||
Item *create_func_crc32(Item* a)
|
||||
{
|
||||
return new Item_func_crc32(a);
|
||||
}
|
||||
|
||||
Item *create_func_compress(Item* a)
|
||||
{
|
||||
@ -689,8 +678,6 @@ Item *create_func_uncompressed_length(Item* a)
|
||||
return new Item_func_uncompressed_length(a);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Item *create_func_datediff(Item *a, Item *b)
|
||||
{
|
||||
return new Item_func_minus(new Item_func_to_days(a),
|
||||
|
@ -33,9 +33,7 @@ Item *create_func_connection_id(void);
|
||||
Item *create_func_conv(Item* a, Item *b, Item *c);
|
||||
Item *create_func_cos(Item* a);
|
||||
Item *create_func_cot(Item* a);
|
||||
#ifdef HAVE_COMPRESS
|
||||
Item *create_func_crc32(Item* a);
|
||||
#endif
|
||||
Item *create_func_date_format(Item* a,Item *b);
|
||||
Item *create_func_dayname(Item* a);
|
||||
Item *create_func_dayofmonth(Item* a);
|
||||
|
@ -27,9 +27,6 @@
|
||||
#include <hash.h>
|
||||
#include <time.h>
|
||||
#include <ft_global.h>
|
||||
#ifdef HAVE_COMPRESS
|
||||
#include <zlib.h>
|
||||
#endif
|
||||
|
||||
|
||||
static void my_coll_agg_error(DTCollation &c1, DTCollation &c2,
|
||||
@ -41,7 +38,6 @@ static void my_coll_agg_error(DTCollation &c1, DTCollation &c2,
|
||||
fname);
|
||||
}
|
||||
|
||||
|
||||
static void my_coll_agg_error(DTCollation &c1,
|
||||
DTCollation &c2,
|
||||
DTCollation &c3,
|
||||
@ -1085,36 +1081,6 @@ longlong Item_func_min_max::val_int()
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_COMPRESS
|
||||
longlong Item_func_crc32::val_int()
|
||||
{
|
||||
String *res=args[0]->val_str(&value);
|
||||
if (!res)
|
||||
{
|
||||
null_value=1;
|
||||
return 0; /* purecov: inspected */
|
||||
}
|
||||
null_value=0;
|
||||
return (longlong) crc32(0L, (Bytef*)res->ptr(), res->length());
|
||||
}
|
||||
|
||||
|
||||
longlong Item_func_uncompressed_length::val_int()
|
||||
{
|
||||
String *res= args[0]->val_str(&value);
|
||||
if (!res)
|
||||
{
|
||||
null_value=1;
|
||||
return 0; /* purecov: inspected */
|
||||
}
|
||||
null_value=0;
|
||||
if (res->is_empty()) return 0;
|
||||
return uint4korr(res->c_ptr()) & 0x3FFFFFFF;
|
||||
}
|
||||
#endif /* HAVE_COMPRESS */
|
||||
|
||||
|
||||
longlong Item_func_length::val_int()
|
||||
{
|
||||
String *res=args[0]->val_str(&value);
|
||||
|
@ -555,27 +555,6 @@ public:
|
||||
};
|
||||
|
||||
|
||||
#ifdef HAVE_COMPRESS
|
||||
class Item_func_crc32 :public Item_int_func
|
||||
{
|
||||
String value;
|
||||
public:
|
||||
Item_func_crc32(Item *a) :Item_int_func(a) {}
|
||||
longlong val_int();
|
||||
const char *func_name() const { return "crc32"; }
|
||||
void fix_length_and_dec() { max_length=10; }
|
||||
};
|
||||
class Item_func_uncompressed_length : public Item_int_func
|
||||
{
|
||||
String value;
|
||||
public:
|
||||
Item_func_uncompressed_length(Item *a):Item_int_func(a){}
|
||||
longlong val_int();
|
||||
const char *func_name() const{return "uncompressed_length";}
|
||||
void fix_length_and_dec() { max_length=10; }
|
||||
};
|
||||
#endif
|
||||
|
||||
class Item_func_length :public Item_int_func
|
||||
{
|
||||
String value;
|
||||
|
@ -167,30 +167,6 @@ public:
|
||||
const char *func_name() const { return "multipoint"; }
|
||||
};
|
||||
|
||||
#ifdef HAVE_COMPRESS
|
||||
|
||||
class Item_func_compress: public Item_str_func
|
||||
{
|
||||
String buffer;
|
||||
public:
|
||||
Item_func_compress(Item *a):Item_str_func(a){}
|
||||
String *val_str(String *);
|
||||
void fix_length_and_dec(){max_length= (args[0]->max_length*120)/100+12;}
|
||||
const char *func_name() const{return "compress";}
|
||||
};
|
||||
|
||||
class Item_func_uncompress: public Item_str_func
|
||||
{
|
||||
String buffer;
|
||||
public:
|
||||
Item_func_uncompress(Item *a): Item_str_func(a){}
|
||||
String *val_str(String *);
|
||||
void fix_length_and_dec(){max_length= MAX_BLOB_WIDTH;}
|
||||
const char *func_name() const{return "uncompress";}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
Spatial relations
|
||||
*/
|
||||
|
@ -2554,6 +2554,31 @@ null:
|
||||
return 0;
|
||||
}
|
||||
|
||||
longlong Item_func_uncompressed_length::val_int()
|
||||
{
|
||||
String *res= args[0]->val_str(&value);
|
||||
if (!res)
|
||||
{
|
||||
null_value=1;
|
||||
return 0; /* purecov: inspected */
|
||||
}
|
||||
null_value=0;
|
||||
if (res->is_empty()) return 0;
|
||||
return uint4korr(res->c_ptr()) & 0x3FFFFFFF;
|
||||
}
|
||||
|
||||
longlong Item_func_crc32::val_int()
|
||||
{
|
||||
String *res=args[0]->val_str(&value);
|
||||
if (!res)
|
||||
{
|
||||
null_value=1;
|
||||
return 0; /* purecov: inspected */
|
||||
}
|
||||
null_value=0;
|
||||
return (longlong) crc32(0L, (uchar*)res->ptr(), res->length());
|
||||
}
|
||||
|
||||
#ifdef HAVE_COMPRESS
|
||||
#include "zlib.h"
|
||||
|
||||
@ -2640,5 +2665,4 @@ String *Item_func_uncompress::val_str(String *str)
|
||||
null_value= 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -630,3 +630,50 @@ public:
|
||||
collation.set(system_charset_info);
|
||||
};
|
||||
};
|
||||
|
||||
class Item_func_crc32 :public Item_int_func
|
||||
{
|
||||
String value;
|
||||
public:
|
||||
Item_func_crc32(Item *a) :Item_int_func(a) {}
|
||||
const char *func_name() const { return "crc32"; }
|
||||
void fix_length_and_dec() { max_length=10; }
|
||||
longlong val_int();
|
||||
};
|
||||
|
||||
class Item_func_uncompressed_length : public Item_int_func
|
||||
{
|
||||
String value;
|
||||
public:
|
||||
Item_func_uncompressed_length(Item *a):Item_int_func(a){}
|
||||
const char *func_name() const{return "uncompressed_length";}
|
||||
void fix_length_and_dec() { max_length=10; }
|
||||
longlong val_int();
|
||||
};
|
||||
|
||||
#ifdef HAVE_COMPRESS
|
||||
#define ZLIB_DEPENDED_FUNCTION ;
|
||||
#else
|
||||
#define ZLIB_DEPENDED_FUNCTION { null_value=1; return 0; }
|
||||
#endif
|
||||
|
||||
class Item_func_compress: public Item_str_func
|
||||
{
|
||||
String buffer;
|
||||
public:
|
||||
Item_func_compress(Item *a):Item_str_func(a){}
|
||||
void fix_length_and_dec(){max_length= (args[0]->max_length*120)/100+12;}
|
||||
const char *func_name() const{return "compress";}
|
||||
String *val_str(String *) ZLIB_DEPENDED_FUNCTION
|
||||
};
|
||||
|
||||
class Item_func_uncompress: public Item_str_func
|
||||
{
|
||||
String buffer;
|
||||
public:
|
||||
Item_func_uncompress(Item *a): Item_str_func(a){}
|
||||
void fix_length_and_dec(){max_length= MAX_BLOB_WIDTH;}
|
||||
const char *func_name() const{return "uncompress";}
|
||||
String *val_str(String *) ZLIB_DEPENDED_FUNCTION
|
||||
};
|
||||
|
||||
|
@ -479,9 +479,7 @@ static SYMBOL sql_functions[] = {
|
||||
{ "COUNT", SYM(COUNT_SYM),0,0},
|
||||
{ "COS", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_cos)},
|
||||
{ "COT", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_cot)},
|
||||
#ifdef HAVE_COMPRESS
|
||||
{ "CRC32", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_crc32)},
|
||||
#endif
|
||||
{ "CROSSES", SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_crosses)},
|
||||
{ "CURDATE", SYM(CURDATE),0,0},
|
||||
{ "CURTIME", SYM(CURTIME),0,0},
|
||||
|
@ -411,6 +411,8 @@ bool check_global_access(THD *thd, ulong want_access);
|
||||
int mysql_backup_table(THD* thd, TABLE_LIST* table_list);
|
||||
int mysql_restore_table(THD* thd, TABLE_LIST* table_list);
|
||||
|
||||
int mysql_checksum_table(THD* thd, TABLE_LIST* table_list,
|
||||
HA_CHECK_OPT* check_opt);
|
||||
int mysql_check_table(THD* thd, TABLE_LIST* table_list,
|
||||
HA_CHECK_OPT* check_opt);
|
||||
int mysql_repair_table(THD* thd, TABLE_LIST* table_list,
|
||||
|
@ -4453,14 +4453,15 @@ struct show_var_st status_vars[]= {
|
||||
{"Bytes_received", (char*) &bytes_received, SHOW_LONG},
|
||||
{"Bytes_sent", (char*) &bytes_sent, SHOW_LONG},
|
||||
{"Com_admin_commands", (char*) &com_other, SHOW_LONG},
|
||||
{"Com_alter_table", (char*) (com_stat+(uint) SQLCOM_ALTER_TABLE),SHOW_LONG},
|
||||
{"Com_alter_db", (char*) (com_stat+(uint) SQLCOM_ALTER_DB),SHOW_LONG},
|
||||
{"Com_alter_table", (char*) (com_stat+(uint) SQLCOM_ALTER_TABLE),SHOW_LONG},
|
||||
{"Com_analyze", (char*) (com_stat+(uint) SQLCOM_ANALYZE),SHOW_LONG},
|
||||
{"Com_backup_table", (char*) (com_stat+(uint) SQLCOM_BACKUP_TABLE),SHOW_LONG},
|
||||
{"Com_begin", (char*) (com_stat+(uint) SQLCOM_BEGIN),SHOW_LONG},
|
||||
{"Com_change_db", (char*) (com_stat+(uint) SQLCOM_CHANGE_DB),SHOW_LONG},
|
||||
{"Com_change_master", (char*) (com_stat+(uint) SQLCOM_CHANGE_MASTER),SHOW_LONG},
|
||||
{"Com_check", (char*) (com_stat+(uint) SQLCOM_CHECK),SHOW_LONG},
|
||||
{"Com_checksum", (char*) (com_stat+(uint) SQLCOM_CHECKSUM),SHOW_LONG},
|
||||
{"Com_commit", (char*) (com_stat+(uint) SQLCOM_COMMIT),SHOW_LONG},
|
||||
{"Com_create_db", (char*) (com_stat+(uint) SQLCOM_CREATE_DB),SHOW_LONG},
|
||||
{"Com_create_function", (char*) (com_stat+(uint) SQLCOM_CREATE_FUNCTION),SHOW_LONG},
|
||||
@ -4473,6 +4474,7 @@ struct show_var_st status_vars[]= {
|
||||
{"Com_drop_function", (char*) (com_stat+(uint) SQLCOM_DROP_FUNCTION),SHOW_LONG},
|
||||
{"Com_drop_index", (char*) (com_stat+(uint) SQLCOM_DROP_INDEX),SHOW_LONG},
|
||||
{"Com_drop_table", (char*) (com_stat+(uint) SQLCOM_DROP_TABLE),SHOW_LONG},
|
||||
{"Com_drop_user", (char*) (com_stat+(uint) SQLCOM_DROP_USER),SHOW_LONG},
|
||||
{"Com_flush", (char*) (com_stat+(uint) SQLCOM_FLUSH),SHOW_LONG},
|
||||
{"Com_grant", (char*) (com_stat+(uint) SQLCOM_GRANT),SHOW_LONG},
|
||||
{"Com_ha_close", (char*) (com_stat+(uint) SQLCOM_HA_CLOSE),SHOW_LONG},
|
||||
@ -4487,6 +4489,7 @@ struct show_var_st status_vars[]= {
|
||||
{"Com_load_master_table", (char*) (com_stat+(uint) SQLCOM_LOAD_MASTER_TABLE),SHOW_LONG},
|
||||
{"Com_lock_tables", (char*) (com_stat+(uint) SQLCOM_LOCK_TABLES),SHOW_LONG},
|
||||
{"Com_optimize", (char*) (com_stat+(uint) SQLCOM_OPTIMIZE),SHOW_LONG},
|
||||
{"Com_preload_keys", (char*) (com_stat+(uint) SQLCOM_PRELOAD_KEYS),SHOW_LONG},
|
||||
{"Com_purge", (char*) (com_stat+(uint) SQLCOM_PURGE),SHOW_LONG},
|
||||
{"Com_purge_before_date", (char*) (com_stat+(uint) SQLCOM_PURGE_BEFORE),SHOW_LONG},
|
||||
{"Com_rename_table", (char*) (com_stat+(uint) SQLCOM_RENAME_TABLE),SHOW_LONG},
|
||||
@ -4496,13 +4499,15 @@ struct show_var_st status_vars[]= {
|
||||
{"Com_reset", (char*) (com_stat+(uint) SQLCOM_RESET),SHOW_LONG},
|
||||
{"Com_restore_table", (char*) (com_stat+(uint) SQLCOM_RESTORE_TABLE),SHOW_LONG},
|
||||
{"Com_revoke", (char*) (com_stat+(uint) SQLCOM_REVOKE),SHOW_LONG},
|
||||
{"Com_revoke_all", (char*) (com_stat+(uint) SQLCOM_REVOKE_ALL),SHOW_LONG},
|
||||
{"Com_rollback", (char*) (com_stat+(uint) SQLCOM_ROLLBACK),SHOW_LONG},
|
||||
{"Com_savepoint", (char*) (com_stat+(uint) SQLCOM_SAVEPOINT),SHOW_LONG},
|
||||
{"Com_select", (char*) (com_stat+(uint) SQLCOM_SELECT),SHOW_LONG},
|
||||
{"Com_set_option", (char*) (com_stat+(uint) SQLCOM_SET_OPTION),SHOW_LONG},
|
||||
{"Com_show_binlog_events", (char*) (com_stat+(uint) SQLCOM_SHOW_BINLOG_EVENTS),SHOW_LONG},
|
||||
{"Com_show_binlogs", (char*) (com_stat+(uint) SQLCOM_SHOW_BINLOGS),SHOW_LONG},
|
||||
{"Com_show_binlog_events", (char*) (com_stat+(uint) SQLCOM_SHOW_BINLOG_EVENTS),SHOW_LONG},
|
||||
{"Com_show_charsets", (char*) (com_stat+(uint) SQLCOM_SHOW_CHARSETS),SHOW_LONG},
|
||||
{"Com_show_collations", (char*) (com_stat+(uint) SQLCOM_SHOW_COLLATIONS),SHOW_LONG},
|
||||
{"Com_show_column_types", (char*) (com_stat+(uint) SQLCOM_SHOW_COLUMN_TYPES),SHOW_LONG},
|
||||
{"Com_show_create_table", (char*) (com_stat+(uint) SQLCOM_SHOW_CREATE),SHOW_LONG},
|
||||
{"Com_show_create_db", (char*) (com_stat+(uint) SQLCOM_SHOW_CREATE_DB),SHOW_LONG},
|
||||
@ -4510,6 +4515,7 @@ struct show_var_st status_vars[]= {
|
||||
{"Com_show_errors", (char*) (com_stat+(uint) SQLCOM_SHOW_ERRORS),SHOW_LONG},
|
||||
{"Com_show_fields", (char*) (com_stat+(uint) SQLCOM_SHOW_FIELDS),SHOW_LONG},
|
||||
{"Com_show_grants", (char*) (com_stat+(uint) SQLCOM_SHOW_GRANTS),SHOW_LONG},
|
||||
{"Com_show_innodb_status", (char*) (com_stat+(uint) SQLCOM_SHOW_INNODB_STATUS),SHOW_LONG},
|
||||
{"Com_show_keys", (char*) (com_stat+(uint) SQLCOM_SHOW_KEYS),SHOW_LONG},
|
||||
{"Com_show_logs", (char*) (com_stat+(uint) SQLCOM_SHOW_LOGS),SHOW_LONG},
|
||||
{"Com_show_master_status", (char*) (com_stat+(uint) SQLCOM_SHOW_MASTER_STAT),SHOW_LONG},
|
||||
@ -4520,7 +4526,6 @@ struct show_var_st status_vars[]= {
|
||||
{"Com_show_slave_hosts", (char*) (com_stat+(uint) SQLCOM_SHOW_SLAVE_HOSTS),SHOW_LONG},
|
||||
{"Com_show_slave_status", (char*) (com_stat+(uint) SQLCOM_SHOW_SLAVE_STAT),SHOW_LONG},
|
||||
{"Com_show_status", (char*) (com_stat+(uint) SQLCOM_SHOW_STATUS),SHOW_LONG},
|
||||
{"Com_show_innodb_status", (char*) (com_stat+(uint) SQLCOM_SHOW_INNODB_STATUS),SHOW_LONG},
|
||||
{"Com_show_tables", (char*) (com_stat+(uint) SQLCOM_SHOW_TABLES),SHOW_LONG},
|
||||
{"Com_show_table_types", (char*) (com_stat+(uint) SQLCOM_SHOW_TABLE_TYPES),SHOW_LONG},
|
||||
{"Com_show_variables", (char*) (com_stat+(uint) SQLCOM_SHOW_VARIABLES),SHOW_LONG},
|
||||
|
@ -172,8 +172,11 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
else
|
||||
res= (table == 0);
|
||||
else
|
||||
{
|
||||
lock_type=TL_WRITE;
|
||||
res= open_and_lock_tables(thd, table_list);
|
||||
}
|
||||
}
|
||||
else
|
||||
res= open_and_lock_tables(thd, table_list);
|
||||
if (res)
|
||||
@ -627,6 +630,7 @@ public:
|
||||
thd.current_tablenr=0;
|
||||
thd.version=refresh_version;
|
||||
thd.command=COM_DELAYED_INSERT;
|
||||
thd.lex.current_select= 0; /* for my_message_sql */
|
||||
|
||||
bzero((char*) &thd.net,sizeof(thd.net)); // Safety
|
||||
thd.system_thread=1;
|
||||
|
@ -73,7 +73,7 @@ enum enum_sql_command {
|
||||
SQLCOM_SHOW_BINLOG_EVENTS, SQLCOM_SHOW_NEW_MASTER, SQLCOM_DO,
|
||||
SQLCOM_SHOW_WARNS, SQLCOM_EMPTY_QUERY, SQLCOM_SHOW_ERRORS,
|
||||
SQLCOM_SHOW_COLUMN_TYPES, SQLCOM_SHOW_TABLE_TYPES, SQLCOM_SHOW_PRIVILEGES,
|
||||
SQLCOM_HELP, SQLCOM_DROP_USER, SQLCOM_REVOKE_ALL,
|
||||
SQLCOM_HELP, SQLCOM_DROP_USER, SQLCOM_REVOKE_ALL, SQLCOM_CHECKSUM,
|
||||
|
||||
/* This should be the last !!! */
|
||||
SQLCOM_END
|
||||
@ -479,15 +479,21 @@ typedef struct st_lex
|
||||
SELECT_LEX *all_selects_list;
|
||||
uchar *ptr,*tok_start,*tok_end,*end_of_query;
|
||||
char *length,*dec,*change,*name;
|
||||
char *help_arg;
|
||||
char *backup_dir; /* For RESTORE/BACKUP */
|
||||
char* to_log; /* For PURGE MASTER LOGS TO */
|
||||
time_t purge_time; /* For PURGE MASTER LOGS BEFORE */
|
||||
char* x509_subject,*x509_issuer,*ssl_cipher;
|
||||
char* found_colon; /* For multi queries - next query */
|
||||
enum SSL_type ssl_type; /* defined in violite.h */
|
||||
String *wild;
|
||||
sql_exchange *exchange;
|
||||
select_result *result;
|
||||
Item *default_value, *comment;
|
||||
LEX_USER *grant_user;
|
||||
gptr yacc_yyss,yacc_yyvs;
|
||||
THD *thd;
|
||||
CHARSET_INFO *charset;
|
||||
SQL_LIST *gorder_list;
|
||||
|
||||
List<key_part_spec> col_list;
|
||||
List<key_part_spec> ref_list;
|
||||
@ -506,11 +512,6 @@ typedef struct st_lex
|
||||
TYPELIB *interval;
|
||||
create_field *last_field;
|
||||
char *savepoint_name; // Transaction savepoint id
|
||||
Item *default_value, *comment;
|
||||
uint uint_geom_type;
|
||||
LEX_USER *grant_user;
|
||||
gptr yacc_yyss,yacc_yyvs;
|
||||
THD *thd;
|
||||
udf_func udf;
|
||||
HA_CHECK_OPT check_opt; // check/repair options
|
||||
HA_CREATE_INFO create_info;
|
||||
@ -519,6 +520,7 @@ typedef struct st_lex
|
||||
ulong thread_id,type;
|
||||
enum_sql_command sql_command;
|
||||
thr_lock_type lock_option;
|
||||
enum SSL_type ssl_type; /* defined in violite.h */
|
||||
enum my_lex_states next_state;
|
||||
enum enum_duplicates duplicates;
|
||||
enum enum_tx_isolation tx_isolation;
|
||||
@ -526,17 +528,15 @@ typedef struct st_lex
|
||||
enum ha_rkey_function ha_rkey_mode;
|
||||
enum enum_enable_or_disable alter_keys_onoff;
|
||||
enum enum_var_type option_type;
|
||||
uint uint_geom_type;
|
||||
uint grant, grant_tot_col, which_columns;
|
||||
uint fk_delete_opt, fk_update_opt, fk_match_option;
|
||||
uint param_count;
|
||||
uint slave_thd_opt;
|
||||
bool drop_primary, drop_if_exists, drop_temporary, local_file;
|
||||
bool in_comment, ignore_space, verbose, simple_alter, no_write_to_binlog;
|
||||
bool derived_tables, describe;
|
||||
bool safe_to_cache_query;
|
||||
uint slave_thd_opt;
|
||||
CHARSET_INFO *charset;
|
||||
char *help_arg;
|
||||
SQL_LIST *gorder_list;
|
||||
st_lex() {}
|
||||
inline void uncacheable()
|
||||
{
|
||||
|
@ -2285,6 +2285,14 @@ mysql_execute_command(THD *thd)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case SQLCOM_CHECKSUM:
|
||||
{
|
||||
if (check_db_used(thd,tables) ||
|
||||
check_table_access(thd, SELECT_ACL | EXTRA_ACL , tables))
|
||||
goto error; /* purecov: inspected */
|
||||
res = mysql_checksum_table(thd, tables, &lex->check_opt);
|
||||
break;
|
||||
}
|
||||
case SQLCOM_REPAIR:
|
||||
{
|
||||
if (check_db_used(thd,tables) ||
|
||||
|
@ -2454,7 +2454,7 @@ static void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array)
|
||||
Constant tables are ignored.
|
||||
To avoid bad matches, we don't make ref_table_rows less than 100.
|
||||
*/
|
||||
keyuse->ref_table_rows= ~(table_map) 0; // If no ref
|
||||
keyuse->ref_table_rows= ~(ha_rows) 0; // If no ref
|
||||
if (keyuse->used_tables &
|
||||
(map= (keyuse->used_tables & ~join->const_table_map &
|
||||
~OUTER_REF_TABLE_BIT)))
|
||||
|
@ -503,6 +503,8 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
|
||||
item->maybe_null=1;
|
||||
field_list.push_back(item=new Item_empty_string("Charset",32));
|
||||
item->maybe_null=1;
|
||||
field_list.push_back(item=new Item_int("Checksum",(longlong) 1,21));
|
||||
item->maybe_null=1;
|
||||
field_list.push_back(item=new Item_empty_string("Create_options",255));
|
||||
item->maybe_null=1;
|
||||
field_list.push_back(item=new Item_empty_string("Comment",80));
|
||||
@ -588,6 +590,10 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
|
||||
}
|
||||
str= (table->table_charset ? table->table_charset->name : "default");
|
||||
protocol->store(str, system_charset_info);
|
||||
if (file->table_flags() & HA_HAS_CHECKSUM)
|
||||
protocol->store((ulonglong)file->checksum());
|
||||
else
|
||||
protocol->store_null(); // Checksum
|
||||
{
|
||||
char option_buff[350],*ptr;
|
||||
ptr=option_buff;
|
||||
|
100
sql/sql_table.cc
100
sql/sql_table.cc
@ -2593,3 +2593,103 @@ copy_data_between_tables(TABLE *from,TABLE *to,
|
||||
*deleted=delete_count;
|
||||
DBUG_RETURN(error > 0 ? -1 : 0);
|
||||
}
|
||||
|
||||
int mysql_checksum_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT *check_opt)
|
||||
{
|
||||
TABLE_LIST *table;
|
||||
List<Item> field_list;
|
||||
Item *item;
|
||||
Protocol *protocol= thd->protocol;
|
||||
DBUG_ENTER("mysql_admin_table");
|
||||
|
||||
field_list.push_back(item = new Item_empty_string("Table", NAME_LEN*2));
|
||||
item->maybe_null= 1;
|
||||
field_list.push_back(item=new Item_int("Checksum",(longlong) 1,21));
|
||||
item->maybe_null= 1;
|
||||
if (protocol->send_fields(&field_list, 1))
|
||||
DBUG_RETURN(-1);
|
||||
|
||||
for (table = tables; table; table = table->next)
|
||||
{
|
||||
char table_name[NAME_LEN*2+2];
|
||||
char* db = (table->db) ? table->db : thd->db;
|
||||
bool fatal_error=0;
|
||||
TABLE *t;
|
||||
strxmov(table_name,db ? db : "",".",table->real_name,NullS);
|
||||
|
||||
t=table->table = open_ltable(thd, table, TL_READ_NO_INSERT);
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
thd->net.last_errno= 0; // these errors shouldn't get client
|
||||
#endif
|
||||
|
||||
protocol->prepare_for_resend();
|
||||
protocol->store(table_name, system_charset_info);
|
||||
|
||||
if (!t)
|
||||
{
|
||||
protocol->store_null();
|
||||
thd->net.last_error[0]=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
t->pos_in_table_list= table;
|
||||
|
||||
if (t->file->table_flags() & HA_HAS_CHECKSUM &&
|
||||
!(check_opt->flags & T_EXTEND))
|
||||
protocol->store((ulonglong)t->file->checksum());
|
||||
else if (!(t->file->table_flags() & HA_HAS_CHECKSUM) &&
|
||||
check_opt->flags & T_QUICK)
|
||||
protocol->store_null();
|
||||
else
|
||||
{
|
||||
/* calculating table's checksum */
|
||||
ha_checksum crc=0;
|
||||
if (t->file->rnd_init(1))
|
||||
protocol->store_null();
|
||||
else
|
||||
{
|
||||
while (!t->file->rnd_next(t->record[0]))
|
||||
{
|
||||
ha_checksum row_crc=0;
|
||||
if (t->record[0] != t->field[0]->ptr)
|
||||
row_crc=my_checksum(row_crc, t->record[0],
|
||||
t->field[0]->ptr - t->record[0]);
|
||||
|
||||
for (uint i=0; i < t->fields; i++ )
|
||||
{
|
||||
Field *f=t->field[i];
|
||||
if (f->type() == FIELD_TYPE_BLOB)
|
||||
{
|
||||
String tmp;
|
||||
f->val_str(&tmp,&tmp);
|
||||
row_crc=my_checksum(row_crc, tmp.ptr(), tmp.length());
|
||||
}
|
||||
else
|
||||
row_crc=my_checksum(row_crc, f->ptr, f->pack_length());
|
||||
}
|
||||
|
||||
crc+=row_crc;
|
||||
}
|
||||
protocol->store((ulonglong)crc);
|
||||
}
|
||||
}
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
thd->net.last_errno= 0; // these errors shouldn't get client
|
||||
#endif
|
||||
|
||||
close_thread_tables(thd);
|
||||
table->table=0; // For query cache
|
||||
}
|
||||
if (protocol->write())
|
||||
goto err;
|
||||
}
|
||||
|
||||
send_eof(thd);
|
||||
DBUG_RETURN(0);
|
||||
err:
|
||||
close_thread_tables(thd); // Shouldn't be needed
|
||||
if (table)
|
||||
table->table=0;
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
|
@ -677,7 +677,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
|
||||
show describe load alter optimize preload flush
|
||||
reset purge begin commit rollback savepoint
|
||||
slave master_def master_defs
|
||||
repair restore backup analyze check start
|
||||
repair restore backup analyze check start checksum
|
||||
field_list field_list_item field_spec kill column_def key_def
|
||||
preload_list preload_keys
|
||||
select_item_list select_item values_list no_braces
|
||||
@ -735,18 +735,21 @@ verb_clause:
|
||||
| begin
|
||||
| change
|
||||
| check
|
||||
| checksum
|
||||
| commit
|
||||
| create
|
||||
| delete
|
||||
| describe
|
||||
| do
|
||||
| drop
|
||||
| grant
|
||||
| insert
|
||||
| flush
|
||||
| grant
|
||||
| handler
|
||||
| help
|
||||
| insert
|
||||
| kill
|
||||
| load
|
||||
| lock
|
||||
| kill
|
||||
| optimize
|
||||
| preload
|
||||
| purge
|
||||
@ -760,15 +763,14 @@ verb_clause:
|
||||
| savepoint
|
||||
| select
|
||||
| set
|
||||
| show
|
||||
| slave
|
||||
| start
|
||||
| show
|
||||
| truncate
|
||||
| handler
|
||||
| unlock
|
||||
| update
|
||||
| use
|
||||
| help;
|
||||
;
|
||||
|
||||
/* help */
|
||||
|
||||
@ -1804,6 +1806,22 @@ backup:
|
||||
Lex->backup_dir = $6.str;
|
||||
};
|
||||
|
||||
checksum:
|
||||
CHECKSUM_SYM table_or_tables
|
||||
{
|
||||
LEX *lex=Lex;
|
||||
lex->sql_command = SQLCOM_CHECKSUM;
|
||||
}
|
||||
table_list opt_checksum_type
|
||||
{}
|
||||
;
|
||||
|
||||
opt_checksum_type:
|
||||
/* nothing */ { Lex->check_opt.flags= 0; }
|
||||
| QUICK { Lex->check_opt.flags= T_QUICK; }
|
||||
| EXTENDED_SYM { Lex->check_opt.flags= T_EXTEND; }
|
||||
;
|
||||
|
||||
repair:
|
||||
REPAIR opt_no_write_to_binlog table_or_tables
|
||||
{
|
||||
@ -3413,7 +3431,7 @@ do: DO_SYM
|
||||
*/
|
||||
|
||||
drop:
|
||||
DROP opt_temporary TABLE_SYM if_exists table_list opt_restrict
|
||||
DROP opt_temporary table_or_tables if_exists table_list opt_restrict
|
||||
{
|
||||
LEX *lex=Lex;
|
||||
lex->sql_command = SQLCOM_DROP_TABLE;
|
||||
@ -5318,3 +5336,4 @@ subselect_end:
|
||||
LEX *lex=Lex;
|
||||
lex->current_select = lex->current_select->return_after_parsing();
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user