This is an automated email from the ASF dual-hosted git repository.

reshke pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit 829077d9b1c1aea7208265303b9d03cc24a68ccb
Author: Brent Doil <[email protected]>
AuthorDate: Thu Jan 25 01:26:28 2024 -0500

    pg_upgrade: Add flag for relocateable output
    
    By default, pg_upgrade output is sent to the target cluster's
    data directory in `pg_upgrade.d`.
    
    Certain use-cases may want to redirect the output.
    
    Add a GPDB specific flag --output-dir to optionally change the default 
location.
---
 src/bin/pg_upgrade/greenplum/option_gp.c            | 14 ++++++++++++++
 src/bin/pg_upgrade/greenplum/pg_upgrade_greenplum.h |  8 ++++++--
 src/bin/pg_upgrade/pg_upgrade.c                     |  8 +++++++-
 src/bin/pg_upgrade/version.c                        | 10 ----------
 4 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/src/bin/pg_upgrade/greenplum/option_gp.c 
b/src/bin/pg_upgrade/greenplum/option_gp.c
index 6eb30cfa3a..f884711808 100644
--- a/src/bin/pg_upgrade/greenplum/option_gp.c
+++ b/src/bin/pg_upgrade/greenplum/option_gp.c
@@ -1,3 +1,5 @@
+#include "postgres_fe.h"
+
 #include "pg_upgrade_greenplum.h"
 
 typedef enum
@@ -12,6 +14,7 @@ typedef struct {
        bool continue_check_on_fatal;
        bool skip_target_check;
        bool skip_checks;
+       char *output_dir;
 } CloudberryUserOpts;
 
 static CloudberryUserOpts greenplum_user_opts;
@@ -24,6 +27,7 @@ initialize_greenplum_user_options(void)
        greenplum_user_opts.continue_check_on_fatal = false;
        greenplum_user_opts.skip_target_check = false;
        greenplum_user_opts.skip_checks = false;
+       greenplum_user_opts.output_dir = NULL;
 }
 
 bool
@@ -76,6 +80,10 @@ process_greenplum_option(greenplumOption option)
                        greenplum_user_opts.skip_checks = true;
                        break;
 
+               case GREENPLUM_OUTPUT_DIR:
+                       greenplum_user_opts.output_dir = pg_strdup(optarg);
+                       break;
+
                default:
                        return false;
        }
@@ -124,3 +132,9 @@ skip_checks(void)
 {
        return greenplum_user_opts.skip_checks;
 }
+
+char*
+get_output_dir(void)
+{
+       return greenplum_user_opts.output_dir;
+}
diff --git a/src/bin/pg_upgrade/greenplum/pg_upgrade_greenplum.h 
b/src/bin/pg_upgrade/greenplum/pg_upgrade_greenplum.h
index 6144720167..f36b2bd705 100644
--- a/src/bin/pg_upgrade/greenplum/pg_upgrade_greenplum.h
+++ b/src/bin/pg_upgrade/greenplum/pg_upgrade_greenplum.h
@@ -36,7 +36,8 @@ typedef enum {
        GREENPLUM_PROGRESS_OPTION = 11,
        GREENPLUM_CONTINUE_CHECK_ON_FATAL = 12,
        GREENPLUM_SKIP_TARGET_CHECK = 13,
-       GREENPLUM_SKIP_CHECKS = 14
+       GREENPLUM_SKIP_CHECKS = 14,
+       GREENPLUM_OUTPUT_DIR = 15
 } greenplumOption;
 
 #define GREENPLUM_OPTIONS \
@@ -44,7 +45,8 @@ typedef enum {
        {"progress", no_argument, NULL, GREENPLUM_PROGRESS_OPTION}, \
        {"continue-check-on-fatal", no_argument, NULL, 
GREENPLUM_CONTINUE_CHECK_ON_FATAL}, \
        {"skip-target-check", no_argument, NULL, GREENPLUM_SKIP_TARGET_CHECK}, \
-       {"skip-checks", no_argument, NULL, GREENPLUM_SKIP_CHECKS},
+       {"skip-checks", no_argument, NULL, GREENPLUM_SKIP_CHECKS}, \
+       {"output-dir", required_argument, NULL, GREENPLUM_OUTPUT_DIR},
 
 #define GREENPLUM_USAGE "\
       --mode=TYPE               designate node type to upgrade, \"segment\" or 
\"dispatcher\" (default \"segment\")\n\
@@ -52,6 +54,7 @@ typedef enum {
       --continue-check-on-fatal continue to run through all pg_upgrade checks 
without upgrade. Stops on major issues\n\
       --skip-target-check       skip all checks on new/target cluster\n\
       --skip-checks             skip all checks\n\
+      --output-dir              directory to output logs. 
Default=\"COORDINATOR_DATA_DIRECTORY/pg_upgrade.d\"\n\
 "
 
 /* option_gp.c */
@@ -64,6 +67,7 @@ void set_check_fatal_occured(void);
 bool get_check_fatal_occurred(void);
 bool is_skip_target_check(void);
 bool skip_checks(void);
+char *get_output_dir(void);
 
 /* controldata_gp.c */
 void freeze_master_data(void);
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 8b4a757b03..036084400b 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -98,6 +98,7 @@ main(int argc, char **argv)
        char       *sequence_script_file_name = NULL;
        char       *analyze_script_file_name = NULL;
        char       *deletion_script_file_name = NULL;
+       char       *output_dir = NULL;
        bool            live_check = false;
 
        pg_logging_init(argv[0]);
@@ -128,8 +129,13 @@ main(int argc, char **argv)
        /*
         * This needs to happen after adjusting the data directory of the new
         * cluster in adjust_data_dir().
+        *
+        * GPDB allows for relocateable output with the --output-dir flag
         */
-       make_outputdirs(new_cluster.pgdata);
+       if ((output_dir = get_output_dir()) != NULL)
+               make_outputdirs(output_dir);
+       else
+               make_outputdirs(new_cluster.pgdata);
 
        setup(argv[0], &live_check);
 
diff --git a/src/bin/pg_upgrade/version.c b/src/bin/pg_upgrade/version.c
index d873abf0c5..7acee2b563 100644
--- a/src/bin/pg_upgrade/version.c
+++ b/src/bin/pg_upgrade/version.c
@@ -470,22 +470,12 @@ 
old_11_check_for_sql_identifier_data_type_usage(ClusterInfo *cluster)
                                                                  output_path))
        {
                pg_log(PG_REPORT, "fatal\n");
-<<<<<<< HEAD
                gp_fatal_log("Your installation contains the \"sql_identifier\" 
data type in user tables.\n"
                                 "The on-disk format for this data type has 
changed, so this\n"
                                 "cluster cannot currently be upgraded.  You 
can\n"
                                 "drop the problem columns and restart the 
upgrade.\n"
                                 "A list of the problem columns is in the 
file:\n"
                                 "    %s\n\n", output_path);
-=======
-               gp_fatal_log(
-                               "| Your installation contains the 
\"sql_identifier\" data type in user tables\n"
-                               "| and/or indexes.  The on-disk format for this 
data type has changed, so this\n"
-                               "| cluster cannot currently be upgraded.  You 
can remove the problem tables or\n"
-                               "| change the data type to \"name\" and restart 
the upgrade.\n"
-                               "| A list of the problem columns is in the 
file:\n"
-                               "|    %s\n\n", output_path);
->>>>>>> c9a80399044 (pg_upgrade: Use gp_fatal_log for check output)
        }
        else
                check_ok();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to