Repository: incubator-hawq Updated Branches: refs/heads/master 9078784a5 -> 025eecbad
HAWQ-741. Set system login user as default when PGUSER is not set. Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/025eecba Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/025eecba Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/025eecba Branch: refs/heads/master Commit: 025eecbad197ee8cbc4bf329c2a72f32472886ed Parents: 9078784 Author: hzhang2 <zhanghuan...@163.com> Authored: Wed May 18 22:13:45 2016 +0800 Committer: hzhang2 <zhanghuan...@163.com> Committed: Thu May 19 10:01:15 2016 +0800 ---------------------------------------------------------------------- src/test/feature/lib/sql-util.cpp | 11 ++++++++++- src/test/feature/lib/sql-util.h | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/025eecba/src/test/feature/lib/sql-util.cpp ---------------------------------------------------------------------- diff --git a/src/test/feature/lib/sql-util.cpp b/src/test/feature/lib/sql-util.cpp index 08e0d09..61b3d87 100644 --- a/src/test/feature/lib/sql-util.cpp +++ b/src/test/feature/lib/sql-util.cpp @@ -1,5 +1,7 @@ #include "sql-util.h" +#include <pwd.h> +#include <sys/types.h> #include <unistd.h> #include <fstream> @@ -77,8 +79,15 @@ void SQLUtility::execSQLFile(const std::string &sqlFile, } std::unique_ptr<PSQL> SQLUtility::getConnection() { + std::string user = HAWQ_USER; + if(user == ""){ + struct passwd *pw; + uid_t uid = geteuid(); + pw = getpwuid(uid); + user.assign(pw->pw_name);; + } std::unique_ptr<PSQL> psql( - new PSQL(HAWQ_DB, HAWQ_HOST, HAWQ_PORT, HAWQ_USER, HAWQ_PASSWORD)); + new PSQL(HAWQ_DB, HAWQ_HOST, HAWQ_PORT, user, HAWQ_PASSWORD)); return std::move(psql); } http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/025eecba/src/test/feature/lib/sql-util.h ---------------------------------------------------------------------- diff --git a/src/test/feature/lib/sql-util.h b/src/test/feature/lib/sql-util.h index 5c5a59d..8070d3f 100644 --- a/src/test/feature/lib/sql-util.h +++ b/src/test/feature/lib/sql-util.h @@ -9,7 +9,7 @@ #define HAWQ_DB (getenv("PGDATABASE") ? getenv("PGDATABASE") : "postgres") #define HAWQ_HOST (getenv("PGHOST") ? getenv("PGHOST") : "localhost") #define HAWQ_PORT (getenv("PGPORT") ? getenv("PGPORT") : "5432") -#define HAWQ_USER (getenv("PGUSER") ? getenv("PGUSER") : "gpadmin") +#define HAWQ_USER (getenv("PGUSER") ? getenv("PGUSER") : "") #define HAWQ_PASSWORD (getenv("PGPASSWORD") ? getenv("PGPASSWORD") : "") struct FilePath {