Skip to content

Commit ed90484

Browse files
committed
Fix build error with codespace
1 parent 8d1bf5e commit ed90484

File tree

10 files changed

+96
-57
lines changed

10 files changed

+96
-57
lines changed

libspectrum/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,22 @@ SET(SPECTRUM_PB_GENERATE_DIR ${CMAKE_BINARY_DIR}/libspectrum/generated/protobuf)
2727

2828
FILE(MAKE_DIRECTORY ${SPECTRUM_PB_GENERATE_DIR})
2929

30+
FOREACH(warning
31+
"unused-parameter"
32+
"unused-result"
33+
)
34+
MY_CHECK_CXX_COMPILER_WARNING("${warning}" HAS_WARN_FLAG)
35+
IF(HAS_WARN_FLAG)
36+
STRING_APPEND(CMAKE_CXX_FLAGS " ${HAS_WARN_FLAG}")
37+
STRING_APPEND(CMAKE_C_FLAGS " ${HAS_WARN_FLAG}")
38+
ENDIF()
39+
ENDFOREACH()
40+
3041
INCLUDE_DIRECTORIES(
3142
${CMAKE_SOURCE_DIR}/sql
3243
${CMAKE_SOURCE_DIR}/libspectrum/include
3344
${SPECTRUM_PB_GENERATE_DIR}
45+
${RAPIDJSON_INCLUDE_DIR}
3446
)
3547

