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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
1d8bf1cb
Commit
1d8bf1cb
authored
May 05, 2004
by
magnus@neptunus.(none)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BUG# 3658 ALTER TABLE corrupts table
Added test file for ALTER TABLE, engine = ndbcluster
parent
6893acc1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
2 deletions
+84
-2
mysql-test/r/ndb_alter_table.result
mysql-test/r/ndb_alter_table.result
+29
-0
mysql-test/t/ndb_alter_table.test
mysql-test/t/ndb_alter_table.test
+41
-0
sql/ha_ndbcluster.cc
sql/ha_ndbcluster.cc
+8
-1
sql/ha_ndbcluster.h
sql/ha_ndbcluster.h
+1
-0
sql/sql_table.cc
sql/sql_table.cc
+5
-1
No files found.
mysql-test/r/ndb_alter_table.result
0 → 100644
View file @
1d8bf1cb
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
a INT NOT NULL,
b INT NOT NULL
) ENGINE=ndbcluster;
INSERT INTO t1 VALUES (9410,9412);
ALTER TABLE t1 ADD COLUMN c int not null;
SELECT * FROM t1;
a b c
9410 9412 0
DROP TABLE t1;
create table t1 (
col1 int not null auto_increment primary key,
col2 varchar(30) not null,
col3 varchar (20) not null,
col4 varchar(4) not null,
col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null,
col6 int not null, to_be_deleted int);
insert into t1 values (2,4,3,5,"PENDING",1,7);
alter table t1
add column col4_5 varchar(20) not null after col4,
add column col7 varchar(30) not null after col5,
add column col8 datetime not null, drop column to_be_deleted,
change column col2 fourth varchar(30) not null after col3,
modify column col6 int not null first;
select * from t1;
col6 col1 col3 fourth col4 col4_5 col5 col7 col8
1 2 3 4 5 PENDING 0000-00-00 00:00:00
drop table t1;
mysql-test/t/ndb_alter_table.test
0 → 100644
View file @
1d8bf1cb
--
source
include
/
have_ndb
.
inc
--
disable_warnings
DROP
TABLE
IF
EXISTS
t1
;
--
enable_warnings
#
# Basic test to show that the ALTER TABLE
# is working
#
CREATE
TABLE
t1
(
a
INT
NOT
NULL
,
b
INT
NOT
NULL
)
ENGINE
=
ndbcluster
;
INSERT
INTO
t1
VALUES
(
9410
,
9412
);
ALTER
TABLE
t1
ADD
COLUMN
c
int
not
null
;
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
#
# More advanced test
#
create
table
t1
(
col1
int
not
null
auto_increment
primary
key
,
col2
varchar
(
30
)
not
null
,
col3
varchar
(
20
)
not
null
,
col4
varchar
(
4
)
not
null
,
col5
enum
(
'PENDING'
,
'ACTIVE'
,
'DISABLED'
)
not
null
,
col6
int
not
null
,
to_be_deleted
int
);
insert
into
t1
values
(
2
,
4
,
3
,
5
,
"PENDING"
,
1
,
7
);
alter
table
t1
add
column
col4_5
varchar
(
20
)
not
null
after
col4
,
add
column
col7
varchar
(
30
)
not
null
after
col5
,
add
column
col8
datetime
not
null
,
drop
column
to_be_deleted
,
change
column
col2
fourth
varchar
(
30
)
not
null
after
col3
,
modify
column
col6
int
not
null
first
;
select
*
from
t1
;
drop
table
t1
;
sql/ha_ndbcluster.cc
View file @
1d8bf1cb
...
...
@@ -951,7 +951,8 @@ int ha_ndbcluster::full_table_scan(byte *buf)
{
Field
*
field
=
table
->
field
[
i
];
if
((
thd
->
query_id
==
field
->
query_id
)
||
(
field
->
flags
&
PRI_KEY_FLAG
))
(
field
->
flags
&
PRI_KEY_FLAG
)
||
retrieve_all_fields
)
{
if
(
get_ndb_value
(
op
,
i
,
field
->
ptr
))
ERR_RETURN
(
op
->
getNdbError
());
...
...
@@ -1779,6 +1780,7 @@ int ha_ndbcluster::extra(enum ha_extra_function operation)
where field->query_id is the same as
the current query id */
DBUG_PRINT
(
"info"
,
(
"HA_EXTRA_RETRIEVE_ALL_COLS"
));
retrieve_all_fields
=
TRUE
;
break
;
case
HA_EXTRA_PREPARE_FOR_DELETE
:
DBUG_PRINT
(
"info"
,
(
"HA_EXTRA_PREPARE_FOR_DELETE"
));
...
...
@@ -2025,6 +2027,8 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type)
(
NdbConnection
*
)
thd
->
transaction
.
all
.
ndb_tid
:
(
NdbConnection
*
)
thd
->
transaction
.
stmt
.
ndb_tid
;
DBUG_ASSERT
(
m_active_trans
);
retrieve_all_fields
=
FALSE
;
}
else
...
...
@@ -2076,6 +2080,8 @@ int ha_ndbcluster::start_stmt(THD *thd)
thd
->
transaction
.
stmt
.
ndb_tid
=
trans
;
}
m_active_trans
=
trans
;
retrieve_all_fields
=
FALSE
;
DBUG_RETURN
(
error
);
}
...
...
@@ -2553,6 +2559,7 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg):
HA_DROP_BEFORE_CREATE
|
HA_NOT_READ_AFTER_KEY
),
m_use_write
(
false
),
retrieve_all_fields
(
FALSE
),
rows_to_insert
(
0
),
rows_inserted
(
0
),
bulk_insert_rows
(
1024
)
...
...
sql/ha_ndbcluster.h
View file @
1d8bf1cb
...
...
@@ -208,6 +208,7 @@ class ha_ndbcluster: public handler
const
char
*
m_unique_index_name
[
MAX_KEY
];
NdbRecAttr
*
m_value
[
NDB_MAX_ATTRIBUTES_IN_TABLE
];
bool
m_use_write
;
bool
retrieve_all_fields
;
ha_rows
rows_to_insert
;
ha_rows
rows_inserted
;
ha_rows
bulk_insert_rows
;
...
...
sql/sql_table.cc
View file @
1d8bf1cb
...
...
@@ -3219,7 +3219,11 @@ copy_data_between_tables(TABLE *from,TABLE *to,
error
=
1
;
goto
err
;
}
/* Handler must be told explicitly to retrieve all columns, because
this function does not set field->query_id in the columns to the
current query id */
from
->
file
->
extra
(
HA_EXTRA_RETRIEVE_ALL_COLS
);
init_read_record
(
&
info
,
thd
,
from
,
(
SQL_SELECT
*
)
0
,
1
,
1
);
if
(
handle_duplicates
==
DUP_IGNORE
||
handle_duplicates
==
DUP_REPLACE
)
...
...
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