Re: Fix overflow in DecodeInterval

2022-02-20 Thread Joseph Koshakow
On Sun, Feb 20, 2022 at 6:37 PM Tom Lane wrote: > Couple of quick comments: Thanks for the comments Tom, I'll work on fixing these and submit a new patch. > * The uses of tm2itm make me a bit itchy. Is that sweeping > upstream-of-there overflow problems under the rug? I agree, I'm not super ha

Extract epoch from Interval weird behavior

2022-02-23 Thread Joseph Koshakow
Hi all, I noticed something odd when going through some of the Interval code. The DAYS_PER_YEAR constant is defined in src/include/datatype/timestamp.h. > #define DAYS_PER_YEAR365.25/* assumes leap year every four years */ We execute the EXTRACT and date_part functions in src/backend/util

Re: Extract epoch from Interval weird behavior

2022-02-23 Thread Joseph Koshakow
On Wed, Feb 23, 2022 at 7:42 PM Joseph Koshakow wrote: > > Hi all, > > I noticed something odd when going through some > of the Interval code. The DAYS_PER_YEAR constant > is defined in src/include/datatype/timestamp.h. > > #define DAYS_PER_YEAR365.25/* assumes le

Re: Extract epoch from Interval weird behavior

2022-02-24 Thread Joseph Koshakow
On Thu, Feb 24, 2022 at 4:47 AM Aleksander Alekseev wrote: > Extracting an epoch from an interval is quite a strange case since intervals > are not connected to any specific dates. I agree, I think it's a weird use case and that it's probably not worth fixing. Though it was fun for me to try. >

Re: Fix overflow in justify_interval related functions

2022-02-25 Thread Joseph Koshakow
Just checking because I'm not very familiar with the process, are there any outstanding items that I need to do for this patch? - Joe Koshakow

Re: Fix overflow in DecodeInterval

2022-03-06 Thread Joseph Koshakow
he ParseISO8601Number function to try and avoid double to int64 conversions. I tried to model it after the parsing done in DecodeInterval, though I would appreciate extra scrutiny here. - Joe Koshakow From a2afce720fb65b87638a634078067a796a639ddc Mon Sep 17 00:00:00 2001 From: Joseph Koshakow

Re: Fix overflow in DecodeInterval

2022-03-07 Thread Joseph Koshakow
I just realized another issue today. It may have been obvious from one of Tom's earlier messages, but I'm just now putting the pieces together. On Fri, Feb 18, 2022 at 11:44 PM Tom Lane wrote: > Also, I notice that there's an overflow hazard upstream of here, > in interval2tm: > > regression=# sel

Re: Can we consider "24 Hours" for "next day" in INTERVAL datatype ?

2022-03-15 Thread Joseph Koshakow
On Tue, Mar 15, 2022 at 3:46 AM Julien Rouhaud wrote: > On Tue, Mar 15, 2022 at 12:54:58PM +0530, Prabhat Sahu wrote: > > > > Is there any specific purpose we are holding the hours as an increasing > > number beyond 24 hours also? > > Yes, you can't blindly assume that adding 24 hours will always

Re: Fix overflow in DecodeInterval

2022-03-23 Thread Joseph Koshakow
On Mon, Mar 21, 2022 at 8:31 PM Tom Lane wrote: > This isn't applying per the cfbot; looks like it got sideswiped > by 9e9858389. Here's a quick rebase. I've not reviewed it, but > I did notice (because git was in my face about this) that it's > got whitespace issues. Please try to avoid unnece

Inconsistency in ACL error message

2023-02-24 Thread Joseph Koshakow
ermission denied to create database It's not a huge deal, but it's easy enough to fix that I thought I'd generate a patch (attached). Let me know if people think that it's worth merging. - Joe Koshakow From 3ab31bc755043973ce56ee620ad99b5789d12111 Mon Sep 17 00:00:00 2001

Re: Inconsistency in ACL error message

2023-02-24 Thread Joseph Koshakow
On Fri, Feb 24, 2023 at 1:31 PM Nathan Bossart wrote: > You might be interested in > >https://commitfest.postgresql.org/42/4145/ Ah, perfect. In that case ignore my patch! - Joe Koshakow

Re: Infinite Interval

2023-03-01 Thread Joseph Koshakow
s rebased? There hasn't really been a review of this patch yet. It's just been mostly me talking to myself in this thread, and a couple of contributions from jian. - Joe Koshakow From 1b35e2b96bcf69431bbd8720523163de10cf Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sat,

Re: is_superuser is not documented

2023-03-02 Thread Joseph Koshakow
On Thu, Mar 2, 2023 at 11:53 AM Fujii Masao wrote: > >On 2022/09/14 14:27, bt22kawamotok wrote: >> I update patch to reflect master update. > >Thanks for updating the patch! > >+ >+Shows whether the current user is a superuser or not. >+ > >How abo

