TC_ASSERT("db_exec", DB_SUCCESS(res));
memset(query, 0, QUERY_LENGTH);
- sprintf(query, "CREATE INDEX %s.%s TYPE %s;", RELATION_NAME2, g_attribute_set[1], INDEX_BPLUS);
+ snprintf(query, QUERY_LENGTH, "CREATE INDEX %s.%s TYPE %s;", RELATION_NAME2, g_attribute_set[1], INDEX_BPLUS);
res = db_exec(query);
TC_ASSERT("db_exec", DB_SUCCESS(res));
tuple_id_t count;
count = cursor_get_count(g_cursor);
- TC_ASSERT_GEQ("cursor_get_count", count, 0);
+ TC_ASSERT_GT("cursor_get_count", count, 0);
printf("cursor count : %d\n", count);
TC_SUCCESS_RESULT();
relation_release(rel);
}
- if (cursor != NULL) {
- cursor_deinit(cursor);
- }
-
aql_deinit_handle(&handler);
return NULL;
/* Search the last set tuple id and update storage id corresponding it. */
db_result_t cursor_move_last(db_cursor_t *cursor)
{
+ if (!cursor) {
+ return DB_CURSOR_ERROR;
+ }
+
return cursor_move_to(cursor, cursor->cursor_rows - 1);
}
/* Search next set tuple id and update storage id corresponding it. */
db_result_t cursor_move_next(db_cursor_t *cursor)
{
+ if (!cursor) {
+ return DB_CURSOR_ERROR;
+ }
+
return cursor_move_to(cursor, cursor->current_cursor_row + 1);
}
/* Search previous set tuple id and update storage id corresponding it. */
db_result_t cursor_move_prev(db_cursor_t *cursor)
{
+ if (!cursor) {
+ return DB_CURSOR_ERROR;
+ }
+
return cursor_move_to(cursor, cursor->current_cursor_row - 1);
}
return DB_STORAGE_ERROR;
}
if (DB_ERROR(storage_read_from(fd, bucket_file, sizeof(tree_t), sizeof(bucket_file)))) {
+ storage_close(fd);
return DB_STORAGE_ERROR;
}
storage_close(fd);
*/
node = tree_read(tree, id);
if (node == NULL) {
+ free(path);
return NULL;
}
index = id;
if (tree->lock_buckets[node->id[index]]) {
pthread_mutex_unlock(&(tree->bucket_lock));
modify_cache(tree, id, NODE, UNLOCK);
+ free(path);
return NULL;
} else {
tree->lock_buckets[node->id[index]] = 1;
modify_cache(tree, index, NODE, UNLOCK);
}
}
+ free(path);
return NULL;
}
}
snprintf(filename, len, "%s%s\0", rel->name, INDEX_NAME_SUFFIX);
result = storage_remove(filename);
+ free(filename);
if (DB_ERROR(result)) {
DB_LOG_E("DB: Index file unlinking failed\n");
}
break;
}
}
+ cursor_deinit(cursor);
return NULL;
}
return DB_STORAGE_ERROR;
}
- strncpy(rel->name, name, sizeof(rel->name));
+ strncpy(rel->name, name, sizeof(rel->name) - 1);
r = storage_read(fd, rel->tuple_filename, sizeof(rel->tuple_filename));
if (r != sizeof(rel->tuple_filename)) {
}
memcpy(g_storage_write_buffer.buffer + g_storage_write_buffer.data_size, row, length);
g_storage_write_buffer.data_size += length;
- memcpy(g_storage_write_buffer.file_name, filename, strlen(filename));
+ memcpy(g_storage_write_buffer.file_name, filename, strlen(filename) + 1);
#else
if (storage_write(fd, row, length) < 0) {
DB_LOG_D("DB: Failed to store %u bytes\n", length);