3648
MYSQL_PROTOBUF_GENERATE_CPP_LIBRARY(

libspectrum/README.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Build
2+
cmake .. -DCMAKE_INSTALL_PREFIX=/home/codespace/mysql-spectrum -DWITH_DEBUG=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/home/codespace/boost
3+
make
4+
make install
5+
16
# Initialize storage server
27
./spectrum-storage-init
38

libspectrum/include/spectrum.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ extern spectrum::StorageNode::Stub* get_storage_primary_client();
154154

155155
extern my_xid next_xid();
156156

157-
extern void spectrum_print_row(char* method, TABLE* table);
158-
extern void spectrum_print_row(char* method, TABLE* table, uchar* record);
157+
extern void spectrum_print_row(const char* method, TABLE* table);
158+
extern void spectrum_print_row(const char* method, TABLE* table, const uchar* record);
159159
extern void spectrum_row_fill_fields(TABLE* table, ::spectrum::Row *spectrum_row);
160-
extern void spectrum_row_fill_fields(TABLE* table, uchar* record, ::spectrum::Row *spectrum_row);
161-
extern void spectrum_row_extract_fields(TABLE *table, ::spectrum::Row *spectrum_row);
162-
extern void spectrum_row_extract_fields(TABLE *table, uchar* record, ::spectrum::Row *spectrum_row);
160+
extern void spectrum_row_fill_fields(TABLE* table, const uchar* record, ::spectrum::Row *spectrum_row);
161+
extern void spectrum_row_extract_fields(TABLE *table, const ::spectrum::Row *spectrum_row);
162+
extern void spectrum_row_extract_fields(TABLE *table, uchar* record, const ::spectrum::Row *spectrum_row);
163163
extern void spectrum_thread_fill(THD *thd, spectrum::Thread *spectrum_thread);
164164

165165
extern TABLE *spectrum_open_table(THD *thd, const char *db_name, const char *table_name, thr_lock_type lock_type, thr_locked_row_action lock_action);

libspectrum/include/spectrum_config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
#define MAX_NODE_ID_LENGTH 256
2525

26+
#include <string>
27+
2628
enum node_role_enum {
2729
COMPUTE,
2830
STORAGE_PRIMARY,

libspectrum/src/spectrum_common.cc

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,18 @@ void spectrum_thread_fill(THD *thd, spectrum::Thread *spectrum_thread) {
112112
spectrum_thread_fill_system_variables(thd, spectrum_thread);
113113
}
114114

115-
void spectrum_print_row(char* method, TABLE* table) {
115+
void spectrum_repoint_field_to_record(TABLE *table, const uchar *old_rec, const uchar *new_rec) {
116+
Field **fields = table->field;
117+
ptrdiff_t ptrdiff = new_rec - old_rec;
118+
for (uint i = 0; i < table->s->fields; i++)
119+
fields[i]->move_field_offset(ptrdiff);
120+
}
121+
122+
void spectrum_print_row(const char* method, TABLE* table) {
116123
spectrum_print_row(method, table, table->record[0]);
117124
}
118125

119-
void spectrum_print_row(char* method, TABLE* table, uchar* record) {
126+
void spectrum_print_row(const char* method, TABLE* table, const uchar* record) {
120127
std::string row;
121128
char value_buffer[1024];
122129
String value(value_buffer, sizeof(value_buffer), &my_charset_bin);
@@ -130,7 +137,7 @@ void spectrum_print_row(char* method, TABLE* table, uchar* record) {
130137

131138
temp_read_set = table->read_set;
132139
table->read_set = nullptr;
133-
repoint_field_to_record(table, table->record[0], record);
140+
spectrum_repoint_field_to_record(table, table->record[0], record);
134141

135142
for (Field **field = table->field; *field; field++) {
136143
row += (*field)->field_name;
@@ -148,19 +155,19 @@ void spectrum_print_row(char* method, TABLE* table, uchar* record) {
148155
}
149156
sql_print_information("%s[%s:%s:%d]: %s", method, table->s->db.str, table->s->table_name.str, hander_id, row.c_str());
150157

151-
repoint_field_to_record(table, record, table->record[0]);
158+
spectrum_repoint_field_to_record(table, record, table->record[0]);
152159
table->read_set = temp_read_set;
153160
}
154161

155162
void spectrum_row_fill_fields(TABLE* table, spectrum::Row *spectrum_row) {
156163
spectrum_row_fill_fields(table, table->record[0], spectrum_row);
157164
}
158165

159-
void spectrum_row_fill_fields(TABLE* table, uchar* record, spectrum::Row *spectrum_row) {
166+
void spectrum_row_fill_fields(TABLE* table, const uchar* record, spectrum::Row *spectrum_row) {
160167
char value_buffer[1024];
161168
String value(value_buffer, sizeof(value_buffer), &my_charset_bin);
162169

163-
repoint_field_to_record(table, table->record[0], record);
170+
spectrum_repoint_field_to_record(table, table->record[0], record);
164171

165172
for (Field **field = table->field; *field; field++) {
166173
spectrum::Field *spectrum_field = spectrum_row->add_fields();
@@ -174,19 +181,19 @@ void spectrum_row_fill_fields(TABLE* table, uchar* record, spectrum::Row *spectr
174181
}
175182
}
176183

177-
repoint_field_to_record(table, record, table->record[0]);
184+
spectrum_repoint_field_to_record(table, record, table->record[0]);
178185
}
179186

180-
void spectrum_row_extract_fields(TABLE *table, spectrum::Row *spectrum_row) {
187+
void spectrum_row_extract_fields(TABLE *table, const spectrum::Row *spectrum_row) {
181188
spectrum_row_extract_fields(table, table->record[0], spectrum_row);
182189
}
183190

184-
void spectrum_row_extract_fields(TABLE *table, uchar* record, spectrum::Row *spectrum_row) {
191+
void spectrum_row_extract_fields(TABLE *table, uchar* record, const spectrum::Row *spectrum_row) {
185192
MY_BITMAP *temp_write_set;
186193

187194
temp_write_set = table->write_set;
188195
table->write_set = nullptr;
189-
repoint_field_to_record(table, table->record[0], record);
196+
spectrum_repoint_field_to_record(table, table->record[0], record);
190197

191198
memset(record, 0, table->s->null_bytes);
192199
for (int i = 0; i < spectrum_row->fields().size(); i++) {
@@ -204,7 +211,7 @@ void spectrum_row_extract_fields(TABLE *table, uchar* record, spectrum::Row *spe
204211
}
205212

206213
table->write_set = temp_write_set;
207-
repoint_field_to_record(table, record, table->record[0]);
214+
spectrum_repoint_field_to_record(table, record, table->record[0]);
208215
}
209216

210217
TABLE *spectrum_open_table(

libspectrum/src/spectrum_compute.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ int spectrum_compute_delete_table(THD *thd, const dd::Table *table_def, const ch
159159
}
160160

161161
const dd::Schema *schema_def = nullptr;
162-
thd->dd_client()->acquire(table_def->schema_id(), &schema_def);
162+
if (thd->dd_client()->acquire(table_def->schema_id(), &schema_def)) {
163+
assert(false);
164+
}
163165
if (!schema_def) {
164166
assert(false);
165167
}
@@ -524,7 +526,7 @@ int spectrum_compute_write_row(THD *thd, TABLE *table, uchar *record) {
524526
sql_print_error("spectrum_write_row[%d:%s:%s:%d]: error=%s", thd->spectrum_thread_id, table->s->db.str, table->s->table_name.str, table->file, status.error_message().c_str());
525527
assert(false);
526528
}
527-
spectrum_row_extract_fields(table, (spectrum::Row *)&response.row());
529+
spectrum_row_extract_fields(table, &response.row());
528530
spectrum_print_row("spectrum_write_row_new", table);
529531

530532
table->file->insert_id_for_cur_row = response.insert_id();
@@ -544,7 +546,7 @@ int spectrum_compute_update_row(THD *thd, TABLE *table, const uchar *old_record,
544546
assert(old_record == table->record[1]);
545547

546548
spectrum_print_row("spectrum_update_row_new", table, new_record);
547-
spectrum_print_row("spectrum_update_row_old", table, (uchar *)old_record);
549+
spectrum_print_row("spectrum_update_row_old", table, old_record);
548550

549551
spectrum::Thread *spectrum_thread = request.mutable_thread();
550552
spectrum_thread_fill(thd, spectrum_thread);
@@ -576,11 +578,11 @@ int spectrum_compute_delete_row(THD *thd, TABLE *table, const uchar *record) {
576578
return 0;
577579
}
578580

579-
spectrum_print_row("spectrum_delete_row", table, (uchar *)record);
581+
spectrum_print_row("spectrum_delete_row", table, record);
580582

581583
spectrum::Thread *spectrum_thread = request.mutable_thread();
582584
spectrum_thread_fill(thd, spectrum_thread);
583-
spectrum_row_fill_fields(table, (uchar *)record, request.mutable_row());
585+
spectrum_row_fill_fields(table, record, request.mutable_row());
584586
request.set_database(table->s->db.str);
585587
request.set_table(table->s->table_name.str);
586588
request.set_handler((uint64)table->file);

libspectrum/src/spectrum_config.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ this program; if not, write to the Free Software Foundation, Inc.,
4242
*****************************************************************************/
4343

4444
#include <vector>
45+
#include <cstring>
46+
#include <cstdlib>
4547

4648
#include "spectrum_config.h"
4749

libspectrum/src/spectrum_log.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ commit_id_t next_commit_id() {
109109
return max_commit_id;
110110
}
111111

112-
commit_id_t update_max_commit_id(commit_id_t commit_id) {
112+
void update_max_commit_id(commit_id_t commit_id) {
113113
mysql_mutex_lock(&max_commit_id_lock);
114114
if (commit_id > max_commit_id) {
115115
max_commit_id = commit_id;
@@ -127,7 +127,7 @@ my_xid next_xid() {
127127
return max_xid;
128128
}
129129

130-
my_xid update_max_xid(my_xid xid) {
130+
void update_max_xid(my_xid xid) {
131131
mysql_mutex_lock(&max_xid_lock);
132132
if (xid > max_xid) {
133133
max_xid = xid;
@@ -287,7 +287,7 @@ int spectrum_log_read_events_by_xid(TABLE *event_table, my_xid xid, spectrum::Ev
287287
event_table->file->ha_index_init(0, true);
288288
error = event_table->file->ha_index_read_map(
289289
event_table->record[0], key, 1, HA_READ_KEY_EXACT);
290-
while(!error && xid == event_table->field[0]->val_int()) {
290+
while(!error && xid == (my_xid)event_table->field[0]->val_int()) {
291291
spectrum_print_row("spectrum_log_read_events_by_xid", event_table);
292292
spectrum_log_build_event(event_table, events->add_event());
293293
error = event_table->file->ha_index_next(event_table->record[0]);
@@ -791,7 +791,6 @@ int spectrum_log_commit(THD *thd, bool all, bool real_trans) {
791791
my_xid xid = storage_thd_context->xid();
792792
event_id_t event_id = storage_thd_context->next_event_id();
793793
commit_id_t commit_id = storage_thd_context->commit_id();
794-
bool commit_locked = false;
795794

796795
sql_print_information("spectrum_log_commit: all=%d, real_trans=%d, xid=%d, commit_id=%d", all, real_trans, xid, commit_id);
797796

@@ -821,7 +820,6 @@ int spectrum_log_rollback(THD *thd, bool all, bool real_trans) {
821820
my_xid xid = storage_thd_context->xid();
822821
event_id_t event_id = storage_thd_context->next_event_id();
823822
commit_id_t commit_id = storage_thd_context->commit_id();
824-
bool commit_locked = false;
825823

826824
sql_print_information("spectrum_log_rollback: all=%d, real_trans=%d, xid=%d, commit_id=%d", all, real_trans, xid, commit_id);
827825

0 commit comments

Comments
 (0)