Re: Date-time extraneous fields with reserved keywords

2023-03-04 Thread Joseph Koshakow
On Sat, Mar 4, 2023 at 11:23 AM Keisuke Kuroda wrote: > >Good catch. >Of the reserved words that are special values of type Date/Time, >'now', 'today', 'tomorrow', 'yesterday', and 'allballs', >I get an error even before applying the patch. Thanks for pointing this out. After taki

Re: Date-time extraneous fields with reserved keywords

2023-03-04 Thread Joseph Koshakow
fault case. Any thoughts? - Joe Koshakow From 78d8f39db8df68502369ffd9edd6f6e38f4dadb8 Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sun, 11 Dec 2022 16:08:43 -0500 Subject: [PATCH] Handle extraneous fields in date-time input DecodeDateTime sometimest allowed extraneous fields to be included

Re: Date-time extraneous fields with reserved keywords

2023-03-04 Thread Joseph Koshakow
On Sat, Mar 4, 2023 at 1:56 PM Tom Lane wrote: > >I think we should tread very carefully about disallowing inputs that >have been considered acceptable for 25 years. I agree with disallowing >numeric fields along with 'epoch' and 'infinity', but for example >this seems perfectly u

Re: Date-time extraneous fields with reserved keywords

2023-03-04 Thread Joseph Koshakow
Joe Koshakow From 64a71ed287aa9611c22eaa6e2cbb7e080d93be79 Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sun, 11 Dec 2022 16:08:43 -0500 Subject: [PATCH] Handle extraneous fields in date-time input DecodeDateTime sometimest allowed extraneous fields to be included with reserved keywords. For

Re: Date-Time dangling unit fix

2023-03-04 Thread Joseph Koshakow
On Sat, Mar 4, 2023 at 4:05 PM Tom Lane wrote: > >I started to look at this, and soon noticed that while we have test cases >matching this sort of date input, there is no documentation for it. The >code claims it's an "ISO" (presumably ISO 8601) format, and maybe it is >because it

Re: Date-Time dangling unit fix

2023-03-05 Thread Joseph Koshakow
Attached is a patch for removing the discussed format of date-times. From f35284762c02ed466496e4e562b5f95a884b5ef1 Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sat, 10 Dec 2022 18:59:26 -0500 Subject: [PATCH] Remove unknown ISO format, handle dandling units This commit removes the date

Re: Date-Time dangling unit fix

2023-03-05 Thread Joseph Koshakow
On Sun, Mar 5, 2023 at 12:54 PM Tom Lane wrote: > > We do accept this: > > => select '12:34'::time; >time > -- > 12:34:00 > (1 row) > > so that must be going through a different code path, which I didn't > try to identify yet. That query will contain a single field of "12:34" with ft

Re: Date-Time dangling unit fix

2023-03-05 Thread Joseph Koshakow
Also I removed some dead code from the previous patch. - Joe Koshakow From 2ff08d729bca87992514d0651fdb62455e43cd8a Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sat, 10 Dec 2022 18:59:26 -0500 Subject: [PATCH] Remove unknown ISO format, handle dandling units This commit removes the date

Re: Infinite Interval

2023-03-18 Thread Joseph Koshakow
On Sat, Mar 18, 2023 at 3:08 PM Tom Lane wrote: > Joseph Koshakow writes: >> On Thu, Mar 9, 2023 at 12:42 PM Ashutosh Bapat < ashutosh.bapat@gmail.com> >> wrote: >>> There are a lot of these diffs. PG code doesn't leave an extra space >>> between v

Re: Infinite Interval

2023-03-19 Thread Joseph Koshakow
On Sat, Mar 18, 2023 at 3:55 PM Tom Lane wrote: > >Joseph Koshakow writes: >> On Sat, Mar 18, 2023 at 3:08 PM Tom Lane wrote: >>> More specifically, those are from running pg_indent with an obsolete >>> typedefs list. > >> I must be d

Re: Infinite Interval

2023-03-19 Thread Joseph Koshakow
syntactically incorrect. Oh duh. I've been doing too much Rust development and did this without thinking. I've attached a patch with a fix. - Joe Koshakow From d3543e7c410f83cbe3f3f3df9715025bc767fc5f Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sat, 18 Mar 2023 13:59:34 -0400

Re: Infinite Interval

2023-03-25 Thread Joseph Koshakow
number 7, but I'll save that for a future patch. - Joe Koshakow From 41fa5de65c757d72331aff6bb626fab76390e9db Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sat, 18 Mar 2023 12:26:28 -0400 Subject: [PATCH 1/2] Move integer helper function to int.h --- src/back

Re: Infinite Interval

