void BTree::AddKey (const Clave &k)
{
uint left, right;
- Clave *kout = AddKeyR (&k, 0, left, right);
+ Clave *kout;
+
+ try {
+ kout = AddKeyR (k.Clone (), 0, left, right);
+ } catch (Exception *e) {
+ throw e;
+ }
if (kout) {
unsigned short level;
ReadNodoHeader (node, &node_header);
delete [] node;
- if (node_header.level == 0)
- return AddKeyLeafR (k, node_num, left_child, right_child);
+ if (node_header.level == 0) {
+ try {
+ return AddKeyLeafR (k, node_num, left_child, right_child);
+ } catch (Exception *e) {
+ throw e;
+ }
+ }
- return AddKeyOtherR (k, node_num, left_child, right_child);
+ try {
+ return AddKeyOtherR (k, node_num, left_child, right_child);
+ } catch (Exception *e) {
+ throw e;
+ }
}
Clave* BTree::AddKeyLeafR (const Clave *k, uint node_num, uint &left_child, uint &right_child)
while (it != node_keys.end ()) {
datait = (*it);
+ if (tree_type == TYPE_UNIQUE) {
+ /* Verifico que la clave no existea ya en el arbol */
+ if ((*data) == (*datait)) {
+ throw new AddException ();
+ return NULL;
+ }
+ }
+
if ((*data) < (*datait))
/* Me pase, lo agrego aca! */
break;
while (it != node_keys.end ()) {
BTreeData *datait;
datait = (*it);
+ if (tree_type == TYPE_UNIQUE) {
+ /* Verifico que la clave no existea ya en el arbol */
+ if ((*data) == (*datait)) {
+ throw new AddException ();
+ return NULL;
+ }
+ }
if ((*data) < (*datait))
/* Me pase, lo agrego aca! */
break;
posterior = it;
while (it != node_keys.end ()) {
+ if (tree_type == TYPE_UNIQUE) {
+ /* Verifico que la clave no existea ya en el arbol */
+ if ((*data) == (*(*it))) {
+ throw new AddException ();
+ return NULL;
+ }
+ }
if ((*data) < (*(*it)))
break;
ultima = it;
while (it != node_keys.end ()) {
datait = (*it);
+ if (tree_type == TYPE_UNIQUE) {
+ /* Verifico que la clave no existea ya en el arbol */
+ if ((*data) == (*datait)) {
+ throw new AddException ();
+ return NULL;
+ }
+ }
if ((*data) < (*datait))
/* Me pase, lo agrego aca! */
break;
while (it != node_keys.end ()) {
BTreeData *datait;
datait = (*it);
+ if (tree_type == TYPE_UNIQUE) {
+ /* Verifico que la clave no existea ya en el arbol */
+ if ((*data) == (*datait)) {
+ throw new AddException ();
+ return NULL;
+ }
+ }
if ((*data) < (*datait))
/* Me pase, lo agrego aca! */
break;