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
ac64c00d
Commit
ac64c00d
authored
Jul 29, 2004
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge mskold@bk-internal.mysql.com:/home/bk/mysql-4.1-ndb
into mysql.com:/usr/local/home/marty/MySQL/mysql-4.1-ndb
parents
bd96e742
d8265499
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
10 deletions
+53
-10
ndb/include/ndbapi/Ndb.hpp
ndb/include/ndbapi/Ndb.hpp
+3
-3
ndb/src/ndbapi/Ndb.cpp
ndb/src/ndbapi/Ndb.cpp
+40
-6
sql/ha_ndbcluster.cc
sql/ha_ndbcluster.cc
+10
-1
No files found.
ndb/include/ndbapi/Ndb.hpp
View file @
ac64c00d
...
...
@@ -1415,11 +1415,11 @@ public:
* @return tuple id or 0 on error
*/
Uint64
getAutoIncrementValue
(
const
char
*
aTableName
,
Uint32
cacheSize
=
1
);
bool
setAutoIncrementValue
(
const
char
*
aTableName
,
Uint64
val
);
bool
setAutoIncrementValue
(
const
char
*
aTableName
,
Uint64
val
,
bool
increase
=
false
);
Uint64
getTupleIdFromNdb
(
const
char
*
aTableName
,
Uint32
cacheSize
=
1000
);
Uint64
getTupleIdFromNdb
(
Uint32
aTableId
,
Uint32
cacheSize
=
1000
);
bool
setTupleIdInNdb
(
const
char
*
aTableName
,
Uint64
val
);
bool
setTupleIdInNdb
(
Uint32
aTableId
,
Uint64
val
);
bool
setTupleIdInNdb
(
const
char
*
aTableName
,
Uint64
val
,
bool
increase
=
false
);
bool
setTupleIdInNdb
(
Uint32
aTableId
,
Uint64
val
,
bool
increase
=
false
);
Uint64
opTupleIdOnNdb
(
Uint32
aTableId
,
Uint64
opValue
,
Uint32
op
);
#endif
...
...
ndb/src/ndbapi/Ndb.cpp
View file @
ac64c00d
...
...
@@ -759,30 +759,47 @@ Ndb::getTupleIdFromNdb(Uint32 aTableId, Uint32 cacheSize )
}
bool
Ndb
::
setAutoIncrementValue
(
const
char
*
aTableName
,
Uint64
val
)
Ndb
::
setAutoIncrementValue
(
const
char
*
aTableName
,
Uint64
val
,
bool
increase
)
{
DEBUG_TRACE
(
"setAutoIncrementValue "
<<
val
);
const
NdbTableImpl
*
table
=
theDictionary
->
getTable
(
aTableName
);
if
(
table
==
0
)
return
false
;
return
setTupleIdInNdb
(
table
->
m_tableId
,
val
);
return
setTupleIdInNdb
(
table
->
m_tableId
,
val
,
increase
);
}
bool
Ndb
::
setTupleIdInNdb
(
const
char
*
aTableName
,
Uint64
val
)
Ndb
::
setTupleIdInNdb
(
const
char
*
aTableName
,
Uint64
val
,
bool
increase
)
{
DEBUG_TRACE
(
"setTupleIdInNdb"
);
const
NdbTableImpl
*
table
=
theDictionary
->
getTable
(
aTableName
);
if
(
table
==
0
)
return
false
;
return
setTupleIdInNdb
(
table
->
m_tableId
,
val
);
return
setTupleIdInNdb
(
table
->
m_tableId
,
val
,
increase
);
}
bool
Ndb
::
setTupleIdInNdb
(
Uint32
aTableId
,
Uint64
val
)
Ndb
::
setTupleIdInNdb
(
Uint32
aTableId
,
Uint64
val
,
bool
increase
)
{
DEBUG_TRACE
(
"setTupleIdInNdb"
);
return
(
opTupleIdOnNdb
(
aTableId
,
val
,
1
)
==
val
);
if
(
increase
)
{
if
(
theFirstTupleId
[
aTableId
]
!=
theLastTupleId
[
aTableId
])
{
// We have a cache sequence
if
(
val
<=
theFirstTupleId
[
aTableId
]
+
1
)
return
true
;
if
(
val
<=
theLastTupleId
[
aTableId
])
{
theFirstTupleId
[
aTableId
]
=
val
-
1
;
return
true
;
}
// else continue;
}
return
(
opTupleIdOnNdb
(
aTableId
,
val
,
2
)
==
val
);
}
else
return
(
opTupleIdOnNdb
(
aTableId
,
val
,
1
)
==
val
);
}
Uint64
...
...
@@ -845,6 +862,23 @@ Ndb::opTupleIdOnNdb(Uint32 aTableId, Uint64 opValue, Uint32 op)
tOperation
->
equal
(
"SYSKEY_0"
,
aTableId
);
tOperation
->
setValue
(
"NEXTID"
,
opValue
);
if
(
tConnection
->
execute
(
Commit
)
==
-
1
)
goto
error_handler
;
theFirstTupleId
[
aTableId
]
=
~
0
;
theLastTupleId
[
aTableId
]
=
~
0
;
ret
=
opValue
;
break
;
case
2
:
tOperation
->
interpretedUpdateTuple
();
tOperation
->
equal
(
"SYSKEY_0"
,
aTableId
);
tOperation
->
load_const_u64
(
1
,
opValue
);
tOperation
->
read_attr
(
"NEXTID"
,
2
);
tOperation
->
branch_le
(
2
,
1
,
0
);
tOperation
->
write_attr
(
"NEXTID"
,
1
);
tOperation
->
def_label
(
0
);
tOperation
->
interpret_exit_ok
();
if
(
tConnection
->
execute
(
Commit
)
==
-
1
)
goto
error_handler
;
...
...
sql/ha_ndbcluster.cc
View file @
ac64c00d
...
...
@@ -1281,6 +1281,7 @@ int ha_ndbcluster::define_read_attrs(byte* buf, NdbOperation* op)
int
ha_ndbcluster
::
write_row
(
byte
*
record
)
{
bool
has_auto_increment
;
uint
i
;
NdbConnection
*
trans
=
m_active_trans
;
NdbOperation
*
op
;
...
...
@@ -1290,7 +1291,8 @@ int ha_ndbcluster::write_row(byte *record)
statistic_increment
(
ha_write_count
,
&
LOCK_status
);
if
(
table
->
timestamp_default_now
)
update_timestamp
(
record
+
table
->
timestamp_default_now
-
1
);
if
(
table
->
next_number_field
&&
record
==
table
->
record
[
0
])
has_auto_increment
=
(
table
->
next_number_field
&&
record
==
table
->
record
[
0
]);
if
(
has_auto_increment
)
update_auto_increment
();
if
(
!
(
op
=
trans
->
getNdbOperation
(
m_tabname
)))
...
...
@@ -1344,6 +1346,13 @@ int ha_ndbcluster::write_row(byte *record)
if
(
trans
->
execute
(
NoCommit
)
!=
0
)
DBUG_RETURN
(
ndb_err
(
trans
));
}
if
(
(
has_auto_increment
)
&&
(
!
auto_increment_column_changed
)
)
{
Uint64
next_val
=
(
Uint64
)
table
->
next_number_field
->
val_int
()
+
1
;
DBUG_PRINT
(
"info"
,
(
"Setting next auto increment value to %u"
,
next_val
));
m_ndb
->
setAutoIncrementValue
(
m_tabname
,
next_val
,
true
);
}
DBUG_RETURN
(
0
);
}
...
...
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