Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rshSV-008grX-6p for pgsql-bugs@arkaria.postgresql.org; Fri, 05 Apr 2024 11:10:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rshST-00DFXs-KW for pgsql-bugs@arkaria.postgresql.org; Fri, 05 Apr 2024 11:10:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rshST-00DFVe-8o for pgsql-bugs@lists.postgresql.org; Fri, 05 Apr 2024 11:10:09 +0000 Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rshSQ-000m6M-BF for pgsql-bugs@lists.postgresql.org; Fri, 05 Apr 2024 11:10:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=depesz.com; s=20170201; h=In-Reply-To:Content-Type:MIME-Version:References:Reply-To: Message-ID:Subject:Cc:To:Sender:From:Date:Content-Transfer-Encoding: Content-ID:Content-Description; bh=RjwFN9WTj+Upc+ZmyHtn1ZhDYsD812AQvepn4EFqXRI=; b=p6DnBOCk/jAuuynT4XJaikbnTl ErWUkliFxODUJyH8a0a+lQ6Fgf6quSpSGZs+7d5yp7oSMbkeyO60rSgLl3M1pvG/h/nekk5K6uJyG 5q5yTQtI4mkkUdGMUwbpA6hxWPEzuPcrMc4c3UrBoqVPh4qLFpzmUxNNsDXlLIcy2c+g=; Received: from depesz by depesz.com with local (Exim 4.96) (envelope-from ) id 1rshSP-00EHtY-00; Fri, 05 Apr 2024 13:10:05 +0200 Date: Fri, 5 Apr 2024 13:10:04 +0200 From: hubert depesz lubaczewski Sender: depesz@depesz.com To: Thibaut BOULDOIRE Cc: pgsql-bugs@lists.postgresql.org Subject: Re: Sequence name with capital letters issue Message-ID: Reply-To: depesz@depesz.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Apr 05, 2024 at 11:35:45AM +0200, Thibaut BOULDOIRE wrote: > So now my sequences are like that : > app_user_seq > app_address_seq > And now the SELECT nextval("app_user_seq"); is working. Are you sure this is what you ran? Because this causes the same error: #v+ depesz=# create sequence app_user_seq; CREATE SEQUENCE depesz=# select nextval("app_user_seq"); ERROR: column "app_user_seq" does not exist LINE 1: select nextval("app_user_seq"); ^ depesz=# select nextval('app_user_seq'); nextval --------- 1 (1 row) #v- There is difference between " and ' :) You *can* use upper case letters in seq names, but it will not be pretty: #v+ depesz=# create sequence "app_user_XXX"; CREATE SEQUENCE depesz=# select nextval('app_user_XXX'); ERROR: relation "app_user_xxx" does not exist LINE 1: select nextval('app_user_XXX'); ^ depesz=# select nextval('"app_user_XXX"'); nextval --------- 1 (1 row) #v- > But now, something interesting happened. > When I call this query : SELECT nextval("app_user_SEQ"); , it's the > app_user_seq sequence that is incremented and not the app_user_SEQ. This is most likely some unrelated thing. Especially since calling nextval(X), where X is in "quotes" is going to fail virtually always. > I didn't find in the documentation something that mentioned this issue > regarding sequence names with capital letters. > Is it a bug ? or is it something that I didn't find in the documentation ? I can't comment on the "wrong sequence gets incremented", but generally you didn't read the "Don't do this" wiki page: https://wiki.postgresql.org/wiki/Don't_Do_This#Don.27t_use_upper_case_table_or_column_names Best regards, depesz