From 1ce74a32d0a32f9b2f15c95361c545fd382f247e Mon Sep 17 00:00:00 2001 From: yjlee Date: Tue, 23 Apr 2024 12:41:42 +0900 Subject: [PATCH 01/11] modify diagdb utility to accept a class-name parameter --- msg/en_US/utils.msg | 7 ++++++- src/executables/util_admin.c | 2 ++ src/executables/util_sa.c | 27 ++++++++++++++++++++++++--- src/executables/utility.h | 3 +++ src/storage/file_manager.c | 15 +++++++++++++++ src/storage/file_manager.h | 1 + 6 files changed, 51 insertions(+), 4 deletions(-) diff --git a/msg/en_US/utils.msg b/msg/en_US/utils.msg index f8f60d43ef1..8e86b37a276 100644 --- a/msg/en_US/utils.msg +++ b/msg/en_US/utils.msg @@ -817,6 +817,7 @@ $set 23 MSGCAT_UTIL_SET_MIGDB $set 24 MSGCAT_UTIL_SET_DIAGDB 15 Couldn't open output file '%1$s'\n +16 Invalid class name '%1$s'.\n 60 \ diagdb: Dump a database.\n\ usage: %1$s diagdb [OPTION] database-name\n\ @@ -834,7 +835,11 @@ valid options:\n\ 6 dump disk bitmaps\n\ 7 dump catalog\n\ 8 dump log\n\ - 9 dump heap\n + 9 dump heap / class\n\ + -n, --class-name=NAME NAME of class; only used in -d 9 option; NAME should be full class name\n\ + that includes owner name and class name, split by '.';\n\ + catalog classes do not need owner name.\n + $set 25 MSGCAT_UTIL_SET_LOCKDB diff --git a/src/executables/util_admin.c b/src/executables/util_admin.c index 4b6d274c2ea..41d4b476c37 100644 --- a/src/executables/util_admin.c +++ b/src/executables/util_admin.c @@ -319,6 +319,7 @@ static UTIL_ARG_MAP ua_Diag_Option_Map[] = { {DIAG_DUMP_RECORDS_S, {ARG_BOOLEAN}, {0}}, {DIAG_OUTPUT_FILE_S, {ARG_STRING}, {0}}, {DIAG_EMERGENCY_S, {ARG_BOOLEAN}, {0}}, + {DIAG_CLASS_NAME_S, {ARG_STRING}, {0}}, {0, {0}, {0}} }; @@ -327,6 +328,7 @@ static GETOPT_LONG ua_Diag_Option[] = { {DIAG_DUMP_RECORDS_L, 0, 0, DIAG_DUMP_RECORDS_S}, {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}, {0, 0, 0, 0} }; diff --git a/src/executables/util_sa.c b/src/executables/util_sa.c index d6fafe7563c..9726328db12 100644 --- a/src/executables/util_sa.c +++ b/src/executables/util_sa.c @@ -1716,10 +1716,31 @@ diagdb (UTIL_FUNCTION_ARG * arg) if (diag == DIAGDUMP_ALL || diag == DIAGDUMP_HEAP) { bool dump_records; - /* this dumps the contents of all heaps */ + const char *class_name; dump_records = utility_get_option_bool_value (arg_map, DIAG_DUMP_RECORDS_S); - fprintf (outfp, "\n*** DUMP OF ALL HEAPS ***\n"); - (void) file_tracker_dump_all_heap (thread_p, outfp, dump_records); + class_name = utility_get_option_string_value (arg_map, DIAG_CLASS_NAME_S, 0); + if (class_name == NULL) + { + /* this dumps the contents of all heaps */ + fprintf (outfp, "\n*** DUMP OF ALL HEAPS ***\n"); + (void) file_tracker_dump_all_heap (thread_p, outfp, dump_records); + } + else + { + /* this dumps the contents of a specific heap for given class name */ + if (!sm_check_system_class_by_name(class_name)) + { + /* check if the format of class name is valid */ + if (utility_check_class_name(class_name) != NO_ERROR) + { + PRINT_AND_LOG_ERR_MSG (msgcat_message (MSGCAT_CATALOG_UTILS, MSGCAT_UTIL_SET_DIAGDB, DIAGDB_MSG_BAD_CLASSNAME), + class_name); + goto error_exit; + } + } + fprintf (outfp, "\n*** DUMP OF A SPECIFIC HEAP ***\n"); + class_dump (thread_p, outfp, dump_records, class_name); + } } db_shutdown (); diff --git a/src/executables/utility.h b/src/executables/utility.h index bbc8e063f21..c1ed501505e 100644 --- a/src/executables/utility.h +++ b/src/executables/utility.h @@ -304,6 +304,7 @@ typedef enum typedef enum { DIAGDB_MSG_BAD_OUTPUT = 15, + DIAGDB_MSG_BAD_CLASSNAME = 16, DIAGDB_MSG_USAGE = 60 } MSGCAT_DIAGDB_MSG; @@ -1197,6 +1198,8 @@ typedef struct _ha_config #define DIAG_OUTPUT_FILE_L "output-file" #define DIAG_EMERGENCY_S 11202 #define DIAG_EMERGENCY_L "emergency" +#define DIAG_CLASS_NAME_S 'n' +#define DIAG_CLASS_NAME_L "class-name" /* patch option list */ #define PATCH_RECREATE_LOG_S 'r' diff --git a/src/storage/file_manager.c b/src/storage/file_manager.c index e9f85dddc37..d50be58c90f 100644 --- a/src/storage/file_manager.c +++ b/src/storage/file_manager.c @@ -11056,6 +11056,21 @@ file_tracker_dump_all_heap (THREAD_ENTRY * thread_p, FILE * fp, bool dump_record return file_tracker_map (thread_p, PGBUF_LATCH_READ, file_tracker_item_dump_heap, &context); } +/* + * class_dump () - dump a specific heap file with class name + * + * return : + * thread_p (in) : thread entry + * fp (in) : output file + * dump_records (in) : true to dump records + * class_name (in) : name of class to dump + */ +void +class_dump (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name) +{ + fprintf (fp, "\n\n*** DUMP A CLASS NAMED %s ***\n\n", class_name); +} + /* * file_tracker_item_dump_heap_capacity () - FILE_TRACK_ITEM_FUNC to dump heap file capacity * diff --git a/src/storage/file_manager.h b/src/storage/file_manager.h index 4314fe8bd0d..7cee3251f5d 100644 --- a/src/storage/file_manager.h +++ b/src/storage/file_manager.h @@ -215,6 +215,7 @@ extern DISK_ISVALID file_tracker_check (THREAD_ENTRY * thread_p); extern int file_tracker_dump (THREAD_ENTRY * thread_p, FILE * fp); extern int file_tracker_dump_all_capacities (THREAD_ENTRY * thread_p, FILE * fp); extern int file_tracker_dump_all_heap (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records); +extern void class_dump (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name); extern int file_tracker_dump_all_heap_capacities (THREAD_ENTRY * thread_p, FILE * fp); extern int file_tracker_dump_all_btree_capacities (THREAD_ENTRY * thread_p, FILE * fp); #if defined (SA_MODE) From f9968bba9c883dc4f5abf12b0259bd1d53c6a31d Mon Sep 17 00:00:00 2001 From: yjlee Date: Tue, 23 Apr 2024 16:33:06 +0900 Subject: [PATCH 02/11] indent --- src/executables/util_sa.c | 43 ++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/executables/util_sa.c b/src/executables/util_sa.c index 9726328db12..7679f83bd57 100644 --- a/src/executables/util_sa.c +++ b/src/executables/util_sa.c @@ -1720,27 +1720,28 @@ diagdb (UTIL_FUNCTION_ARG * arg) dump_records = utility_get_option_bool_value (arg_map, DIAG_DUMP_RECORDS_S); class_name = utility_get_option_string_value (arg_map, DIAG_CLASS_NAME_S, 0); if (class_name == NULL) - { - /* this dumps the contents of all heaps */ - fprintf (outfp, "\n*** DUMP OF ALL HEAPS ***\n"); - (void) file_tracker_dump_all_heap (thread_p, outfp, dump_records); - } - else - { - /* this dumps the contents of a specific heap for given class name */ - if (!sm_check_system_class_by_name(class_name)) - { - /* check if the format of class name is valid */ - if (utility_check_class_name(class_name) != NO_ERROR) - { - PRINT_AND_LOG_ERR_MSG (msgcat_message (MSGCAT_CATALOG_UTILS, MSGCAT_UTIL_SET_DIAGDB, DIAGDB_MSG_BAD_CLASSNAME), - class_name); - goto error_exit; - } - } - fprintf (outfp, "\n*** DUMP OF A SPECIFIC HEAP ***\n"); - class_dump (thread_p, outfp, dump_records, class_name); - } + { + /* this dumps the contents of all heaps */ + fprintf (outfp, "\n*** DUMP OF ALL HEAPS ***\n"); + (void) file_tracker_dump_all_heap (thread_p, outfp, dump_records); + } + else + { + /* this dumps the contents of a specific heap for given class name */ + if (!sm_check_system_class_by_name (class_name)) + { + /* check if the format of class name is valid */ + if (utility_check_class_name (class_name) != NO_ERROR) + { + PRINT_AND_LOG_ERR_MSG (msgcat_message + (MSGCAT_CATALOG_UTILS, MSGCAT_UTIL_SET_DIAGDB, DIAGDB_MSG_BAD_CLASSNAME), + class_name); + goto error_exit; + } + } + fprintf (outfp, "\n*** DUMP OF A SPECIFIC HEAP ***\n"); + class_dump (thread_p, outfp, dump_records, class_name); + } } db_shutdown (); From 456117c3fa808a5a6fdcaa615b59dc6503c980ff Mon Sep 17 00:00:00 2001 From: yjlee Date: Tue, 23 Apr 2024 17:26:40 +0900 Subject: [PATCH 03/11] change argument flag, function name. --- msg/en_US/utils.msg | 3 +-- src/executables/util_sa.c | 7 ++----- src/executables/utility.h | 3 +-- src/storage/file_manager.c | 5 +++-- src/storage/file_manager.h | 2 +- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/msg/en_US/utils.msg b/msg/en_US/utils.msg index 8e86b37a276..aefb20171f2 100644 --- a/msg/en_US/utils.msg +++ b/msg/en_US/utils.msg @@ -817,7 +817,6 @@ $set 23 MSGCAT_UTIL_SET_MIGDB $set 24 MSGCAT_UTIL_SET_DIAGDB 15 Couldn't open output file '%1$s'\n -16 Invalid class name '%1$s'.\n 60 \ diagdb: Dump a database.\n\ usage: %1$s diagdb [OPTION] database-name\n\ @@ -836,7 +835,7 @@ valid options:\n\ 7 dump catalog\n\ 8 dump log\n\ 9 dump heap / class\n\ - -n, --class-name=NAME NAME of class; only used in -d 9 option; NAME should be full class name\n\ + -c, --class-name=CLASS name of CLASS; only used in -d 9 option; class name should be full class name\n\ that includes owner name and class name, split by '.';\n\ catalog classes do not need owner name.\n diff --git a/src/executables/util_sa.c b/src/executables/util_sa.c index 7679f83bd57..32238bdafa5 100644 --- a/src/executables/util_sa.c +++ b/src/executables/util_sa.c @@ -1733,14 +1733,11 @@ diagdb (UTIL_FUNCTION_ARG * arg) /* check if the format of class name is valid */ if (utility_check_class_name (class_name) != NO_ERROR) { - PRINT_AND_LOG_ERR_MSG (msgcat_message - (MSGCAT_CATALOG_UTILS, MSGCAT_UTIL_SET_DIAGDB, DIAGDB_MSG_BAD_CLASSNAME), - class_name); goto error_exit; } } - fprintf (outfp, "\n*** DUMP OF A SPECIFIC HEAP ***\n"); - class_dump (thread_p, outfp, dump_records, class_name); + fprintf (outfp, "\n*** DUMP OF SPECIFIC HEAP(S) ***\n"); + file_class_dump_specific_heap_file (thread_p, outfp, dump_records, class_name); } } diff --git a/src/executables/utility.h b/src/executables/utility.h index c1ed501505e..4c39f85d97c 100644 --- a/src/executables/utility.h +++ b/src/executables/utility.h @@ -304,7 +304,6 @@ typedef enum typedef enum { DIAGDB_MSG_BAD_OUTPUT = 15, - DIAGDB_MSG_BAD_CLASSNAME = 16, DIAGDB_MSG_USAGE = 60 } MSGCAT_DIAGDB_MSG; @@ -1198,7 +1197,7 @@ typedef struct _ha_config #define DIAG_OUTPUT_FILE_L "output-file" #define DIAG_EMERGENCY_S 11202 #define DIAG_EMERGENCY_L "emergency" -#define DIAG_CLASS_NAME_S 'n' +#define DIAG_CLASS_NAME_S 'c' #define DIAG_CLASS_NAME_L "class-name" /* patch option list */ diff --git a/src/storage/file_manager.c b/src/storage/file_manager.c index d50be58c90f..bb441318741 100644 --- a/src/storage/file_manager.c +++ b/src/storage/file_manager.c @@ -11057,7 +11057,7 @@ file_tracker_dump_all_heap (THREAD_ENTRY * thread_p, FILE * fp, bool dump_record } /* - * class_dump () - dump a specific heap file with class name + * file_class_dump_specific_heap_file () - dump a specific heap file with class name * * return : * thread_p (in) : thread entry @@ -11066,8 +11066,9 @@ file_tracker_dump_all_heap (THREAD_ENTRY * thread_p, FILE * fp, bool dump_record * class_name (in) : name of class to dump */ void -class_dump (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name) +file_class_dump_specific_heap_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name) { + /* todo: Fetch HFID of class which corresponds to class_name, and dump heap file by HFID. Will be handled at CBRD-25313 and CBRD-25314. */ fprintf (fp, "\n\n*** DUMP A CLASS NAMED %s ***\n\n", class_name); } diff --git a/src/storage/file_manager.h b/src/storage/file_manager.h index 7cee3251f5d..9674e934d65 100644 --- a/src/storage/file_manager.h +++ b/src/storage/file_manager.h @@ -215,7 +215,7 @@ extern DISK_ISVALID file_tracker_check (THREAD_ENTRY * thread_p); extern int file_tracker_dump (THREAD_ENTRY * thread_p, FILE * fp); extern int file_tracker_dump_all_capacities (THREAD_ENTRY * thread_p, FILE * fp); extern int file_tracker_dump_all_heap (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records); -extern void class_dump (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name); +extern void file_class_dump_specific_heap_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name); extern int file_tracker_dump_all_heap_capacities (THREAD_ENTRY * thread_p, FILE * fp); extern int file_tracker_dump_all_btree_capacities (THREAD_ENTRY * thread_p, FILE * fp); #if defined (SA_MODE) From 473e6277c4cb43f8f74281a8b36a3d2a3fc07d56 Mon Sep 17 00:00:00 2001 From: yjlee Date: Tue, 23 Apr 2024 17:40:16 +0900 Subject: [PATCH 04/11] indent --- src/storage/file_manager.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/storage/file_manager.h b/src/storage/file_manager.h index 9674e934d65..445d90e02bf 100644 --- a/src/storage/file_manager.h +++ b/src/storage/file_manager.h @@ -215,7 +215,8 @@ extern DISK_ISVALID file_tracker_check (THREAD_ENTRY * thread_p); extern int file_tracker_dump (THREAD_ENTRY * thread_p, FILE * fp); extern int file_tracker_dump_all_capacities (THREAD_ENTRY * thread_p, FILE * fp); extern int file_tracker_dump_all_heap (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records); -extern void file_class_dump_specific_heap_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name); +extern void file_class_dump_specific_heap_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, + const char *class_name); extern int file_tracker_dump_all_heap_capacities (THREAD_ENTRY * thread_p, FILE * fp); extern int file_tracker_dump_all_btree_capacities (THREAD_ENTRY * thread_p, FILE * fp); #if defined (SA_MODE) From c2916c94baba74af07c6c4fa5580303d62445192 Mon Sep 17 00:00:00 2001 From: yjlee Date: Wed, 24 Apr 2024 17:00:48 +0900 Subject: [PATCH 05/11] check dump mode and class name to print usage message when class name exists on DIAGDUMP_ALL option --- msg/en_US/utils.msg | 5 +---- src/executables/util_sa.c | 21 +++++++++++++-------- src/storage/file_manager.c | 16 ---------------- src/storage/file_manager.h | 2 -- src/storage/heap_file.c | 16 ++++++++++++++++ src/storage/heap_file.h | 1 + 6 files changed, 31 insertions(+), 30 deletions(-) diff --git a/msg/en_US/utils.msg b/msg/en_US/utils.msg index aefb20171f2..06442173e0e 100644 --- a/msg/en_US/utils.msg +++ b/msg/en_US/utils.msg @@ -834,10 +834,7 @@ valid options:\n\ 6 dump disk bitmaps\n\ 7 dump catalog\n\ 8 dump log\n\ - 9 dump heap / class\n\ - -c, --class-name=CLASS name of CLASS; only used in -d 9 option; class name should be full class name\n\ - that includes owner name and class name, split by '.';\n\ - catalog classes do not need owner name.\n + 9 dump heap\n diff --git a/src/executables/util_sa.c b/src/executables/util_sa.c index 32238bdafa5..7aff023d4f9 100644 --- a/src/executables/util_sa.c +++ b/src/executables/util_sa.c @@ -1531,6 +1531,7 @@ diagdb (UTIL_FUNCTION_ARG * arg) char er_msg_file[PATH_MAX]; const char *db_name; const char *output_file = NULL; + const char *class_name; FILE *outfp = NULL; bool is_emergency = false; DIAGDUMP_TYPE diag; @@ -1565,13 +1566,17 @@ diagdb (UTIL_FUNCTION_ARG * arg) } } + class_name = utility_get_option_string_value (arg_map, DIAG_CLASS_NAME_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_ALL && class_name != NULL) + { + goto print_diag_usage; + } if (check_database_name (db_name)) { goto error_exit; @@ -1716,28 +1721,28 @@ diagdb (UTIL_FUNCTION_ARG * arg) if (diag == DIAGDUMP_ALL || diag == DIAGDUMP_HEAP) { bool dump_records; - const char *class_name; dump_records = utility_get_option_bool_value (arg_map, DIAG_DUMP_RECORDS_S); - class_name = utility_get_option_string_value (arg_map, DIAG_CLASS_NAME_S, 0); + if (class_name == NULL) { - /* this dumps the contents of all heaps */ fprintf (outfp, "\n*** DUMP OF ALL HEAPS ***\n"); (void) file_tracker_dump_all_heap (thread_p, outfp, dump_records); } else { - /* this dumps the contents of a specific heap for given class name */ + if (diag == DIAGDUMP_ALL) + { + goto print_diag_usage; + } if (!sm_check_system_class_by_name (class_name)) { - /* check if the format of class name is valid */ if (utility_check_class_name (class_name) != NO_ERROR) { goto error_exit; } } - fprintf (outfp, "\n*** DUMP OF SPECIFIC HEAP(S) ***\n"); - file_class_dump_specific_heap_file (thread_p, outfp, dump_records, class_name); + fprintf (outfp, "\n*** DUMP HEAP OF %s ***\n", class_name); + heap_dump_specific_file (thread_p, outfp, dump_records, class_name); } } diff --git a/src/storage/file_manager.c b/src/storage/file_manager.c index bb441318741..e9f85dddc37 100644 --- a/src/storage/file_manager.c +++ b/src/storage/file_manager.c @@ -11056,22 +11056,6 @@ file_tracker_dump_all_heap (THREAD_ENTRY * thread_p, FILE * fp, bool dump_record return file_tracker_map (thread_p, PGBUF_LATCH_READ, file_tracker_item_dump_heap, &context); } -/* - * file_class_dump_specific_heap_file () - dump a specific heap file with class name - * - * return : - * thread_p (in) : thread entry - * fp (in) : output file - * dump_records (in) : true to dump records - * class_name (in) : name of class to dump - */ -void -file_class_dump_specific_heap_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name) -{ - /* todo: Fetch HFID of class which corresponds to class_name, and dump heap file by HFID. Will be handled at CBRD-25313 and CBRD-25314. */ - fprintf (fp, "\n\n*** DUMP A CLASS NAMED %s ***\n\n", class_name); -} - /* * file_tracker_item_dump_heap_capacity () - FILE_TRACK_ITEM_FUNC to dump heap file capacity * diff --git a/src/storage/file_manager.h b/src/storage/file_manager.h index 445d90e02bf..4314fe8bd0d 100644 --- a/src/storage/file_manager.h +++ b/src/storage/file_manager.h @@ -215,8 +215,6 @@ extern DISK_ISVALID file_tracker_check (THREAD_ENTRY * thread_p); extern int file_tracker_dump (THREAD_ENTRY * thread_p, FILE * fp); extern int file_tracker_dump_all_capacities (THREAD_ENTRY * thread_p, FILE * fp); extern int file_tracker_dump_all_heap (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records); -extern void file_class_dump_specific_heap_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, - const char *class_name); extern int file_tracker_dump_all_heap_capacities (THREAD_ENTRY * thread_p, FILE * fp); extern int file_tracker_dump_all_btree_capacities (THREAD_ENTRY * thread_p, FILE * fp); #if defined (SA_MODE) diff --git a/src/storage/heap_file.c b/src/storage/heap_file.c index afa8561588a..d1b16128843 100644 --- a/src/storage/heap_file.c +++ b/src/storage/heap_file.c @@ -14507,6 +14507,22 @@ heap_dump (THREAD_ENTRY * thread_p, FILE * fp, HFID * hfid, bool dump_records) fprintf (fp, "\n\n*** END OF DUMP FOR HEAP FILE ***\n\n"); } +/* + * heap_dump_specific_file () - dump a specific heap file with class name + * + * return : + * thread_p (in) : thread entry + * fp (in) : output file + * dump_records (in) : true to dump records + * class_name (in) : name of class to dump + */ +void +heap_dump_specific_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name) +{ + /* todo: Fetch HFID of class which corresponds to class_name, and dump heap file by HFID. Will be handled at CBRD-25313 and CBRD-25314. */ + fprintf (fp, "\n\n*** DUMP A CLASS NAMED %s ***\n\n", class_name); +} + /* * heap_dump_capacity () - dump heap file capacity * diff --git a/src/storage/heap_file.h b/src/storage/heap_file.h index edb77b6e198..1cd6f69e827 100644 --- a/src/storage/heap_file.h +++ b/src/storage/heap_file.h @@ -554,6 +554,7 @@ extern int heap_set_autoincrement_value (THREAD_ENTRY * thread_p, HEAP_CACHE_ATT HEAP_SCANCACHE * scan_cache, int *is_set); extern void heap_dump (THREAD_ENTRY * thread_p, FILE * fp, HFID * hfid, bool dump_records); +extern void heap_dump_specific_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name); extern void heap_attrinfo_dump (THREAD_ENTRY * thread_p, FILE * fp, HEAP_CACHE_ATTRINFO * attr_info, bool dump_schema); #if defined (CUBRID_DEBUG) extern void heap_chnguess_dump (FILE * fp); From 78e537769532cbcb985915a0bb9fff2ab6c73d8b Mon Sep 17 00:00:00 2001 From: YeunjunLee <48234872+YeunjunLee@users.noreply.github.com> Date: Wed, 24 Apr 2024 17:43:32 +0900 Subject: [PATCH 06/11] delete redundant check Co-authored-by: Jooho Kim <54789363+joohok@users.noreply.github.com> --- src/executables/util_sa.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/executables/util_sa.c b/src/executables/util_sa.c index 7aff023d4f9..8b5895a2223 100644 --- a/src/executables/util_sa.c +++ b/src/executables/util_sa.c @@ -1730,10 +1730,7 @@ diagdb (UTIL_FUNCTION_ARG * arg) } else { - if (diag == DIAGDUMP_ALL) - { - goto print_diag_usage; - } + assert (diag != DIAGDUMP_ALL); if (!sm_check_system_class_by_name (class_name)) { if (utility_check_class_name (class_name) != NO_ERROR) From 03d40b62f48056886dcbff8b7c74d14a633ac0d0 Mon Sep 17 00:00:00 2001 From: yjlee Date: Wed, 24 Apr 2024 17:46:14 +0900 Subject: [PATCH 07/11] indent --- src/executables/util_sa.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/executables/util_sa.c b/src/executables/util_sa.c index 7aff023d4f9..3bb9f9c512e 100644 --- a/src/executables/util_sa.c +++ b/src/executables/util_sa.c @@ -1730,10 +1730,7 @@ diagdb (UTIL_FUNCTION_ARG * arg) } else { - if (diag == DIAGDUMP_ALL) - { - goto print_diag_usage; - } + assert (diag != DIAGDUMP_ALL); if (!sm_check_system_class_by_name (class_name)) { if (utility_check_class_name (class_name) != NO_ERROR) From 5032a773e68f55f50fd8b2ad80f28611345a6b3b Mon Sep 17 00:00:00 2001 From: yjlee Date: Wed, 24 Apr 2024 17:59:51 +0900 Subject: [PATCH 08/11] indent --- src/executables/util_sa.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/executables/util_sa.c b/src/executables/util_sa.c index 7aff023d4f9..783f316f679 100644 --- a/src/executables/util_sa.c +++ b/src/executables/util_sa.c @@ -1730,10 +1730,7 @@ diagdb (UTIL_FUNCTION_ARG * arg) } else { - if (diag == DIAGDUMP_ALL) - { - goto print_diag_usage; - } + assert (diag != DIAGDUMP_ALL); if (!sm_check_system_class_by_name (class_name)) { if (utility_check_class_name (class_name) != NO_ERROR) From 0ae9fe39c585a1d2777d261ef06f98d8e237337e Mon Sep 17 00:00:00 2001 From: YeunjunLee <48234872+YeunjunLee@users.noreply.github.com> Date: Thu, 25 Apr 2024 12:38:26 +0900 Subject: [PATCH 09/11] Update src/storage/heap_file.c Co-authored-by: Jooho Kim <54789363+joohok@users.noreply.github.com> --- src/storage/heap_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/heap_file.c b/src/storage/heap_file.c index d1b16128843..a4c63b91fad 100644 --- a/src/storage/heap_file.c +++ b/src/storage/heap_file.c @@ -14519,7 +14519,7 @@ heap_dump (THREAD_ENTRY * thread_p, FILE * fp, HFID * hfid, bool dump_records) void heap_dump_specific_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name) { - /* todo: Fetch HFID of class which corresponds to class_name, and dump heap file by HFID. Will be handled at CBRD-25313 and CBRD-25314. */ + /* TODO: Fetch HFID of class which corresponds to class_name, and dump heap file by HFID. Will be handled at CBRD-25313 and CBRD-25314. */ fprintf (fp, "\n\n*** DUMP A CLASS NAMED %s ***\n\n", class_name); } From aae7f38f37825f69bfddc7ec6cac91a58ca50f3b Mon Sep 17 00:00:00 2001 From: YeunjunLee <48234872+YeunjunLee@users.noreply.github.com> Date: Thu, 25 Apr 2024 12:38:56 +0900 Subject: [PATCH 10/11] Update msg/en_US/utils.msg Co-authored-by: Jooho Kim <54789363+joohok@users.noreply.github.com> --- msg/en_US/utils.msg | 1 - 1 file changed, 1 deletion(-) diff --git a/msg/en_US/utils.msg b/msg/en_US/utils.msg index 06442173e0e..f8f60d43ef1 100644 --- a/msg/en_US/utils.msg +++ b/msg/en_US/utils.msg @@ -837,7 +837,6 @@ valid options:\n\ 9 dump heap\n - $set 25 MSGCAT_UTIL_SET_LOCKDB 15 Couldn't open output file '%1$s'\n 59 lockdb cannot run as standalone mode.\n From d06428da870b88ad039622278caa844332be19d0 Mon Sep 17 00:00:00 2001 From: yjlee Date: Thu, 25 Apr 2024 15:05:22 +0900 Subject: [PATCH 11/11] limit function only for SA_MODE --- src/executables/util_sa.c | 5 +++-- src/storage/heap_file.c | 7 ++++--- src/storage/heap_file.h | 4 +++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/executables/util_sa.c b/src/executables/util_sa.c index 783f316f679..7235953bef2 100644 --- a/src/executables/util_sa.c +++ b/src/executables/util_sa.c @@ -1573,10 +1573,12 @@ diagdb (UTIL_FUNCTION_ARG * arg) { goto print_diag_usage; } + if (diag == DIAGDUMP_ALL && class_name != NULL) { goto print_diag_usage; } + if (check_database_name (db_name)) { goto error_exit; @@ -1730,7 +1732,6 @@ diagdb (UTIL_FUNCTION_ARG * arg) } else { - assert (diag != DIAGDUMP_ALL); if (!sm_check_system_class_by_name (class_name)) { if (utility_check_class_name (class_name) != NO_ERROR) @@ -1739,7 +1740,7 @@ diagdb (UTIL_FUNCTION_ARG * arg) } } fprintf (outfp, "\n*** DUMP HEAP OF %s ***\n", class_name); - heap_dump_specific_file (thread_p, outfp, dump_records, class_name); + heap_dump_heap_file (thread_p, outfp, dump_records, class_name); } } diff --git a/src/storage/heap_file.c b/src/storage/heap_file.c index a4c63b91fad..7f0ae712ed9 100644 --- a/src/storage/heap_file.c +++ b/src/storage/heap_file.c @@ -14507,8 +14507,9 @@ heap_dump (THREAD_ENTRY * thread_p, FILE * fp, HFID * hfid, bool dump_records) fprintf (fp, "\n\n*** END OF DUMP FOR HEAP FILE ***\n\n"); } +#if defined (SA_MODE) /* - * heap_dump_specific_file () - dump a specific heap file with class name + * heap_dump_heap_file () - dump a specific heap file with class name * * return : * thread_p (in) : thread entry @@ -14517,11 +14518,11 @@ heap_dump (THREAD_ENTRY * thread_p, FILE * fp, HFID * hfid, bool dump_records) * class_name (in) : name of class to dump */ void -heap_dump_specific_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name) +heap_dump_heap_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name) { /* TODO: Fetch HFID of class which corresponds to class_name, and dump heap file by HFID. Will be handled at CBRD-25313 and CBRD-25314. */ - fprintf (fp, "\n\n*** DUMP A CLASS NAMED %s ***\n\n", class_name); } +#endif /* * heap_dump_capacity () - dump heap file capacity diff --git a/src/storage/heap_file.h b/src/storage/heap_file.h index 1cd6f69e827..f59bb71a064 100644 --- a/src/storage/heap_file.h +++ b/src/storage/heap_file.h @@ -554,7 +554,9 @@ extern int heap_set_autoincrement_value (THREAD_ENTRY * thread_p, HEAP_CACHE_ATT HEAP_SCANCACHE * scan_cache, int *is_set); extern void heap_dump (THREAD_ENTRY * thread_p, FILE * fp, HFID * hfid, bool dump_records); -extern void heap_dump_specific_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name); +#if defined (SA_MODE) +extern void heap_dump_heap_file (THREAD_ENTRY * thread_p, FILE * fp, bool dump_records, const char *class_name); +#endif extern void heap_attrinfo_dump (THREAD_ENTRY * thread_p, FILE * fp, HEAP_CACHE_ATTRINFO * attr_info, bool dump_schema); #if defined (CUBRID_DEBUG) extern void heap_chnguess_dump (FILE * fp);