Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ejrCc-0004Ec-EU for pgsql-general@arkaria.postgresql.org; Thu, 08 Feb 2018 18:45:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ejrCb-0006FX-89 for pgsql-general@arkaria.postgresql.org; Thu, 08 Feb 2018 18:45:45 +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 1ejrCa-0006FO-UU for pgsql-general@lists.postgresql.org; Thu, 08 Feb 2018 18:45:45 +0000 Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ejrCX-0001Pm-Ea for pgsql-general@lists.postgresql.org; Thu, 08 Feb 2018 18:45:44 +0000 Received: by mail-qk0-x243.google.com with SMTP id d129so3619446qke.10 for ; Thu, 08 Feb 2018 10:45:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:in-reply-to:message-id:references:user-agent :mime-version; bh=sx7rkU1fzAnawS0XM3zyDBTcNo+CF+6R+ejGayrEWxA=; b=gJDYddV3e495NNmZuRsinNU+F285wQox3NfMX3dHANWh5cv0rB3IuWS3WxHXtd7Pib S40lqljFM5+nEhUG+8XOV3BZ9o+v0RZv8bJzaEfzQj0nibIfe3VevMCvqbBwatPVYxxr VbBfuSOzQRyK2bZaro0R6PQ8ClZzzNP86bkh5F2VJkjsnQMPQ6Go9cOP0/RJqKgn1ip2 Pqh57A1Cl2icWIN2JacJcoCek2RE4tO4slPEIhMT2Y0FNnfRy94IpNiN765r3JCJgOjb F7SzL/iAA1u1s5Zha6kgSCUrhMgD3b3HQbrx70zUDABuEF8Jfk94BlkJBnHfMXRRHkXA 4vvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=sx7rkU1fzAnawS0XM3zyDBTcNo+CF+6R+ejGayrEWxA=; b=ab/gZ2WR0sOWU77xOlfP5rAQXnBW+lXYFC7g7yPChbpg9SE3lmmgGnPrloPoe+fTpB /32htxZV4ANtyTUsPo5O5M2UeupdI2EFvNzuJphSbYsUW+l2TsXo7HUjzilVqNrY0nvF 6RNOR3vEBIHq3O9HnKISyUdwyz/eYTW7HFdy1mt0kbJsR10/LdVZ1IOhkblp8yxJ/8e4 MQyqLh8AKJkCquS9x9+eDXuAp2xg0Vm8hsCOa5ua3TEXjJP387Z6SD78j5aqijaowrkL /SNwZ9Qtt1KqbriToa/WBbr9mGMnYn3ztYmYbuw/ZDN7Hrijp/zzWxMvXhYccgx0LEBi YyVg== X-Gm-Message-State: APf1xPCyq268pa/em388GJZcXsD+L1QEsRZmgGT0O1MxNSIdwT4EsZbf jF4UQPMS1a8fXZQjJwF/hvqUbw== X-Google-Smtp-Source: AH8x225TrjgAcp6VP03EUBJKHHp5dJN5U2IY/J19lcp/aIPmaFWyuf+novd1O235CQ+J1Fev2N+cZg== X-Received: by 10.55.111.196 with SMTP id k187mr135984qkc.31.1518115539467; Thu, 08 Feb 2018 10:45:39 -0800 (PST) Received: from [192.168.245.27] ([65.183.149.206]) by smtp.gmail.com with ESMTPSA id q73sm385329qkl.75.2018.02.08.10.45.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Feb 2018 10:45:38 -0800 (PST) Date: Thu, 8 Feb 2018 13:45:38 -0500 (EST) From: Steven Hirsch X-X-Sender: hirsch@z87 To: pgsql-general@lists.postgresql.org Subject: Re: Odd behavior with 'currval' In-Reply-To: Message-ID: References: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, 8 Feb 2018, Melvin Davidson wrote: > I believe your problem is in your usage. > In order for currval(regclass) to work, you must first do a > SELECT nextval(regclass) in your _current transaction_! > > https://www.postgresql.org/docs/9.6/static/functions-sequence.html I AM doing that. It is returning zero. The code is identical to that used in all other tables in the schema - all of them work. This one does not - unless I use the INSERT .. RETURNING .. approach. I suspect the weirdness with the sequence not being found is part of the underlying problem. --