incubator-hawq git commit: [#116576425] - Add option to ignore hosts on which SSH test fails to skip syncing configuration files

2016-03-31 Thread bhuvnesh2703
Repository: incubator-hawq
Updated Branches:
  refs/heads/HAWQ-617 [created] 7e8331a7e


[#116576425] - Add option to ignore hosts on which SSH test fails to skip 
syncing configuration files


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/7e8331a7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/7e8331a7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/7e8331a7

Branch: refs/heads/HAWQ-617
Commit: 7e8331a7e314c9d5b7f2ec65078fa069271a284d
Parents: 071f276
Author: Bhuvnesh Chaudhary 
Authored: Thu Mar 31 23:14:54 2016 -0700
Committer: Bhuvnesh Chaudhary 
Committed: Thu Mar 31 23:14:54 2016 -0700

--
 .gitignore  | 55 +---
 tools/bin/gppylib/util/ssh_utils.py | 23 +
 tools/bin/gpscp | 36 +
 tools/bin/hawq_ctl  | 13 +---
 tools/bin/hawqconfig| 12 ---
 tools/bin/hawqpylib/HAWQ_HELP.py|  1 +
 6 files changed, 64 insertions(+), 76 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/7e8331a7/.gitignore
--
diff --git a/.gitignore b/.gitignore
index 8fd9023..485dee6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,54 +1 @@
-# Object files
-*.o
-*.ko
-*.obj
-*.elf
-.deps
-
-# Precompiled Headers
-*.gch
-*.pch
-
-# Libraries
-*.lib
-*.a
-*.la
-*.lo
-
-# Shared objects (inc. Windows DLLs)
-*.dll
-*.so
-*.so.*
-*.dylib
-
-# Executables
-*.exe
-*.app
-*.i*86
-*.x86_64
-*.hex
-
-# Debug files
-*.dSYM/
-*.o
-*.ko
-*.obj
-*.elf
-objfiles.txt
-
-# Eclipse Project
-.project
-.pydevproject
-.cproject
-.settings
-
-# Generated files
-BUILD_NUMBER
-GNUmakefile
-config.log
-config.status
-VERSION
-env.sh
-ext/
-plr.tgz
-autom4te.cache/
+.idea

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/7e8331a7/tools/bin/gppylib/util/ssh_utils.py
--
diff --git a/tools/bin/gppylib/util/ssh_utils.py 
b/tools/bin/gppylib/util/ssh_utils.py
index 3194e11..853c0f5 100644
--- a/tools/bin/gppylib/util/ssh_utils.py
+++ b/tools/bin/gppylib/util/ssh_utils.py
@@ -160,6 +160,29 @@ class HostList():
 
 return self.list
 
+def removeBadHosts(self):
+''' Update list of host to include only the host on which SSH was 
successful'''
+
+pool = WorkerPool()
+
+for h in self.list:
+cmd = Echo('ssh test', '', ctxt=REMOTE, remoteHost=h)
+pool.addCommand(cmd)
+
+pool.join()
+pool.haltWork()
+
+bad_hosts = []
+working_hosts = []
+for cmd in pool.getCompletedItems():
+if not cmd.get_results().wasSuccessful():
+bad_hosts.append(cmd.remoteHost)
+else:
+working_hosts.append(cmd.remoteHost)
+
+self.list = working_hosts[:]
+return bad_hosts
+
 # Session is a command session, derived from a base class cmd.Cmd
 class Session(cmd.Cmd):
 '''Implements a list of open ssh sessions ready to execute commands'''

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/7e8331a7/tools/bin/gpscp
--
diff --git a/tools/bin/gpscp b/tools/bin/gpscp
index d00f15d..c02d677 100755
--- a/tools/bin/gpscp
+++ b/tools/bin/gpscp
@@ -64,6 +64,7 @@ class Global:
 opt['-f'] = None
 opt['-J'] = '=:'
 opt['-r'] = False
+opt['--ignore-bad-hosts'] = False
 filePath = []
 
 GV = Global()
@@ -86,18 +87,19 @@ def print_version():
 #
 def parseCommandLine():
 try:
-(options, args) = getopt.getopt(sys.argv[1:], '?vrJ:p:u:h:f:', 
['version'])
+(options, args) = getopt.getopt(sys.argv[1:], '?vrJ:p:u:h:f:', 
['version', 'ignore-bad-hosts'])
 except Exception, e:
 usage('[ERROR] ' + str(e))
 
 for (switch, val) in options:
-   if (switch == '-?'):  usage(0)
-   elif (switch == '-v'):GV.opt[switch] = True
-   elif (switch == '-f'):GV.opt[switch] = val
-   elif (switch == '-h'):GV.opt[switch].append(val)
-elif (switch == '-J'):GV.opt[switch] = val + ':'
-elif (switch == '-r'):GV.opt[switch] = True
-elif (switch == '--version'): print_version()
+if (switch == '-?'): usage(0)
+elif (switch == '-v'):  GV.opt[switch] = 
True
+elif (switch == '-f'):  GV.opt[switch] = 
val
+elif (switch == '-h'):  
GV.opt[switch].append(val)
+elif (switch == '-J'):  GV.opt[switch] = 
va

incubator-hawq git commit: HAWQ-608. Hot refactor libyarn to fix bug under higher version of gcc, upgrade libyarn version number.

2016-03-31 Thread wlin
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 071f276bc -> b0ddaea73


HAWQ-608. Hot refactor libyarn to fix bug under higher version of gcc,
upgrade libyarn version number.


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/b0ddaea7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/b0ddaea7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/b0ddaea7

Branch: refs/heads/master
Commit: b0ddaea73b10e5ea809285d8c98b83428260de25
Parents: 071f276
Author: xunzhang 
Authored: Wed Mar 30 21:35:47 2016 +0800
Committer: Wen Lin 
Committed: Fri Apr 1 14:12:40 2016 +0800

--
 depends/libyarn/mock/MockApplicationClient.h| 2 +-
 depends/libyarn/mock/MockApplicationClientProtocol.h| 2 +-
 depends/libyarn/mock/MockApplicationMaster.h| 2 +-
 depends/libyarn/mock/MockApplicationMasterProtocol.h| 2 +-
 depends/libyarn/mock/MockContainerManagement.h  | 2 +-
 depends/libyarn/mock/MockContainerManagementProtocol.h  | 2 +-
 depends/libyarn/mock/MockLibYarnClient.h| 2 +-
 depends/libyarn/sample/client_main.cpp  | 5 -
 depends/libyarn/src/CMakeLists.txt  | 2 +-
 depends/libyarn/src/libyarnclient/ApplicationClient.cpp | 2 +-
 depends/libyarn/src/libyarnclient/ApplicationClient.h   | 2 +-
 depends/libyarn/src/libyarnclient/ApplicationMaster.cpp | 2 +-
 depends/libyarn/src/libyarnclient/ApplicationMaster.h   | 2 +-
 depends/libyarn/src/libyarnclient/ContainerManagement.h | 2 +-
 depends/libyarn/src/libyarnclient/LibYarnClient.h   | 5 +
 depends/libyarn/src/libyarnclient/LibYarnClientC.cpp| 2 +-
 depends/libyarn/src/libyarnserver/ApplicationClientProtocol.h   | 2 +-
 depends/libyarn/src/libyarnserver/ApplicationMasterProtocol.h   | 2 +-
 depends/libyarn/src/libyarnserver/ContainerManagementProtocol.h | 2 +-
 depends/libyarn/src/protocolrecords/AllocateRequest.h   | 2 +-
 depends/libyarn/src/protocolrecords/AllocateResponse.h  | 2 +-
 .../src/protocolrecords/FinishApplicationMasterRequest.h| 2 +-
 depends/libyarn/src/protocolrecords/GetApplicationsRequest.h| 2 +-
 depends/libyarn/src/protocolrecords/GetApplicationsResponse.h   | 2 +-
 depends/libyarn/src/protocolrecords/GetClusterNodesRequest.h| 2 +-
 depends/libyarn/src/protocolrecords/GetClusterNodesResponse.h   | 2 +-
 .../libyarn/src/protocolrecords/GetContainerStatusesRequest.h   | 2 +-
 .../src/protocolrecords/GetContainerStatusesResponse.cpp| 1 +
 .../libyarn/src/protocolrecords/GetContainerStatusesResponse.h  | 2 +-
 depends/libyarn/src/protocolrecords/GetContainersRequest.h  | 2 +-
 depends/libyarn/src/protocolrecords/GetContainersResponse.h | 2 +-
 depends/libyarn/src/protocolrecords/GetQueueInfoRequest.h   | 2 +-
 .../libyarn/src/protocolrecords/GetQueueUserAclsInfoResponse.h  | 2 +-
 .../src/protocolrecords/RegisterApplicationMasterRequest.h  | 2 +-
 .../src/protocolrecords/RegisterApplicationMasterResponse.h | 2 +-
 depends/libyarn/src/protocolrecords/StartContainerRequest.h | 2 +-
 depends/libyarn/src/protocolrecords/StartContainerResponse.h| 2 +-
 depends/libyarn/src/protocolrecords/StartContainersRequest.h| 2 +-
 depends/libyarn/src/protocolrecords/StartContainersResponse.h   | 2 +-
 depends/libyarn/src/protocolrecords/StopContainersRequest.h | 2 +-
 depends/libyarn/src/protocolrecords/StopContainersResponse.h| 2 +-
 depends/libyarn/src/records/ApplicationACLMap.h | 2 +-
 depends/libyarn/src/records/ApplicationReport.h | 2 +-
 depends/libyarn/src/records/ApplicationSubmissionContext.h  | 2 +-
 depends/libyarn/src/records/Container.h | 2 +-
 depends/libyarn/src/records/ContainerLaunchContext.h| 2 +-
 depends/libyarn/src/records/ContainerReport.h   | 2 +-
 depends/libyarn/src/records/ContainerStatus.h   | 2 +-
 depends/libyarn/src/records/LocalResource.h | 2 +-
 depends/libyarn/src/records/NodeId.h| 2 +-
 depends/libyarn/src/records/NodeReport.h| 2 +-
 depends/libyarn/src/records/PreemptionContract.cpp  | 3 +++
 depends/libyarn/src/records/PreemptionContract.h| 3 ++-
 depends/libyarn/src/records/QueueInfo.h | 2 +-
 depends/libyarn/src/records/QueueUserACLInfo.h  | 2 +-
 depends/libyarn/src/records/ResourceBlacklistRequest.h  | 2 +-
 depends/libyarn/src/records/ResourceRequest.h   | 2 +-
 depends/libyarn/src/records/SerializedException.h   | 2 +-
 depends/libyarn/src/records/StrictPreempt

incubator-hawq git commit: HAWQ-616. Mininum resource needed by copy random table from a file should be one.

2016-03-31 Thread hubertzhang
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 7fef48058 -> 071f276bc


HAWQ-616. Mininum resource needed by copy random table from a file should be 
one.


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/071f276b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/071f276b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/071f276b

Branch: refs/heads/master
Commit: 071f276bc3c3e14b818ecf584a5697a2ebf24870
Parents: 7fef480
Author: hzhang2 
Authored: Fri Apr 1 10:26:28 2016 +0800
Committer: hzhang2 
Committed: Fri Apr 1 10:26:28 2016 +0800

--
 src/backend/commands/copy.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/071f276b/src/backend/commands/copy.c
--
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 2ed87e6..6dc41c1 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -1557,7 +1557,8 @@ DoCopy(const CopyStmt *stmt, const char *queryString)
Oid relid = RelationGetRelid(cstate->rel);
List*all_relids = NIL;
GpPolicy *target_policy = NULL;
-   int target_segment_num = 0;
+   int min_target_segment_num = 0;
+   int max_target_segment_num = 0;
QueryResource *savedResource = NULL;
 
target_policy = GpPolicyFetch(CurrentMemoryContext, 
relid);
@@ -1567,14 +1568,16 @@ DoCopy(const CopyStmt *stmt, const char *queryString)
 * For random table, we use a fixed GUC value to 
request vsegs.
 */
if(target_policy->nattrs > 0){
-   target_segment_num = target_policy->bucketnum;
+   min_target_segment_num = 
target_policy->bucketnum;
+   max_target_segment_num = 
target_policy->bucketnum;
}
else{
-   target_segment_num = 
hawq_rm_nvseg_for_copy_from_perquery;
+   min_target_segment_num = 1;
+   max_target_segment_num = 
hawq_rm_nvseg_for_copy_from_perquery;
}
pfree(target_policy);
 
-   cstate->resource = AllocateResource(QRL_ONCE, 1, 1, 
target_segment_num, target_segment_num,NULL,0);
+   cstate->resource = AllocateResource(QRL_ONCE, 1, 1, 
max_target_segment_num, min_target_segment_num,NULL,0);
savedResource = GetActiveQueryResource();
SetActiveQueryResource(cstate->resource);
all_relids = lappend_oid(all_relids, relid);



incubator-hawq git commit: HAWQ-612. Improve error message if unavailable segments exceeds GUC

2016-03-31 Thread wlin
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 02a1c6c22 -> 7fef48058


HAWQ-612. Improve error message if unavailable segments exceeds GUC


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/7fef4805
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/7fef4805
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/7fef4805

Branch: refs/heads/master
Commit: 7fef48058c3572f4c4454d1726d07eefdfe0558c
Parents: 02a1c6c
Author: Wen Lin 
Authored: Fri Apr 1 10:04:33 2016 +0800
Committer: Wen Lin 
Committed: Fri Apr 1 10:04:33 2016 +0800

--
 src/backend/resourcemanager/requesthandler.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/7fef4805/src/backend/resourcemanager/requesthandler.c
--
diff --git a/src/backend/resourcemanager/requesthandler.c 
b/src/backend/resourcemanager/requesthandler.c
index 7112ba3..4e24848 100644
--- a/src/backend/resourcemanager/requesthandler.c
+++ b/src/backend/resourcemanager/requesthandler.c
@@ -392,10 +392,12 @@ bool handleRMRequestAcquireResource(void **arg)
if ( unavailcount > rejectlimit )
{
snprintf(errorbuf, sizeof(errorbuf),
-"%d of %d segments %s unavailable",
+"%d of %d segments %s unavailable, exceeds 
%.1f%% defined in GUC hawq_rm_rejectrequest_nseg_limit. "
+"The allocation request is rejected.",
 unavailcount,
 PRESPOOL->SlavesHostCount,
-unavailcount == 1 ? "is" : "are");
+unavailcount == 1 ? "is" : "are",
+rm_rejectrequest_nseg_limit*100.0);
elog(WARNING, "ConnID %d. %s", (*conntrack)->ConnID, errorbuf);
res = RESOURCEPOOL_TOO_MANY_UAVAILABLE_HOST;
goto sendresponse;



incubator-hawq git commit: HAWQ-564. QD hangs when connecting to resource manager

2016-03-31 Thread yjin
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 758d26539 -> 02a1c6c22


HAWQ-564. QD hangs when connecting to resource manager


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/02a1c6c2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/02a1c6c2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/02a1c6c2

Branch: refs/heads/master
Commit: 02a1c6c221184d2dfbda8c2c29b36e049646f12f
Parents: 758d265
Author: YI JIN 
Authored: Fri Apr 1 12:53:22 2016 +1100
Committer: YI JIN 
Committed: Fri Apr 1 12:53:22 2016 +1100

--
 .../communication/rmcomm_RM2RMSEG.c |  6 ++-
 .../resourcemanager/include/resourcepool.h  |  1 -
 src/backend/resourcemanager/resourcepool.c  | 45 
 3 files changed, 41 insertions(+), 11 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/02a1c6c2/src/backend/resourcemanager/communication/rmcomm_RM2RMSEG.c
--
diff --git a/src/backend/resourcemanager/communication/rmcomm_RM2RMSEG.c 
b/src/backend/resourcemanager/communication/rmcomm_RM2RMSEG.c
index 85629a8..c784f65 100644
--- a/src/backend/resourcemanager/communication/rmcomm_RM2RMSEG.c
+++ b/src/backend/resourcemanager/communication/rmcomm_RM2RMSEG.c
@@ -618,7 +618,7 @@ void 
processContainersAfterIncreaseMemoryQuota(GRMContainerSet ctns, bool accept
ctn->Life += 1;
 
PRESPOOL->AddPendingContainerCount--;
-   elog(LOG, "AddPendingContainerCount minused 1, current value 
%d",
+   elog(LOG, "AddPendingContainerCount minus 1, current value %d",
  PRESPOOL->AddPendingContainerCount);
/*
 * Add container to ToKickContainers if lifetime is not too 
long.
@@ -628,6 +628,10 @@ void 
processContainersAfterIncreaseMemoryQuota(GRMContainerSet ctns, bool accept
if( !isCleanGRMResourceStatus() &&
ctn->Life < RESOURCE_CONTAINER_MAX_LIFETIME )
{
+   /* This container can not generate additional increase 
pending */
+   minusResourceBundleData(&(ctn->Resource->IncPending),
+   
ctn->MemoryMB,
+   
ctn->Core);
addGRMContainerToToBeAccepted(ctn);
}
/* Add container to KickedContainers if lifetime is long enough 
*/

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/02a1c6c2/src/backend/resourcemanager/include/resourcepool.h
--
diff --git a/src/backend/resourcemanager/include/resourcepool.h 
b/src/backend/resourcemanager/include/resourcepool.h
index f9f893d..8c25ee1 100644
--- a/src/backend/resourcemanager/include/resourcepool.h
+++ b/src/backend/resourcemanager/include/resourcepool.h
@@ -308,7 +308,6 @@ struct SegResourceData {
 SegResource createSegResource(SegStat segstat);
 
 int setSegResHAWQAvailability( SegResource segres, uint8_t newstatus);
-int setSegResGLOBAvailability( SegResource segres, uint8_t newstatus);
 
 /* Set the segment is under or not under RUAlive pending status. */
 bool setSegResRUAlivePending( SegResource segres, bool pending);

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/02a1c6c2/src/backend/resourcemanager/resourcepool.c
--
diff --git a/src/backend/resourcemanager/resourcepool.c 
b/src/backend/resourcemanager/resourcepool.c
index 976ddca..0f06f22 100644
--- a/src/backend/resourcemanager/resourcepool.c
+++ b/src/backend/resourcemanager/resourcepool.c
@@ -907,8 +907,8 @@ int addHAWQSegWithSegStat(SegStat segstat, bool 
*capstatchanged)
int32_t  segid   = SEGSTAT_ID_INVALID;
SimpString   hostnamekey;
SimpArrayhostaddrkey;
-   bool segcapchanged  = false;
-
+   bool segcapchanged   = false;
+   bool segavailchanged = false;
/*
 * Anyway, the host capacity is updated here if the cluster level 
capacity
 * is fixed.
@@ -1040,6 +1040,7 @@ int addHAWQSegWithSegStat(SegStat segstat, bool 
*capstatchanged)
if (segresource->Stat->StatusDesc == 0)
{
setSegResHAWQAvailability(segresource, 
RESOURCE_SEG_STATUS_AVAILABLE);
+   segavailchanged = true;
}
 
/* Add this node into the table gp_segment_configurat

[incubator-hawq] Git Push Summary

2016-03-31 Thread odiachenko
Repository: incubator-hawq
Updated Branches:
  refs/heads/HAWQ-546 [deleted] 758d26539


incubator-hawq git commit: HAWQ-546. Implemented call of pxf_get_object_fields for Hive on psql.

2016-03-31 Thread odiachenko
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 012716357 -> 758d26539


HAWQ-546. Implemented call of pxf_get_object_fields for Hive on psql.


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/758d2653
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/758d2653
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/758d2653

Branch: refs/heads/master
Commit: 758d265396252121c914673b71fe6b2fef08dcd0
Parents: 0127163
Author: Oleksandr Diachenko 
Authored: Thu Mar 31 13:36:48 2016 -0700
Committer: Oleksandr Diachenko 
Committed: Thu Mar 31 13:36:48 2016 -0700

--
 src/bin/psql/describe.c| 143 
 src/test/regress/input/hcatalog_lookup.source  |   4 +
 src/test/regress/output/hcatalog_lookup.source |   9 +-
 3 files changed, 155 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/758d2653/src/bin/psql/describe.c
--
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 99718d2..f1de41b 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -42,11 +42,16 @@ static bool describeOneTSConfig(const char *oid, const char 
*nspname,
 static void printACLColumn(PQExpBuffer buf, const char *colname);
 static bool isGPDB(void);
 static bool isGPDB4200OrLater(void);
+static bool describePxfTable(const char *profile, const char *pattern, bool 
verbose);
+static void parsePxfPattern(const char *user_pattern, char **pattern);
 
 /* GPDB 3.2 used PG version 8.2.10, and we've moved the minor number up since 
then for each release,  4.1 = 8.2.15 */
 /* Allow for a couple of future releases.  If the version isn't in this range, 
we are talking to PostgreSQL, not GPDB */
 #define mightBeGPDB() (pset.sversion >= 80210 && pset.sversion < 80222)
 
+#define HiveProfileName "Hive"
+#define HCatalogSourceName "hcatalog"
+
 static bool isGPDB(void)
 {
static enum { gpdb_maybe, gpdb_yes, gpdb_no } talking_to_gpdb;
@@ -1152,6 +1157,24 @@ describeTableDetails(const char *pattern, bool verbose, 
bool showSystem)
PGresult   *res;
int i;
 
+   //Hive hook in this method
+   if(pattern && strncmp(pattern, HCatalogSourceName, 
strlen(HCatalogSourceName)) == 0)
+   {
+   char *pxf_pattern = NULL;
+   char *pattern_dup = strdup(pattern);
+   parsePxfPattern(pattern_dup, &pxf_pattern);
+   if (!pxf_pattern)
+   {
+   fprintf(stderr, _("Invalid pattern provided.\n"));
+   free(pattern_dup);
+   return false;
+   }
+
+   bool success = describePxfTable(HiveProfileName, pxf_pattern, 
verbose);
+   free(pattern_dup);
+   return success;
+   }
+
initPQExpBuffer(&buf);
 
printfPQExpBuffer(&buf,
@@ -4213,3 +4236,123 @@ printACLColumn(PQExpBuffer buf, const char *colname)
  
"pg_catalog.array_to_string(%s, '\\n') AS \"%s\"",
  colname, gettext_noop("Access 
privileges"));
 }
+
+/*
+ * parsePxfPattern
+ *
+ * Splits user_pattern by "." and writes second part to pattern.
+ */
+static void
+parsePxfPattern(const char *user_pattern, char **pattern)
+{
+   strtok(user_pattern, ".");
+   *pattern = strtok(NULL, "/0");
+}
+
+/*
+ * describePxfTable
+ *
+ * Describes external PXF table.
+ */
+static bool
+describePxfTable(const char *profile, const char *pattern, bool verbose)
+{
+   PQExpBufferData buf;
+   PQExpBufferData title;
+   PGresult *res;
+   printQueryOpt myopt = pset.popt;
+   printTableContent cont;
+   int cols = 0;
+   int total_numrows = 0;
+   char   *headers[2];
+   boolprintTableInitialized = false;
+
+   char *previous_path = NULL;
+   char *previous_itemname = NULL;
+
+   char *path;
+   char *itemname;
+   char *fieldname;
+   char *fieldtype;
+   int total_fields = 0; //needed to know how much memory allocate for 
current table
+
+   initPQExpBuffer(&buf);
+
+   printfPQExpBuffer(&buf, "SELECT t.*, COUNT() OVER(PARTITION BY path, 
itemname) as total_fields FROM\n"
+   "pxf_get_item_fields('%s', '%s') t\n", profile, 
pattern);
+
+   res = PSQLexec(buf.data, false);
+   total_numrows = PQntuples(res);
+   termPQExpBuffer(&buf);
+   if (!res)
+   return false;
+
+   myopt.nullPrint = NULL;
+   myopt.title = _("List of external PXF tables");
+   myopt.translate_header = true;
+
+

incubator-hawq git commit: HAWQ-546. Implemented call of pxf_get_object_fields for Hive on psql.

2016-03-31 Thread odiachenko
Repository: incubator-hawq
Updated Branches:
  refs/heads/HAWQ-546 [created] 758d26539


HAWQ-546. Implemented call of pxf_get_object_fields for Hive on psql.


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/758d2653
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/758d2653
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/758d2653

Branch: refs/heads/HAWQ-546
Commit: 758d265396252121c914673b71fe6b2fef08dcd0
Parents: 0127163
Author: Oleksandr Diachenko 
Authored: Thu Mar 31 13:36:48 2016 -0700
Committer: Oleksandr Diachenko 
Committed: Thu Mar 31 13:36:48 2016 -0700

--
 src/bin/psql/describe.c| 143 
 src/test/regress/input/hcatalog_lookup.source  |   4 +
 src/test/regress/output/hcatalog_lookup.source |   9 +-
 3 files changed, 155 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/758d2653/src/bin/psql/describe.c
--
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 99718d2..f1de41b 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -42,11 +42,16 @@ static bool describeOneTSConfig(const char *oid, const char 
*nspname,
 static void printACLColumn(PQExpBuffer buf, const char *colname);
 static bool isGPDB(void);
 static bool isGPDB4200OrLater(void);
+static bool describePxfTable(const char *profile, const char *pattern, bool 
verbose);
+static void parsePxfPattern(const char *user_pattern, char **pattern);
 
 /* GPDB 3.2 used PG version 8.2.10, and we've moved the minor number up since 
then for each release,  4.1 = 8.2.15 */
 /* Allow for a couple of future releases.  If the version isn't in this range, 
we are talking to PostgreSQL, not GPDB */
 #define mightBeGPDB() (pset.sversion >= 80210 && pset.sversion < 80222)
 
+#define HiveProfileName "Hive"
+#define HCatalogSourceName "hcatalog"
+
 static bool isGPDB(void)
 {
static enum { gpdb_maybe, gpdb_yes, gpdb_no } talking_to_gpdb;
@@ -1152,6 +1157,24 @@ describeTableDetails(const char *pattern, bool verbose, 
bool showSystem)
PGresult   *res;
int i;
 
+   //Hive hook in this method
+   if(pattern && strncmp(pattern, HCatalogSourceName, 
strlen(HCatalogSourceName)) == 0)
+   {
+   char *pxf_pattern = NULL;
+   char *pattern_dup = strdup(pattern);
+   parsePxfPattern(pattern_dup, &pxf_pattern);
+   if (!pxf_pattern)
+   {
+   fprintf(stderr, _("Invalid pattern provided.\n"));
+   free(pattern_dup);
+   return false;
+   }
+
+   bool success = describePxfTable(HiveProfileName, pxf_pattern, 
verbose);
+   free(pattern_dup);
+   return success;
+   }
+
initPQExpBuffer(&buf);
 
printfPQExpBuffer(&buf,
@@ -4213,3 +4236,123 @@ printACLColumn(PQExpBuffer buf, const char *colname)
  
"pg_catalog.array_to_string(%s, '\\n') AS \"%s\"",
  colname, gettext_noop("Access 
privileges"));
 }
+
+/*
+ * parsePxfPattern
+ *
+ * Splits user_pattern by "." and writes second part to pattern.
+ */
+static void
+parsePxfPattern(const char *user_pattern, char **pattern)
+{
+   strtok(user_pattern, ".");
+   *pattern = strtok(NULL, "/0");
+}
+
+/*
+ * describePxfTable
+ *
+ * Describes external PXF table.
+ */
+static bool
+describePxfTable(const char *profile, const char *pattern, bool verbose)
+{
+   PQExpBufferData buf;
+   PQExpBufferData title;
+   PGresult *res;
+   printQueryOpt myopt = pset.popt;
+   printTableContent cont;
+   int cols = 0;
+   int total_numrows = 0;
+   char   *headers[2];
+   boolprintTableInitialized = false;
+
+   char *previous_path = NULL;
+   char *previous_itemname = NULL;
+
+   char *path;
+   char *itemname;
+   char *fieldname;
+   char *fieldtype;
+   int total_fields = 0; //needed to know how much memory allocate for 
current table
+
+   initPQExpBuffer(&buf);
+
+   printfPQExpBuffer(&buf, "SELECT t.*, COUNT() OVER(PARTITION BY path, 
itemname) as total_fields FROM\n"
+   "pxf_get_item_fields('%s', '%s') t\n", profile, 
pattern);
+
+   res = PSQLexec(buf.data, false);
+   total_numrows = PQntuples(res);
+   termPQExpBuffer(&buf);
+   if (!res)
+   return false;
+
+   myopt.nullPrint = NULL;
+   myopt.title = _("List of external PXF tables");
+   myopt.translate_header = true;
+

[incubator-hawq] Git Push Summary

2016-03-31 Thread odiachenko
Repository: incubator-hawq
Updated Branches:
  refs/heads/HAWQ-432 [deleted] e80c20cff


[incubator-hawq] Git Push Summary

2016-03-31 Thread odiachenko
Repository: incubator-hawq
Updated Branches:
  refs/heads/HAWQ-400 [deleted] 686529d34


[incubator-hawq] Git Push Summary

2016-03-31 Thread odiachenko
Repository: incubator-hawq
Updated Branches:
  refs/heads/HAWQ-369 [deleted] 9db45b948


[incubator-hawq] Git Push Summary

2016-03-31 Thread odiachenko
Repository: incubator-hawq
Updated Branches:
  refs/heads/HAWQ-340 [deleted] b1d2e90f1


[incubator-hawq] Git Push Summary

2016-03-31 Thread odiachenko
Repository: incubator-hawq
Updated Branches:
  refs/heads/HAWQ-546 [deleted] eb3e4c93d


[1/2] incubator-hawq git commit: HAWQ-613. rename variable for code convention

2016-03-31 Thread mli
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 323f265aa -> 012716357


HAWQ-613. rename variable for code convention


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/01271635
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/01271635
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/01271635

Branch: refs/heads/master
Commit: 01271635761f449891d7e7810b3ca1e8d36787e5
Parents: ac5ab17
Author: Ming LI 
Authored: Thu Mar 31 17:43:54 2016 +0800
Committer: Ming LI 
Committed: Thu Mar 31 17:47:00 2016 +0800

--
 src/backend/executor/execQual.c | 16 
 src/backend/tcop/postgres.c | 12 ++--
 2 files changed, 14 insertions(+), 14 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/01271635/src/backend/executor/execQual.c
--
diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c
index 3d12c02..6059a66 100644
--- a/src/backend/executor/execQual.c
+++ b/src/backend/executor/execQual.c
@@ -1619,13 +1619,13 @@ restart:
fcinfo.isnull = false;
rsinfo.isDone = ExprSingleResult;
 
-   bool save_ImmediateInterruptOK = 
ImmediateInterruptOK;
+   bool savedImmediateInterruptOK = 
ImmediateInterruptOK;
/* Allow "die" interrupt to be processed while 
waiting */
ImmediateInterruptOK = true;
InterruptWhenCallingPLUDF = true;
result = FunctionCallInvoke(&fcinfo);
InterruptWhenCallingPLUDF = false;
-   ImmediateInterruptOK = 
save_ImmediateInterruptOK;
+   ImmediateInterruptOK = 
savedImmediateInterruptOK;
 
*isNull = fcinfo.isnull;
*isDone = rsinfo.isDone;
@@ -1755,13 +1755,13 @@ restart:
}
fcinfo.isnull = false;
 
-   bool save_ImmediateInterruptOK = ImmediateInterruptOK;
+   bool savedImmediateInterruptOK = ImmediateInterruptOK;
/* Allow "die" interrupt to be processed while waiting */
ImmediateInterruptOK = true;
InterruptWhenCallingPLUDF = true;
result = FunctionCallInvoke(&fcinfo);
InterruptWhenCallingPLUDF = false;
-   ImmediateInterruptOK = save_ImmediateInterruptOK;
+   ImmediateInterruptOK = savedImmediateInterruptOK;
 
*isNull = fcinfo.isnull;
}
@@ -1824,13 +1824,13 @@ ExecMakeFunctionResultNoSets(FuncExprState *fcache,
}
/* fcinfo.isnull = false; *//* handled by InitFunctionCallInfoData 
*/
 
-   bool save_ImmediateInterruptOK = ImmediateInterruptOK;
+   bool savedImmediateInterruptOK = ImmediateInterruptOK;
/* Allow "die" interrupt to be processed while waiting */
ImmediateInterruptOK = true;
InterruptWhenCallingPLUDF = true;
result = FunctionCallInvoke(&fcinfo);
InterruptWhenCallingPLUDF = false;
-   ImmediateInterruptOK = save_ImmediateInterruptOK;
+   ImmediateInterruptOK = savedImmediateInterruptOK;
 
*isNull = fcinfo.isnull;
 
@@ -1987,13 +1987,13 @@ ExecMakeTableFunctionResult(ExprState *funcexpr,
fcinfo.isnull = false;
rsinfo.isDone = ExprSingleResult;
 
-   bool save_ImmediateInterruptOK = ImmediateInterruptOK;
+   bool savedImmediateInterruptOK = ImmediateInterruptOK;
/* Allow "die" interrupt to be processed while waiting 
*/
ImmediateInterruptOK = true;
InterruptWhenCallingPLUDF = true;
result = FunctionCallInvoke(&fcinfo);
InterruptWhenCallingPLUDF = false;
-   ImmediateInterruptOK = save_ImmediateInterruptOK;
+   ImmediateInterruptOK = savedImmediateInterruptOK;
}
else
{

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/01271635/src/backend/tcop/postgres.c
--
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 9ffd0d9..5910582 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -266,8 +266,8 @@ static int getSlaveHostNumber(FILE *fp);
 static bool CheckSlaveFile();
 
 /*saved interrupt global variable for client_read_xxx funct

[2/2] incubator-hawq git commit: HAWQ-613. Cannot cancel query when PL UDF has infinity loops

2016-03-31 Thread mli
HAWQ-613. Cannot cancel query when PL UDF has infinity loops


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/ac5ab17c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/ac5ab17c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/ac5ab17c

Branch: refs/heads/master
Commit: ac5ab17c49579e161ef6469e839ae5f33dab9274
Parents: 323f265
Author: Ming LI 
Authored: Thu Mar 31 17:14:34 2016 +0800
Committer: Ming LI 
Committed: Thu Mar 31 17:47:00 2016 +0800

--
 src/backend/executor/execQual.c  | 31 +++
 src/backend/storage/ipc/ipc.c|  1 +
 src/backend/tcop/postgres.c  | 12 +---
 src/backend/utils/error/elog.c   |  4 
 src/backend/utils/init/globals.c |  1 +
 src/include/miscadmin.h  |  1 +
 6 files changed, 47 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ac5ab17c/src/backend/executor/execQual.c
--
diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c
index 79d8345..3d12c02 100644
--- a/src/backend/executor/execQual.c
+++ b/src/backend/executor/execQual.c
@@ -1618,7 +1618,15 @@ restart:
{
fcinfo.isnull = false;
rsinfo.isDone = ExprSingleResult;
+
+   bool save_ImmediateInterruptOK = 
ImmediateInterruptOK;
+   /* Allow "die" interrupt to be processed while 
waiting */
+   ImmediateInterruptOK = true;
+   InterruptWhenCallingPLUDF = true;
result = FunctionCallInvoke(&fcinfo);
+   InterruptWhenCallingPLUDF = false;
+   ImmediateInterruptOK = 
save_ImmediateInterruptOK;
+
*isNull = fcinfo.isnull;
*isDone = rsinfo.isDone;
}
@@ -1746,7 +1754,15 @@ restart:
}
}
fcinfo.isnull = false;
+
+   bool save_ImmediateInterruptOK = ImmediateInterruptOK;
+   /* Allow "die" interrupt to be processed while waiting */
+   ImmediateInterruptOK = true;
+   InterruptWhenCallingPLUDF = true;
result = FunctionCallInvoke(&fcinfo);
+   InterruptWhenCallingPLUDF = false;
+   ImmediateInterruptOK = save_ImmediateInterruptOK;
+
*isNull = fcinfo.isnull;
}
 
@@ -1807,7 +1823,15 @@ ExecMakeFunctionResultNoSets(FuncExprState *fcache,
}
}
/* fcinfo.isnull = false; *//* handled by InitFunctionCallInfoData 
*/
+
+   bool save_ImmediateInterruptOK = ImmediateInterruptOK;
+   /* Allow "die" interrupt to be processed while waiting */
+   ImmediateInterruptOK = true;
+   InterruptWhenCallingPLUDF = true;
result = FunctionCallInvoke(&fcinfo);
+   InterruptWhenCallingPLUDF = false;
+   ImmediateInterruptOK = save_ImmediateInterruptOK;
+
*isNull = fcinfo.isnull;
 
return result;
@@ -1962,7 +1986,14 @@ ExecMakeTableFunctionResult(ExprState *funcexpr,
{
fcinfo.isnull = false;
rsinfo.isDone = ExprSingleResult;
+
+   bool save_ImmediateInterruptOK = ImmediateInterruptOK;
+   /* Allow "die" interrupt to be processed while waiting 
*/
+   ImmediateInterruptOK = true;
+   InterruptWhenCallingPLUDF = true;
result = FunctionCallInvoke(&fcinfo);
+   InterruptWhenCallingPLUDF = false;
+   ImmediateInterruptOK = save_ImmediateInterruptOK;
}
else
{

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ac5ab17c/src/backend/storage/ipc/ipc.c
--
diff --git a/src/backend/storage/ipc/ipc.c b/src/backend/storage/ipc/ipc.c
index 51e19d9..4934f80 100644
--- a/src/backend/storage/ipc/ipc.c
+++ b/src/backend/storage/ipc/ipc.c
@@ -158,6 +158,7 @@ proc_exit_prepare(int code)
QueryCancelPending = false;
/* And let's just make *sure* we're not interrupted ... */
ImmediateInterruptOK = false;
+   InterruptWhenCallingPLUDF = false;
InterruptHoldoffCount = 1;
CritSectionCount = 0;
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ac5ab17c/src/backend/tcop/postgres.c
--
diff --git a/src

incubator-hawq git commit: HAWQ-573. Refix the bug as last fix has imported more warning messages.

2016-03-31 Thread hubertzhang
Repository: incubator-hawq
Updated Branches:
  refs/heads/master b65815a3c -> 323f265aa


HAWQ-573. Refix the bug as last fix has imported more warning messages.


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/323f265a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/323f265a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/323f265a

Branch: refs/heads/master
Commit: 323f265aa28cfb49d29311cc1626e7bd2048e4bf
Parents: b65815a
Author: doli 
Authored: Thu Mar 31 13:59:29 2016 +0800
Committer: hzhang2 
Committed: Thu Mar 31 17:36:12 2016 +0800

--
 src/backend/tcop/pquery.c | 81 +++---
 1 file changed, 77 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/323f265a/src/backend/tcop/pquery.c
--
diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c
index 23b59a1..04420c3 100644
--- a/src/backend/tcop/pquery.c
+++ b/src/backend/tcop/pquery.c
@@ -85,6 +85,7 @@ static List *ActiveRelsType =NULL;
 typedef struct QueryResourceItem {
   bool alive;
   int resource_id;
+  bool allocateSucceed;
 } QueryResourceItem;
 
 static List *GlobalQueryResources = NIL;
@@ -111,7 +112,8 @@ static int64 DoPortalRunFetch(Portal portal,
 static void DoPortalRewind(Portal portal);
 
 static void AddToGlobalQueryResources(int resourceId, QueryResourceLife life);
-
+static void RemoveFromGlobalQueryResources(int resourceId, QueryResourceLife 
life);
+static void SetResourcesAllocatedSucceed(int resourceId, QueryResourceLife 
life);
 static int compare_segment(const void *e1, const void *e2);
 /*
  * CreateQueryDesc
@@ -805,7 +807,10 @@ AllocateResource(QueryResourceLife   life,
errorbuf,

sizeof(errorbuf));
if (ret != FUNC_RETURN_OK) {
+   RemoveFromGlobalQueryResources(resourceId, life);
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), 
errmsg("%s",errorbuf)));
+   } else {
+   SetResourcesAllocatedSucceed(resourceId, life);
}
 
elog(DEBUG3, "Acquired resource from resource manager.");
@@ -948,10 +953,73 @@ AddToGlobalQueryResources(int resourceId, 
QueryResourceLife life)
   newItem = palloc(sizeof(QueryResourceItem));
   newItem->alive = true;
   newItem->resource_id = resourceId;
+  /*
+   * Only if the allocate resource RPC returns OK,
+   * the allocateSucceed can be set true by using 
SetResourcesAllocatedSucceed()
+   */
+  newItem->allocateSucceed = false;
   GlobalQueryResources = lappend(GlobalQueryResources, newItem);
   MemoryContextSwitchTo(old);
 }
 
+static void
+RemoveFromGlobalQueryResources(int resourceId, QueryResourceLife life)
+{
+  ListCell *lc;
+  QueryResourceItem *newItem;
+  MemoryContext old;
+
+  if (life == QRL_NONE)
+  {
+return;
+  }
+
+  foreach(lc, GlobalQueryResources)
+  {
+QueryResourceItem *qri = lfirst(lc);
+if(qri->resource_id == resourceId)
+{
+  /*
+   * found, delete it.
+   */
+  break;
+}
+  }
+
+  /*
+   * remove from the global query resource.
+   */
+  old = MemoryContextSwitchTo(TopMemoryContext);
+  GlobalQueryResources = list_delete_ptr(GlobalQueryResources,lfirst(lc));
+  MemoryContextSwitchTo(old);
+}
+
+static void
+SetResourcesAllocatedSucceed(int resourceId, QueryResourceLife life)
+{
+   ListCell *lc;
+   QueryResourceItem *newItem;
+   MemoryContext old;
+
+   if (life == QRL_NONE)
+   {
+ return;
+   }
+
+   foreach(lc, GlobalQueryResources)
+   {
+ QueryResourceItem *qri = lfirst(lc);
+ if(qri->resource_id == resourceId)
+ {
+/*
+* found, set it succeed.
+*/
+qri->allocateSucceed = true;
+return;
+ }
+   }
+}
+
 void
 FreeResource(QueryResource *resource)
 {
@@ -1068,17 +1136,22 @@ CleanupGlobalQueryResources(void)
if (qri->alive)
{
ret = returnResource(qri->resource_id, errorbuf, 
sizeof(errorbuf));
-   if (ret != FUNC_RETURN_OK)
+   /*
+* If qri->allocateSucceed == false, that means it 
interrupts during acquireResourceFromRM().
+* And we don't know if it has been allocated succeed.
+* It also means it may return resource failed as if 
the resource hasn't been allocated yet.
+* So don't report warning message in this situation.
+*/
+   if (ret != FUNC_RETURN_OK && qri->alloc

incubator-hawq git commit: HAWQ-611. Improve performance for query with entry database involved

2016-03-31 Thread huor
Repository: incubator-hawq
Updated Branches:
  refs/heads/master ae8aff2ea -> b65815a3c


HAWQ-611. Improve performance for query with entry database involved


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/b65815a3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/b65815a3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/b65815a3

Branch: refs/heads/master
Commit: b65815a3c32bfc6a733ccec00f684193d450e389
Parents: ae8aff2
Author: Ruilong Huo 
Authored: Thu Mar 31 01:54:40 2016 -0700
Committer: Ruilong Huo 
Committed: Thu Mar 31 01:54:40 2016 -0700

--
 src/backend/storage/ipc/procarray.c | 32 -
 src/backend/storage/lmgr/lock.c | 41 +---
 src/include/storage/procarray.h |  2 --
 3 files changed, 1 insertion(+), 74 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/b65815a3/src/backend/storage/ipc/procarray.c
--
diff --git a/src/backend/storage/ipc/procarray.c 
b/src/backend/storage/ipc/procarray.c
index b3bb8c6..620c01c 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -1016,38 +1016,6 @@ DisplayXidCache(void)
 
 #endif   /* XIDCACHE_DEBUG */
 
-PGPROC *
-FindProcByGpSessionId(long gp_session_id)
-{
-   /* Find the guy who should manage our locks */
-   ProcArrayStruct *arrayP = procArray;
-   int index;
-
-   Assert(gp_session_id > 0);
-   
-   LWLockAcquire(ProcArrayLock, LW_SHARED);
-
-   for (index = 0; index < arrayP->numProcs; index++)
-   {
-   PGPROC *proc = arrayP->procs[index];
-   
-   if (proc->pid == MyProc->pid)
-   continue;
-   
-   if (!proc->mppIsWriter)
-   continue;
-   
-   if (proc->mppSessionId == gp_session_id)
-   {
-   LWLockRelease(ProcArrayLock);
-   return proc;
-   }
-   }
-   
-   LWLockRelease(ProcArrayLock);
-   return NULL;
-}
-
 /*
  * FindAndSignalProcess
  * Find the PGPROC entry in procArray which contains the given sessionId 
and commandId,

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/b65815a3/src/backend/storage/lmgr/lock.c
--
diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c
index c848f94..7b43a10 100644
--- a/src/backend/storage/lmgr/lock.c
+++ b/src/backend/storage/lmgr/lock.c
@@ -552,49 +552,10 @@ LockAcquire(const LOCKTAG *locktag,
 #endif /* USE_TEST_UTILS_X86 */
 
/*
-* lockHolder is the gang member that should hold and manage locks for 
this
-* transaction.  In Utility mode, or on the QD, it's allways myself.
-* 
-* On the QEs, it should normally be the Writer gang member.
+* QD needs to acquire locks, while QE and entry database don't in hawq 
indeed
 */
if (lockHolderProcPtr == NULL)
lockHolderProcPtr = MyProc;
-   
-   if (lockmethodid == DEFAULT_LOCKMETHOD && locktag->locktag_type != 
LOCKTAG_TRANSACTION)
-   {
-   if (Gp_role == GP_ROLE_EXECUTE && !Gp_is_writer)
-   {   
-   if (lockHolderProcPtr == NULL || lockHolderProcPtr == 
MyProc)
-   {
-   /* Find the guy who should manage our locks */
-   PGPROC * proc = 
FindProcByGpSessionId(gp_session_id);
-   int count = 0;
-   while(proc==NULL && count < 5)
-   {
-   pg_usleep( /* microseconds */ 2000);
-   count++;
-   CHECK_FOR_INTERRUPTS();
-   proc = 
FindProcByGpSessionId(gp_session_id);
-   }
-   if (proc != NULL)
-   {
-   elog(DEBUG1,"Found writer proc entry.  
My Pid %d, his pid %d", MyProc-> pid, proc->pid);
-   lockHolderProcPtr = proc;
-   }
-   else
-   elog(DEBUG1,"Could not find writer proc 
entry!");
-   
-   elog(DEBUG1,"Reader gang member trying 
to acquire a lock [%u,%u] %s %d",
-