Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
2fcab1c2
Commit
2fcab1c2
authored
Sep 03, 2003
by
serg@serg.mylan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CHECKSUM TABLE table1, table2, ... [ QUICK | EXTENDED ]
parent
8424aec8
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
138 additions
and
28 deletions
+138
-28
myisam/mi_checksum.c
myisam/mi_checksum.c
+1
-1
mysql-test/r/innodb.result
mysql-test/r/innodb.result
+25
-0
mysql-test/r/myisam.result
mysql-test/r/myisam.result
+20
-3
mysql-test/r/show_check.result
mysql-test/r/show_check.result
+1
-1
mysql-test/t/innodb.test
mysql-test/t/innodb.test
+12
-0
mysql-test/t/myisam.test
mysql-test/t/myisam.test
+12
-1
mysys/checksum.c
mysys/checksum.c
+3
-1
sql/mysql_priv.h
sql/mysql_priv.h
+2
-1
sql/sql_parse.cc
sql/sql_parse.cc
+1
-1
sql/sql_table.cc
sql/sql_table.cc
+51
-15
sql/sql_yacc.yy
sql/sql_yacc.yy
+10
-4
No files found.
myisam/mi_checksum.c
View file @
2fcab1c2
...
...
@@ -50,7 +50,7 @@ ha_checksum mi_checksum(MI_INFO *info, const byte *buf)
pos
=
buf
;
break
;
}
crc
=
my_checksum
(
crc
,
pos
,
length
);
crc
=
my_checksum
(
crc
,
pos
?
pos
:
""
,
length
);
}
return
crc
;
}
...
...
mysql-test/r/innodb.result
View file @
2fcab1c2
...
...
@@ -1341,3 +1341,28 @@ 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;
mysql-test/r/myisam.result
View file @
2fcab1c2
...
...
@@ -394,6 +394,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;
mysql-test/r/show_check.result
View file @
2fcab1c2
...
...
@@ -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 C
hecksum C
reate_options Comment
show databases;
Database
mysql
...
...
mysql-test/t/innodb.test
View file @
2fcab1c2
...
...
@@ -920,3 +920,15 @@ replace delayed into t1 (c1, c2) values ( "text1","12"),( "text2","13"),( "text
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
;
mysql-test/t/myisam.test
View file @
2fcab1c2
...
...
@@ -360,4 +360,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
;
mysys/checksum.c
View file @
2fcab1c2
...
...
@@ -30,9 +30,11 @@
ha_checksum
my_checksum
(
ha_checksum
crc
,
const
byte
*
pos
,
uint
length
)
{
const
byte
*
end
=
pos
+
length
;
/*
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
);
}
sql/mysql_priv.h
View file @
2fcab1c2
...
...
@@ -398,7 +398,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
);
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
,
...
...
sql/sql_parse.cc
View file @
2fcab1c2
...
...
@@ -2269,7 +2269,7 @@ mysql_execute_command(THD *thd)
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
);
res
=
mysql_checksum_table
(
thd
,
tables
,
&
lex
->
check_opt
);
break
;
}
case
SQLCOM_REPAIR
:
...
...
sql/sql_table.cc
View file @
2fcab1c2
...
...
@@ -2588,7 +2588,7 @@ copy_data_between_tables(TABLE *from,TABLE *to,
DBUG_RETURN
(
error
>
0
?
-
1
:
0
);
}
int
mysql_checksum_table
(
THD
*
thd
,
TABLE_LIST
*
tables
)
int
mysql_checksum_table
(
THD
*
thd
,
TABLE_LIST
*
tables
,
HA_CHECK_OPT
*
check_opt
)
{
TABLE_LIST
*
table
;
List
<
Item
>
field_list
;
...
...
@@ -2608,9 +2608,10 @@ int mysql_checksum_table(THD* thd, TABLE_LIST* tables)
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
);
table
->
table
=
open_ltable
(
thd
,
table
,
TL_READ_NO_INSERT
);
t
=
t
able
->
table
=
open_ltable
(
thd
,
table
,
TL_READ_NO_INSERT
);
#ifdef EMBEDDED_LIBRARY
thd
->
net
.
last_errno
=
0
;
// these errors shouldn't get client
#endif
...
...
@@ -2618,19 +2619,54 @@ int mysql_checksum_table(THD* thd, TABLE_LIST* tables)
protocol
->
prepare_for_resend
();
protocol
->
store
(
table_name
,
system_charset_info
);
if
(
!
t
able
->
table
)
if
(
!
t
)
{
protocol
->
store_null
();
thd
->
net
.
last_error
[
0
]
=
0
;
}
else
{
t
able
->
table
->
pos_in_table_list
=
table
;
t
->
pos_in_table_list
=
table
;
if
(
table
->
table
->
file
->
table_flags
()
&
HA_HAS_CHECKSUM
)
protocol
->
store
((
ulonglong
)
table
->
table
->
file
->
checksum
());
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
...
...
sql/sql_yacc.yy
View file @
2fcab1c2
...
...
@@ -1760,10 +1760,16 @@ checksum:
LEX *lex=Lex;
lex->sql_command = SQLCOM_CHECKSUM;
}
table_list
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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment