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 1uJykv-00AgTa-DX for pgsql-general@arkaria.postgresql.org; Tue, 27 May 2025 18:10:29 +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 1uJyku-009yYi-2w for pgsql-general@arkaria.postgresql.org; Tue, 27 May 2025 18:10:28 +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 1uJykt-009yYa-3p for pgsql-general@lists.postgresql.org; Tue, 27 May 2025 18:10:27 +0000 Received: from fhigh-b6-smtp.messagingengine.com ([202.12.124.157]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uJykp-000PVm-0k for pgsql-general@lists.postgresql.org; Tue, 27 May 2025 18:10:26 +0000 Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id 6BB6A254012E; Tue, 27 May 2025 14:10:21 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Tue, 27 May 2025 14:10:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1748369421; x=1748455821; bh=i+iypqeRrjt7YAXoWx3q6fgzOIvU6uz7fknOokh2uzY=; b= Mufgdw8MkBGpRYC5VkrPmJfD+fgwzpgAqLj8mzkA1ls7b76nP3hxgX9tzMB8pgjr ZUCIEnv9sNPJmamssSxsdWennTrhukAO1RUY1hS/FiNF1bIqir6/OKjq/MBgTfRq hDns49H+TzMfQy/x1gwHRKW9zlhQiDAJ/pTqZWDdvhpnyXhW84tK51vX02kR7GRv J0vFHSrWjjdTnHCIHBa68MBBuyS2p48Y1+tDdrun6sbul9GEr4KjNEG/9flEUV2E Hm9jlsNIYCNu3sSH5L2YCt04swQ8t3q979AKxmlDZQS4zPEa7XsVyMPTstZgHYQu wbYHQvne3uuNqHdL7hFvXQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1748369421; x=1748455821; bh=i +iypqeRrjt7YAXoWx3q6fgzOIvU6uz7fknOokh2uzY=; b=HtOTH/WZD3/XKodVa 5zvh80SrfdXXuKWbwTk7apg5+YE1WbA80w39a9UuO86L7NtEjW8qkaz6x2FuIJX9 n2w+lav2/qkCapOncH4iv0SXqUsakILMfbmVhvjDZbCDuUJczpGQnrCtds9WdAgI CeaTWzGw+oDJUFBTM3nyyBT7nchTKDVHM6B01liBMI7xibkJRLa53LPR3B+kqxLJ whY2tjPzqc7ArVE4YeXbrOwCYsae6p/oMsIsRWXRfs/YKGdvOnl4dVwHpKAN3b74 bMxlc1lnfuI0S7sBoK6pCFNRtWW4bO3+sC+z6B6eGOBfrJeaSf33wdF7F8RUXgFt c9VIg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtddtgddvuddtieculddtuddrgeefvddrtd dtmdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggft fghnshhusghstghrihgsvgdpuffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftd dtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefkffggfgfuvfhf hfgjtgfgsehtjeertddtvdejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorg gurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghr nhepvdevveegvdeiuddvffevhefghfdvheefgfefudejfefhfeeghfegudehtdevhfffne cuffhomhgrihhnpegtrghtrdhiugenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgr mhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmpdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehr ihgthhgrrhgurdiivghtthgvrhgsvghrghesghhoohhglhgvmhgrihhlrdgtohhmpdhrtg hpthhtohepphhgshhqlhdqghgvnhgvrhgrlheslhhishhtshdrphhoshhtghhrvghsqhhl rdhorhhg X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 27 May 2025 14:10:20 -0400 (EDT) Message-ID: <4c1c0192-e4f1-4e13-8dae-bfd9bb1801c1@aklaver.com> Date: Tue, 27 May 2025 11:09:40 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Changing a varchar(7) domain into text directly in pg_type To: Richard Zetterberg , pgsql-general@lists.postgresql.org References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 5/27/25 7:27 AM, Richard Zetterberg wrote: > Hello, > > I have a read-only table that contains a set of never changing > categories. Each category has a unique alpha numerical ID and a > description. The purpose of this table is so that other tables can > reference the ID of this table, to make sure that they don't contain > invalid/unknown categories and so that users can lookup the description > of each category. Define 'read-only'. In other words can you temporarily make it not read-only and change the type to text(or just varchar (no length specifier)? This would be the easiest fix. > > This category table has the following type on the ID column: > "varchar(7)" (yes, I should have used text). In order to avoid having to > type "varchar(7)" in all the tables that references the category table, > I created this domain that I used as type for all referencing columns: > "CREATE DOMAIN cat.id AS varchar(7);". > > During some data archeology, I found a bunch of new categories that > haven't been imported into the database yet, and they have IDs longer > than 7. If the read-only table field has a maximum length of 7 and you have incoming data that is coming in longer then 7 characters, how are they going to reference the read-only table? > > I've seen claims that varchar and text have the same representation on > disk and that they are treated the same way "under the hood", except for > the extra constraint checks on varchar. So, I thought that maybe I could > just change the type of my domain to text, directly in pg_type and that > should solve my problems Per my comment above, how? > Thanks for any insight, > Richard Zetterberg -- Adrian Klaver adrian.klaver@aklaver.com