Skip to content

Commit

Permalink
[CBRD-24372] Add new client type for loaddb to resolve migration issu…
Browse files Browse the repository at this point in the history
…e by user schema. (#3636)

http://jira.cubrid.org/browse/CBRD-24372

Resolve this issue by removing the system parameter no_user_specified_name and setting DB_CLIENT_TYPE_ADMIN_LOADDB_COMPAT instead of DB_CLIENT_TYPE_ADMIN_UTILITY as the client type in the loaddb utility.
  • Loading branch information
youngjinj authored Jun 15, 2022
1 parent b00cf28 commit f12f4b0
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 44 deletions.
18 changes: 0 additions & 18 deletions src/base/system_parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,8 +709,6 @@ static const char sysprm_ha_conf_file_name[] = "cubrid_ha.conf";
#define PRM_VALUE_MAX "MAX"
#define PRM_VALUE_MIN "MIN"

#define PRM_NAME_NO_USER_SPECIFIED_NAME "no_user_specified_name"

/*
* Note about ERROR_LIST and INTEGER_LIST type
* ERROR_LIST type is an array of bool type with the size of -(ER_LAST_ERROR)
Expand Down Expand Up @@ -2407,10 +2405,6 @@ static int prm_flashback_max_transaction_lower = 1;
static int prm_flashback_max_transaction_upper = INT_MAX;
static unsigned int prm_flashback_max_transaction_flag = 0;

bool PRM_NO_USER_SPECIFIED_NAME = false;
static const bool prm_no_user_specified_name_default = false;
static unsigned int prm_no_user_specified_name_flag = 0;

typedef int (*DUP_PRM_FUNC) (void *, SYSPRM_DATATYPE, void *, SYSPRM_DATATYPE);

static int prm_size_to_io_pages (void *out_val, SYSPRM_DATATYPE out_type, void *in_val, SYSPRM_DATATYPE in_type);
Expand Down Expand Up @@ -6198,18 +6192,6 @@ static SYSPRM_PARAM prm_Def[] = {
(void *) &prm_flashback_max_transaction_lower,
(char *) NULL,
(DUP_PRM_FUNC) NULL,
(DUP_PRM_FUNC) NULL},
{PRM_ID_NO_USER_SPECIFIED_NAME,
PRM_NAME_NO_USER_SPECIFIED_NAME,
(PRM_FOR_CLIENT | PRM_USER_CHANGE | PRM_FOR_SESSION),
PRM_BOOLEAN,
&prm_no_user_specified_name_flag,
(void *) &prm_no_user_specified_name_default,
(void *) &PRM_NO_USER_SPECIFIED_NAME,
(void *) NULL,
(void *) NULL,
(char *) NULL,
(DUP_PRM_FUNC) NULL,
(DUP_PRM_FUNC) NULL}
};

Expand Down
3 changes: 1 addition & 2 deletions src/base/system_parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,8 @@ enum param_id
PRM_ID_THREAD_CORE_COUNT,
PRM_ID_FLASHBACK_TIMEOUT,
PRM_ID_FLASHBACK_MAX_TRANSACTION, /* Hidden parameter For QA test */
PRM_ID_NO_USER_SPECIFIED_NAME,
/* change PRM_LAST_ID when adding new system parameters */
PRM_LAST_ID = PRM_ID_NO_USER_SPECIFIED_NAME
PRM_LAST_ID = PRM_ID_FLASHBACK_MAX_TRANSACTION
};
typedef enum param_id PARAM_ID;

Expand Down
5 changes: 3 additions & 2 deletions src/compat/db_client_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ enum db_client_type
DB_CLIENT_TYPE_RO_BROKER_REPLICA_ONLY = 12,
DB_CLIENT_TYPE_SO_BROKER_REPLICA_ONLY = 13,
DB_CLIENT_TYPE_ADMIN_CSQL_WOS = 14, /* admin csql that can write on standby */
DB_CLIENT_TYPE_SKIP_VACUUM_CSQL = 15,
DB_CLIENT_TYPE_SKIP_VACUUM_ADMIN_CSQL = 16,
DB_CLIENT_TYPE_SKIP_VACUUM_CSQL = 15,
DB_CLIENT_TYPE_SKIP_VACUUM_ADMIN_CSQL = 16,
DB_CLIENT_TYPE_ADMIN_COMPACTDB_WOS = 17, /* admin compactdb that can run on standby */
DB_CLIENT_TYPE_ADMIN_LOADDB_COMPAT = 18, /* loaddb with --no-user-specified-name option */

DB_CLIENT_TYPE_MAX
};
Expand Down
9 changes: 2 additions & 7 deletions src/loaddb/load_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,9 @@ loaddb_internal (UTIL_FUNCTION_ARG * arg, int dba_mode)
/* login */
if (!args.user_name.empty () || !dba_mode)
{
if (strcasecmp (args.user_name.c_str (), "DBA") == 0)
if (strcasecmp (args.user_name.c_str (), "DBA") == 0 && args.no_user_specified_name)
{
db_set_client_type (DB_CLIENT_TYPE_ADMIN_UTILITY);
db_set_client_type (DB_CLIENT_TYPE_ADMIN_LOADDB_COMPAT);
}
(void) db_login (args.user_name.c_str (), args.password.c_str ());
error = db_restart (arg->command_name, true, args.volume.c_str ());
Expand All @@ -548,11 +548,6 @@ loaddb_internal (UTIL_FUNCTION_ARG * arg, int dba_mode)
error = db_restart (arg->command_name, true, args.volume.c_str ());
}
}

