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 1ejrKp-0004fp-Ny for pgsql-general@arkaria.postgresql.org; Thu, 08 Feb 2018 18:54:15 +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 1ejrKn-0007Cx-Q1 for pgsql-general@arkaria.postgresql.org; Thu, 08 Feb 2018 18:54:13 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ejrKn-0007Co-Bk for pgsql-general@lists.postgresql.org; Thu, 08 Feb 2018 18:54:13 +0000 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ejrKk-0006Vx-JD for pgsql-general@lists.postgresql.org; Thu, 08 Feb 2018 18:54:11 +0000 Received: by mail-qt0-x242.google.com with SMTP id m11so7496163qtn.10 for ; Thu, 08 Feb 2018 10:54:10 -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=Z6au3uoHxkw5m2AhrKgkTAA7L3CnxS5jkGD02X/ymYE=; b=CRm4GO1hiWnm6zQtLIXF+CosixQ7WPNrGEbV2l6RfUhAwI+L8g4zNlVs/AVzho35D0 UfudJ2Jl1RCNCmlXs54uYA0FFTt4Ds+T8290pasYxazDC01jizRYpUIXqxci7zmTzo/D gDJbkKLQwpzzMQJ5gZotjpRCJWBoDCGw1ELr/4Md3lvPe0TRfxohFawws9xgJjR29u85 BeCaENoXY4Jgu8NRZCtse6agbNmBwF6P6LCrejhQYGq8ioCA8cejD4SQ4ysnk2hw/MW6 2IamrxgYk9IkYVQRPRCM9A8x1BJw+3kecmiIMUKhriVbrJ/y0R30p2ziLHWLpUqGgRnL vzzA== 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=Z6au3uoHxkw5m2AhrKgkTAA7L3CnxS5jkGD02X/ymYE=; b=OrIH1zShIiW2WzI5rIWqVMeGuNeHCLocllm/CX5h0T/+0eTemLyc1Ih9CCxdXoIHKR thilwGkPODxFaSptY8t623yTVomZ7A7metVcAMJV+lbmiNXfhYikQ12CoAcgx0qTbq25 iWz7OqQZsH++i9VW5GH460ojpDiEYCbT0GogVSEjpzQDNk0lqtInuCWzr5SDoRsxN9v+ JFnZiHKUe7CbzAJeFVXbC1ilaA2EOeq7E1e3jPoOczeQyDXVekpdAHUe0PtWIiQKCVDd WEGjU9uDEpy4Lm39izTggpygnnxEmy+AJFioezQPRhGPq56L/CruHi65VGmpuNsR+4SY wI4A== X-Gm-Message-State: APf1xPDdnXxc7Vsvm2sTM12jrrvluRP+W9nRyCLm3rvETP0Bwyb+drio naB54OQCoB3SJBEnsX1e4JjEnw== X-Google-Smtp-Source: AH8x227hHoBUBhmrUuC3t/Lk3br7PFWE37/0EyOea7yj1CrQLq65dsm1J1WZ7RIIM/zXtzMoc6PSAQ== X-Received: by 10.200.43.68 with SMTP id 4mr269550qtv.265.1518116049231; Thu, 08 Feb 2018 10:54:09 -0800 (PST) Received: from [192.168.245.27] ([65.183.149.206]) by smtp.gmail.com with ESMTPSA id v185sm429079qkb.30.2018.02.08.10.54.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Feb 2018 10:54:08 -0800 (PST) Date: Thu, 8 Feb 2018 13:54:08 -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: <31344c43-4f1d-78bd-1a07-4e4e544a1deb@aklaver.com> Message-ID: References: <31344c43-4f1d-78bd-1a07-4e4e544a1deb@aklaver.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, 8 Feb 2018, Adrian Klaver wrote: >>> SELECT currval('udm_asset_type_definition_id_seq'); > > Arrgh my mistake, the above should have been > > SELECT currval('udm_asset_type_definition_def_id_seq'); [Code: , SQL State: 55000] ERROR: currval of sequence "udm_asset_type_definition_def_id_seq" is not yet defined in this session Which is what I'd expect at the psql command line. In real-life, I am calling from JDBC in a single session - in fact, from inside a single transaction. I will post the JDBC code as soon as I can cut it down to the pertinent area. Also, since you request it: [hirschs@ui24-lin ~]$ psql -d asset_registry -U hirschs psql (9.6.5) Type "help" for help. asset_registry=# \d udm_asset_type_definition_def_id_seq Sequence "main.udm_asset_type_definition_def_id_seq" Column | Type | Value ---------------+---------+-------------------------------------- sequence_name | name | udm_asset_type_definition_def_id_seq last_value | bigint | 21 start_value | bigint | 1 increment_by | bigint | 1 max_value | bigint | 9223372036854775807 min_value | bigint | 1 cache_value | bigint | 1 log_cnt | bigint | 32 is_cycled | boolean | f is_called | boolean | t To me, the greater mystery is why 'pg_get_serial_sequence' is unable to find that sequence when invoked by table + column. --