Re: Preventing non-superusers from altering session authorization

2023-07-08 Thread Joseph Koshakow
ession_authorization. I've attached a patch with this change. Thanks, Joe Koshakow From cb0198524d96068079e301a6785301440f3be3aa Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Thu, 15 Jun 2023 14:53:11 -0400 Subject: [PATCH] Prevent non-superusers from altering session auth Previously, if a

Re: Preventing non-superusers from altering session authorization

2023-07-09 Thread Joseph Koshakow
imes reports an incorrect value [0], and potentially is not used internally for anything. I've rebased my changes over your patch and attached them both. [0] https://www.postgresql.org/message-id/CAAvxfHcxH-hLndty6CRThGXL1hLsgCn%2BE3QuG_4Qi7GxrHmgKg%40mail.gmail.com From 2e1689b5fe384d675043beb9df

Re: DecodeInterval fixes

2023-07-09 Thread Joseph Koshakow
698c7da Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sun, 9 Jul 2023 13:12:16 -0400 Subject: [PATCH 1/3] Remove dead code in DecodeInterval This commit removes dead code for handling unit type RESERVE. There used to be a unit called "invalid" that was of type RESERVE. At some poi

Re: Preventing non-superusers from altering session authorization

2023-07-09 Thread Joseph Koshakow
On Sun, Jul 9, 2023 at 1:03 PM Joseph Koshakow wrote: >> * Only a superuser may set auth ID to something other than himself > Is "auth ID" the right term here? Maybe something like "Only a > superuser may set their session authorization/ID to something other &g

Re: Preventing non-superusers from altering session authorization

2023-07-10 Thread Joseph Koshakow
On Mon, Jul 10, 2023 at 4:32 PM Nathan Bossart wrote: > Okay. Here's a new patch set in which I believe I've addressed all > feedback. I didn't keep the GetAuthenticatedUserIsSuperuser() helper > function around, as I didn't see a strong need for it. Thanks, I think the patch set looks good to

Re: DecodeInterval fixes

2023-08-27 Thread Joseph Koshakow
On Tue, Aug 22, 2023 at 12:58 PM Jacob Champion wrote: > > On Mon, Aug 21, 2023 at 10:39 PM Michael Paquier wrote: > > 0002 and 0003 make this stuff fail, but isn't there a risk that this > > breaks applications that relied on these accidental behaviors? > > Assuming that this is OK makes me nerv

Fix overflow hazard in timestamp_pl_interval

2024-04-27 Thread Joseph Koshakow
ch it early. I couldn't find any existing timestamp plus interval tests so I stuck a new tests in `timestamp.sql`. If there's a better place, then please let me know. Thanks, Joe Koshakow From 4350e540fd45d3c868a36021ae79ce533bdeab5f Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: S

Re: Fix overflow hazard in timestamp_pl_interval

2024-04-27 Thread Joseph Koshakow
Hi all, Immediately after sending this I realized that timestamptz suffers from the same problem. Attached is an updated patch that fixes timestamptz too. Thanks, Joe Koshakow On Sat, Apr 27, 2024 at 10:59 PM Joseph Koshakow wrote: > Hi all, > > Attached is a patch that fixes some

drop column name conflict

2024-05-04 Thread Joseph Koshakow
ached patch. Does anyone think this is worth fixing? If so I can submit it to the current commitfest. Thanks, Joe Koshakow From 50f6e73d9bc1e00ad3988faa80a84af70aef Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sat, 4 May 2024 10:12:37 -0400 Subject: [PATCH] Prevent name conflic

Re: drop column name conflict