2023-03-25 Thread Joseph Koshakow
In terms of adding/subtracting infinities, the IEEE standard is pay walled and I don't have a copy. I tried finding information online but I also wasn't able to find anything useful. I additionally checked to see the results of C++, C, and Java, and they all match which increases my confidence that

Fix overflow hazard in interval rounding

2024-02-13 Thread Joseph Koshakow
&& src/tools/pgindent/pgindent src/backend/utils/adt/timestamp.c` Thanks, Joe Koshakow From 389b0d1e3f3cca6fca1e45fdd202b1ca066326c2 Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Tue, 13 Feb 2024 13:06:13 -0500 Subject: [PATCH] Fix overflow hazard in interval rounding This commit fixes

Re: Fix overflow hazard in interval rounding

2024-02-13 Thread Joseph Koshakow
to >me to probably not be worth back-patching.) Agreed, this seems like a pretty rare overflow/underflow. Thanks, Joe Koshakow From 470aa9c8898b4e4ebbad97d6e421377b9a3e03cf Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Tue, 13 Feb 2024 13:06:13 -0500 Subject: [PATCH] Fix overflow h

Date-Time dangling unit fix

2022-12-11 Thread Joseph Koshakow
me fixes. - Joe Koshakow From fbcf39211fc7a379ea021160298604694383d56c Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sat, 10 Dec 2022 18:59:26 -0500 Subject: [PATCH] Handle dangling units in date-time input DecodeDateTime and DecodeTimeOnly allowed dangling unit types on input without returning an error. For example,

Re: Date-Time dangling unit fix

2022-12-11 Thread Joseph Koshakow
On Sun, Dec 11, 2022 at 10:29 AM Joseph Koshakow wrote: > > Hi all, > > Attached is a patch to fix a parsing error for date-time types that > allow dangling units in the input. For example, > `date '1995-08-06 m y d'` was considered a valid date and the d

Date-time extraneous fields with reserved keywords

2022-12-11 Thread Joseph Koshakow
- Joe Koshakow From fb4c161afff08b926eea12d8689a148e99cbdb5c Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sun, 11 Dec 2022 16:08:43 -0500 Subject: [PATCH] Handle extraneous fields in date-time input DecodeDateTime sometimest allowed extraneous fields to be included with reserved keywords. For examp

Re: Date-Time dangling unit fix

2022-12-12 Thread Joseph Koshakow
I just found another class of this bug that the submitted patch does not fix. If the units are at the beginning of the string, then they are also ignored. For example, `date 'm d y2020m11d3'` is also valid. I think the fix here is to check and make sure that ptype is 0 before reassigning the value

Re: Date-Time dangling unit fix

2022-12-12 Thread Joseph Koshakow
On Mon, Dec 12, 2022 at 10:55 AM Joseph Koshakow wrote: > > I just found another class of this bug that the submitted patch does > not fix. If the units are at the beginning of the string, then they are > also ignored. For example, `date 'm d y2020m11d3'` is also valid. I &

Re: Infinite Interval

2022-12-15 Thread Joseph Koshakow
On Mon, Dec 12, 2022 at 8:05 AM Ashutosh Bapat wrote: > > Hi Joseph, > I stumbled upon this requirement a few times. So I started working on > this support in my spare time as a hobby project to understand > horology code in PostgreSQL. This was sitting in my repositories for > more than an year.

Re: Infinite Interval

2022-12-17 Thread Joseph Koshakow
the answer is yes, we do change the sign of infinity. - Joe Koshakow From 4c1be4e2aa7abd56967fdce14b100715f3a63fee Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sat, 17 Dec 2022 14:21:26 -0500 Subject: [PATCH] This is WIP. Following things are supported 1. Accepts '+/-infinity'

Re: Infinite Interval

2022-12-17 Thread Joseph Koshakow
On Sat, Dec 17, 2022 at 2:34 PM Joseph Koshakow wrote: > > Hi Ashutosh, > > I've added tests for all the operators and functions involving > intervals and what I think the expected behaviors to be. The > formatting might be slightly off and I've left the contents of t

Re: Infinite Interval

2022-12-23 Thread Joseph Koshakow
- General cleanup, remove TODOs. Attached is my most recent patch. - Joe Koshakow From 380cde4061afd6eed4cde938a4c668a2c96bb58f Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sat, 17 Dec 2022 14:21:26 -0500 Subject: [PATCH] This is WIP. Following things are supported 1. Accepts '+/

Re: Infinite Interval

2022-12-30 Thread Joseph Koshakow
I have another update, I cleaned up some of the error messages, fixed the horology tests, and ran pgindent. - Joe From 518c59be586abf5779c5727c2117b6a46b466503 Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sat, 17 Dec 2022 14:21:26 -0500 Subject: [PATCH] This is WIP. Following things are

Re: Infinite Interval

2023-01-02 Thread Joseph Koshakow
On Sat, Dec 31, 2022 at 12:09 AM jian he wrote: > In float8, select float8 'inf' / float8 'inf' return NaN. Now in your patch > select interval 'infinity' / float8 'infinity'; returns infinity. > I am not sure it's right. I found this related post > (https://math.stackexchange.com/questions/181

Re: Infinite Interval

2023-01-02 Thread Joseph Koshakow
On Mon, Jan 2, 2023 at 1:21 PM Joseph Koshakow wrote: > > On Sat, Dec 31, 2022 at 12:09 AM jian he wrote: > > In float8, select float8 'inf' / float8 'inf' return NaN. Now in your patch > > select interval 'infinity' / float8 'infinity'

Re: Infinite Interval

2023-01-02 Thread Joseph Koshakow
25bc090375b60d140b1630cabcc90f1c9c Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sat, 17 Dec 2022 14:21:26 -0500 Subject: [PATCH] This is WIP. TODOs 1. Various TODOs in code. 2. Correctly implement interval_part for infinite intervals. 3. Test consolidation. 4. Should we just use the month

Re: Infinite Interval

2023-01-05 Thread Joseph Koshakow
On Thu, Jan 5, 2023 at 5:20 AM jian he wrote: > > > > On Wed, Jan 4, 2023 at 10:13 PM jian he wrote: >> >> >> >> I don't know how to generate an interval.out file. Personally I just write the .out files manually. I think it especially helps as a way to double-check that the results are what you

Re: Infinite Interval

2023-01-05 Thread Joseph Koshakow
Jian, I incorporated your changes and updated interval.out and ran pgindent. Looks like some of the error messages have changed and we have some issues with parsing "+infinity" after rebasing. - Joe From 4bf672f9079322cffde635dff2078582fca55f09 Mon Sep 17 00:00:00 2001 From: Josep

Re: Infinite Interval

2023-01-07 Thread Joseph Koshakow
On Thu, Jan 5, 2023 at 11:30 PM jian he wrote: > > > > On Fri, Jan 6, 2023 at 6:54 AM Joseph Koshakow wrote: >> >> Looks like some of the error messages have changed and we >> have some issues with parsing "+infinity"

Re: Infinite Interval

2023-01-07 Thread Joseph Koshakow
On Sat, Jan 7, 2023 at 3:04 PM Joseph Koshakow wrote: > > On Thu, Jan 5, 2023 at 11:30 PM jian he wrote: > > > > > > > > On Fri, Jan 6, 2023 at 6:54 AM Joseph Koshakow wrote: > >> > >> Looks like some of the error messages have changed and we >

Re: Infinite Interval

2023-01-07 Thread Joseph Koshakow
On Sat, Jan 7, 2023 at 3:05 PM Joseph Koshakow wrote: > > On Sat, Jan 7, 2023 at 3:04 PM Joseph Koshakow wrote: > > > > I think this patch is just about ready for review, except for the > > following two questions: > > 1. Should finite checks on intervals on

Re: Infinite Interval

2023-01-10 Thread Joseph Koshakow
On Sun, Jan 8, 2023 at 11:17 PM jian he wrote: > > > > On Sun, Jan 8, 2023 at 4:22 AM Joseph Koshakow wrote: >> >> On Sat, Jan 7, 2023 at 3:05 PM Joseph Koshakow wrote: >> > >> > On Sat, Jan 7, 2023 at 3:04 PM Joseph Koshakow wrote: >> >

Re: Infinite Interval

2023-01-14 Thread Joseph Koshakow
handling of infinite timestamp subtraction. At this point the patch is ready for review again except for the one outstanding question of: Should finite checks on intervals only look at months or all three fields? - Joe From 23868228ad2c0be57408b38db76bced85ab83cb1 Mon Sep 17 00:00:00 2001 From: Joseph Kos

Re: Infinite Interval

2023-01-15 Thread Joseph Koshakow
On Sat, Jan 14, 2023 at 4:22 PM Joseph Koshakow wrote: > > At this point the patch is ready for review again except for the one > outstanding question of: Should finite checks on intervals only look at > months or all three fields? > > - Joe I've gone ahead and updated th

Re: is_superuser is not documented

2023-04-01 Thread Joseph Koshakow
On Wed, Mar 29, 2023 at 5:21 PM Bruce Momjian wrote: > >On Thu, Mar 2, 2023 at 12:00:43PM -0500, Joseph Koshakow wrote: >> >> >> On Thu, Mar 2, 2023 at 11:53 AM Fujii Masao < masao.fu...@oss.nttdata.com> >> wrote: >> > >

Re: Infinite Interval

2023-04-02 Thread Joseph Koshakow
patches. Let me know what you think. With this patch I believe that I've addressed all open comments except for the discussion around whether we should check just the months field or all three fields for finiteness. Please let me know if I've missed something. Thanks, Joe Koshakow From e50d

Re: Infinite Interval

2023-04-02 Thread Joseph Koshakow
>On Sun, Apr 2, 2023 at 5:36 PM Tom Lane wrote: > > Joseph Koshakow writes: >> I've attached a patch with these changes that is meant to be applied >> over the previous three patches. Let me know what you think. > >Does not really seem like an im

Re: Infinite Interval

2023-04-02 Thread Joseph Koshakow
On Sun, Apr 2, 2023 at 6:54 PM Tom Lane wrote: > >Joseph Koshakow writes: >>> I've added an errcontext to all the errors of the form "X out of >>> range". > >Please note the style guidelines [1]: > >errcontext(const c

Re: is_superuser is not documented

2023-04-08 Thread Joseph Koshakow
On Mon, Apr 3, 2023 at 10:47 AM Fujii Masao wrote: >Yes, the patch has not been committed yet because of lack of review comments. >Do you have any review comments on this patch? >Or you think it's ready for committer? I'm not very familiar with this code, so I'm not sure how much my r

DecodeInterval fixes

2023-04-09 Thread Joseph Koshakow
?p=postgresql.git;a=commit;h=5b3c5953553bb9fb0b171abc6041e7c7e9ca5b4d [2] https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=bcc704b52490492e6bd73c4444056b3e9644504d From 4c5641f15e5409ef5973a5f305352018f06da538 Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sun, 9 Apr 2023 20:37:27

Re: is_superuser is not documented

2023-04-11 Thread Joseph Koshakow
On Tue, Apr 11, 2023 at 9:37 AM Fujii Masao wrote: >> > Yes, this patch moves the descriptions of is_superuser to config.sgml >> > and changes its group to PRESET_OPTIONS. >> >> is_superuser feels a little out of place in this file. All of >> the options here apply to the en

Re: Fix overflow in DecodeInterval

2022-04-02 Thread Joseph Koshakow
On Fri, Apr 1, 2022 at 8:06 PM Tom Lane wrote: > > Joseph Koshakow writes: > > * The existing code for rounding had a lot of int to double > > casting and vice versa. I *think* that doubles are able to completely > > represent the range of ints. However doubles are not a

Re: Fix overflow in DecodeInterval

2022-04-02 Thread Joseph Koshakow
On Sat, Apr 2, 2022 at 1:29 PM Joseph Koshakow wrote: > > On Fri, Apr 1, 2022 at 8:06 PM Tom Lane wrote: > > > > Joseph Koshakow writes: > > > * The existing code for rounding had a lot of int to double > > > casting and vice versa. I *think* that doubles ar

Re: Fix overflow in DecodeInterval

2022-04-02 Thread Joseph Koshakow
On Sat, Apr 2, 2022 at 2:22 PM Joseph Koshakow wrote: > > On Sat, Apr 2, 2022 at 1:29 PM Joseph Koshakow wrote: > > > > On Fri, Apr 1, 2022 at 8:06 PM Tom Lane wrote: > > > > > > Joseph Koshakow writes: > > > > * The existing code for roundin

Re: Fix overflow in DecodeInterval

2022-04-02 Thread Joseph Koshakow
his issue and the attached patch (which would be applied on top of your v10 patch) seems to fix the issue. Feel free to ignore it if you're already working on a fix. - Joe From f43d27142a76fcbabf49e45b9457f8376744e759 Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sat, 2 Apr 2022

Re: Fix overflow in DecodeInterval

2022-04-02 Thread Joseph Koshakow
On Sat, Apr 2, 2022 at 3:08 PM Tom Lane wrote: > > Joseph Koshakow writes: > > Ok I actually remember now, the issue is with the rounding > > code in AdjustFractMicroseconds. > > ... > > I believe it's possible for `frac -= usec;` to result in a value greate

Re: Fix overflow in DecodeInterval

2022-04-03 Thread Joseph Koshakow
On Sun, Apr 3, 2022 at 3:09 AM Tom Lane wrote: > > I wrote: > > Cool. I've pushed the patch. > > Hmm ... buildfarm's not entirely happy [1][2][3]: > > diff -U3 > /home/nm/farm/gcc64/HEAD/pgsql.build/src/test/regress/expected/interval.out > /home/nm/farm/gcc64/HEAD/pgsql.build/src/test/regress/r

Re: Fix overflow in DecodeInterval

2022-04-03 Thread Joseph Koshakow
On Sun, Apr 3, 2022 at 12:03 PM Tom Lane wrote: > > I wrote: > > Joseph Koshakow writes: > >> I think I know that the issue is. It's with `ParseISO8601Number` and > >> the minutes field "1.". > >> Previously that function parsed the entire

Re: Fix overflow in DecodeInterval

2022-04-03 Thread Joseph Koshakow
On Sun, Apr 3, 2022 at 12:30 PM Tom Lane wrote: > > Joseph Koshakow writes: > > So I think we need to check that endptr has moved both after > > the call to strtoi64() and strtod(). > > I'm not sure we need to do that explicitly, given that there's >

Re: Fix overflow in DecodeInterval

2022-04-03 Thread Joseph Koshakow
On Sun, Apr 3, 2022 at 12:44 PM Joseph Koshakow wrote: > > On Sun, Apr 3, 2022 at 12:30 PM Tom Lane wrote: > > > > Joseph Koshakow writes: > > > So I think we need to check that endptr has moved both after > > > the call to strtoi64() and strtod(). >

Re: Fix overflow in DecodeInterval

2022-04-03 Thread Joseph Koshakow
On Sun, Apr 3, 2022 at 3:06 PM Tom Lane wrote: > That buildfarm machine is pretty slow, so I'm not in a hurry to test > it manually either. However, now that we realize the issue is about > whether strtod(".") produces EINVAL or not, I think we need to fix > all the places in datetime.c that are

Re: Infinite Interval

2023-11-18 Thread Joseph Koshakow
On Thu, Nov 16, 2023 at 2:03 AM Ashutosh Bapat wrote: > >On Tue, Nov 14, 2023 at 4:39 PM Dean Rasheed wrote: >> >> On Thu, 9 Nov 2023 at 12:49, Dean Rasheed wrote: >> > >> > OK, I have pushed 0001 and 0002. Here's the remaining (main) patch. >> > >> >> OK, I have

Fix overflow in DecodeInterval

2022-02-11 Thread Joseph Koshakow
first patch, so apologies if I screwed up the process somewhere. - Joe Koshakow From b3c096039a4684646806e2959d7ac9318504b031 Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Fri, 11 Feb 2022 14:18:32 -0500 Subject: [PATCH] Check for overflow when decoding an interval When decoding an

Re: Fix overflow in DecodeInterval

2022-02-11 Thread Joseph Koshakow
Tom Lane writes: > Joseph Koshakow writes: > > The attached patch fixes an overflow bug in DecodeInterval when applying > > the units week, decade, century, and millennium. The overflow check logic > > was modelled after the overflow check at the beginning of `int > &g

