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 1sP0rx-002ST5-UQ for pgsql-general@arkaria.postgresql.org; Wed, 03 Jul 2024 14:22:01 +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 1sP0rv-009ciY-W8 for pgsql-general@arkaria.postgresql.org; Wed, 03 Jul 2024 14:22:00 +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 1sP0rv-009ciP-Kp for pgsql-general@lists.postgresql.org; Wed, 03 Jul 2024 14:22:00 +0000 Received: from mail-yb1-xb35.google.com ([2607:f8b0:4864:20::b35]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sP0rp-000DH5-8d for pgsql-general@postgresql.org; Wed, 03 Jul 2024 14:21:58 +0000 Received: by mail-yb1-xb35.google.com with SMTP id 3f1490d57ef6-e02b79c6f21so5890379276.2 for ; Wed, 03 Jul 2024 07:21:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720016512; x=1720621312; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=u3mqaDyDPbzDpzVMdrjpSCqs799y1BAb4PEm3QFECEk=; b=OqfCImuv6K1eOEsyLxUdSIldqI0RmB30k0G29uAqCpjOM8SJYkK0Q15+rKPfyrqDPh sqXrwy41zzMMRUppnmH4p4gjpxkvN7PzADI8dGlms3URpgpR0Ru3BMUe/5Gb/eNxbHfI 6dKV9ZKd2pjj+N9DQrpr292+a+L6Cwx/dX1XUJQzVjWx33jUsEEhjPRhedEZbOeF3gH+ mr+tNjXzDb3OX62xkhbHAF2qdPpYqfP85BhrV7zIleghb4zlJb7n/6UR1UoRu8Zx1JW0 auDAYA8srB6qjPPwIQieCDGr3Nn/qHuWTl+Xg1G/U34Bhg04Giw5b5b8QVWYicmatcIo o99w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720016512; x=1720621312; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=u3mqaDyDPbzDpzVMdrjpSCqs799y1BAb4PEm3QFECEk=; b=Q9RsbQmIVuhJCZ5c4FxjHgfKc+xR21B+d02dp82ysasqoSvNZTKWEiB+X9NApTMTrG zLfud2ycwdSI1nxYEweZfOMHLiEaLYqexxkwpzzYo4EUB/y905kS5NNmsqtERE27Nl+1 K09D+Pjvi3VwE3LJ5ZjNlF59DwVTmGObUGz3HHjJLiYTd0HNO3OAdr6QoK1XHwnGdU5i pR3qvS4yOGEmn4nDKSYne0yeViZuNhd5CUs13iOP9yco/mIu6Wo37yx+Er0o/9YnrVOf g9JTPeAm6e8dFl+Kat2oU5OYy2TxJHz55OBFmSc79jeiRr4fc4iUkLc7pWXAfqM2lz9E qhrw== X-Gm-Message-State: AOJu0YzSL2/iqtzhnqrwMp3gsx3F9+DXRMpERpL/4EJ1LqaNkwe2+UDv 5E8OlgXvZiMSQ9IS6+sn3dYUhmpbku+vU+lra76ihKXS9dVNy7FnbNamEIjnWozAXcSWX0nR/N4 1Fo124QH6t4rZyttjLsy/iJ/erjq4dysL6w== X-Google-Smtp-Source: AGHT+IE4i1bojKqSLA53bilb2m1OtQsEUe5MQdKej2r5WYucnVF2cBh6CmBxhjkmtZoNgFiPnNgzL+SbveqLm5u+0SY= X-Received: by 2002:a05:690c:d82:b0:631:78a1:bb5 with SMTP id 00721157ae682-64c73419043mr137829907b3.35.1720016512422; Wed, 03 Jul 2024 07:21:52 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: <286181eb-9fdd-6680-de4-edcdc82d42a9@appl-ecosys.com> From: =?UTF-8?Q?Torsten_F=C3=B6rtsch?= Date: Wed, 3 Jul 2024 16:21:39 +0200 Message-ID: Subject: Re: Accommodating alternative column values To: Rich Shepard Cc: "pgsql-general@postgresql.org" Content-Type: multipart/alternative; boundary="0000000000003b1bf0061c588d99" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000003b1bf0061c588d99 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Check this out https://www.postgresql.org/docs/16/arrays.html#ARRAYS-INPUT You can use ('{' || email || '}')::varchar(64)[] or the syntax I suggested earlier. On Wed, Jul 3, 2024 at 4:13=E2=80=AFPM Rich Shepard wrote: > On Wed, 3 Jul 2024, David G. Johnston wrote: > > > Yeah, the simply cast suggested will not work. You=E2=80=99d have to ap= ply 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=3D# 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 content= s > 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? > > Rich > > > --0000000000003b1bf0061c588d99 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Check this out
https://www.postgresql.org/docs/16/a= rrays.html#ARRAYS-INPUT

You can use
= =C2=A0 =C2=A0 ('{' || email || '}')::varchar(64)[]

or the syntax I suggested earlier.

On Wed, Jul 3, 202= 4 at 4:13=E2=80=AFPM Rich Shepard <rshepard@appl-ecosys.com> wrote:
On Wed, 3 Jul 2024, David G. Johnston wrot= e:

> Yeah, the simply cast suggested will not work. You=E2=80=99d have to a= pply an
> expression that turns the current contents into an array. The current<= br> > 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=3D# alter table people alter column email set data type varchar(64)= [] using email::varchar(64)[];
RROR:=C2=A0 malformed array literal: "frank@dmipx.com"
DETAIL:=C2=A0 Array value must start with "{" or dimension inform= ation.

If I correctly understand the error detail I'd need to change the conte= nts
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?

Rich


--0000000000003b1bf0061c588d99--