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
cdccc772
Commit
cdccc772
authored
May 22, 2006
by
mskold@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql.com:/home/marty/MySQL/mysql-4.1
into mysql.com:/home/marty/MySQL/mysql-5.0
parents
b9cd71e6
4efdebed
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
141 additions
and
30 deletions
+141
-30
mysql-test/r/ndb_rename.result
mysql-test/r/ndb_rename.result
+14
-0
mysql-test/t/ndb_rename.test
mysql-test/t/ndb_rename.test
+32
-0
ndb/include/ndbapi/NdbDictionary.hpp
ndb/include/ndbapi/NdbDictionary.hpp
+19
-3
ndb/src/ndbapi/NdbDictionary.cpp
ndb/src/ndbapi/NdbDictionary.cpp
+16
-0
ndb/src/ndbapi/NdbDictionaryImpl.cpp
ndb/src/ndbapi/NdbDictionaryImpl.cpp
+5
-22
ndb/src/ndbapi/NdbDictionaryImpl.hpp
ndb/src/ndbapi/NdbDictionaryImpl.hpp
+15
-4
sql/ha_ndbcluster.cc
sql/ha_ndbcluster.cc
+40
-1
No files found.
mysql-test/r/ndb_rename.result
0 → 100644
View file @
cdccc772
DROP TABLE IF EXISTS t1,t2;
drop database if exists mysqltest;
CREATE TABLE t1 (
pk1 INT NOT NULL PRIMARY KEY,
attr1 INT NOT NULL,
attr2 INT,
attr3 VARCHAR(10),
INDEX i1(attr1)
) ENGINE=ndbcluster;
alter table t1 rename t2;
create database ndbtest;
alter table t2 rename ndbtest.t2;
drop table ndbtest.t2;
drop database ndbtest;
mysql-test/t/ndb_rename.test
0 → 100644
View file @
cdccc772
--
source
include
/
have_ndb
.
inc
--
source
include
/
not_embedded
.
inc
--
disable_warnings
DROP
TABLE
IF
EXISTS
t1
,
t2
;
drop
database
if
exists
mysqltest
;
--
enable_warnings
#
# Table rename tests
#
#
# Create a normal table with primary key
#
CREATE
TABLE
t1
(
pk1
INT
NOT
NULL
PRIMARY
KEY
,
attr1
INT
NOT
NULL
,
attr2
INT
,
attr3
VARCHAR
(
10
),
INDEX
i1
(
attr1
)
)
ENGINE
=
ndbcluster
;
alter
table
t1
rename
t2
;
create
database
ndbtest
;
alter
table
t2
rename
ndbtest
.
t2
;
drop
table
ndbtest
.
t2
;
drop
database
ndbtest
;
# End of 4.1 tests
ndb/include/ndbapi/NdbDictionary.hpp
View file @
cdccc772
...
...
@@ -1230,14 +1230,14 @@ public:
/**
* Create defined table given defined Table instance
* @param
table Tabl
e to create
* @param
Table instanc
e to create
* @return 0 if successful otherwise -1.
*/
int
createTable
(
const
Table
&
table
);
/**
* Drop table given retrieved Table instance
* @param
table Tabl
e to drop
* @param
Table instanc
e to drop
* @return 0 if successful otherwise -1.
*/
int
dropTable
(
Table
&
table
);
...
...
@@ -1301,7 +1301,23 @@ public:
*/
int
dropIndex
(
const
char
*
indexName
,
const
char
*
tableName
);
/**
* Get index with given name, NULL if undefined
* @param indexName Name of index to get.
* @param tableName Name of table that index belongs to.
* @return index if successful, otherwise 0.
*/
const
Index
*
getIndex
(
const
char
*
indexName
,
const
char
*
tableName
);
/**
* Get index with given name, NULL if undefined
* @param indexName Name of index to get.
* @param Table instance table that index belongs to.
* @return index if successful, otherwise 0.
*/
const
Index
*
getIndex
(
const
char
*
indexName
,
const
Table
&
table
);
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
/**
* Invalidate cached index object
...
...
ndb/src/ndbapi/NdbDictionary.cpp
View file @
cdccc772
...
...
@@ -800,6 +800,12 @@ NdbDictionary::Dictionary::dropIndex(const char * indexName,
return
m_impl
.
dropIndex
(
indexName
,
tableName
);
}
int
NdbDictionary
::
Dictionary
::
dropIndex
(
const
Index
&
ind
)
{
return
m_impl
.
dropIndex
(
NdbIndexImpl
::
getImpl
(
ind
));
}
const
NdbDictionary
::
Index
*
NdbDictionary
::
Dictionary
::
getIndex
(
const
char
*
indexName
,
const
char
*
tableName
)
const
...
...
@@ -810,6 +816,16 @@ NdbDictionary::Dictionary::getIndex(const char * indexName,
return
0
;
}
const
NdbDictionary
::
Index
*
NdbDictionary
::
Dictionary
::
getIndex
(
const
char
*
indexName
,
const
Table
&
t
)
{
NdbIndexImpl
*
i
=
m_impl
.
getIndex
(
indexName
,
&
NdbTableImpl
::
getImpl
(
t
));
if
(
i
)
return
i
->
m_facade
;
return
0
;
}
void
NdbDictionary
::
Dictionary
::
invalidateIndex
(
const
char
*
indexName
,
const
char
*
tableName
){
...
...
ndb/src/ndbapi/NdbDictionaryImpl.cpp
View file @
cdccc772
...
...
@@ -2274,7 +2274,7 @@ NdbDictionaryImpl::dropIndex(const char * indexName,
m_error
.
code
=
4243
;
return
-
1
;
}
int
ret
=
dropIndex
(
*
idx
,
tableName
);
int
ret
=
dropIndex
(
*
idx
);
//
, tableName);
// If index stored in cache is incompatible with the one in the kernel
// we must clear the cache and try again
if
(
ret
==
INCOMPATIBLE_VERSION
)
{
...
...
@@ -2296,40 +2296,23 @@ NdbDictionaryImpl::dropIndex(const char * indexName,
}
int
NdbDictionaryImpl
::
dropIndex
(
NdbIndexImpl
&
impl
,
const
char
*
tableName
)
NdbDictionaryImpl
::
dropIndex
(
NdbIndexImpl
&
impl
)
{
const
char
*
indexName
=
impl
.
getName
();
if
(
tableName
||
m_ndb
.
usingFullyQualifiedNames
())
{
NdbTableImpl
*
timpl
=
impl
.
m_table
;
if
(
timpl
==
0
)
{
m_error
.
code
=
709
;
return
-
1
;
}
const
BaseString
internalIndexName
((
tableName
)
?
m_ndb
.
internalize_index_name
(
getTable
(
tableName
),
indexName
)
:
m_ndb
.
internalize_table_name
(
indexName
));
// Index is also a table
if
(
impl
.
m_status
==
NdbDictionary
::
Object
::
New
){
return
dropIndex
(
indexName
,
tableName
);
}
int
ret
=
m_receiver
.
dropIndex
(
impl
,
*
timpl
);
if
(
ret
==
0
){
m_localHash
.
drop
(
internalIndex
Name
.
c_str
());
m_localHash
.
drop
(
timpl
->
m_internal
Name
.
c_str
());
m_globalHash
->
lock
();
impl
.
m_table
->
m_status
=
NdbDictionary
::
Object
::
Invalid
;
m_globalHash
->
drop
(
impl
.
m_table
);
timpl
->
m_status
=
NdbDictionary
::
Object
::
Invalid
;
m_globalHash
->
drop
(
timpl
);
m_globalHash
->
unlock
();
}
return
ret
;
}
m_error
.
code
=
4243
;
return
-
1
;
}
int
...
...
ndb/src/ndbapi/NdbDictionaryImpl.hpp
View file @
cdccc772
...
...
@@ -395,7 +395,8 @@ public:
int
createIndex
(
NdbIndexImpl
&
ix
);
int
dropIndex
(
const
char
*
indexName
,
const
char
*
tableName
);
int
dropIndex
(
NdbIndexImpl
&
,
const
char
*
tableName
);
// int dropIndex(NdbIndexImpl &, const char * tableName);
int
dropIndex
(
NdbIndexImpl
&
);
NdbTableImpl
*
getIndexTable
(
NdbIndexImpl
*
index
,
NdbTableImpl
*
table
);
...
...
@@ -413,6 +414,8 @@ public:
const
BaseString
&
internalTableName
,
bool
do_add_blob_tables
);
NdbIndexImpl
*
getIndex
(
const
char
*
indexName
,
const
char
*
tableName
);
NdbIndexImpl
*
getIndex
(
const
char
*
indexName
,
NdbTableImpl
*
table
);
NdbEventImpl
*
getEvent
(
const
char
*
eventName
);
NdbEventImpl
*
getEventImpl
(
const
char
*
internalName
);
...
...
@@ -694,17 +697,25 @@ NdbDictionaryImpl::get_local_table_info(const BaseString& internalTableName,
return
info
;
// autoincrement already initialized
}
inline
NdbIndexImpl
*
NdbDictionaryImpl
::
getIndex
(
const
char
*
index_name
,
const
char
*
table_name
)
return
getIndex
(
index_name
,
(
table_name
)
?
getTable
(
table_name
)
:
NULL
);
}
inline
NdbIndexImpl
*
NdbDictionaryImpl
::
getIndex
(
const
char
*
index_name
,
NdbTableImpl
*
table
)
{
if
(
table
_name
||
m_ndb
.
usingFullyQualifiedNames
())
if
(
table
||
m_ndb
.
usingFullyQualifiedNames
())
{
{
const
BaseString
internal_indexname
(
(
table
_name
)
(
table
)
?
m_ndb
.
internalize_index_name
(
getTable
(
table_name
)
,
index_name
)
m_ndb
.
internalize_index_name
(
table
,
index_name
)
:
m_ndb
.
internalize_table_name
(
index_name
));
// Index is also a table
...
...
sql/ha_ndbcluster.cc
View file @
cdccc772
...
...
@@ -1028,6 +1028,8 @@ static int fix_unique_index_attr_order(NDB_INDEX_DATA &data,
DBUG_RETURN
(
0
);
}
int
ha_ndbcluster
::
build_index_list
(
Ndb
*
ndb
,
TABLE
*
tab
,
enum
ILBP
phase
)
{
uint
i
;
...
...
@@ -4246,7 +4248,6 @@ int ha_ndbcluster::create_index(const char *name,
DBUG_RETURN
(
0
);
}
/*
Rename a table in NDB Cluster
*/
...
...
@@ -4255,12 +4256,16 @@ int ha_ndbcluster::rename_table(const char *from, const char *to)
{
NDBDICT
*
dict
;
char
new_tabname
[
FN_HEADLEN
];
char
new_dbname
[
FN_HEADLEN
];
const
NDBTAB
*
orig_tab
;
int
result
;
bool
recreate_indexes
=
FALSE
;
NDBDICT
::
List
index_list
;
DBUG_ENTER
(
"ha_ndbcluster::rename_table"
);
DBUG_PRINT
(
"info"
,
(
"Renaming %s to %s"
,
from
,
to
));
set_dbname
(
from
);
set_dbname
(
to
,
new_dbname
);
set_tabname
(
from
);
set_tabname
(
to
,
new_tabname
);
...
...
@@ -4278,6 +4283,12 @@ int ha_ndbcluster::rename_table(const char *from, const char *to)
if
(
!
(
orig_tab
=
dict
->
getTable
(
m_tabname
)))
ERR_RETURN
(
dict
->
getNdbError
());
}
if
(
my_strcasecmp
(
system_charset_info
,
new_dbname
,
m_dbname
))
{
dict
->
listIndexes
(
index_list
,
m_tabname
);
recreate_indexes
=
TRUE
;
}
m_table
=
(
void
*
)
orig_tab
;
// Change current database to that of target table
set_dbname
(
to
);
...
...
@@ -4288,6 +4299,34 @@ int ha_ndbcluster::rename_table(const char *from, const char *to)
result
=
handler
::
rename_table
(
from
,
to
);
}
// If we are moving tables between databases, we need to recreate
// indexes
if
(
recreate_indexes
)
{
const
NDBTAB
*
new_tab
;
set_tabname
(
to
);
if
(
!
(
new_tab
=
dict
->
getTable
(
m_tabname
)))
ERR_RETURN
(
dict
->
getNdbError
());
for
(
unsigned
i
=
0
;
i
<
index_list
.
count
;
i
++
)
{
NDBDICT
::
List
::
Element
&
index_el
=
index_list
.
elements
[
i
];
set_dbname
(
from
);
ndb
->
setDatabaseName
(
m_dbname
);
const
NDBINDEX
*
index
=
dict
->
getIndex
(
index_el
.
name
,
*
new_tab
);
set_dbname
(
to
);
ndb
->
setDatabaseName
(
m_dbname
);
DBUG_PRINT
(
"info"
,
(
"Creating index %s/%s"
,
m_dbname
,
index
->
getName
()));
dict
->
createIndex
(
*
index
);
DBUG_PRINT
(
"info"
,
(
"Dropping index %s/%s"
,
m_dbname
,
index
->
getName
()));
set_dbname
(
from
);
ndb
->
setDatabaseName
(
m_dbname
);
dict
->
dropIndex
(
*
index
);
}
}
DBUG_RETURN
(
result
);
}
...
...
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