2024-05-04 Thread Joseph Koshakow
n the previous one and may not be worth the effort. If you feel that it's worth it I can clean it up, otherwise I'll drop it. Thanks, Joe Koshakow From 936a9e3509867574633882f5c1ec714d2f2604ec Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sat, 4 May 2024 10:12:37 -0400 Subject: [

Re: Fix overflow hazard in interval rounding

2024-06-02 Thread Joseph Koshakow
Hi Andres, Sorry for such a late reply. On Tue, Feb 13, 2024 at 2:14 PM Andres Freund wrote: > Random, mildly related thought: I wonder if it's time to, again, look at > enabling -ftrapv in assert enabled builds.I had looked at that a few years > back, and fixed a number of instances, but not a

Missing warning on revokes with grant options

2023-05-15 Thread Joseph Koshakow
Hi Hackers, I noticed some confusing behavior with REVOKE recently. Normally if REVOKE fails to revoke anything a warning is printed. For example, see the following scenario: ``` test=# SELECT current_role; current_role -- joe (1 row) test=# CREATE ROLE r1; CREATE ROLE test=# CREAT

Re: Missing warning on revokes with grant options

2023-05-18 Thread Joseph Koshakow
On Wed, May 17, 2023 at 11:48 PM Nathan Bossart wrote: > >The thread for the aforementioned change [0] mentions the standard quite a >bit, which might explain the current behavior. I went through that thread and the quoted parts of the SQL standard. It seems clear that if a user tries to

Re: Missing warning on revokes with grant options

2023-05-18 Thread Joseph Koshakow
On Thu, May 18, 2023 at 7:17 PM Joseph Koshakow wrote: > >I looked into this function and that is correct. We fail to find a >match for the revoked privilege here: > >/* >* Search the ACL for an existing entry for this grantee and grantor. If >* one ex

Re: Missing warning on revokes with grant options

2023-05-19 Thread Joseph Koshakow
I've been thinking about this some more and reading the SQL99 spec. In the original thread that added these warnings [0], which was linked earlier in this thread by Nathan, the following assertion was made: > After that, you get to the General Rules, which pretty clearly say that > trying to grant

Re: Missing warning on revokes with grant options

2023-05-19 Thread Joseph Koshakow
Sorry for the multiple consecutive emails. I just came across this comment that explains the current behavior in restrict_and_check_grant /* * Restrict the operation to what we can actually grant or revoke, and * issue a warning if appropriate. (For REVOKE this isn't quite what the * spec says to

Re: is_superuser is not documented

2023-06-07 Thread Joseph Koshakow
I think I may have discovered a reason why is_superuser is intentionally undocumented. is_superuser is not updated if a role's superuser attribute is changed by another session. Therefore, is_superuser may show you an incorrect stale value. Perhaps this can be fixed with a show_hook? Otherwise it'

Re: is_superuser is not documented

2023-06-07 Thread Joseph Koshakow
On Wed, Jun 7, 2023 at 11:36 AM Fujii Masao wrote: > > > >On 2023/06/07 23:15, Joseph Koshakow wrote: >> I think I may have discovered a reason why is_superuser is >> intentionally undocumented. is_superuser is not updated if a role's >> superu

Preventing non-superusers from altering session authorization

2023-06-21 Thread Joseph Koshakow
5sFzqEJQ%40mail.gmail.com [1] https://www.postgresql.org/docs/15/sql-set-session-authorization.html From b5f7d42ea325b2be46b7c93e5404792046f1befc Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Thu, 15 Jun 2023 14:53:11 -0400 Subject: [PATCH] Prevent non-superusers from altering session auth Previo

Re: Preventing non-superusers from altering session authorization

2023-06-22 Thread Joseph Koshakow
On Wed, Jun 21, 2023 at 11:48 PM Nathan Bossart wrote: > >On Wed, Jun 21, 2023 at 04:28:43PM -0400, Joseph Koshakow wrote: >> + roleTup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(AuthenticatedUserId)); >> + if (!HeapTupleIsValid(roleTup)) >> +

Re: Preventing non-superusers from altering session authorization

2023-07-01 Thread Joseph Koshakow
shakow On Fri, Jun 23, 2023 at 1:54 PM Nathan Bossart wrote: > On Thu, Jun 22, 2023 at 06:39:45PM -0400, Joseph Koshakow wrote: > > On Wed, Jun 21, 2023 at 11:48 PM Nathan Bossart < > nathandboss...@gmail.com> > > wrote: > >> I see that RESET SESSION AUTHORIZATI

Re: DecodeInterval fixes

2023-07-08 Thread Joseph Koshakow
s a rebase for the CI, too, but there are > no conflicts. The attached patch is rebased against master. Thanks, Joe Koshakow From eee98dd65c3556528803b6ee2cab10e9ece8d871 Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sun, 9 Apr 2023 20:37:27 -0400 Subject: [PATCH] Fix interval decode handli

Re: Preventing non-superusers from altering session authorization

2023-07-08 Thread Joseph Koshakow
alog lookup is only done if userid != AuthenticatedUserId. So RESET SESSION AUTHORIZATION with a concurrently dropped role will no longer FATAL. Thanks, Joe On Sat, Jul 1, 2023 at 11:33 AM Joseph Koshakow wrote: > >> That might be a good change? If the original authenticated role ID no >

Re: Preventing non-superusers from altering session authorization

2023-07-08 Thread Joseph Koshakow
I've discovered an issue with this approach. Let's say you have some session open that is connected as a superuser and you run the following commands: - CREATE ROLE r1 LOGIN SUPERUSER; - CREATE ROLE r2; - CREATE ROLE r3; Then you open another session connected with user r1 and run the follo

Re: Remove dependence on integer wrapping

2024-08-24 Thread Joseph Koshakow
ors test=# SELECT to_timestamp('2147483647,999', 'Y,YYY'); ERROR: invalid input string for "Y,YYY" test=# SELECT to_date('-2147483648', 'CC'); ERROR: date out of range: "-2147483648" So, it might be worth committing only his changes before moving on. Thanks, Joseph Koshakow

Re: Remove dependence on integer wrapping

2024-07-15 Thread Joseph Koshakow
integer, but there's multiple functions that divide cash by an integer. I've added a "cash_div_int64" in the updated patch. The other patches, 0001, 0003, and 0004 are unchanged but have their version number incremented. Thanks, Joe Koshakow From 018d952a44d51fb9e0a186003556aebb69

Re: Remove dependence on integer wrapping

2024-07-16 Thread Joseph Koshakow
On Tue, Jul 16, 2024 at 1:57 PM Nathan Bossart wrote: >> >>On Mon, Jul 15, 2024 at 07:55:22PM -0400, Joseph Koshakow wrote: >> On Mon, Jul 15, 2024 at 11:31 AM Nathan Bossart >> wrote: >>>I'm curious why you aren't using float8_mul/float8_div he

Re: Remove dependence on integer wrapping

2024-07-17 Thread Joseph Koshakow
On Tue, Jul 16, 2024 at 11:17 PM Nathan Bossart wrote: > I've attached an editorialized version of 0002 based on my thoughts above. Looks great, thanks! Thanks, Joe Koshakow

Re: Remove dependence on integer wrapping

2024-07-18 Thread Joseph Koshakow
rray size exceeds the maximum allowed (134217727) As a reminder: - 0001 is reviewed. - 0002 is reviewed and a bug fix. - 0003 is currently under review and a bug fix. - 0004 needs a review. Thanks, Joe Koshakow From 6c47deeb39eb352d7888c9490613dcf18aee198b Mon Sep 17 00:00:00 2001 From: Joseph Koshakow

Re: Remove dependence on integer wrapping

2024-07-19 Thread Joseph Koshakow
Since the patches have been renumbered, here's an overview of their status: - 0001 is reviewed and waiting for v18. - 0002 is under review and a bug fix. - 0003 needs review. Thanks, Joseph Koshakow From 6996c17b06d4b7c98130e5c70c368d08ea1ccc80 Mon Sep 17 00:00:00 2001 From: Joseph Koshako

Re: Remove dependence on integer wrapping

2024-07-22 Thread Joseph Koshakow
On Mon, Jul 22, 2024 at 11:17 AM Nathan Bossart wrote: > On Fri, Jul 19, 2024 at 07:32:18PM -0400, Joseph Koshakow wrote: >> On Fri, Jul 19, 2024 at 2:45 PM Nathan Bossart >> wrote: >>> +/* dim[i] = 1 + upperIndx[i] - lowerIndx[i]; */ >>> +

Re: Remove dependence on integer wrapping

2024-07-22 Thread Joseph Koshakow
ng the following statement: # INSERT INTO arroverflowtest(i[-2147483648:2147483647]) VALUES ('{1}'); So we may want to add that test back in. Thanks, Joseph Koshakow

Re: Remove dependence on integer wrapping

2024-07-23 Thread Joseph Koshakow
ch that fixes the to_date() overflow. Patches 1 through 3 remain unchanged. Thanks for the contribution Mattew! On Tue, Jul 23, 2024 at 2:14 AM jian he wrote: > > On Tue, Jul 23, 2024 at 6:56 AM Joseph Koshakow wrote: >> >> The specific bug that this patch fixes is preventing the

Fix overflow in pg_size_pretty

2024-07-27 Thread Joseph Koshakow
;s why the `::bigint` cast is omitted from my test. [0] https://www.postgresql.org/message-id/flat/caavxfhdbpoyegs7s+xf4iaw0-cgiq25jpydwbqqqvltle_t...@mail.gmail.com Thanks, Joseph Koshakow From 6ec885412f2e0f3a3e019ec1906901e39c6d517a Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sat, 27 Jul

Re: Fix overflow in pg_size_pretty

2024-07-27 Thread Joseph Koshakow
On Sat, Jul 27, 2024 at 3:18 PM Joseph Koshakow wrote: > > `SELECT -9223372036854775808::bigint` results in an out of range error, > even though `-9223372036854775808` can fit in a `bigint` and > `SELECT pg_typeof(-9223372036854775808)` returns `bigint`. That's why > th

Re: Fix overflow in pg_size_pretty

2024-07-27 Thread Joseph Koshakow
On Sat, Jul 27, 2024 at 6:28 PM David Rowley wrote: > > On Sun, 28 Jul 2024 at 07:18, Joseph Koshakow wrote: >> Attached is a patch that resolves an overflow in pg_size_pretty() that >> resulted in unexpected behavior when PG_INT64_MIN was passed in as an >> argument. &g

Re: Fix overflow in pg_size_pretty

2024-07-27 Thread Joseph Koshakow
On Sat, Jul 27, 2024 at 8:00 PM David Rowley wrote: > > On Sun, 28 Jul 2024 at 11:06, Joseph Koshakow wrote: >> > + uint64 usize = size < 0 ? (uint64) (-size) : (uint64) size; >> >> I think that the explicit test for PG_INT64_MIN is still required. If >>

Re: Fix overflow in pg_size_pretty

2024-07-27 Thread Joseph Koshakow
rom the negative case because I think it was unnecessary, but happy to add it back in if I missed something. Thanks for the review! Thanks, Joseph Koshakow [0] https://www.gnu.org/software/autoconf/manual/autoconf-2.63/html_node/Integer-Overflow-Basics.html From 1811b94ba4c08a0de972e8ded4892

Re: Remove dependence on integer wrapping

2024-08-04 Thread Joseph Koshakow
he fix here is to just convert `nbuckets` to a `long`. I plan on checking if that's feasible. I also found this commit [0] that increased the max of `nbuckets` from `INT_MAX / BLCKSZ` to `INT_MAX / 2`, which introduced the possibility of this overflow. So I plan on re

Re: Remove dependence on integer wrapping

2024-08-07 Thread Joseph Koshakow
ue is > returned? I've added a comment to the top of the file where we describe the return values of the other functions. I also updated the implementations of the pg_abs_sX() functions to something a bit simpler. This was based on feedback in another patch [0], and more closely matches similar lo

Re: Remove dependence on integer wrapping

2024-08-10 Thread Joseph Koshakow
error? If so, I'm not sure I understand the reasoning. -2147483648 is an allowed integer, it's the minimum allowed value for integers. test=# SELECT (-2147483648)::integer; int4 ----- -2147483648 (1 row) Thanks, Joseph Koshakow

Re: Remove dependence on integer wrapping

2024-08-14 Thread Joseph Koshakow
+ 1; return i64_abs(a); } Thanks, Joseph Koshakow

Re: Remove dependence on integer wrapping

2024-08-15 Thread Joseph Koshakow
nd godbolt.org [0] seems to indicate that it might produce better code, > too (at least to my eye). This updated version LGTM, I agree it's a good use of pg_abs_s32(). Thanks, Joseph Koshakow

Re: Remove dependence on integer wrapping

2024-08-17 Thread Joseph Koshakow
ing on -fwrapv here. godbolt.org indicates that > it produces roughly the same code, too. > > diff --git a/src/backend/nodes/bitmapset.c b/src/backend/nodes/bitmapset.c > index cd05c642b0..d37a997c0e 100644 > --- a/src/backend/nodes/bitmapset.c > +++ b/src/backend/nodes/bi

Re: Remove dependence on integer wrapping

2024-08-17 Thread Joseph Koshakow
ced another potential issue with next_pow2_int. The implementation is in dynahash.c and is as follows /* calculate first power of 2 >= num, bounded to what will fit in an int */ static int next_pow2_int(long num) { if (num > INT_MAX / 2) num = INT_MAX / 2;

date_trunc invalid units with infinite value

2024-12-01 Thread Joseph Koshakow
think it's worth pursuing. Thanks, Joseph Koshakow From c046465d4532e9b9086e0aadd13526e2a284b072 Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sun, 1 Dec 2024 14:55:35 -0500 Subject: [PATCH v1] Fix date_trunc units for infinite intervals Previously, if an infinite value was passe

Re: Remove dependence on integer wrapping

2024-12-05 Thread Joseph Koshakow
is happy. Also I agree, we should close the commitfest entry. Thanks, Joseph Koshakow

Re: Add pg_buffercache_evict_all() and pg_buffercache_mark_dirty[_all]() functions

2025-03-20 Thread Joseph Koshakow
Hi I am working with Aidar to give a review and I am also a beginner reviewer. > From 813e5ec0da4c65970b4b1ce2ec2918e4652da9ab Mon Sep 17 00:00:00 2001 > From: Nazir Bilal Yavuz > Date: Fri, 20 Dec 2024 14:06:47 +0300 > Subject: [PATCH v1 1/2] Add pg_buffercache_evict_all() function for testing >

Re: Assert when executing query on partitioned table

2025-03-15 Thread Joseph Koshakow
On Sat, Mar 8, 2025 at 4:28 PM Joseph Koshakow wrote: > > The assert was introduced commit f16241 > > So if I understand correctly, at the time the assert was added, we in > fact did not support UPDATE of INSERT ON CONFLICT for a partitioned > table. However, since then we&#x

Re: Assert when executing query on partitioned table

2025-03-08 Thread Joseph Koshakow
I don't fully understand why an error is needed though. This specific case will return false which will signal the caller to retry the insert. Just as an experiment I tried deleting the assert (attached patch) and running your test. Everything behaved as expected and nothing blew up. It also seems t

<    1   2