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

Remtrancdb2api #4717

Closed
wants to merge 21 commits into from
Closed
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
1 change: 1 addition & 0 deletions db/comdb2.h
Original file line number Diff line number Diff line change
Expand Up @@ -3687,6 +3687,7 @@ extern int gbl_server_admin_mode;
void csc2_free_all(void);

int fdb_default_ver_set(int val);
int fdb_push_write_set(int val);

/* hack to temporary allow bools on production stage */
void csc2_allow_bools(void);
Expand Down
12 changes: 12 additions & 0 deletions db/db_tunables.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,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_push_remote_write;
extern int gbl_fdb_remsql_cdb2api;
extern int gbl_goslow;
extern int gbl_heartbeat_send;
Expand Down Expand Up @@ -1085,6 +1086,17 @@ static int fdb_default_ver_update(void *context, void *value)
return 0;
}

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



/* Forward declaration */
int ctrace_set_rollat(void *unused, void *value);
Expand Down
3 changes: 2 additions & 1 deletion db/db_tunables.h
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,10 @@ REGISTER_TUNABLE("foreign_db_allow_cross_class", NULL, TUNABLE_BOOLEAN, &gbl_fdb
REGISTER_TUNABLE("foreign_db_resolve_local", NULL, TUNABLE_BOOLEAN, &gbl_fdb_resolve_local,
READONLY | NOARG | READEARLY, NULL, NULL, NULL, NULL);
REGISTER_TUNABLE("foreign_db_push_remote", NULL, TUNABLE_BOOLEAN, &gbl_fdb_push_remote, NOARG, NULL, NULL, NULL, NULL);
REGISTER_TUNABLE("foreign_db_push_remote_write", NULL, TUNABLE_BOOLEAN, &gbl_fdb_push_remote_write, NOARG, NULL, NULL, NULL, NULL);
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);
&gbl_fdb_push_redirect_foreign, NOARG, NULL, NULL, fdb_push_write_update, NULL);
REGISTER_TUNABLE("foreign_db_resolve_local", NULL, TUNABLE_BOOLEAN,
&gbl_fdb_resolve_local, READONLY | NOARG | READEARLY, NULL,
NULL, NULL, NULL);
Expand Down
61 changes: 46 additions & 15 deletions db/dohast.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "ast.h"
#include "dohsql.h"
#include "sql.h"
#include "fdb_fend.h"

int gbl_dohast_disable = 0;
int gbl_dohast_verbose = 0;
Expand Down Expand Up @@ -947,36 +948,66 @@ int comdb2_check_parallel(Parse *pParse)
return 0;
}

int comdb2_check_push_remote(Parse *pParse)
ast_node_t *_get_ast_node(Parse *pParse)
{
if (comdb2IsPrepareOnly(pParse))
return 0;
return NULL;

if (pParse->explain)
return NULL;

ast_t *ast = pParse->ast;
dohsql_node_t *node;

GET_CLNT;
if (!gbl_fdb_push_remote && !clnt->force_fdb_push_remote && !clnt->force_fdb_push_redirect)
if (ast && ast->unsupported)
return NULL;
if (!ast->stack[0].obj)
return NULL;

return ast->stack;
}

int comdb2_check_push_remote(Parse *pParse)
{
if (has_parallel_sql(NULL) == 0)
return 0;

if (ast && ast->unsupported)
ast_node_t * anode = _get_ast_node(pParse);
if (!anode)
return 0;
if (has_parallel_sql(NULL) == 0)

if (anode->op != AST_TYPE_SELECT)
return 0;
if (ast->nused > 1)

if (pParse->ast->nused > 1)
return 0;
if (!ast->stack[0].obj)

dohsql_node_t *node = (dohsql_node_t*)anode->obj;

if (node->remotedb > 1)
if (!fdb_push_setup(pParse, node))
return 1;

return 0;
}

int comdb2_check_push_remote_write(Parse *pParse)
{
ast_node_t *anode = _get_ast_node(pParse);
if (!anode)
return 0;

node = (dohsql_node_t *)ast->stack[0].obj;
if (anode->op != AST_TYPE_INSERT &&
anode->op != AST_TYPE_DELETE &&
anode->op != AST_TYPE_UPDATE)
return 0;

if (node->type != AST_TYPE_SELECT)
Table *pTab = (Table*)anode->obj;
if (!pTab)
return 0;

if (!pParse->explain)
if (node->remotedb > 1)
if (!fdb_push_run(pParse, node))
return 1;
if (pTab->iDb > 1)
if (!fdb_push_write_setup(pParse, anode->op, pTab))
return 1;
return 0;
}

Expand Down
1 change: 1 addition & 0 deletions db/fdb_comm.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <sbuf2.h>
#include "comdb2.h"
#include "sql.h"
#include "fdb_fend.h"

enum {
/* all previous versions 0-4 are legacy and reserved */
Expand Down
Loading