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

Distributed table creation and drop for generic sharding. #5026

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
20 changes: 10 additions & 10 deletions bdb/bdb_schemachange.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ void bdb_bump_dbopen_gen(scdone_t type, const char *message,
}

static int bdb_scdone_int(bdb_state_type *bdb_state, DB_TXN *txnid,
const char table[], const char *newtable,
const char *table, const char *strarg,
int fastinit)
{
int rc;
char *db_newtable = NULL;
char *db_strarg= NULL;

if (newtable && newtable[0])
db_newtable = strdup(newtable);
if (strarg && strarg[0])
db_strarg = strdup(strarg);

if (bdb_state == NULL)
return 0;
Expand All @@ -161,7 +161,7 @@ static int bdb_scdone_int(bdb_state_type *bdb_state, DB_TXN *txnid,

/* TODO fail gracefully now that inline? */
/* reload the changed table (if necesary) and update the schemas in memory*/
if ((rc = bdb_state->callback->scdone_rtn(bdb_state, table, db_newtable,
if ((rc = bdb_state->callback->scdone_rtn(bdb_state, table, db_strarg,
fastinit))) {
if (rc == BDBERR_DEADLOCK)
rc = DB_LOCK_DEADLOCK;
Expand All @@ -177,7 +177,7 @@ int handle_scdone(DB_ENV *dbenv, u_int32_t rectype, llog_scdone_args *scdoneop,
{
int rc = 0;
const char *table = (const char *)scdoneop->table.data;
const char *newtable = NULL;
const char *strarg = NULL;

uint32_t type;
assert(sizeof(type) == scdoneop->fastinit.size);
Expand All @@ -189,9 +189,9 @@ int handle_scdone(DB_ENV *dbenv, u_int32_t rectype, llog_scdone_args *scdoneop,
TABLENAME_LOCKED_WRITE));
}

if (sctype == rename_table || sctype == alias_table) {
assert(strlen(table) + 1 < scdoneop->table.size);
newtable = &table[strlen(table) + 1];
if (sctype == rename_table || sctype == alias_table ||
(sctype == add && (strlen(table) + 1 < scdoneop->table.size))) {
strarg = &table[strlen(table) + 1];
}

switch (op) {
Expand All @@ -206,7 +206,7 @@ int handle_scdone(DB_ENV *dbenv, u_int32_t rectype, llog_scdone_args *scdoneop,
/* make a copy of the row that's being deleted. */
case DB_TXN_APPLY:
rc = bdb_scdone_int(dbenv->app_private, scdoneop->txnid, table,
newtable, sctype);
strarg, sctype);
break;

case DB_TXN_SNAPISOL:
Expand Down
3 changes: 3 additions & 0 deletions cdb2api/cdb2api.c
Original file line number Diff line number Diff line change
Expand Up @@ -4373,6 +4373,9 @@ static int process_set_command(cdb2_hndl_tp *hndl, const char *sql)
set_tok = set_tok2;
set_tok2 = NULL;
}
} else if (strncasecmp(set_tok, "partition", 9) == 0) {
skip_len += 10;
set_tok = strtok_r(rest, " ", &rest);
}
}
if (!set_tok) {
Expand Down
4 changes: 3 additions & 1 deletion db/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ enum ast_type {
AST_TYPE_UNION = 3,
AST_TYPE_IN = 4,
AST_TYPE_DELETE = 5,
AST_TYPE_UPDATE = 6
AST_TYPE_UPDATE = 6,
AST_TYPE_CREATE = 7,
AST_TYPE_DROP = 8
};

struct Vdbe;
Expand Down
5 changes: 5 additions & 0 deletions db/comdb2.h
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,11 @@ typedef struct dbtable {

/* name of the timepartition, if this is a shard */
const char *timepartition_name;

/* THIS SECTION IS A STUB; TO BE REPLACED BY ACTUAL PARTITION SCHEMA */
/* testgenshard stub */
char *dbnames[4];
/* END: THIS SECTION IS A STUB; TO BE REPLACED BY ACTUAL PARTITION SCHEMA */
} dbtable;

struct dbview {
Expand Down
Loading