if (args.no_user_specified_name)
{
prm_set_bool_value (PRM_ID_NO_USER_SPECIFIED_NAME, true);
}
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/loaddb/load_sa_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,7 @@ ldr_find_class (const char *class_name)
}

/* This is the case when the loaddb utility is executed with the --no-user-specified-name option as the dba user. */
if (db_get_client_type() == DB_CLIENT_TYPE_ADMIN_UTILITY && prm_get_bool_value (PRM_ID_NO_USER_SPECIFIED_NAME))
if (db_get_client_type() == DB_CLIENT_TYPE_ADMIN_LOADDB_COMPAT)
{
char other_class_name[DB_MAX_IDENTIFIER_LENGTH] = { '\0' };

Expand Down
5 changes: 3 additions & 2 deletions src/loaddb/load_server_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,17 @@ namespace cubload
return found;
}

#if defined(SERVER_MODE)
/* This is the case when the loaddb utility is executed with the --no-user-specified-name option as the dba user. */
if (thread_ref.conn_entry->client_type == DB_CLIENT_TYPE_ADMIN_UTILITY
&& prm_get_bool_value (PRM_ID_NO_USER_SPECIFIED_NAME))
if (thread_ref.conn_entry->client_type == DB_CLIENT_TYPE_ADMIN_LOADDB_COMPAT)
{
found_again = locate_class_for_all_users (class_name, class_oid);
if (found_again == LC_CLASSNAME_EXIST)
{
return found_again;
}
}
#endif

return found;
}
Expand Down
5 changes: 0 additions & 5 deletions src/loaddb/load_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,11 +551,6 @@ namespace cubload
{
thread_ref.m_loaddb_driver = m_driver;

if (m_args.no_user_specified_name)
{
prm_set_bool_value (PRM_ID_NO_USER_SPECIFIED_NAME, true);
}

int error_code = NO_ERROR;
bool parser_result = invoke_parser (m_driver, batch);
const class_entry *cls_entry = get_class_registry ().get_class_entry (batch.get_class_id ());
Expand Down
3 changes: 1 addition & 2 deletions src/object/trigger_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -4254,8 +4254,7 @@ tr_find_trigger (const char *name)
if (object == NULL)
{
/* This is the case when the loaddb utility is executed with the --no-user-specified-name option as the dba user. */
if (db_get_client_type () == DB_CLIENT_TYPE_ADMIN_UTILITY
&& prm_get_bool_value (PRM_ID_NO_USER_SPECIFIED_NAME))
if (db_get_client_type () == DB_CLIENT_TYPE_ADMIN_LOADDB_COMPAT)
{
char other_trigger_name[DB_MAX_IDENTIFIER_LENGTH] = { '\0' };

Expand Down
3 changes: 1 addition & 2 deletions src/parser/name_resolution.c
Original file line number Diff line number Diff line change
Expand Up @@ -6029,8 +6029,7 @@ pt_make_flat_name_list (PARSER_CONTEXT * parser, PT_NODE * spec, PT_NODE * spec_
if (au_fetch_class (classop, &class_, fetchmode, type) == NO_ERROR)
{
/* This is the case when the loaddb utility is executed with the --no-user-specified-name option as the dba user. */
if (db_get_client_type () == DB_CLIENT_TYPE_ADMIN_UTILITY
&& prm_get_bool_value (PRM_ID_NO_USER_SPECIFIED_NAME))
if (db_get_client_type () == DB_CLIENT_TYPE_ADMIN_LOADDB_COMPAT)
{
if (intl_identifier_casecmp (class_name, class_->header.ch_name) != 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/parser/semantic_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ pt_check_user_owns_class (PARSER_CONTEXT * parser, PT_NODE * cls_ref)
}

/* This is the case when the loaddb utility is executed with the --no-user-specified-name option as the dba user. */
if (db_get_client_type () == DB_CLIENT_TYPE_ADMIN_UTILITY && prm_get_bool_value (PRM_ID_NO_USER_SPECIFIED_NAME))
if (db_get_client_type () == DB_CLIENT_TYPE_ADMIN_LOADDB_COMPAT)
{
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/query/execute_statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ do_get_serial_obj_id (DB_IDENTIFIER * serial_obj_id, DB_OBJECT * serial_class_mo
}

/* This is the case when the loaddb utility is executed with the --no-user-specified-name option as the dba user. */
if (db_get_client_type () == DB_CLIENT_TYPE_ADMIN_UTILITY && prm_get_bool_value (PRM_ID_NO_USER_SPECIFIED_NAME))
if (db_get_client_type () == DB_CLIENT_TYPE_ADMIN_LOADDB_COMPAT)
{
char other_serial_name[DB_MAX_SERIAL_NAME_LENGTH] = { '\0' };

Expand Down
2 changes: 1 addition & 1 deletion src/transaction/locator_cl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3184,7 +3184,7 @@ locator_find_class_with_purpose (const char *classname, bool for_update)
}

/* This is the case when the loaddb utility is executed with the --no-user-specified-name option as the dba user. */
if (db_get_client_type () == DB_CLIENT_TYPE_ADMIN_UTILITY && prm_get_bool_value (PRM_ID_NO_USER_SPECIFIED_NAME))
if (db_get_client_type () == DB_CLIENT_TYPE_ADMIN_LOADDB_COMPAT)
{
char other_class_name[DB_MAX_IDENTIFIER_LENGTH] = { '\0' };

Expand Down

0 comments on commit f12f4b0

Please sign in to comment.