Skip to content

Commit c7f17bd

Browse files
committed
error code cleanups
1 parent 25f4957 commit c7f17bd

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

handlersocket/database.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ dbcontext::cmd_insert_internal(dbcallback_i& cb, const prep_stmt& pst,
650650
}
651651
lock_tables_if();
652652
if (lock == 0) {
653-
return cb.dbcb_resp_short(2, "lock_tables");
653+
return cb.dbcb_resp_short(1, "lock_tables");
654654
}
655655
if (pst.get_table_id() >= table_vec.size()) {
656656
return cb.dbcb_resp_short(2, "tblnum");
@@ -680,7 +680,10 @@ dbcontext::cmd_insert_internal(dbcallback_i& cb, const prep_stmt& pst,
680680
if (r == 0 && table->found_next_number_field != 0) {
681681
return cb.dbcb_resp_short_num64(0, insert_id);
682682
}
683-
return cb.dbcb_resp_short(r != 0 ? 1 : 0, "");
683+
if (r != 0) {
684+
return cb.dbcb_resp_short_num(1, r);
685+
}
686+
return cb.dbcb_resp_short(0, "");
684687
}
685688

686689
void
@@ -722,7 +725,7 @@ dbcontext::cmd_find_internal(dbcallback_i& cb, const prep_stmt& pst,
722725
}
723726
lock_tables_if();
724727
if (lock == 0) {
725-
return cb.dbcb_resp_short(2, "lock_tables");
728+
return cb.dbcb_resp_short(1, "lock_tables");
726729
}
727730
if (pst.get_table_id() >= table_vec.size()) {
728731
return cb.dbcb_resp_short(2, "tblnum");
@@ -844,7 +847,7 @@ dbcontext::cmd_find_internal(dbcallback_i& cb, const prep_stmt& pst,
844847
/* revert dbcb_resp_begin() and dbcb_resp_entry() */
845848
cb.dbcb_resp_cancel();
846849
}
847-
cb.dbcb_resp_short_num(2, r);
850+
cb.dbcb_resp_short_num(1, r);
848851
} else {
849852
/* succeeded */
850853
if (need_resp_record) {
@@ -1004,7 +1007,7 @@ dbcontext::cmd_open_index(dbcallback_i& cb, size_t pst_id, const char *dbn,
10041007
DENA_VERBOSE(10, fprintf(stderr,
10051008
"HNDSOCK failed to open %p [%s] [%s] [%d]\n",
10061009
thd, dbn, tbl, static_cast<int>(refresh)));
1007-
return cb.dbcb_resp_short(2, "open_table");
1010+
return cb.dbcb_resp_short(1, "open_table");
10081011
}
10091012
statistic_increment(open_tables_count, &LOCK_status);
10101013
table->reginfo.lock_type = lock_type;
@@ -1113,7 +1116,7 @@ dbcontext::cmd_exec_on_index(dbcallback_i& cb, const cmd_exec_args& args)
11131116
wrop = db_write_op_sql;
11141117
break;
11151118
default:
1116-
return cb.dbcb_resp_short(1, "op");
1119+
return cb.dbcb_resp_short(2, "op");
11171120
}
11181121
} else if (args.op.size() == 2 && args.op.begin()[1] == '=') {
11191122
switch (args.op.begin()[0]) {
@@ -1124,10 +1127,10 @@ dbcontext::cmd_exec_on_index(dbcallback_i& cb, const cmd_exec_args& args)
11241127
find_flag = HA_READ_KEY_OR_PREV;
11251128
break;
11261129
default:
1127-
return cb.dbcb_resp_short(1, "op");
1130+
return cb.dbcb_resp_short(2, "op");
11281131
}
11291132
} else {
1130-
return cb.dbcb_resp_short(1, "op");
1133+
return cb.dbcb_resp_short(2, "op");
11311134
}
11321135
if (args.kvalslen <= 0) {
11331136
return cb.dbcb_resp_short(2, "klen");

handlersocket/hstcpsvr_worker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ hstcpsvr_worker::do_authorization(char *start, char *finish,
880880
char *wp = key_begin;
881881
unescape_string(wp, key_begin, key_end);
882882
if (authtype_len != 1 || authtype_begin[0] != '1') {
883-
return conn.dbcb_resp_short(2, "authtype");
883+
return conn.dbcb_resp_short(3, "authtype");
884884
}
885885
if (cshared.plain_secret.size() == key_len &&
886886
memcmp(cshared.plain_secret.data(), key_begin, key_len) == 0) {

0 commit comments

Comments
 (0)