Re: Fix overflow in DecodeInterval

2022-02-12 Thread Joseph Koshakow
On Fri, Feb 11, 2022 at 4:58 PM Joseph Koshakow wrote: > > Tom Lane writes: > > Joseph Koshakow writes: > > > The attached patch fixes an overflow bug in DecodeInterval when applying > > > the units week, decade, century, and millennium. The overflow check logi

Re: Fix overflow in DecodeInterval

2022-02-13 Thread Joseph Koshakow
On Sat, Feb 12, 2022 at 10:51 PM Andres Freund wrote: > Any reason for using int return types? > > particularly since the pg_*_overflow stuff uses bool? I chose int return types to keep all these methods consistent with DecodeInterval, which returns a non-zero int to indicate an error. Though I w

Fix overflow in justify_interval related functions

2022-02-13 Thread Joseph Koshakow
I mentioned this issue briefly in another thread, but the justify_interval, justify_days, and justify_hours functions all have the potential to overflow. The attached patch fixes this issue. Cheers, Joe Koshakow From 4400f2e6886097e3b75d455aeec1ffa9cbc88510 Mon Sep 17 00:00:00 2001 From: Joseph

Re: Fix overflow in DecodeInterval

2022-02-13 Thread Joseph Koshakow
ep 17 00:00:00 2001 From: Joseph Koshakow Date: Fri, 11 Feb 2022 14:18:32 -0500 Subject: [PATCH] Check for overflow when decoding an interval When decoding an interval there are various date units which are aliases for some multiple of another unit. For example a week is 7 days and a decade is 10

