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
8ad0e2a2
Commit
8ad0e2a2
authored
Jul 02, 2004
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for update of pk
parent
1ed75f56
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
10 deletions
+50
-10
mysql-test/r/ndb_basic.result
mysql-test/r/ndb_basic.result
+13
-3
mysql-test/t/ndb_basic.test
mysql-test/t/ndb_basic.test
+8
-3
sql/ha_ndbcluster.cc
sql/ha_ndbcluster.cc
+29
-4
No files found.
mysql-test/r/ndb_basic.result
View file @
8ad0e2a2
...
...
@@ -3,25 +3,35 @@ CREATE TABLE t1 (
pk1 INT NOT NULL PRIMARY KEY,
attr1 INT NOT NULL
) ENGINE=ndbcluster;
INSERT INTO t1 VALUES (9410,9412);
INSERT INTO t1 VALUES (9410,9412)
,(9411,9413)
;
SELECT pk1 FROM t1;
pk1
9410
9411
SELECT * FROM t1;
pk1 attr1
9410 9412
9411 9413
SELECT t1.* FROM t1;
pk1 attr1
9410 9412
9411 9413
UPDATE t1 SET attr1=1 WHERE pk1=9410;
SELECT * FROM t1;
pk1 attr1
9410 1
9411 9413
UPDATE t1 SET pk1=2 WHERE attr1=1;
ERROR 42000: Table 't1' uses an extension that doesn't exist in this MySQL version
SELECT * FROM t1;
pk1 attr1
9410 1
2 1
9411 9413
UPDATE t1 SET pk1=2 WHERE attr1=9413;
ERROR 23000: Can't write; duplicate key in table 't1'
SELECT * FROM t1;
pk1 attr1
2 1
9411 9413
DELETE FROM t1;
SELECT * FROM t1;
pk1 attr1
...
...
mysql-test/t/ndb_basic.test
View file @
8ad0e2a2
...
...
@@ -17,7 +17,7 @@ CREATE TABLE t1 (
attr1
INT
NOT
NULL
)
ENGINE
=
ndbcluster
;
INSERT
INTO
t1
VALUES
(
9410
,
9412
);
INSERT
INTO
t1
VALUES
(
9410
,
9412
)
,(
9411
,
9413
)
;
SELECT
pk1
FROM
t1
;
SELECT
*
FROM
t1
;
...
...
@@ -27,11 +27,16 @@ SELECT t1.* FROM t1;
UPDATE
t1
SET
attr1
=
1
WHERE
pk1
=
9410
;
SELECT
*
FROM
t1
;
# Can't UPDATE PK! Test that correct error is returned
--
error
1112
# Update pk
UPDATE
t1
SET
pk1
=
2
WHERE
attr1
=
1
;
SELECT
*
FROM
t1
;
# Try to set same pk
# 1022: Can't write; duplicate key in table 't1'
--
error
1022
UPDATE
t1
SET
pk1
=
2
WHERE
attr1
=
9413
;
SELECT
*
FROM
t1
;
# Delete the record
DELETE
FROM
t1
;
SELECT
*
FROM
t1
;
...
...
sql/ha_ndbcluster.cc
View file @
8ad0e2a2
...
...
@@ -866,7 +866,8 @@ int ha_ndbcluster::ordered_index_scan(const key_range *start_key,
index_name
=
get_index_name
(
active_index
);
if
(
!
(
op
=
trans
->
getNdbIndexScanOperation
(
index_name
,
m_tabname
)))
ERR_RETURN
(
trans
->
getNdbError
());
if
(
!
(
cursor
=
op
->
readTuples
(
get_ndb_lock_type
(
m_lock
.
type
),
0
,
parallelism
)))
if
(
!
(
cursor
=
op
->
readTuples
(
get_ndb_lock_type
(
m_lock
.
type
),
0
,
parallelism
)))
//, sorted))) // Bug
ERR_RETURN
(
trans
->
getNdbError
());
m_active_cursor
=
cursor
;
...
...
@@ -1173,8 +1174,30 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data)
/* Check for update of primary key and return error */
if
((
table
->
primary_key
!=
MAX_KEY
)
&&
(
key_cmp
(
table
->
primary_key
,
old_data
,
new_data
)))
DBUG_RETURN
(
HA_ERR_UNSUPPORTED
);
{
DBUG_PRINT
(
"info"
,
(
"primary key update, doing insert + delete"
));
int
insert_res
=
write_row
(
new_data
);
if
(
!
insert_res
)
{
DBUG_PRINT
(
"info"
,
(
"delete succeded"
));
int
delete_res
=
delete_row
(
old_data
);
if
(
!
delete_res
)
{
DBUG_PRINT
(
"info"
,
(
"insert + delete succeeded"
));
DBUG_RETURN
(
0
);
}
else
{
DBUG_PRINT
(
"info"
,
(
"delete failed"
));
DBUG_RETURN
(
delete_row
(
new_data
));
}
}
else
{
DBUG_PRINT
(
"info"
,
(
"insert failed"
));
DBUG_RETURN
(
insert_res
);
}
}
if
(
cursor
)
{
/*
...
...
@@ -2600,10 +2623,12 @@ int ndbcluster_drop_database(const char *path)
longlong
ha_ndbcluster
::
get_auto_increment
()
{
DBUG_ENTER
(
"get_auto_increment"
);
DBUG_PRINT
(
"enter"
,
(
"m_tabname: %s"
,
m_tabname
));
int
cache_size
=
rows_to_insert
?
rows_to_insert
:
32
;
Uint64
auto_value
=
m_ndb
->
getAutoIncrementValue
(
m_tabname
,
cache_size
);
return
(
longlong
)
auto_value
;
DBUG_RETURN
((
longlong
)
auto_value
)
;
}
...
...
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