38 printf(
_(
"Failure, exiting\n"));
129 vsnprintf(query,
sizeof(query), fmt, args);
133 result =
PQexec(conn, query);
142 printf(
_(
"Failure, exiting\n"));
165 snprintf(ver_filename,
sizeof(ver_filename),
"%s/PG_VERSION",
167 if ((version_fd = fopen(ver_filename,
"r")) == NULL)
168 pg_fatal(
"could not open version file \"%s\": %m\n", ver_filename);
172 pg_fatal(
"could not parse version file \"%s\"\n", ver_filename);
179 return v1 * 10000 + v2 * 100;
201 bool pg_ctl_return =
false;
204 static bool exit_hook_registered =
false;
206 if (!exit_hook_registered)
209 exit_hook_registered =
true;
212 socket_string[0] =
'\0';
214 #if defined(HAVE_UNIX_SOCKETS) && !defined(WIN32) 216 strcat(socket_string,
217 " -c listen_addresses='' -c unix_socket_permissions=0700");
221 snprintf(socket_string + strlen(socket_string),
222 sizeof(socket_string) - strlen(socket_string),
225 "unix_socket_directory" :
"unix_socket_directories",
248 "\"%s/pg_ctl\" -w -l \"%s\" -D \"%s\" -o \"-p %d%s%s %s%s\" start",
252 " -c autovacuum=off -c autovacuum_freeze_max_age=2000000000",
254 " -c synchronous_commit=off -c fsync=off -c full_page_writes=off -c vacuum_defer_cleanup_age=0" :
"",
266 report_and_exit_on_error,
false,
270 if (!pg_ctl_return && !report_and_exit_on_error)
295 if ((conn =
get_db_conn(cluster,
"template1")) == NULL ||
302 pg_fatal(
"could not connect to source postmaster started with the command:\n" 306 pg_fatal(
"could not connect to target postmaster started with the command:\n" 320 pg_fatal(
"pg_ctl failed to start the source server, or connection failed\n");
322 pg_fatal(
"pg_ctl failed to start the target server, or connection failed\n");
342 "\"%s/pg_ctl\" -w -D \"%s\" -o \"%s\" %s stop",
345 in_atexit ?
"-m fast" :
"-m smart");
369 for (option = start; option->
keyword != NULL; option++)
371 if (option->
envvar && (strcmp(option->
envvar,
"PGHOST") == 0 ||
372 strcmp(option->
envvar,
"PGHOSTADDR") == 0))
376 if (value && strlen(value) > 0 &&
378 (strcmp(value,
"localhost") != 0 && strcmp(value,
"127.0.0.1") != 0 &&
379 strcmp(value,
"::1") != 0 && value[0] !=
'/'))
380 pg_fatal(
"libpq environment variable %s has a non-local server value: %s\n",
char * cluster_conn_opts(ClusterInfo *cluster)
char * PQerrorMessage(const PGconn *conn)
void cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel)
void termPQExpBuffer(PQExpBuffer str)
void stop_postmaster(bool in_atexit)
void appendPQExpBufferStr(PQExpBuffer str, const char *data)
#define GET_MAJOR_VERSION(v)
void appendConnStrVal(PQExpBuffer buf, const char *str)
void PQfinish(PGconn *conn)
#define SERVER_STOP_LOG_FILE
PGconn * connectToServer(ClusterInfo *cluster, const char *db_name)
ExecStatusType PQresultStatus(const PGresult *res)
char major_version_str[64]
bool start_postmaster(ClusterInfo *cluster, bool report_and_exit_on_error)
void appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
void PQconninfoFree(PQconninfoOption *connOptions)
PGresult * executeQueryOrDie(PGconn *conn, const char *fmt,...)
void check_pghost_envvar(void)
static void stop_postmaster_atexit(void)
PQExpBuffer createPQExpBuffer(void)
void appendPQExpBufferChar(PQExpBuffer str, char ch)
void PQclear(PGresult *res)
void appendShellString(PQExpBuffer buf, const char *str)
void void pg_log(eLogType type, const char *fmt,...) pg_attribute_printf(2
PQconninfoOption * PQconndefaults(void)
#define ALWAYS_SECURE_SEARCH_PATH_SQL
ClusterInfo * running_cluster
#define SERVER_START_LOG_FILE
PGresult * PQexec(PGconn *conn, const char *query)
#define BINARY_UPGRADE_SERVER_FLAG_CAT_VER
bool exec_prog(const char *log_file, const char *opt_log_file, bool report_error, bool exit_on_error, const char *fmt,...)
void resetPQExpBuffer(PQExpBuffer str)
static void static void status(const char *fmt,...) pg_attribute_printf(1
ConnStatusType PQstatus(const PGconn *conn)
uint32 get_major_server_version(ClusterInfo *cluster)
static PGconn * get_db_conn(ClusterInfo *cluster, const char *db_name)
void initPQExpBuffer(PQExpBuffer str)
PGconn * PQconnectdb(const char *conninfo)