Re: Fix overflow in DecodeInterval

2022-02-13 Thread Joseph Koshakow
Attached is a new version switching from ints to bools, as requested. - Joe Koshakow From af8f030ad146602b4386f77b5664c6013743569b Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Fri, 11 Feb 2022 14:18:32 -0500 Subject: [PATCH] Check for overflow when decoding an interval When decoding an

Re: Fix overflow in justify_interval related functions

2022-02-14 Thread Joseph Koshakow
On Mon, Feb 14, 2022 at 2:15 PM Nathan Bossart wrote: > Makes sense. So we could likely avoid it for justify_interval, but the > others are at the mercy of the interval implementation. I'm not entirely sure what you mean by "it", but for both justify_interval and justify_days this commit throws

Re: Fix overflow in justify_interval related functions

2022-02-14 Thread Joseph Koshakow
further to the attached patch. - Joe From 8ff8302b90c790d967f770286dfa54432f63662c Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sun, 13 Feb 2022 13:26:16 -0500 Subject: [PATCH] Check for overflow in justify_interval functions justify_interval, justify_hours, and justify_days didn't check for ove

Re: Fix overflow in justify_interval related functions

2022-02-15 Thread Joseph Koshakow
r review and comments! - Joe Koshakow From 62e3c824c9243fd53ad95b4d4fc3ef2542d8a941 Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sun, 13 Feb 2022 13:26:16 -0500 Subject: [PATCH] Check for overflow in justify_interval functions justify_interval, justify_hours, and justify_days didn't

