From ded9b1c3380089c9b330862ac274939d4f187e65 Mon Sep 17 00:00:00 2001 From: timothy-e Date: Tue, 14 Jan 2025 18:26:02 +0000 Subject: [PATCH] [#25429] YSQL: Address YB_TODO in exec.c Summary: `ysqlsh -V` gives the following result: ``` psql (PostgreSQL) 15.2-YB-2.25.1.0-b0 ``` The outputted command name is different than the actual command name. There are three options to fix this check: 1. Update `ysqlsh -V` to print `ysqlsh (PostgreSQL) 15.2...`. This would have a pretty large impact. 2. Disable the check. 3. Modify the check to reflect the differences in Yugabyte. Option 3 seems the best to preserve the safety of the check, without having a far-reaching impact, so this change uses that approach. Jira: DB-14660 Test Plan: Jenkins Reviewers: hsunder, fizaa Reviewed By: hsunder Subscribers: yql Differential Revision: https://phorge.dev.yugabyte.com/D40888 --- src/postgres/src/bin/pg_upgrade/exec.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/postgres/src/bin/pg_upgrade/exec.c b/src/postgres/src/bin/pg_upgrade/exec.c index 15e1703f077f..5c3dab5ae0ed 100644 --- a/src/postgres/src/bin/pg_upgrade/exec.c +++ b/src/postgres/src/bin/pg_upgrade/exec.c @@ -265,10 +265,12 @@ verify_directories(void) if (!is_yugabyte_enabled() || user_opts.check) /* YB: No "old cluster" data dir needed for actual upgrade. */ check_data_dir(&old_cluster); - check_bin_dir(&new_cluster, true); if (!(is_yugabyte_enabled() && user_opts.check)) + { /* YB: No new cluster for preflight checks. */ + check_bin_dir(&new_cluster, true); check_data_dir(&new_cluster); + } } @@ -416,13 +418,10 @@ check_bin_dir(ClusterInfo *cluster, bool check_versions) check_exec(cluster->bindir, "ysql_dump", check_versions); check_exec(cluster->bindir, "ysql_dumpall", check_versions); check_exec(cluster->bindir, "pg_restore", check_versions); -#ifdef YB_TODO - /* Make this version check work (ysqlsh -V returns psql, name mismatch) */ if (is_yugabyte_enabled()) check_exec(cluster->bindir, "ysqlsh", check_versions); else check_exec(cluster->bindir, "psql", check_versions); -#endif check_exec(cluster->bindir, "vacuumdb", check_versions); } } @@ -458,6 +457,8 @@ check_exec(const char *dir, const char *program, bool check_version) pg_strip_crlf(line); if (strstr(cmd, "ysql_dump") != NULL) snprintf(versionstr, sizeof(versionstr), "%s (YSQL) " PG_VERSION, program); + else if (strstr(cmd, "ysqlsh") != NULL) + snprintf(versionstr, sizeof(versionstr), "%s (PostgreSQL) " PG_VERSION, "psql"); else snprintf(versionstr, sizeof(versionstr), "%s (PostgreSQL) " PG_VERSION, program);