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

[CBRD-25771] Add -i option to DIAGDB for input file and update usage message #5743

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
2 changes: 2 additions & 0 deletions src/executables/util_admin.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ static UTIL_ARG_MAP ua_Diag_Option_Map[] = {
{DIAG_OUTPUT_FILE_S, {ARG_STRING}, {0}},
{DIAG_EMERGENCY_S, {ARG_BOOLEAN}, {0}},
{DIAG_CLASS_NAME_S, {ARG_STRING}, {0}},
{DIAG_INPUT_FILE_S, {ARG_STRING}, {0}},
{0, {0}, {0}}
};

Expand All @@ -329,6 +330,7 @@ static GETOPT_LONG ua_Diag_Option[] = {
{DIAG_OUTPUT_FILE_L, 1, 0, DIAG_OUTPUT_FILE_S},
{DIAG_EMERGENCY_L, 0, 0, DIAG_EMERGENCY_S},
{DIAG_CLASS_NAME_L, 1, 0, DIAG_CLASS_NAME_S},
{DIAG_INPUT_FILE_L, 1, 0, DIAG_INPUT_FILE_S},
{0, 0, 0, 0}
};

Expand Down
14 changes: 11 additions & 3 deletions src/executables/util_sa.c
hornetmj marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,7 @@ diagdb (UTIL_FUNCTION_ARG * arg)
DIAGDUMP_TYPE diag;
THREAD_ENTRY *thread_p;
int error_code = NO_ERROR;
char *class_list_file;

db_name = utility_get_option_string_value (arg_map, OPTION_STRING_TABLE, 0);
if (db_name == NULL)
Expand Down Expand Up @@ -1587,14 +1588,21 @@ diagdb (UTIL_FUNCTION_ARG * arg)
}

class_name = utility_get_option_string_value (arg_map, DIAG_CLASS_NAME_S, 0);

class_list_file = utility_get_option_string_value (arg_map, DIAG_INPUT_FILE_S, 0);

diag = (DIAGDUMP_TYPE) utility_get_option_int_value (arg_map, DIAG_DUMP_TYPE_S);

if (diag != DIAGDUMP_LOG && utility_get_option_string_table_size (arg_map) != 1)
{
goto print_diag_usage;
}

if (diag != DIAGDUMP_HEAP && class_name != NULL)
if (diag != DIAGDUMP_HEAP && (class_name != NULL || class_list_file != NULL))
{
goto print_diag_usage;
}
if (class_name && class_list_file)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (class_name && class_list_file)
if (class_name && class_list_file)

{
goto print_diag_usage;
}
Expand Down Expand Up @@ -1747,12 +1755,12 @@ diagdb (UTIL_FUNCTION_ARG * arg)
bool dump_records;
dump_records = utility_get_option_bool_value (arg_map, DIAG_DUMP_RECORDS_S);

if (class_name == NULL)
if (class_name == NULL && class_list_file == NULL)
{
fprintf (outfp, "\n*** DUMP OF ALL HEAPS ***\n");
(void) file_tracker_dump_all_heap (thread_p, outfp, dump_records);
}
else
else if (class_name != NULL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위에서 class_name와 class_list_file가 모두 NULL이 아닌 경우에 대한 예외처리를 수행했기 때문에 다음이 더 가독성이 좋을 수 있습니다. 다음 이슈 구현에 따라 달라질 수 있는 부분이니 해당 PR에서 고민해 보도록 하세요.

if (class_name != NULL) { // 이 경우 처리 }
else if (class_list_file != NULL { // 이 경우 처리}
else { // 전체 dump }

{
if (!sm_check_system_class_by_name (class_name))
{
Expand Down
2 changes: 2 additions & 0 deletions src/executables/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,8 @@ typedef struct _ha_config
#define DIAG_EMERGENCY_L "emergency"
#define DIAG_CLASS_NAME_S 'n'
#define DIAG_CLASS_NAME_L "class-name"
#define DIAG_INPUT_FILE_S 'i'
#define DIAG_INPUT_FILE_L "input-file"

/* patch option list */
#define PATCH_RECREATE_LOG_S 'r'
Expand Down
Loading