Re: Fix overflow in DecodeInterval

2022-02-15 Thread Joseph Koshakow
On Sun, Feb 13, 2022 at 5:12 PM Joseph Koshakow wrote: > > Attached is a new version switching from ints to bools, as requested. > > - Joe Koshakow Tom, Andres, Thanks for your feedback! I'm not super familiar with the process, should I submit this thread to the commitfest or

Re: Fix overflow in DecodeInterval

2022-02-17 Thread Joseph Koshakow
Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Fri, 11 Feb 2022 14:18:32 -0500 Subject: [PATCH] Check for overflow when decoding an interval When decoding an interval there are various date units which are aliases for some multiple of another unit. For example a week is 7 days and a dec

Fix formatting of Interval output

2022-02-17 Thread Joseph Koshakow
the issue: postgres=# SELECT INTERVAL '-2147483648 hrs'; interval --2147483648:00:00 (1 row) Cheers, Joe Koshakow From 720f0903c71a428695672aa866fc8fb0146a472e Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Thu, 17 Feb 2022 21:57:48 -0500

Re: Fix formatting of Interval output

2022-02-19 Thread Joseph Koshakow
On Fri, Feb 18, 2022 at 11:44 PM Tom Lane wrote: > > Joseph Koshakow writes: > > When formatting the output of an Interval, we call abs() on the hours > > field of the Interval. Calling abs(INT_MIN) returns back INT_MIN > > causing the output to contain two '-&#x

