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 1jLv0C-0005k7-IU for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Apr 2020 20:39:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jLv0B-0001p9-5C for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Apr 2020 20:39:19 +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 1jLv0A-0001p1-UH for pgsql-hackers@lists.postgresql.org; Tue, 07 Apr 2020 20:39:18 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jLv08-0007ul-IJ for pgsql-hackers@lists.postgresql.org; Tue, 07 Apr 2020 20:39:17 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 037KdCT4017605; Tue, 7 Apr 2020 16:39:12 -0400 From: Tom Lane To: "movead.li@highgo.ca" cc: "Daniel Verite" , pgsql-hackers , "ashutosh.bapat" Subject: Re: A bug when use get_bit() function for a long bytea string In-reply-to: <9172.1586271763@sss.pgh.pa.us> References: <3ae0e84f-1d80-4f98-b36e-235ebcae4ff6@manitou-mail.org>, <2020040709294706977061@highgo.ca> <2020040713393391866468@highgo.ca> <9172.1586271763@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Tue, 07 Apr 2020 11:02:43 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <17603.1586291952.1@sss.pgh.pa.us> Date: Tue, 07 Apr 2020 16:39:12 -0400 Message-ID: <17604.1586291952@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I wrote: > It would be easier to get this done if you had addressed any of the > objections to the patch as given. Integer-overflow handling is still > missing, and you still are assuming that it's okay to change catalog > entries in released branches. Since we are hard upon the feature freeze deadline, I took it on myself to split this apart. As far as I can see, the only part we really want to back-patch is the adjustment of the range-limit comparisons in byteaGetBit and byteaSetBit to use int64 arithmetic, so they don't go wacko when the input bytea exceeds 256MB. The other changes are not live bugs because in current usage the estimated result size of an encoding or decoding transform couldn't exceed 4 times 1GB. Hence it won't overflow size_t even on 32-bit machines, thus the check in palloc() is sufficient to deal with overlength values. But it's worth making those changes going forward, I suppose, in case somebody wants to deal with longer strings someday. There were some other minor problems too, but I think I fixed everything. regards, tom lane