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.96) (envelope-from ) id 1wbZzE-002g9h-0m for pgsql-novice@arkaria.postgresql.org; Mon, 22 Jun 2026 08:26:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wbZzB-005Jm2-0G for pgsql-novice@arkaria.postgresql.org; Mon, 22 Jun 2026 08:26:29 +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.96) (envelope-from ) id 1wbZzA-005Jlu-2Y for pgsql-novice@lists.postgresql.org; Mon, 22 Jun 2026 08:26:28 +0000 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wbZz8-00000001j4p-2QJf for pgsql-novice@lists.postgresql.org; Mon, 22 Jun 2026 08:26:28 +0000 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-45ef779c1c2so3160431f8f.1 for ; Mon, 22 Jun 2026 01:26:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1782116785; x=1782721585; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=IFn71Lq384YrmFT9OcLMgQdf3y1AJPW7D1w3vPl2yys=; b=QmWwtHvVrbJuBBUcUQEKW18XODNIWAUMmlzLlhdrOhg1osQGtC1fRTNKgdChfyGujD 9QKW1zPp4trK3F4L/r7kdStlQ6qhB6MhG1eHVEAMAUcHI50c7FLycmnHj5BSsQ4ttkdI QQrDmgEk5I6RkbQAmr6j4+tgpLxB4aPZM0aGnTi4aay9+WjsQ1TFXog0sxY0OvKueQLO Rs7JbPQ4tVlRHh7N4W7W8s2vELLKU0hqccFqfYAw3YbeRVmc4GGDYksll87dRmPHPZ85 eHmXstPCZKmuVLPRiUbWB00rJAtkftBbICQAklL1Db08Pr6j+jRusX8Gbkil4FcbCoHh W8+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782116785; x=1782721585; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IFn71Lq384YrmFT9OcLMgQdf3y1AJPW7D1w3vPl2yys=; b=N9uYj0SKcPrXBeFGPOUr3/veRCgnKG4FiuuEhnDJaaz46a0s29y30z+tmQbXdWuJyu oJMag4zXMLio3iL/UxagWiYMgB7tycQzuuSVFAl464GvyLGmNpeYncKGnVuzxw5IPlfj Pbr52w3DwgpemYlsdqLUu2CJcJR2XeIuFn22kZmQ7WISWTRXiQ+NNB5M4+hxqD8TDIOW RK4bDy+KPeFOSdKHMfWvXvHlJMQc4iAHBxmBzuaU41z4N5+yjKZplcwLTHOEKelTW0v5 69CEH66UHWXd70i/4DdhgGmAFExPMJFNALdf7gmkug5qRYZEFG4F6nkSSVG6TzbHJWPZ 6SjQ== X-Forwarded-Encrypted: i=1; AHgh+Rok3omS1b3WsJ43KLdfWzlfp5jxOsrhSQEiPf5xIsHT4sW1shZkvG51F9LO2wMYE/kalAWYOcQPepvyCic=@lists.postgresql.org X-Gm-Message-State: AOJu0YwRSX08PdgTkpEX5ScR4cCWnmtPOcgvwsmQWxo8VaP3QseN5tVY rEBLspRAMvh08Y0Wq40YqUAsYlC0YNJRue1CadZdGVFP0EUJ6nuS5zBASr4R5CV5Do0= X-Gm-Gg: AfdE7ckHXNOWkhscmZdEh/y2HqCIYj4ECRbGGDdCjaO+ZySCl/c58RpwenLnwYoMNbQ 8N7cvpFwvu5uVuHHQmPP7Kw/fdwfRXwjbhB9d8kUOvTJzCYVzT8whV5c0M3x5trtNPNCyxUdS/B nbRypqdR/PW0H2399D21qiEhPC5QvfXwdUN2wbn4QvV+KNoaNVBbejXV3WmKGVlAycqfcYgkTg3 N7YL9yM63dMnSZvYQtCGD/DmRTbm6GIAHOBKCLroiXlkD4lvyeGZ/JtPI+veE4Gd/ngfc6rf1uJ 8L31dCIPYztw3G9viUi5l/F9eNiZBNX3PSsMPT9TutV46feQn6fVlAFKw6b9E798qmGfPuhlCHr sPs84yKoHm5nxiBZHT4jznmsL40dvxzDk8BkQNKSAn1xnpvLgjj7pQoknjPwwPLjjHwCZOBNLhi Amd9d4tE0hkfAHFJni58Nzf9ptTX8I8XpiVBbeULLVxw== X-Received: by 2002:adf:e00c:0:10b0:461:c779:1e45 with SMTP id ffacd0b85a97d-4650694fe57mr16773900f8f.2.1782116785491; Mon, 22 Jun 2026 01:26:25 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:70:9b65:c0ad:acd9:c791:1e01]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-466648c5413sm25167065f8f.11.2026.06.22.01.26.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2026 01:26:25 -0700 (PDT) Message-ID: <4c3c231f54e9d6bae4cba0c84079f000901da653.camel@cybertec.at> Subject: Re: How to surround a selected value with double quotes? From: Laurenz Albe To: "Subramanian,Ramachandran" , "pgsql-novice@lists.postgresql.org" Date: Mon, 22 Jun 2026 10:26:24 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-1.fc43) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2026-06-22 at 07:46 +0000, Subramanian,Ramachandran wrote: > I wrote a script to analyze and run vacuum on tables that need it. I assume you are talking about a bash script. > Sadly at the time I wrote the script, I never expected a schema name to b= e pure numbers.=C2=A0 > =C2=A0 > So my Script does not work now. > =C2=A0 > I want to add double quote marks to each schema name and table name selec= t. > I tried using the CONCAT function, but it does not work as I expected it = to. > =C2=A0 > I would be grateful if someone can help me understand the mistake I am ma= king with the CONCAT. You are a victim of (self-inflicted) SQL injection. Just surrounding the schema name with double quotes is not enough. What if the schema name itself contains a double quote? You should use PostgreSQL's functions to properly quote an identifier. With a shell script, I think your only choice is to use SQL: #!/bin/bash schema=3D'12345 43' table=3D'tab"567' quoted_schema=3D$(psql -Atq -v var=3D"$schema" <