Re: Fix formatting of Interval output

2022-02-19 Thread Joseph Koshakow
On Sat, Feb 19, 2022 at 12:00 PM Tom Lane wrote: > I think that messing with struct pg_tm might have too many side-effects. > However, pg_tm isn't all that well adapted to intervals in the first > place, so it'd make sense to make a new struct specifically for interval > decoding. Yeah that's a g

Re: Fix overflow in DecodeInterval

2022-02-19 Thread Joseph Koshakow
Copying over a related thread here to have info all in one place. It's a little fragmented so sorry about that. On Fri, Feb 18, 2022 at 11:44 PM Tom Lane wrote: > > Joseph Koshakow writes: > > When formatting the output of an Interval, we call abs() on the hours > >

Re: Fix overflow in DecodeInterval

2022-02-19 Thread Joseph Koshakow
code copied and pasted from other files. The code seemed out of date from those other files, so I tried to bring it up to date and add my changes. - Joe Koshakow From f678ee1bdcd6e075f1b1c771e6d5f6b3f9089086 Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Fri, 11 Feb 2022 14:18:32 -0500 Su

Infinite Interval

2022-12-10 Thread Joseph Koshakow
Hi all, There have been multiple threads in the past discussing infinite intervals: https://www.postgresql.org/message-id/flat/4EB095C8.1050703%40agliodbs.com https://www.postgresql.org/message-id/flat/200101241913.f0OJDUu45423%40hub.org https://www.postgresql.org/message-id/flat/CANP8%2BjKTxQh4Mj

Re: Wrong security context for deferred triggers?

2024-06-08 Thread Joseph Koshakow
Hi, I see that this patch is marked as ready for review, so I thought I would attempt to review it. This is my first review, so please take it with a grain of salt. > So a deferred constraint trigger does not run with the same security context > as an immediate trigger. It sounds like the crux o

Re: Wrong security context for deferred triggers?

2024-06-08 Thread Joseph Koshakow
On Sat, Jun 8, 2024 at 5:36 PM Joseph Koshakow wrote: >Additionally, I applied your patch to master and re-ran the example and >didn't notice any behavior change. > >test=# CREATE TABLE tab (i integer); >CREATE TABLE >test=# CREATE FUNCTION

Re: Wrong security context for deferred triggers?

2024-06-09 Thread Joseph Koshakow
On Sat, Jun 8, 2024 at 10:13 PM Isaac Morland wrote: > Speaking as a table owner, when I set a trigger on it, I expect that when the specified actions occur my trigger will fire and will do what I specify, without regard to the execution environment of the caller (search_path in particular); and

