Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New remsql version (standalone queries only) that runs over cdb2api. #4631

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions cdb2api/cdb2api.c
Original file line number Diff line number Diff line change
Expand Up @@ -4347,20 +4347,22 @@ static int process_set_command(cdb2_hndl_tp *hndl, const char *sql)
char *dup_sql = strdup(sql + skip_len);
char *rest = NULL;
char *set_tok = strtok_r(dup_sql, " ", &rest);
/* special case for spversion */
if (set_tok && strcasecmp(set_tok, "spversion") == 0) {
skip_len += 10;
set_tok = strtok_r(rest, " ", &rest);
}
/* special case for transaction chunk */
if (set_tok && strncasecmp(set_tok, "transaction", 11) == 0) {
char *set_tok2 = strtok_r(rest, " ", &rest);
if (set_tok2 && strncasecmp(set_tok2, "chunk", 5) == 0) {
/* skip "transaction" if chunk, set we can set
* both transaction and chunk mode
*/
skip_len += 12;
set_tok = set_tok2;
if (set_tok) {
/* special case for spversion */
if (strcasecmp(set_tok, "spversion") == 0) {
skip_len += 10;
set_tok = strtok_r(rest, " ", &rest);
/* special case for transaction chunk */
} else if (strncasecmp(set_tok, "transaction", 11) == 0) {
char *set_tok2 = strtok_r(rest, " ", &rest);
if (set_tok2 && strncasecmp(set_tok2, "chunk", 5) == 0) {
/* skip "transaction" if chunk, set we can set
* both transaction and chunk mode
*/
skip_len += 12;
set_tok = set_tok2;
set_tok2 = NULL;
}
}
}
if (!set_tok) {
Expand Down
12 changes: 12 additions & 0 deletions db/comdb2.h
Original file line number Diff line number Diff line change
Expand Up @@ -3684,9 +3684,21 @@ extern int gbl_server_admin_mode;

void csc2_free_all(void);

int fdb_default_ver_set(int val);

/* hack to temporary allow bools on production stage */
void csc2_allow_bools(void);
void csc2_disallow_bools(void);
int csc2_used_bools(void);

/* Skip spaces and tabs, requires at least one space */
static inline char *skipws(char *str)
{
if (str) {
while (*str && isspace(*str))
str++;
}
return str;
}

#endif /* !INCLUDED_COMDB2_H */
14 changes: 14 additions & 0 deletions db/db_tunables.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ extern int gbl_sparse_lockerid_map;
extern int gbl_spstrictassignments;
extern int gbl_early;
extern int gbl_exit_alarm_sec;
extern int gbl_fdb_default_ver;
extern int gbl_fdb_track;
extern int gbl_fdb_track_hints;
extern int gbl_forbid_ulonglong;
Expand All @@ -101,6 +102,7 @@ extern int gbl_fdb_allow_cross_classes;
extern int gbl_fdb_resolve_local;
extern int gbl_fdb_push_redirect_foreign;
extern int gbl_fdb_push_remote;
extern int gbl_fdb_remsql_cdb2api;
extern int gbl_goslow;
extern int gbl_heartbeat_send;
extern int gbl_keycompr;
Expand Down Expand Up @@ -316,6 +318,7 @@ extern int gbl_ufid_dbreg_test;
extern int gbl_debug_add_replication_latency;
extern int gbl_javasp_early_release;
extern int gbl_debug_drop_nth_rep_message;
extern int gbl_fdb_emulate_old;

extern long long sampling_threshold;

Expand Down Expand Up @@ -1058,6 +1061,17 @@ static int hostname_update(void *context, void *value)
return 0;
}

static int fdb_default_ver_update(void *context, void *value)
{
comdb2_tunable *tunable = (comdb2_tunable *)context;
int val = *(int*)value;
if (fdb_default_ver_set(val))
return -1;
*(int*)tunable->var = val;
return 0;
}


/* Forward declaration */
int ctrace_set_rollat(void *unused, void *value);

Expand Down
15 changes: 15 additions & 0 deletions db/db_tunables.h
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,15 @@ REGISTER_TUNABLE("exclusive_blockop_qconsume", "Enables serialization of blockop
REGISTER_TUNABLE("exitalarmsec", NULL, TUNABLE_INTEGER, &gbl_exit_alarm_sec, READONLY, NULL, NULL, NULL, NULL);
REGISTER_TUNABLE("exit_on_internal_failure", NULL, TUNABLE_BOOLEAN, &gbl_exit_on_internal_error, READONLY | NOARG, NULL,
NULL, NULL, NULL);
REGISTER_TUNABLE("fdb_version_emulate_precdbapi",
"Testing setting: cdb2api will refuse to parse remsql SET, emulating"
" a pre-cdb2api remsql implementation",
TUNABLE_INTEGER, &gbl_fdb_emulate_old, 0, NULL,
NULL, NULL, NULL);
REGISTER_TUNABLE("fdb_default_version",
"Override the default fdb version",
TUNABLE_INTEGER, &gbl_fdb_default_ver, 0, NULL, NULL,
fdb_default_ver_update, NULL);
REGISTER_TUNABLE("fdbdebg", NULL, TUNABLE_INTEGER, &gbl_fdb_track, 0, NULL, NULL, NULL, NULL);
REGISTER_TUNABLE("fdbtrackhints", NULL, TUNABLE_INTEGER, &gbl_fdb_track_hints, READONLY, NULL, NULL, NULL, NULL);
REGISTER_TUNABLE("forbid_ulonglong", "Disallow u_longlong. (Default: on)", TUNABLE_BOOLEAN, &gbl_forbid_ulonglong,
Expand All @@ -545,6 +554,9 @@ REGISTER_TUNABLE("foreign_db_push_remote", NULL, TUNABLE_BOOLEAN, &gbl_fdb_push_
REGISTER_TUNABLE("foreign_db_push_redirect",
"Redirect fdb query to run via client instead of on server. (Default: off)", TUNABLE_BOOLEAN,
&gbl_fdb_push_redirect_foreign, NOARG, NULL, NULL, NULL, NULL);
REGISTER_TUNABLE("foreign_db_resolve_local", NULL, TUNABLE_BOOLEAN,
&gbl_fdb_resolve_local, READONLY | NOARG | READEARLY, NULL,
NULL, NULL, NULL);
REGISTER_TUNABLE("foreign_db_auth_enabled", "Redirect extern auth data to remote server. (Default: on)",
TUNABLE_BOOLEAN, &gbl_fdb_auth_enabled, NOARG, NULL, NULL, NULL, NULL);
REGISTER_TUNABLE("fullrecovery",
Expand Down Expand Up @@ -2368,6 +2380,9 @@ REGISTER_TUNABLE("fdb_io_error_retries_phase_1", "Number of immediate retries; c
REGISTER_TUNABLE("fdb_io_error_retries_phase_2_poll",
"Poll initial value for slow retries in phase 2; doubled for each retry", TUNABLE_INTEGER,
&gbl_fdb_io_error_retries_phase_2_poll, 0, NULL, NULL, NULL, NULL);
REGISTER_TUNABLE("fdb_remsql_cdb2api",
"Switch the standalone remote sql queries to cdb2api",
TUNABLE_BOOLEAN, &gbl_fdb_remsql_cdb2api, 0, NULL, NULL, NULL, NULL);
REGISTER_TUNABLE("unexpected_last_type_warn",
"print a line of trace if the last response server sent before sockpool reset isn't LAST_ROW",
TUNABLE_INTEGER, &gbl_unexpected_last_type_warn, EXPERIMENTAL | INTERNAL, NULL, NULL, NULL, NULL);
Expand Down
Loading