Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E2A2E200BBC for ; Sun, 9 Oct 2016 04:06:03 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E154A160ADF; Sun, 9 Oct 2016 02:06:03 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2E6D8160AEF for ; Sun, 9 Oct 2016 04:06:03 +0200 (CEST) Received: (qmail 40823 invoked by uid 500); 9 Oct 2016 02:06:02 -0000 Mailing-List: contact commits-help@hawq.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hawq.incubator.apache.org Delivered-To: mailing list commits@hawq.incubator.apache.org Received: (qmail 40814 invoked by uid 99); 9 Oct 2016 02:06:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Oct 2016 02:06:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id D783D18050F for ; Sun, 9 Oct 2016 02:06:01 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.219 X-Spam-Level: X-Spam-Status: No, score=-6.219 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id j1iE0juaK4a0 for ; Sun, 9 Oct 2016 02:06:00 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with SMTP id 602365FB82 for ; Sun, 9 Oct 2016 02:06:00 +0000 (UTC) Received: (qmail 40695 invoked by uid 99); 9 Oct 2016 02:05:59 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Oct 2016 02:05:59 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 901E5DF99D; Sun, 9 Oct 2016 02:05:59 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mli@apache.org To: commits@hawq.incubator.apache.org Date: Sun, 09 Oct 2016 02:06:00 -0000 Message-Id: In-Reply-To: <1bf8c72838a144ac816e7cf68d5ea47e@git.apache.org> References: <1bf8c72838a144ac816e7cf68d5ea47e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] incubator-hawq git commit: HAWQ-1076. Fixed privileg check for sequence function in column DEFAULT statement archived-at: Sun, 09 Oct 2016 02:06:04 -0000 HAWQ-1076. Fixed privileg check for sequence function in column DEFAULT statement Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/8928e88e Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/8928e88e Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/8928e88e Branch: refs/heads/master Commit: 8928e88ea8426950bbfda3c4b6c75b70599704cb Parents: 8837934 Author: Ming LI Authored: Mon Sep 26 14:58:23 2016 +0800 Committer: Ming LI Committed: Sat Oct 8 10:19:18 2016 +0800 ---------------------------------------------------------------------- src/backend/cdb/cdbquerycontextdispatching.c | 12 +++++++++--- src/backend/utils/cache/relcache.c | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/8928e88e/src/backend/cdb/cdbquerycontextdispatching.c ---------------------------------------------------------------------- diff --git a/src/backend/cdb/cdbquerycontextdispatching.c b/src/backend/cdb/cdbquerycontextdispatching.c index efc6079..88d4f44 100644 --- a/src/backend/cdb/cdbquerycontextdispatching.c +++ b/src/backend/cdb/cdbquerycontextdispatching.c @@ -1499,8 +1499,10 @@ prepareDispatchedCatalogSingleRelation(QueryContextInfo *cxt, Oid relid, prepareDispatchedCatalogAttribute(cxt, relid); /* collect pg_attrdef info */ - prepareDispatchedCatalogAttributeDefault(cxt, relid); - + /* Only INSERT statement will use column default value*/ + if(forInsert){ + prepareDispatchedCatalogAttributeDefault(cxt, relid); + } /* collect pg_attribute_encoding info */ prepareDispatchedCatalogAttributeEncoding(cxt, relid); @@ -1854,9 +1856,13 @@ static bool collect_func_walker(Node *node, QueryContextInfo *context) if (IsA(node, FuncExpr)) { FuncExpr *func = (FuncExpr *) node; + AclMode needAcl = ACL_NO_RIGHTS; switch (func->funcid) { + case SETVAL_FUNC_OID: + needAcl = ACL_UPDATE; case NEXTVAL_FUNC_OID: + needAcl |= ACL_USAGE; { Const *arg; Oid seqoid; @@ -1872,7 +1878,7 @@ static bool collect_func_walker(Node *node, QueryContextInfo *context) * aclchecks on segments defeats the purpose. Do the aclchecks * on the master, prior to dispatch */ - if (pg_class_aclcheck(seqoid, GetUserId(), ACL_UPDATE) != ACLCHECK_OK) + if (pg_class_aclcheck(seqoid, GetUserId(), needAcl) != ACLCHECK_OK) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), errmsg("permission denied for sequence %s", http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/8928e88e/src/backend/utils/cache/relcache.c ---------------------------------------------------------------------- diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 1a41090..95865fc 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -3265,7 +3265,7 @@ AttrDefaultFetch(Relation relation) caql_endscan(pcqCtx); heap_close(adrel, AccessShareLock); - if (found != ndef) + if (found != ndef && AmIMaster()) elog(WARNING, "%d attrdef record(s) missing for rel %s", ndef - found, RelationGetRelationName(relation)); }