!4252 socketpath路径拼接
Merge pull request !4252 from 张悦萌/socketpath-joint
This commit is contained in:
@ -5843,6 +5843,18 @@ static long long int strtollSafe(const char* nptr, long long int default_value)
|
||||
return res;
|
||||
}
|
||||
|
||||
static void checkDssInput(const char* file, const char** socketpath)
|
||||
{
|
||||
if (!enable_dss && file != NULL && file[0] == '+') {
|
||||
enable_dss = true;
|
||||
}
|
||||
|
||||
/* set socketpath if not existed when enable dss */
|
||||
if (enable_dss && *socketpath == NULL) {
|
||||
*socketpath = getSocketpathFromEnv();
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int c;
|
||||
@ -5996,6 +6008,8 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
checkDssInput(filename, &socketpath);
|
||||
|
||||
if (NULL == filename) {
|
||||
fprintf(stderr, "must specify a file to parse.\n");
|
||||
exit(1);
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "storage/page_compression.h"
|
||||
#include "storage/dss/dss_adaptor.h"
|
||||
#include "storage/file/fio_device.h"
|
||||
#include "tool_common.h"
|
||||
|
||||
static const char* progname;
|
||||
|
||||
@ -1002,6 +1003,14 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (!dumpprivate.enable_dss && dumpprivate.inpath != NULL && dumpprivate.inpath[0] == '+') {
|
||||
dumpprivate.enable_dss = true;
|
||||
}
|
||||
|
||||
if (dumpprivate.enable_dss && dumpprivate.socketpath == NULL) {
|
||||
dumpprivate.socketpath = getSocketpathFromEnv();
|
||||
}
|
||||
|
||||
if ((optind + 2) < argc) {
|
||||
fprintf(stderr, "%s: too many command-line arguments (first is \"%s\")\n", progname, argv[optind + 2]);
|
||||
goto bad_argument;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "getopt_long.h"
|
||||
#include "storage/dss/dss_adaptor.h"
|
||||
#include "storage/file/fio_device.h"
|
||||
#include "tool_common.h"
|
||||
|
||||
#define FirstNormalTransactionId ((TransactionId)3)
|
||||
#define TransactionIdIsNormal(xid) ((xid) >= FirstNormalTransactionId)
|
||||
@ -278,6 +279,18 @@ static void display_last_page(ss_reformer_ctrl_t reformerCtrl, int last_page_id)
|
||||
printf(_("Cluster run mode: %s\n"), SSClusterRunMode(reformerCtrl.clusterRunMode));
|
||||
}
|
||||
|
||||
static void checkDssInput(const char* file, char** socketpath)
|
||||
{
|
||||
if (file[0] == '+') {
|
||||
enable_dss = true;
|
||||
}
|
||||
|
||||
/* set socketpath if not existed when enable dss */
|
||||
if (enable_dss && *socketpath == NULL) {
|
||||
*socketpath = getSocketpathFromEnv();
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
ControlFileData ControlFile;
|
||||
@ -359,6 +372,8 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
check_env_value_c(DataDir);
|
||||
|
||||
checkDssInput(DataDir, &socketpath);
|
||||
|
||||
if (enable_dss) {
|
||||
if (socketpath == NULL || strlen(socketpath) == 0 || strncmp("UDS:", socketpath, 4) != 0) {
|
||||
fprintf(stderr, _("%s: socketpath must be specific correctly when enable dss, "
|
||||
|
@ -707,6 +707,17 @@ static void check_backid_option(char *command_name)
|
||||
dbuser = gs_pstrdup(instance_config.conn_opt.pguser);
|
||||
}
|
||||
|
||||
static void check_dss_input()
|
||||
{
|
||||
if (!instance_config.dss.enable_dss && instance_config.dss.vgname != NULL) {
|
||||
instance_config.dss.enable_dss = true;
|
||||
}
|
||||
|
||||
if (instance_config.dss.enable_dss && instance_config.dss.socketpath == NULL) {
|
||||
instance_config.dss.socketpath = getSocketpathFromEnv();
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *command = NULL,
|
||||
@ -830,6 +841,8 @@ int main(int argc, char *argv[])
|
||||
/* compress_init */
|
||||
compress_init();
|
||||
|
||||
check_dss_input();
|
||||
|
||||
dss_init();
|
||||
|
||||
initDataPathStruct(IsDssMode());
|
||||
|
@ -98,6 +98,17 @@ static inline bool is_negative_num(char *str)
|
||||
return *s == '-' ? true : false;
|
||||
}
|
||||
|
||||
static void checkDssInput()
|
||||
{
|
||||
if (!dss.enable_dss && dss.vgname != NULL) {
|
||||
dss.enable_dss = true;
|
||||
}
|
||||
|
||||
if (dss.enable_dss && dss.socketpath == NULL) {
|
||||
dss.socketpath = getSocketpathFromEnv();
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int c;
|
||||
@ -268,6 +279,8 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
checkDssInput();
|
||||
|
||||
/* the data directory is not necessary in dss mode */
|
||||
if (optind >= argc) {
|
||||
fprintf(stderr, _("%s: no data directory specified\n"), progname);
|
||||
|
@ -215,3 +215,19 @@ static void initDSSDataPathStruct(datadir_t *dataDir)
|
||||
"%s/pg_doublewrite%d/dw_batch_upgrade_files", dataDir->dss_data, dataDir->instance_id);
|
||||
securec_check_ss_c(rc, "", "");
|
||||
}
|
||||
|
||||
char *getSocketpathFromEnv()
|
||||
{
|
||||
char* env_value = NULL;
|
||||
env_value = getenv("DSS_HOME");
|
||||
if ((env_value == NULL) || (env_value[0] == '\0')) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *file = (char*)malloc(MAXPGPATH);
|
||||
errno_t rc = EOK;
|
||||
rc = snprintf_s(file, MAXPGPATH, MAXPGPATH - 1, "UDS:%s/.dss_unix_d_socket", env_value);
|
||||
securec_check_ss_c(rc, "\0", "\0");
|
||||
|
||||
return file;
|
||||
}
|
@ -128,4 +128,6 @@ extern datadir_t g_datadir;
|
||||
|
||||
void initDataPathStruct(bool enable_dss);
|
||||
|
||||
char *getSocketpathFromEnv();
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user