MCPcopy Create free account
hub / github.com/apache/cloudberry / check_exec

Function check_exec

src/bin/pg_upgrade/exec.c:431–469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

429}
430
431static void
432check_exec(const char *dir, const char *program, bool check_version)
433{
434 char path[MAXPGPATH];
435 char line[MAXPGPATH];
436 char cmd[MAXPGPATH];
437 char versionstr[128];
438 char gp_versionstr[128];
439 int ret;
440
441 snprintf(path, sizeof(path), "%s/%s", dir, program);
442
443 ret = validate_exec(path);
444
445 if (ret == -1)
446 pg_fatal("check for \"%s\" failed: not a regular file\n",
447 path);
448 else if (ret == -2)
449 pg_fatal("check for \"%s\" failed: cannot execute (permission denied)\n",
450 path);
451
452 snprintf(cmd, sizeof(cmd), "\"%s\" -V", path);
453
454 if (!pipe_read_line(cmd, line, sizeof(line)))
455 pg_fatal("check for \"%s\" failed: cannot execute\n",
456 path);
457
458 if (check_version)
459 {
460 pg_strip_crlf(line);
461
462 snprintf(versionstr, sizeof(versionstr), "%s (PostgreSQL) " PG_VERSION, program);
463 snprintf(gp_versionstr, sizeof(versionstr), "%s (Apache Cloudberry) " PG_VERSION, program);
464
465 if (strcmp(line, versionstr) != 0 && strcmp(line, gp_versionstr) != 0)
466 pg_fatal("check for \"%s\" failed: incorrect version: found \"%s\", expected \"%s\" or \"%s\"\n",
467 path, line, versionstr, gp_versionstr);
468 }
469}

Callers 1

check_bin_dirFunction · 0.85

Calls 4

validate_execFunction · 0.85
pg_fatalFunction · 0.85
pipe_read_lineFunction · 0.85
pg_strip_crlfFunction · 0.85

Tested by

no test coverage detected