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 1nKLzB-0006Ia-Vf for pgsql-bugs@arkaria.postgresql.org; Wed, 16 Feb 2022 15:12:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nKLzA-0005VQ-Q9 for pgsql-bugs@arkaria.postgresql.org; Wed, 16 Feb 2022 15:12:52 +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 1nKLz9-0005VH-Uv for pgsql-bugs@lists.postgresql.org; Wed, 16 Feb 2022 15:12:52 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nKLz3-0008A9-68 for pgsql-bugs@lists.postgresql.org; Wed, 16 Feb 2022 15:12:50 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 0BC023201F56; Wed, 16 Feb 2022 10:12:42 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 16 Feb 2022 10:12:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=HEenfD A00Jy8TRBE55A9bHPoyRScy3Z8Okf5BYtoGlg=; b=Xbg9xhheMLoPOKeFjf3sil TzIryHFEdJS7/PO0kGzO2aNBpbr7M6kcip58Ns3IiEeOM7B9mJLet6drU54xzoen 1ig+ZvF0Yi2wEu6Rd9o2UWTPU4FMkZhWnvzwvg/1z0qtUsZ6bqW0aRvzmBogjkH5 eexVw9b1haaXh3g677BWrMVAEbqSxS/tvtKPC3BQGbF3wZa4Q2UGLcNIVAEx35o7 91rzbI0DKoXSR5yFNm5Ty7vvvTy9ztdc3hPRa5y2PNlzdZ9Jv+4GAx/re4RByx6x BCZWxRVei3okRAe/mWXapdN6kLrLpk2iDI6cQuJ+0YyJtK5HyaJAfUGrxjQjRAWQ == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrjeeigdejvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfggtggugfgjsehtkeertd dttdejnecuhfhrohhmpeetlhhvrghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvges rghlvhhhrdhnohdqihhprdhorhhgqeenucggtffrrghtthgvrhhnpedujeevjeffjeevud dutedvkeeiueeitddvieelfeekveejudefgeeuvdejhfeuleenucffohhmrghinhepvghn thgvrhhprhhishgvuggsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 16 Feb 2022 10:12:42 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 55A142A0804; Wed, 16 Feb 2022 12:12:38 -0300 (-03) Date: Wed, 16 Feb 2022 12:12:38 -0300 From: Alvaro Herrera To: unmesh.joshi126@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17407: trim trims more than expected Message-ID: <202202161512.tsbczybuwa3i@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <17407-d39ff77fdea57c42@postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2022-Feb-16, PG Bug reporting form wrote: > Unexpected output > > demo=# select trim ('nextval(''' from > substring('nextval(''auth_table_id_seq''::regclass)' from '%#"%_id_seq#"%' > for '#' )); > btrim > ------------------ > uth_table_id_seq Not a bug. trim() receives a *set* of characters to remove, not a *substring* to remove, so the 'a' in 'auth' is matched to the 'a' in 'nextval(' and gets removed. You can probably achieve what you want by combining substring() with position() and char_length(), or by using a regular expression in regexp_replace(). -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "La conclusión que podemos sacar de esos estudios es que no podemos sacar ninguna conclusión de ellos" (Tanenbaum)