Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mgWrW-0002BD-PV for pgsql-general@arkaria.postgresql.org; Fri, 29 Oct 2021 18:44:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mgWrV-0003V3-HT for pgsql-general@arkaria.postgresql.org; Fri, 29 Oct 2021 18:44:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mgWrV-0003Uu-3J for pgsql-general@lists.postgresql.org; Fri, 29 Oct 2021 18:44:21 +0000 Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mgWrS-0005vt-KC for pgsql-general@lists.postgresql.org; Fri, 29 Oct 2021 18:44:20 +0000 Received: by mail-qk1-x735.google.com with SMTP id a132so9195788qkg.0 for ; Fri, 29 Oct 2021 11:44:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=americanefficient-com.20210112.gappssmtp.com; s=20210112; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=BRAxnphDJl0UlYuRJLSwzmMH3uBRklK+LHOIU7ZIsqo=; b=eRlB9PLJZ4yp00k4fMQodUr5LYUP/Ar6kT1D96Wm2cSI98TP7bTkP+v5p3VJnz4XnH nVlNuKwdsgB8R3DZxzvE0PcRzNCa3g+/GQwLS47mRobOY/Bp++hd6hGNP3+7vDHEOl3g o+WrDlzatW2ofOfv8f4bOJZNjQ+LAjZL5Bn1A1i1OigvnNO5bYNhWwQaeEg7j7q7YkBQ g8l9I3qlH04ckowms/ifUBOzXmf0BSbdvFfZEaDHSiGmmolgKyY6NDRQk9fL80fZRsq4 aVIIv1TgIJwNCV8a4/JN1B93yRs8ysl0syjDBKVINUEye+uJ9IXaDWyFulN0r/+WeaZt poWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=BRAxnphDJl0UlYuRJLSwzmMH3uBRklK+LHOIU7ZIsqo=; b=j5Ast5QZspwrTDFBcHbhDUbwDlqZAz4XN+p6u3/FoO8daXkkTDyxsMwMWL4OaSC4qt SR+I/6v6SLJyAm//wJ4v2J1SWMU9dcT7GDOTj9bmNlPsZwOWWu46HzruW4WOeqs+quH/ 4gmMydh2K0BxKKWbvL1lN3iYSjuyVfYqMZaYkKZDl3/K5U5HC3wF2Igg4xRCfKeOC5gm 33vAZ45/D5730lxG8Wh1zZ67JMBVXYKu++Nc7O/QFvbWfyZEf8h+rcqPONlGMjHbqmJN pyERE492sy9RohtwsLSUPk8gYbWj4xsQggyw3LaRGqlA++SD6rqfE3HGdJyR0g5lp1pZ MYTA== X-Gm-Message-State: AOAM532aMO3X6VKoPKVSQ+2pqhiAkomp9Is9SsHbCtaRLIoxXgeWmLLH xmO4j9g9vgXoeeTxgeD1L2fncw== X-Google-Smtp-Source: ABdhPJwrrXJL3pyZfLjB0co8MPusQb7/f2YW1E0+mlEKWyjkrGcoNYr3AhenDcZHZUcYnyFqfTueMg== X-Received: by 2002:a37:a589:: with SMTP id o131mr10212740qke.209.1635533056681; Fri, 29 Oct 2021 11:44:16 -0700 (PDT) Received: from smtpclient.apple (cpe-24-211-149-51.nc.res.rr.com. [24.211.149.51]) by smtp.gmail.com with ESMTPSA id br17sm4559086qkb.10.2021.10.29.11.44.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Oct 2021 11:44:16 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: psql syntax for array of strings in a variable? From: Philip Semanchuk In-Reply-To: <714331.1635530724@sss.pgh.pa.us> Date: Fri, 29 Oct 2021 14:44:15 -0400 Cc: "David G. Johnston" , PostgreSQL General Content-Transfer-Encoding: quoted-printable Message-Id: <7EBBD1CA-CE01-4026-BEB5-73064D4B07B2@americanefficient.com> References: <8A98A8A6-7AFE-42C8-884B-984323381269@americanefficient.com> <714331.1635530724@sss.pgh.pa.us> To: Tom Lane X-Mailer: Apple Mail (2.3654.120.0.1.13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Oct 29, 2021, at 2:05 PM, Tom Lane wrote: >=20 > "David G. Johnston" writes: >> On Friday, October 29, 2021, Philip Semanchuk = >> wrote: >>> I would appreciate help with the syntax for querying an array of = strings >>> declared as a psql variable. Here's an example. >>>=20 >>> \set important_days ARRAY['monday', 'friday'] >=20 >> Not sure why the single quotes are getting stripped out but that is = the >> issue. Maybe double them up to escape them like in a normal text = literal? >=20 > Yeah, that's just the way that \set works (and most other psql = backslash > commands, I believe). You've likely got an issue with whitespace > disappearing, too, though that might be harmless in this specific = example. >=20 > regression=3D# \set foo 'bar baz' > regression=3D# \echo :foo > bar baz > regression=3D# \set foo 'bar ''baz' > regression=3D# \echo :foo > bar 'baz > regression=3D# \set foo bar ''baz=20 > regression=3D# \echo :foo > barbaz >=20 > Not sure offhand how well-documented this is. Thanks, all. Glad to know I wasn=E2=80=99t missing something obvious.=20 > On Oct 29, 2021, at 1:52 PM, Pavel Stehule = wrote: > psql variables can hold only text. There is not any type - all is just = text. ^^^ This was especially helpful; I=E2=80=99d never considered that = before. Cheers Philip