39 printf(
_(
"Failure, exiting\n"));
143 printf(
_(
"Failure, exiting\n"));
166 snprintf(ver_filename,
sizeof(ver_filename),
"%s/PG_VERSION",
168 if ((version_fd = fopen(ver_filename,
"r")) == NULL)
169 pg_fatal(
"could not open version file \"%s\": %m", ver_filename);
171 if (fscanf(version_fd,
"%63s",
cluster->major_version_str) == 0 ||
172 sscanf(
cluster->major_version_str,
"%d.%d", &v1, &v2) < 1)
173 pg_fatal(
"could not parse version file \"%s\"", ver_filename);
180 return v1 * 10000 + v2 * 100;
202 bool pg_ctl_return =
false;
206 static bool exit_hook_registered =
false;
208 if (!exit_hook_registered)
211 exit_hook_registered =
true;
214 socket_string[0] =
'\0';
218 strcat(socket_string,
219 " -c listen_addresses='' -c unix_socket_permissions=0700");
223 snprintf(socket_string + strlen(socket_string),
224 sizeof(socket_string) - strlen(socket_string),
227 "unix_socket_directory" :
"unix_socket_directories",
242 appendPQExpBufferStr(&pgoptions,
" -c synchronous_commit=off -c fsync=off -c full_page_writes=off");
260 "\"%s/pg_ctl\" -w -l \"%s/%s\" -D \"%s\" -o \"-p %d -b%s %s%s\" start",
278 report_and_exit_on_error,
false,
282 if (!pg_ctl_return && !report_and_exit_on_error)
314 pg_fatal(
"could not connect to source postmaster started with the command:\n"
318 pg_fatal(
"could not connect to target postmaster started with the command:\n"
332 pg_fatal(
"pg_ctl failed to start the source server, or connection failed");
334 pg_fatal(
"pg_ctl failed to start the target server, or connection failed");
354 "\"%s/pg_ctl\" -w -D \"%s\" -o \"%s\" %s stop",
357 in_atexit ?
"-m fast" :
"-m smart");
383 if (
option->envvar && (strcmp(
option->envvar,
"PGHOST") == 0 ||
384 strcmp(
option->envvar,
"PGHOSTADDR") == 0))
390 (strcmp(
value,
"localhost") != 0 && strcmp(
value,
"127.0.0.1") != 0 &&
392 pg_fatal(
"libpq environment variable %s has a non-local server value: %s",
bool exec_prog(const char *log_filename, const char *opt_log_file, bool report_error, bool exit_on_error, const char *fmt,...)
void cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel)
#define ALWAYS_SECURE_SEARCH_PATH_SQL
PGconn * PQconnectdb(const char *conninfo)
void PQconninfoFree(PQconninfoOption *connOptions)
ConnStatusType PQstatus(const PGconn *conn)
void PQfinish(PGconn *conn)
PQconninfoOption * PQconndefaults(void)
char * PQerrorMessage(const PGconn *conn)
ExecStatusType PQresultStatus(const PGresult *res)
PGresult * PQexec(PGconn *conn, const char *query)
static void const char * fmt
#define SERVER_START_LOG_FILE
#define SERVER_STOP_LOG_FILE
void void pg_log(eLogType type, const char *fmt,...) pg_attribute_printf(2
#define GET_MAJOR_VERSION(v)
static bool is_unixsock_path(const char *path)
PQExpBuffer createPQExpBuffer(void)
void initPQExpBuffer(PQExpBuffer str)
void resetPQExpBuffer(PQExpBuffer str)
void appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
void appendPQExpBufferChar(PQExpBuffer str, char ch)
void appendPQExpBufferStr(PQExpBuffer str, const char *data)
void termPQExpBuffer(PQExpBuffer str)
static PGconn * get_db_conn(ClusterInfo *cluster, const char *db_name)
void check_pghost_envvar(void)
bool start_postmaster(ClusterInfo *cluster, bool report_and_exit_on_error)
PGresult * executeQueryOrDie(PGconn *conn, const char *fmt,...)
PGconn * connectToServer(ClusterInfo *cluster, const char *db_name)
void stop_postmaster(bool in_atexit)
uint32 get_major_server_version(ClusterInfo *cluster)
char * cluster_conn_opts(ClusterInfo *cluster)
static void stop_postmaster_atexit(void)
void appendShellString(PQExpBuffer buf, const char *str)
void appendConnStrVal(PQExpBuffer buf, const char *str)
ClusterInfo * running_cluster