--- postgresql-15.2/src/bin/pg_upgrade/option.c 2023-03-07 23:37:50.271950638 +0100 +++ postgresql-15.2/src/bin/pg_upgrade/option.c 2023-03-07 23:40:28.343899006 +0100 @@ -445,8 +445,14 @@ get_sock_dir(ClusterInfo *cluster, bool live_check) { #if defined(HAVE_UNIX_SOCKETS) && !defined(WIN32) - if (!live_check) + if (!live_check) { cluster->sockdir = user_opts.socketdir; +#ifndef UNIX_PATH_MAX +#define UNIX_PATH_MAX 108 +#endif + if (strlen(cluster->sockdir) >= UNIX_PATH_MAX - sizeof(".s.PGSQL.50432")) + strcpy(cluster->sockdir, "/tmp"); /* fall back to tmp */ + } else { /* --- postgresql-15.2/src/include/pg_config_manual.h 2023-03-07 23:37:50.153949183 +0100 +++ postgresql-15.2/src/include/pg_config_manual.h 2023-03-07 23:38:28.898426739 +0100 @@ -224,7 +224,7 @@ * support them yet. */ #ifndef WIN32 -#define DEFAULT_PGSOCKET_DIR "/tmp" +#define DEFAULT_PGSOCKET_DIR "/var/run/postgresql" #else #define DEFAULT_PGSOCKET_DIR "" #endif