Re: [HACKERS] fortnight interval support
On Tue, Nov 3, 2015 at 6:40 PM, Michael Paquier wrote: > On Wed, Nov 4, 2015 at 2:31 AM, Robert Haas wrote: >> On Tue, Nov 3, 2015 at 8:31 AM, Alvaro Herrera >> wrote: >>> (WRT the reference to Jane Austen and "Se'ennight" for "week", it occurs >>> to me that fortnight is a similar contraction for "forteen night".) >> >> Well, clearly we also need enquië for the elves of Arda and tenday for >> for Faerûnians. Seems like a serious oversight, though making enquië >> work in non-Unicode locales might be tricky. > > You are forgetting Klingon, parseltongue, dwarfic and the one of > Mordor. It's not worth angering them as well. But I'll stop here. I'm not aware that any of those have weeks of some duration other than 7 days, but the lack of support for the Klingon calendar in general is indeed troubling. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] fortnight interval support
On Wed, Nov 4, 2015 at 2:31 AM, Robert Haas wrote: > On Tue, Nov 3, 2015 at 8:31 AM, Alvaro Herrera > wrote: >> (WRT the reference to Jane Austen and "Se'ennight" for "week", it occurs >> to me that fortnight is a similar contraction for "forteen night".) > > Well, clearly we also need enquië for the elves of Arda and tenday for > for Faerûnians. Seems like a serious oversight, though making enquië > work in non-Unicode locales might be tricky. You are forgetting Klingon, parseltongue, dwarfic and the one of Mordor. It's not worth angering them as well. But I'll stop here. -- Michael -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] fortnight interval support
On Tue, Nov 3, 2015 at 8:31 AM, Alvaro Herrera wrote: > (WRT the reference to Jane Austen and "Se'ennight" for "week", it occurs > to me that fortnight is a similar contraction for "forteen night".) Well, clearly we also need enquië for the elves of Arda and tenday for for Faerûnians. Seems like a serious oversight, though making enquië work in non-Unicode locales might be tricky. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] fortnight interval support
Michael Paquier wrote: > On Wed, Oct 28, 2015 at 4:17 AM, Gavin Flower wrote: > > You trying to get PostgreSQL banned in France??? :-) > > > > When I was learning French many years ago, I was told that the French > > consider their fortnight to be 15 days!!! > > Confirmed. I would translate fornight as 'quinzaine' to French. > (please let's not add that btw). I don't know what's the origin of the word "fortnight", in particular whether it's always supposed to be exactly fourteen days, but the equivalent to quizaine in Spanish ("quincena") is ambiguous enough that I would have trouble making it part of intervals in Postgres. It is sometimes interpreted as "two weeks", other times as exactly fifteen days, other times as "half a month". (WRT the reference to Jane Austen and "Se'ennight" for "week", it occurs to me that fortnight is a similar contraction for "forteen night".) -- Álvaro Herrerahttp://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] fortnight interval support
On Wed, Oct 28, 2015 at 4:17 AM, Gavin Flower wrote: > You trying to get PostgreSQL banned in France??? :-) > > When I was learning French many years ago, I was told that the French > consider their fortnight to be 15 days!!! Confirmed. I would translate fornight as 'quinzaine' to French. (please let's not add that btw). -- Michael -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] fortnight interval support
On 02/11/15 07:06, Tom Lane wrote: David Fetter writes: On Tue, Oct 27, 2015 at 07:30:13PM +, Nathan Wagner wrote: On Wed, Oct 28, 2015 at 08:17:25AM +1300, Gavin Flower wrote: I had actually written: > You trying to get PostgreSQL banned in France??? > > When I was learning French many years ago, I was told that the French > consider their fortnight to be 15 days!!! The following 2 lines were from Nathan, not me! What, it's a "fortnight", not a "quinzaine". You have no idea how hard it was to resist updating the patch... Well, if you won't do it, I will. Please tell me this is a joke. (FWIW, I don't have a problem with "fortnight", but I draw the line at units that are not used in English.) regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] fortnight interval support
On 11/02/2015 09:20 AM, Merlin Moncure wrote: On Sun, Nov 1, 2015 at 2:20 PM, David Fetter wrote: On Sun, Nov 01, 2015 at 01:06:39PM -0500, Tom Lane wrote: David Fetter writes: On Tue, Oct 27, 2015 at 07:30:13PM +, Nathan Wagner wrote: On Wed, Oct 28, 2015 at 08:17:25AM +1300, Gavin Flower wrote: What, it's a "fortnight", not a "quinzaine". You have no idea how hard it was to resist updating the patch... Well, if you won't do it, I will. Please tell me this is a joke. Yes, it's a joke. (FWIW, I don't have a problem with "fortnight", but I draw the line at units that are not used in English.) It's used in English, but not in this context. https://en.wikipedia.org/wiki/Quinzaine As to localization, I think we need to consider carefully whether PostgreSQL is to be a US-only RDBMS with a few concessions to usage elsewhere, or one usable by all the world's peoples That baggage comes with the SQL Standard. It's fun to think about a functional equivalent of SQL that doesn't attempt to have statements be grammatically correct English sentences but due to various human pressures that isn't how things worked out. Since I'm daydreaming, let's have this hypothetical language implement relational division. By the way, I fell for the joke. Note, we do implement 'allballs' so I'll take a pass. I respectfully submit that there is a case for supporting lovers of Jane Austen (such as me!) by recognizing "se'nnight", with or without apostrophe, as a synonym for "week". cheers andrew -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] fortnight interval support
On Sun, Nov 1, 2015 at 2:20 PM, David Fetter wrote: > On Sun, Nov 01, 2015 at 01:06:39PM -0500, Tom Lane wrote: >> David Fetter writes: >> > On Tue, Oct 27, 2015 at 07:30:13PM +, Nathan Wagner wrote: >> >> On Wed, Oct 28, 2015 at 08:17:25AM +1300, Gavin Flower wrote: >> >> What, it's a "fortnight", not a "quinzaine". >> >> >> >> You have no idea how hard it was to resist updating the patch... >> >> > Well, if you won't do it, I will. >> >> Please tell me this is a joke. > > Yes, it's a joke. > >> (FWIW, I don't have a problem with "fortnight", but I draw the line >> at units that are not used in English.) > > It's used in English, but not in this context. > > https://en.wikipedia.org/wiki/Quinzaine > > As to localization, I think we need to consider carefully whether > PostgreSQL is to be a US-only RDBMS with a few concessions to usage > elsewhere, or one usable by all the world's peoples That baggage comes with the SQL Standard. It's fun to think about a functional equivalent of SQL that doesn't attempt to have statements be grammatically correct English sentences but due to various human pressures that isn't how things worked out. Since I'm daydreaming, let's have this hypothetical language implement relational division. By the way, I fell for the joke. Note, we do implement 'allballs' so I'll take a pass. merlin -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] fortnight interval support
On Sun, Nov 01, 2015 at 01:06:39PM -0500, Tom Lane wrote: > David Fetter writes: > > On Tue, Oct 27, 2015 at 07:30:13PM +, Nathan Wagner wrote: > >> On Wed, Oct 28, 2015 at 08:17:25AM +1300, Gavin Flower wrote: > >> What, it's a "fortnight", not a "quinzaine". > >> > >> You have no idea how hard it was to resist updating the patch... > > > Well, if you won't do it, I will. > > Please tell me this is a joke. Yes, it's a joke. > (FWIW, I don't have a problem with "fortnight", but I draw the line > at units that are not used in English.) It's used in English, but not in this context. https://en.wikipedia.org/wiki/Quinzaine As to localization, I think we need to consider carefully whether PostgreSQL is to be a US-only RDBMS with a few concessions to usage elsewhere, or one usable by all the world's peoples, and no, we should probably not continue this thread to work out the decisions implicit in whatever direction we settle on. Cheers, David. -- David Fetter http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david.fet...@gmail.com Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] fortnight interval support
David Fetter writes: > On Tue, Oct 27, 2015 at 07:30:13PM +, Nathan Wagner wrote: >> On Wed, Oct 28, 2015 at 08:17:25AM +1300, Gavin Flower wrote: >> What, it's a "fortnight", not a "quinzaine". >> >> You have no idea how hard it was to resist updating the patch... > Well, if you won't do it, I will. Please tell me this is a joke. (FWIW, I don't have a problem with "fortnight", but I draw the line at units that are not used in English.) regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] fortnight interval support
On Tue, Oct 27, 2015 at 07:30:13PM +, Nathan Wagner wrote: > On Wed, Oct 28, 2015 at 08:17:25AM +1300, Gavin Flower wrote: > > You trying to get PostgreSQL banned in France??? :-) > > > > When I was learning French many years ago, I was told that the French > > consider their fortnight to be 15 days!!! > > What, it's a "fortnight", not a "quinzaine". > > You have no idea how hard it was to resist updating the patch... Well, if you won't do it, I will. Please find attached. Cheers, David. -- David Fetter http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david.fet...@gmail.com Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 926358e..8a62d65 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -186,6 +186,8 @@ static const datetkn deltatktbl[] = { {DDECADE, UNITS, DTK_DECADE}, /* "decade" relative */ {"decades", UNITS, DTK_DECADE}, /* "decades" relative */ {"decs", UNITS, DTK_DECADE},/* "decades" relative */ + {DFORTNIGHT, UNITS, DTK_FORTNIGHT}, /* "fortnights" relative */ + {"fortnights", UNITS, DTK_FORTNIGHT}, /* "fortnights" relative */ {"h", UNITS, DTK_HOUR}, /* "hour" relative */ {DHOUR, UNITS, DTK_HOUR}, /* "hour" relative */ {"hours", UNITS, DTK_HOUR}, /* "hours" relative */ @@ -214,6 +216,8 @@ static const datetkn deltatktbl[] = { {"msecs", UNITS, DTK_MILLISEC}, {"qtr", UNITS, DTK_QUARTER},/* "quarter" relative */ {DQUARTER, UNITS, DTK_QUARTER}, /* "quarter" relative */ + {DQUINZAINE, UNITS, DTK_QUINZAINE}, /* "quinzaines" relative */ + {"quinzaines", UNITS, DTK_QUINZAINE}, /* "quinzaines" relative */ {"s", UNITS, DTK_SECOND}, {"sec", UNITS, DTK_SECOND}, {DSECOND, UNITS, DTK_SECOND}, @@ -3281,6 +3285,18 @@ DecodeInterval(char **field, int *ftype, int nf, int range, tmask = DTK_M(DAY); break; + case DTK_FORTNIGHT: + tm->tm_mday += val * 14; + AdjustFractDays(fval, tm, fsec, 14); + tmask = DTK_M(WEEK); + break; + + case DTK_QUINZAINE: + tm->tm_mday += val * 15; + AdjustFractDays(fval, tm, fsec, 15); + tmask = DTK_M(WEEK); + break; + case DTK_WEEK: tm->tm_mday += val * 7; AdjustFractDays(fval, tm, fsec, 7); diff --git a/src/include/utils/datetime.h b/src/include/utils/datetime.h index e9a1ece..3944912 100644 --- a/src/include/utils/datetime.h +++ b/src/include/utils/datetime.h @@ -52,6 +52,8 @@ struct tzEntry; #define DHOUR "hour" #define DDAY "day" #define DWEEK "week" +#define DFORTNIGHT "fortnight" +#define DQUINZAINE "quinzaine" #define DMONTH "month" #define DQUARTER "quarter" #define DYEAR "year" @@ -181,6 +183,8 @@ struct tzEntry; #define DTK_TZ_MINUTE 35 #define DTK_ISOYEAR36 #define DTK_ISODOW 37 +#define DTK_FORTNIGHT 38 +#define DTK_QUINZAINE 39 /* diff --git a/src/test/regress/expected/interval.out b/src/test/regress/expected/interval.out index c873a99..350f097 100644 --- a/src/test/regress/expected/interval.out +++ b/src/test/regress/expected/interval.out @@ -40,6 +40,18 @@ SELECT INTERVAL '1.5 weeks' AS "Ten days twelve hours"; 10 days 12:00:00 (1 row) +SELECT INTERVAL '1 fortnight' AS "Fourteen days"; + Fourteen days +--- + 14 days +(1 row) + +SELECT INTERVAL '1 quinzaine' AS "Fifteen days"; + Fifteen days +-- + 15 days +(1 row) + SELECT INTERVAL '1.5 months' AS "One month 15 days"; One month 15 days --- diff --git a/src/test/regress/sql/interval.sql b/src/test/regress/sql/interval.sql index 789c3de..ae884bc 100644 --- a/src/test/regress/sql/interval.sql +++ b/src/test/regress/sql/interval.sql @@ -12,6 +12,8 @@ SELECT INTERVAL '-08:00' AS "Eight hours"; SELECT INTERVAL '-1 +02:03' AS "22 hours ago..."; SELECT INTERVAL '-1 days +02:03' AS "22 hours ago..."; SELECT INTERVAL '1.5 weeks' AS "Ten days twelve hours"; +SELECT INTERVAL '1 fortnight' AS "Fourteen days"; +SELECT INTERVAL '1 quinzaine' AS "
Re: [HACKERS] fortnight interval support
On Tue, Oct 27, 2015 at 01:52:11PM +, Nathan Wagner wrote: > On Mon, Oct 26, 2015 at 01:58:52PM -0400, Robert Haas wrote: > > Aw, you're no fun. select '1 fortnight'::interval => '14 days' would be > > cool. > > Patch attached... This isn't necessarily bad, but I observe that it would be difficult or impossible to add fortnight support to intervals as an extension rather than by modifying the scanner tables that the interval parser uses at original compile time. You might be able to override symbols with a C extension, but parts of the parser are static (in the C sense), so you'd need to override and duplicate a lot of the existing functions. Of course, a hookable interval parser is absurd in the first place. -- nw -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] fortnight interval support
On Wed, Oct 28, 2015 at 08:17:25AM +1300, Gavin Flower wrote: > You trying to get PostgreSQL banned in France??? :-) > > When I was learning French many years ago, I was told that the French > consider their fortnight to be 15 days!!! What, it's a "fortnight", not a "quinzaine". You have no idea how hard it was to resist updating the patch... -- nw -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] fortnight interval support
On Tue, Oct 27, 2015 at 12:04:55PM -0500, Merlin Moncure wrote: > On Tue, Oct 27, 2015 at 8:52 AM, Nathan Wagner wrote: > > On Mon, Oct 26, 2015 at 01:58:52PM -0400, Robert Haas wrote: > >> Aw, you're no fun. select '1 fortnight'::interval => '14 days' would be > >> cool. > > > > Patch attached... > This is very cool (you are 100% certain there are no performance > impacts on current cases, right?)! :-) It passed the regression test. It must be perfect :) -- nw -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] fortnight interval support
On 28/10/15 02:52, Nathan Wagner wrote: On Mon, Oct 26, 2015 at 01:58:52PM -0400, Robert Haas wrote: Aw, you're no fun. select '1 fortnight'::interval => '14 days' would be cool. Patch attached... :) [...] You trying to get PostgreSQL banned in France??? :-) When I was learning French many years ago, I was told that the French consider their fortnight to be 15 days!!! see: https://nz.answers.yahoo.com/question/index?qid=20100920093722AAc54Xo https://en.wikipedia.org/wiki/Fortnight http://www.wordsense.eu/fortnight Cheers, Gavin -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] fortnight interval support
On Tue, Oct 27, 2015 at 01:52:11PM +, Nathan Wagner wrote: > On Mon, Oct 26, 2015 at 01:58:52PM -0400, Robert Haas wrote: > > Aw, you're no fun. select '1 fortnight'::interval => '14 days' > > would be cool. > > Patch attached... > > :) I'd argue for a back-patch all the way to 9.1, as the lack of fortnight support is clearly a bug. Cheers, David. -- David Fetter http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david.fet...@gmail.com Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] fortnight interval support
On Tue, Oct 27, 2015 at 8:52 AM, Nathan Wagner wrote: > On Mon, Oct 26, 2015 at 01:58:52PM -0400, Robert Haas wrote: >> Aw, you're no fun. select '1 fortnight'::interval => '14 days' would be >> cool. > > Patch attached... > > :) This is very cool (you are 100% certain there are no performance impacts on current cases, right?)! :-) merlin -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
[HACKERS] fortnight interval support
On Mon, Oct 26, 2015 at 01:58:52PM -0400, Robert Haas wrote: > Aw, you're no fun. select '1 fortnight'::interval => '14 days' would be cool. Patch attached... :) % psql -p 5433 -d template1 -h localhost psql (9.4.5, server 9.6devel) WARNING: psql major version 9.4, server major version 9.6. Some psql features might not work. Type "help" for help. template1=# select current_date; date 2015-10-27 (1 row) template1=# select '1 fortnight'::interval; interval -- 14 days (1 row) template1=# select current_date + '1 fortnight'::interval; ?column? - 2015-11-10 00:00:00 (1 row) template1=# select current_date + '1.3 fortnight'::interval; ?column? - 2015-11-14 04:48:00 (1 row) template1=# select current_date + '1.3 fortnights'::interval; ?column? - 2015-11-14 04:48:00 (1 row) -- nw diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 926358e..2032fe0 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -186,6 +186,8 @@ static const datetkn deltatktbl[] = { {DDECADE, UNITS, DTK_DECADE}, /* "decade" relative */ {"decades", UNITS, DTK_DECADE}, /* "decades" relative */ {"decs", UNITS, DTK_DECADE},/* "decades" relative */ + {DFORTNIGHT, UNITS, DTK_FORTNIGHT}, /* "fortnights" relative */ + {"fortnights", UNITS, DTK_FORTNIGHT}, /* "fortnights" relative */ {"h", UNITS, DTK_HOUR}, /* "hour" relative */ {DHOUR, UNITS, DTK_HOUR}, /* "hour" relative */ {"hours", UNITS, DTK_HOUR}, /* "hours" relative */ @@ -3281,6 +3283,12 @@ DecodeInterval(char **field, int *ftype, int nf, int range, tmask = DTK_M(DAY); break; + case DTK_FORTNIGHT: + tm->tm_mday += val * 14; + AdjustFractDays(fval, tm, fsec, 14); + tmask = DTK_M(WEEK); + break; + case DTK_WEEK: tm->tm_mday += val * 7; AdjustFractDays(fval, tm, fsec, 7); diff --git a/src/include/utils/datetime.h b/src/include/utils/datetime.h index e9a1ece..3641292 100644 --- a/src/include/utils/datetime.h +++ b/src/include/utils/datetime.h @@ -52,6 +52,7 @@ struct tzEntry; #define DHOUR "hour" #define DDAY "day" #define DWEEK "week" +#define DFORTNIGHT "fortnight" #define DMONTH "month" #define DQUARTER "quarter" #define DYEAR "year" @@ -181,6 +182,7 @@ struct tzEntry; #define DTK_TZ_MINUTE 35 #define DTK_ISOYEAR36 #define DTK_ISODOW 37 +#define DTK_FORTNIGHT 38 /* diff --git a/src/test/regress/expected/interval.out b/src/test/regress/expected/interval.out index c873a99..7a72f2a 100644 --- a/src/test/regress/expected/interval.out +++ b/src/test/regress/expected/interval.out @@ -40,6 +40,12 @@ SELECT INTERVAL '1.5 weeks' AS "Ten days twelve hours"; 10 days 12:00:00 (1 row) +SELECT INTERVAL '1 fortnight' AS "Fourteen days"; + Fourteen days +--- + 14 days +(1 row) + SELECT INTERVAL '1.5 months' AS "One month 15 days"; One month 15 days --- diff --git a/src/test/regress/sql/interval.sql b/src/test/regress/sql/interval.sql index 789c3de..285266a 100644 --- a/src/test/regress/sql/interval.sql +++ b/src/test/regress/sql/interval.sql @@ -12,6 +12,7 @@ SELECT INTERVAL '-08:00' AS "Eight hours"; SELECT INTERVAL '-1 +02:03' AS "22 hours ago..."; SELECT INTERVAL '-1 days +02:03' AS "22 hours ago..."; SELECT INTERVAL '1.5 weeks' AS "Ten days twelve hours"; +SELECT INTERVAL '1 fortnight' AS "Fourteen days"; SELECT INTERVAL '1.5 months' AS "One month 15 days"; SELECT INTERVAL '10 years -11 month -12 days +13:14' AS "9 years..."; -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers