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 1wbbx6-002hkp-0H for pgsql-novice@arkaria.postgresql.org; Mon, 22 Jun 2026 10:32:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wbbx3-0064Nk-2M for pgsql-novice@arkaria.postgresql.org; Mon, 22 Jun 2026 10:32:25 +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.96) (envelope-from ) id 1wbbx3-0064Nc-1W for pgsql-novice@lists.postgresql.org; Mon, 22 Jun 2026 10:32:25 +0000 Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wbbx2-00000001Zdn-0fjs for pgsql-novice@lists.postgresql.org; Mon, 22 Jun 2026 10:32:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=depesz.com; s=20170201; h=In-Reply-To:Content-Transfer-Encoding:Content-Type:MIME-Version :References:Reply-To:Message-ID:Subject:Cc:To:Sender:From:Date:Content-ID: Content-Description; bh=dhfAS3odUBRyV+lYLiRmpBNqQm5FSEt1DnNl3Uwr10s=; b=kJQte QX70oVpM4cNqD4EByNskYKT1oh1zL0IU1UjRAqFx25Ad+7xve4togGqK+Zko8f3OrENfaLq0vAH3h LWUEbM07UpEnenPcAPgAE47K5t7sNUjfrjcxm+LZLJdkFEE2TO/SuKcdA5rT/HbFJgDLi8qvak+/H XzETX11gVpMI=; Received: from depesz by depesz.com with local (Exim 4.98.2) (envelope-from ) id 1wbbwz-00000009BJr-4AIK; Mon, 22 Jun 2026 12:32:22 +0200 Date: Mon, 22 Jun 2026 12:32:21 +0200 From: hubert depesz lubaczewski Sender: depesz@depesz.com To: "Subramanian,Ramachandran" Cc: "pgsql-novice@lists.postgresql.org" Subject: Re: How to surround a selected value with double quotes? Message-ID: Reply-To: depesz@depesz.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Jun 22, 2026 at 07:46:09AM +0000, Subramanian,Ramachandran wrote: > #Build the SQL needed to get the list of tables that are approaching the SAFE_XID_GAP > LIST_OLDEST_UNFROZEN_XID_SQL=" SELECT \ > cast (age(PGCL.relfrozenxid) as integer) as GAP, \ > INTB.table_catalog as DB_NAME, \ > "$PORT_NO" , \ > CONCAT('"',INTB.table_schema,'"') || '.' || \ > CONCAT('"',PGCL.relname,'"') as TABLE_NAME, \ > pg_table_size(PGCL.oid) as TABLE_SIZE \ > FROM \ > pg_class PGCL, \ > information_schema.tables INTB \ > WHERE \ > PGCL.relname=INTB.table_name \ > AND \ > PGCL.relkind='r' \ > AND \ > age(PGCL.relfrozenxid) > "$SAFE_XID_GAP" \ > ORDER BY \ > 1 DESC ;" Some more comments, this time related to how you write bash/shell scripts. 1. you don't need to end line with \ if the value is in quotes - this is needed only if you split single command and it's options 2. if you have long string, multiline, it's better to use here-doc. like: psql … << _END_OF_SQL_ SELECT cast (age(PGCL.relfrozenxid) as integer) as GAP, INTB.table_catalog as DB_NAME, "$PORT_NO" , CONCAT('"',INTB.table_schema,'"') || '.' || CONCAT('"',PGCL.relname,'"') as TABLE_NAME, pg_table_size(PGCL.oid) as TABLE_SIZE FROM pg_class PGCL, information_schema.tables INTB WHERE PGCL.relname=INTB.table_name AND PGCL.relkind='r' AND age(PGCL.relfrozenxid) > "$SAFE_XID_GAP" ORDER BY 1 DESC _END_OF_SQL_ 3. if you really need to put the multi-line value in a variable, you can do it using: read -r -d '' LIST_OLDEST_UNFROZEN_XID_SQL << _END_OF_SQL_ … _END_OF_SQL_ Best regards, depesz