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 1sP18e-002U3e-4I for pgsql-general@arkaria.postgresql.org; Wed, 03 Jul 2024 14:39:16 +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 1sP18b-009pfd-Ns for pgsql-general@arkaria.postgresql.org; Wed, 03 Jul 2024 14:39:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sP18a-009pfV-7l for pgsql-general@lists.postgresql.org; Wed, 03 Jul 2024 14:39:14 +0000 Received: from fout8-smtp.messagingengine.com ([103.168.172.151]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sP18T-000DOw-Pj for pgsql-general@postgresql.org; Wed, 03 Jul 2024 14:39:11 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.nyi.internal (Postfix) with ESMTP id 1191F1380175; Wed, 3 Jul 2024 10:39:05 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 03 Jul 2024 10:39:05 -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=fm1; t=1720017545; x=1720103945; bh=CM0/zZAvWA5j06KXt5tcHBI2o14VJJO12pXutJcPcxQ=; b= uHToUgXvfpqamTCjmXzkdZzgxTqKxMiEbWsj59gLuacnDsMAFhgd91ykVR6EJgdp h6PJaSFa7ZH2sffAEIAbBT425q5k6+8HuwaRKCm4V1DSv8xOcloae3Bnu3azmWjN YB+00lcOJoTaolvZsvHBQXWKcbdO+KbnZhdNjCIcWkYWh3RUED4v0BpcBGSShBXW 4Bx80vixEb8dgZBT2rDdtoCkrZnYNvF1cIyMhZ01ZET+aFEiWq1zIgr1i308Ib47 0f37/Hrfee+UrwPnpdwZQlA57lkAmKhQJ6B7zV1wsCQZsD80YLF5fqo4UWBWTL9Q 3bTM3/964k2WRW00LUJTeA== 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-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1720017545; x= 1720103945; bh=CM0/zZAvWA5j06KXt5tcHBI2o14VJJO12pXutJcPcxQ=; b=q 3Kuc8agcfDgOndaX4eltsP60N3rT2+avS4qSs/JATDZrUkFvqgkmPIVAsvyNijU+ QI+7q3hLESLbSW83Nu5WyNpkqUr87+PCq9z/RltB4nsoFrcwFfF6b79qny+OglY2 K3loteDQPZmJkbmiDvIhmh7/S1z5zZeTYx7BOpAYyKvdwOI66USj4U9IHEmU7HFY C8N7ELXZcx+vjXY1Q/N4WGEOrbZqLY/06PQOb5IDdBLPUpieUAq6sAcyAJVVBK1h ErMXjwNjWGAJmhFbiyIPrUvoEnHE7Xz5U2c39ZVZYRBQ9MKJHygP8JjM8YumEBfi /CD9EOiaiiugDloxQOAXw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudejgdejlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecuggftrfgrthhtvghrnhepffelgeeifefgveduhedthfekuedtffejveegffegjeev tdehgfduieetfeehjeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 3 Jul 2024 10:39:04 -0400 (EDT) Message-ID: <39759897-4e11-4c3d-a7ab-f7e6a8c479aa@aklaver.com> Date: Wed, 3 Jul 2024 07:39:03 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Accommodating alternative column values To: Rich Shepard , "pgsql-general@postgresql.org" References: <449bdf5-31d-9189-34d-5ce4188fe2@appl-ecosys.com> <74f52ac6-61cb-f995-34e5-16271b5c6832@appl-ecosys.com> <3eb9a2d3-28c-9066-d3b5-fd6cca32af9@appl-ecosys.com> <286181eb-9fdd-6680-de4-edcdc82d42a9@appl-ecosys.com> Content-Language: en-US From: Adrian Klaver In-Reply-To: <286181eb-9fdd-6680-de4-edcdc82d42a9@appl-ecosys.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 7/3/24 07:13, Rich Shepard wrote: > On Wed, 3 Jul 2024, David G. Johnston wrote: > >> Yeah, the simply cast suggested will not work. You’d have to apply an >> expression that turns the current contents into an array. The current >> contents are not likely to be an array literal. > > David, > > No, it's not now an array. > > I thought that this expression would work, but it doesn't: > bustrac=# alter table people alter column email set data type > varchar(64)[] using email::varchar(64)[]; > RROR:  malformed array literal: "frank@dmipx.com" > DETAIL:  Array value must start with "{" or dimension information. > > If I correctly understand the error detail I'd need to change the contents > of that column for all 1280 rows to enclose the contents in curly braces > before I can convert the datatype to an array. Is that correct? An example: create table array_conv(id integer, email varchar(64)); insert into array_conv values (1, 'adrian.klaver@aklaver.com'), (2, 'aklaver@example.com'); select * from array_conv ; id | email ----+--------------------------- 1 | adrian.klaver@aklaver.com 2 | aklaver@example.com alter table array_conv alter column email type varchar[] using array[email]; select * from array_conv ; id | email ----+----------------------------- 1 | {adrian.klaver@aklaver.com} 2 | {aklaver@example.com} > > Rich > > -- Adrian Klaver adrian.klaver@aklaver.com