Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cv8ey-0007cP-6D for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Apr 2017 20:33:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cv8ex-0006CL-Ot for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Apr 2017 20:33:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cv8dQ-0000dM-G6 for pgsql-hackers@postgresql.org; Mon, 03 Apr 2017 20:31:32 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cv8dN-0008VB-SN for pgsql-hackers@postgresql.org; Mon, 03 Apr 2017 20:31:32 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 974332081D; Mon, 3 Apr 2017 16:31:28 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute7.internal (MEProxy); Mon, 03 Apr 2017 16:31:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=K6k8ehVBpeLH4OySF+W1piGlFc3kjZtptluFEFissp0=; b=Wx58hBtp 4R5X4xaO9M6t9LBcLKuxNepFLLoGCrkq8iSoHN7p/M+8GFSaSk8WlfIvh6tJ/7iY ZxiYcz8Yy2BWniDV7/u9K+adOIPimZYF9Q20pEksb9GXe/33M4/AvZKCYFb7Ctng 0Dv4ZPAEJRHqLKa6qqVi5b0Y+Q4gpEGM8oIk1dOyoR8IuwHUIQb2yPPqlgc+6Fg1 /Es0JdL2PYb4spv3cA+lLKoBafPxFmWXWuEMuxCR/OVjdzz/ygN5iC8tUdT4hicu Dmy30w/8nwn2UaLoV9aEB19O5AgBT/UKn1KgfMmoMXTlaUn4Cnt2Axy3hjll7Mlm trNaAGtl2NH7uA== X-ME-Sender: X-Sasl-enc: rjevijhRo9woNfhr2pcpeguWQuFnZ/3THcO0ydBjCUm4 1491251488 Received: from april.local (c-73-13-66-39.hsd1.pa.comcast.net [73.13.66.39]) by mail.messagingengine.com (Postfix) with ESMTPA id 62EFF7E350; Mon, 3 Apr 2017 16:31:28 -0400 (EDT) Subject: Re: identity columns To: Andres Freund References: <06a416db-e35b-36d1-7e2f-0affdee24745@2ndquadrant.com> <4b1d703f-818f-00bf-4169-3279af377f3d@2ndquadrant.com> <20170403181918.55rci53cll6fhcq6@alap3.anarazel.de> Cc: Vitaly Burovoy , pgsql-hackers From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: <38c3769c-eec5-19c6-ce33-16838de77ccc@2ndquadrant.com> Date: Mon, 3 Apr 2017 16:31:27 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170403181918.55rci53cll6fhcq6@alap3.anarazel.de> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 4/3/17 14:19, Andres Freund wrote: > Are you going to try to merge this soon, or are you pushing this to 11? I plan to commit it this week. It was basically ready weeks ago, but had to be adjusted after the executor changes. >> + case T_NextValueExpr: >> + { >> + NextValueExpr *nve = (NextValueExpr *) node; >> + >> + scratch.opcode = EEOP_NEXTVALUEEXPR; >> + scratch.d.nextvalueexpr.seqid = nve->seqid; >> + >> + ExprEvalPushStep(state, &scratch); >> + break; >> + } > > Hm - that's probably been answered somewhere, but why do we need a > special expression type for this? Because that's the way to evade the separate permission check that nextval the function would otherwise do. >> diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c >> index 4fbb5c1e74..5935b9ef75 100644 >> --- a/src/backend/executor/execExprInterp.c >> +++ b/src/backend/executor/execExprInterp.c >> @@ -60,6 +60,7 @@ >> >> #include "access/tuptoaster.h" >> #include "catalog/pg_type.h" >> +#include "commands/sequence.h" >> #include "executor/execExpr.h" >> #include "executor/nodeSubplan.h" >> #include "funcapi.h" >> @@ -337,6 +338,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull) >> &&CASE_EEOP_NULLIF, >> &&CASE_EEOP_SQLVALUEFUNCTION, >> &&CASE_EEOP_CURRENTOFEXPR, >> + &&CASE_EEOP_NEXTVALUEEXPR, >> &&CASE_EEOP_ARRAYEXPR, >> &&CASE_EEOP_ARRAYCOERCE, >> &&CASE_EEOP_ROW, >> @@ -1228,6 +1230,14 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull) >> EEO_NEXT(); >> } >> >> + EEO_CASE(EEOP_NEXTVALUEEXPR) >> + { >> + *op->resvalue = Int64GetDatum(nextval_internal(op->d.nextvalueexpr.seqid, false)); >> + *op->resnull = false; >> + >> + EEO_NEXT(); >> + } > > Is it guaranteed that the caller expects an int64? I saw that > nextvalueexpr's have a typeid field. It expects one of the integer types. We could cast the result of Int64GetDatum() to the appropriate type, but that wouldn't actually do anything. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers