Skip to content

Commit

Permalink
[CBRD-25003] remove run_child_cwd () for ts_loaddb () (#84)
Browse files Browse the repository at this point in the history
revert, remove run_child_cwd () and replace it to run_child ()
  • Loading branch information
kisoo-han authored Sep 20, 2023
1 parent b35b6d4 commit 6a6c40d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 46 deletions.
55 changes: 28 additions & 27 deletions server/src/cm_job_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ static int get_sql_info (char *dbmt_file, int *file_size);
static int get_sql_text (char *tmpfile, char *query_p, TS_SQL_INFO *qry_info, int query_file_size);
static int get_next_sqltext (FILE * qfp, char *qry_buf, int offset, int query_file_size);

static void unlink_schema_files (const char *path, const char *schema_list_file);
static void unlink_schema_files (const char *schema_list_file);

static int
_verify_user_passwd (char *dbname, char *dbuser, char *dbpasswd,
Expand Down Expand Up @@ -5095,8 +5095,6 @@ ts_loaddb (nvplist *req, nvplist *res, char *_dbmt_error)
char *no_user_specified_name = NULL;
char *schema_file_list = NULL;
char schema_file_list_opt [PATH_MAX];
bool schema_file_list_opt_flag = false;
char loaddb_exe_path[PATH_MAX];

cubrid_err_file[0] = '\0';

Expand Down Expand Up @@ -5241,7 +5239,6 @@ ts_loaddb (nvplist *req, nvplist *res, char *_dbmt_error)
}
if (schema_file_list != NULL && !uStringEqual (schema_file_list, "none"))
{
schema_file_list_opt_flag = true;
snprintf (schema_file_list_opt, PATH_MAX, "%s%s", "--" LOAD_SCHEMA_FILE_LIST_L "=", schema_file_list);
argv[argc++] = schema_file_list_opt;
}
Expand All @@ -5250,26 +5247,7 @@ ts_loaddb (nvplist *req, nvplist *res, char *_dbmt_error)

make_temp_filepath (cubrid_err_file, sco.dbmt_tmp_dir, "loaddb_err_tmp", TS_LOADDB, PATH_MAX);

if (schema_file_list_opt_flag)
{
#if defined (WINDOWS)
char drive [_MAX_DRIVE];
char dir[PATH_MAX];

if (_splitpath_s(schema_file_list, drive, _MAX_DRIVE, dir, PATH_MAX, NULL, 0, NULL, 0) == 0)
{
snprintf (loaddb_exe_path, PATH_MAX, "%s%s", drive, dir);
retval = run_child_cwd (argv, loaddb_exe_path, 1, NULL, tmpfile, cubrid_err_file, NULL);
}
#else
snprintf (loaddb_exe_path, PATH_MAX, "%s", schema_file_list);
retval = run_child_cwd (argv, dirname(loaddb_exe_path), 1, NULL, tmpfile, cubrid_err_file, NULL);
#endif
}
else
{
retval = run_child (argv, 1, NULL, tmpfile, cubrid_err_file, NULL);
}
retval = run_child (argv, 1, NULL, tmpfile, cubrid_err_file, NULL); /* loaddb */

if (retval < 0)
{
Expand Down Expand Up @@ -5315,25 +5293,48 @@ ts_loaddb (nvplist *req, nvplist *res, char *_dbmt_error)
}
if (schema_file_list)
{
unlink_schema_files (loaddb_exe_path, schema_file_list);
unlink_schema_files (schema_file_list);
}
}

return ERR_NO_ERROR;
}

static void
unlink_schema_files (const char *path, const char *schema_list_file)
unlink_schema_files (const char *schema_list_file)
{
FILE *fp;
char *p, filename[PATH_MAX] = { 0, };
char path_name[PATH_MAX*2];
char path[PATH_MAX];

if (path == NULL || schema_list_file == NULL || (fp = fopen (schema_list_file, "r")) == NULL)
if (schema_list_file == NULL || (fp = fopen (schema_list_file, "r")) == NULL)
{
return;
}

#if defined (WINDOWS)
{
char drive[_MAX_DRIVE];
char dir[PATH_MAX];

if (_splitpath_s(schema_list_file, drive, _MAX_DRIVE, dir, PATH_MAX, NULL, 0, NULL, 0) == 0)
{
snprintf (path, PATH_MAX, "%s%s", drive, dir);
}
else
{
return;
}
}
#else
snprintf (path, PATH_MAX, "%s", schema_list_file);
if (dirname(path) == NULL)
{
return;
}
#endif

while (fgets (filename, PATH_MAX, fp))
{
p = strchr (filename, '\n');
Expand Down
16 changes: 0 additions & 16 deletions server/src/cm_server_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,22 +324,6 @@ is_process_running (const char *process_name, unsigned int sleep_time)
return true;
}

int
run_child_cwd (const char *const argv[], const char * dir, int wait_flag,
const char *stdin_file, char *stdout_file, char *stderr_file,
int *exit_status)
{
#if defined (WINDOWS)
if (_chdir (dir) < 0)
#else
if (chdir (dir) < 0)
#endif
{
return -1;
}

return run_child (argv, wait_flag, stdin_file, stdout_file, stderr_file, exit_status);
}
#if !defined(WINDOWS)
int
run_child_linux (const char *pname, const char *const argv[], int wait_flag,
Expand Down
3 changes: 0 additions & 3 deletions server/src/cm_server_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,6 @@ int ut_get_host_stat (T_CMS_HOST_STAT *stat, char *_dbmt_error);
int ut_get_proc_stat (T_CMS_PROC_STAT *stat, int pid);
int ut_record_cubrid_utility_log_stderr (const char *msg);
int ut_record_cubrid_utility_log_stdout (const char *msg);
int run_child_cwd (const char *const argv[], const char *dir, int wait_flag,
const char *stdin_file, char *stdout_file, char *stderr_file,
int *exit_status);
int run_child_linux (const char *pname, const char *const argv[], int wait_flag,
const char *stdin_file, char *stdout_file, char *stderr_file,
int *exit_status);
Expand Down

0 comments on commit 6a6c40d

Please sign in to comment.