Remove dependence on integer wrapping

2024-06-09 Thread Joseph Koshakow
, Joe Koshakow [0] https://www.postgresql.org/message-id/20240213191401.jjhsic7et4tiahjs%40awork3.anarazel.de From 319bc904858ad8fbcc687a923733defd3358c7b9 Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sat, 8 Jun 2024 22:16:46 -0400 Subject: [PATCH] Remove dependence on integer wrapping This commit upd

Re: Remove dependence on integer wrapping

2024-06-11 Thread Joseph Koshakow
tip of the iceberg. Agreed. > Is there any chance of using static > analysis to find all the places of concern? I'm not personally familiar with any static analysis tools, but I can try and do some research. Andres had previously suggested SQLSmith. I think any kind of fuzz testing wi

Re: Remove dependence on integer wrapping

2024-06-11 Thread Joseph Koshakow
mp.c... The attached patch has updated this file too. For some reason I was under the impression that I should leave the ecpg/ files alone, though I can't remember why. Thanks, Joe Koshakow From adcf89561cec31499754a7c04da50c408a12724a Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sa

Re: Remove dependence on integer wrapping

2024-06-13 Thread Joseph Koshakow
e whole iceberg too. +1 Thanks, Joe Koshakow From 31e8de30a82e60151848439143169e562bc848a3 Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sat, 8 Jun 2024 22:16:46 -0400 Subject: [PATCH 1/2] Remove dependence on integer wrapping This commit updates various parts of the code to no longer rely on i

Re: Remove dependence on integer wrapping

2024-06-13 Thread Joseph Koshakow
On Thu, Jun 13, 2024 at 10:48 PM Joseph Koshakow wrote: >I've attached >v4-0002-Handle-overflow-in-money-arithmetic.patch which adds some >overflow checks and tests. I didn't address the float multiplication >because I didn't see any helper method

Re: Remove dependence on integer wrapping

2024-06-19 Thread Joseph Koshakow
On Thu, Jun 13, 2024 at 10:56 PM Joseph Koshakow wrote: On Thu, Jun 13, 2024 at 10:48 PM Joseph Koshakow wrote: >I've attached >v4-0002-Handle-overflow-in-money-arithmetic.patch which adds some >overflow checks and tests. I didn't address the f

Re: Wrong security context for deferred triggers?

2024-06-22 Thread Joseph Koshakow
On Mon, Jun 10, 2024 at 1:00 PM Laurenz Albe wrote: >Like you, I was surprised by the current behavior. There is a design >principle that PostgreSQL tries to follow, called the "Principle of >least astonishment". Things should behave like a moderately skilled >user would expect

Re: Wrong security context for deferred triggers?

2024-06-22 Thread Joseph Koshakow
On Sat, Jun 22, 2024 at 6:23 PM David G. Johnston < david.g.johns...@gmail.com> wrote: > except invoker and triggerer are the same entity Maybe "executor" would have been a better term than 'invoker". In this specific example they are not the same entity. The trigger is triggered and queued by on

Re: Remove dependence on integer wrapping

2024-07-06 Thread Joseph Koshakow
is reviewed and waiting for v18 and a committer. 0002 and 0003 are unreviewed. So, I'm going to mark this as waiting for a reviewer. Thanks, Joe Koshakow From f3747da14c887f97e50d9a3104881cbd3d5f60de Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Sat, 8 Jun 2024 22:16:46 -0400 Subject

Re: Remove dependence on integer wrapping

2024-07-06 Thread Joseph Koshakow
s=0, op_type=2) at jsonfuncs.c:5407 > 5407if (-idx > nelems) > (gdb) p idx > $1 = -2147483648 I've added another patch, 0004, to resolve the jsonb wrap-arounds. The other patches, 0001, 0002, and 0003 are unchanged but have their version number incremented.

Re: Wrong security context for deferred triggers?

2024-07-07 Thread Joseph Koshakow
On Mon, Jul 1, 2024 at 11:45 AM Laurenz Albe wrote: > I asked them for a statement, and they were nice enough to write up > https://postgr.es/m/e89e8dd9-7143-4db8-ac19-b2951cb0c0da%40gmail.com > They have a workaround, so the patch is not absolutely necessary for them. It sounds like the issue

Re: Remove dependence on integer wrapping

2024-07-13 Thread Joseph Koshakow
On Fri, Jul 12, 2024 at 12:49 PM Nathan Bossart wrote: > On Sat, Jul 06, 2024 at 07:04:38PM -0400, Joseph Koshakow wrote: >> I've added another patch, 0004, to resolve the jsonb wrap-arounds. >> >> The other patches, 0001, 0002, and 0003 are unchanged but have their >

  1   2   >