pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
[PATCH] interval squash commit
9+ messages / 5 participants
[nested] [flat]

* [PATCH] interval squash commit
@ 2021-04-08 17:07  Bruce Momjian <bruce@momjian.us>
  0 siblings, 0 replies; 9+ messages in thread

From: Bruce Momjian @ 2021-04-08 17:07 UTC (permalink / raw)

---
 doc/src/sgml/datatype.sgml                | 16 +++++++---------
 src/backend/utils/adt/datetime.c          | 13 ++++++-------
 src/interfaces/ecpg/pgtypeslib/interval.c | 12 ++++++------
 src/test/regress/expected/interval.out    |  8 ++++----
 src/test/regress/sql/interval.sql         |  2 +-
 5 files changed, 24 insertions(+), 27 deletions(-)

inline patch 1: doc/src/sgml/datatype.sgml, src/backend/utils/adt/datetime.c, src/interfaces/ecpg/pgtypeslib/interval.c and 2 more (+24/-27 lines) download inline-1.patchdiff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index 7c341c8e3f..9454107e75 100644 --- a/doc/src/sgml/datatype.sgml +++ b/doc/src/sgml/datatype.sgml @@ -2770,15 +2770,13 @@ P <optional> <replaceable>years</replaceable>-<replaceable>months</replaceable>- </para> <para> - In the verbose input format, and in some fields of the more compact - input formats, field values can have fractional parts; for example - <literal>'1.5 week'</literal> or <literal>'01:02:03.45'</literal>. Such input is - converted to the appropriate number of months, days, and seconds - for storage. When this would result in a fractional number of - months or days, the fraction is added to the lower-order fields - using the conversion factors 1 month = 30 days and 1 day = 24 hours. - For example, <literal>'1.5 month'</literal> becomes 1 month and 15 days. - Only seconds will ever be shown as fractional on output. + Field values can have fractional parts; for example, <literal>'1.5 + weeks'</literal> or <literal>'01:02:03.45'</literal>. The fractional + parts are used to compute appropriate values for the next lower-order + internal fields (months, days, seconds). For example, <literal>'1.5 + months'</literal> becomes <literal>1 month 15 days</literal>. + The fractional conversion factors used are 1 month = 30 days and 1 day + = 24 hours. Only seconds will ever be shown as fractional on output. </para> <para> diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 889077f55c..d5b3705145 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -526,7 +526,6 @@ AdjustFractDays(double frac, struct pg_tm *tm, fsec_t *fsec, int scale) extra_days = (int) frac; tm->tm_mday += extra_days; frac -= extra_days; - AdjustFractSeconds(frac, tm, fsec, SECS_PER_DAY); } /* Fetch a fractional-second value with suitable error checking */ @@ -3307,28 +3306,28 @@ DecodeInterval(char **field, int *ftype, int nf, int range, case DTK_YEAR: tm->tm_year += val; if (fval != 0) - tm->tm_mon += fval * MONTHS_PER_YEAR; + tm->tm_mon += rint(fval * MONTHS_PER_YEAR); tmask = DTK_M(YEAR); break; case DTK_DECADE: tm->tm_year += val * 10; if (fval != 0) - tm->tm_mon += fval * MONTHS_PER_YEAR * 10; + tm->tm_mon += rint(fval * MONTHS_PER_YEAR * 10); tmask = DTK_M(DECADE); break; case DTK_CENTURY: tm->tm_year += val * 100; if (fval != 0) - tm->tm_mon += fval * MONTHS_PER_YEAR * 100; + tm->tm_mon += rint(fval * MONTHS_PER_YEAR * 100); tmask = DTK_M(CENTURY); break; case DTK_MILLENNIUM: tm->tm_year += val * 1000; if (fval != 0) - tm->tm_mon += fval * MONTHS_PER_YEAR * 1000; + tm->tm_mon += rint(fval * MONTHS_PER_YEAR * 1000); tmask = DTK_M(MILLENNIUM); break; @@ -3565,7 +3564,7 @@ DecodeISO8601Interval(char *str, { case 'Y': tm->tm_year += val; - tm->tm_mon += (fval * MONTHS_PER_YEAR); + tm->tm_mon += rint(fval * MONTHS_PER_YEAR); break; case 'M': tm->tm_mon += val; @@ -3601,7 +3600,7 @@ DecodeISO8601Interval(char *str, return DTERR_BAD_FORMAT; tm->tm_year += val; - tm->tm_mon += (fval * MONTHS_PER_YEAR); + tm->tm_mon += rint(fval * MONTHS_PER_YEAR); if (unit == '\0') return 0; if (unit == 'T') diff --git a/src/interfaces/ecpg/pgtypeslib/interval.c b/src/interfaces/ecpg/pgtypeslib/interval.c index 4245016c8e..fccb9765ae 100644 --- a/src/interfaces/ecpg/pgtypeslib/interval.c +++ b/src/interfaces/ecpg/pgtypeslib/interval.c @@ -155,7 +155,7 @@ DecodeISO8601Interval(char *str, { case 'Y': tm->tm_year += val; - tm->tm_mon += (fval * MONTHS_PER_YEAR); + tm->tm_mon += rint(fval * MONTHS_PER_YEAR); break; case 'M': tm->tm_mon += val; @@ -191,7 +191,7 @@ DecodeISO8601Interval(char *str, return DTERR_BAD_FORMAT; tm->tm_year += val; - tm->tm_mon += (fval * MONTHS_PER_YEAR); + tm->tm_mon += rint(fval * MONTHS_PER_YEAR); if (unit == '\0') return 0; if (unit == 'T') @@ -529,28 +529,28 @@ DecodeInterval(char **field, int *ftype, int nf, /* int range, */ case DTK_YEAR: tm->tm_year += val; if (fval != 0) - tm->tm_mon += fval * MONTHS_PER_YEAR; + tm->tm_mon += rint(fval * MONTHS_PER_YEAR); tmask = (fmask & DTK_M(YEAR)) ? 0 : DTK_M(YEAR); break; case DTK_DECADE: tm->tm_year += val * 10; if (fval != 0) - tm->tm_mon += fval * MONTHS_PER_YEAR * 10; + tm->tm_mon += rint(fval * MONTHS_PER_YEAR * 10); tmask = (fmask & DTK_M(YEAR)) ? 0 : DTK_M(YEAR); break; case DTK_CENTURY: tm->tm_year += val * 100; if (fval != 0) - tm->tm_mon += fval * MONTHS_PER_YEAR * 100; + tm->tm_mon += rint(fval * MONTHS_PER_YEAR * 100); tmask = (fmask & DTK_M(YEAR)) ? 0 : DTK_M(YEAR); break; case DTK_MILLENNIUM: tm->tm_year += val * 1000; if (fval != 0) - tm->tm_mon += fval * MONTHS_PER_YEAR * 1000; + tm->tm_mon += rint(fval * MONTHS_PER_YEAR * 1000); tmask = (fmask & DTK_M(YEAR)) ? 0 : DTK_M(YEAR); break; diff --git a/src/test/regress/expected/interval.out b/src/test/regress/expected/interval.out index 0191949137..3f948f56c0 100644 --- a/src/test/regress/expected/interval.out +++ b/src/test/regress/expected/interval.out @@ -34,10 +34,10 @@ SELECT INTERVAL '-1 days +02:03' AS "22 hours ago..."; -1 day +02:03:00 (1 row) -SELECT INTERVAL '1.5 weeks' AS "Ten days twelve hours"; - Ten days twelve hours ------------------------ - 10 days 12:00:00 +SELECT INTERVAL '1.5 weeks' AS "Ten days"; + Ten days +---------- + 10 days (1 row) SELECT INTERVAL '1.5 months' AS "One month 15 days"; diff --git a/src/test/regress/sql/interval.sql b/src/test/regress/sql/interval.sql index 6d532398bd..58bc06178c 100644 --- a/src/test/regress/sql/interval.sql +++ b/src/test/regress/sql/interval.sql @@ -11,7 +11,7 @@ SELECT INTERVAL '+02:00' AS "Two hours"; 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.5 weeks' AS "Ten days"; SELECT INTERVAL '1.5 months' AS "One month 15 days"; SELECT INTERVAL '10 years -11 month -12 days +13:14' AS "9 years..."; -- 2.20.1
--17pEHd4RhPHOinZp-- ^ permalink raw reply [nested|flat] 9+ messages in thread

* Postgres 11.5 not logging all sqls
@ 2023-09-25 11:24  shashidhar Reddy <shashidharreddy001@gmail.com>
  0 siblings, 2 replies; 9+ messages in thread

From: shashidhar Reddy @ 2023-09-25 11:24 UTC (permalink / raw)
  To: pgsql-general

Hello

We are using postgres 11.5 on Ubuntu we have enabled logging and set
log_statements to all but when I checked the statements in the logs I can
see only first few lines of the query and also when I check in pgadmin for
current queries I could see only few lines. Some one please help me to get
full queries in the logs and in pgadmin4.

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Postgres 11.5 not logging all sqls
@ 2023-09-25 11:35  Laurenz Albe <laurenz.albe@cybertec.at>
  parent: shashidhar Reddy <shashidharreddy001@gmail.com>
  1 sibling, 1 reply; 9+ messages in thread

From: Laurenz Albe @ 2023-09-25 11:35 UTC (permalink / raw)
  To: shashidhar Reddy <shashidharreddy001@gmail.com>; pgsql-general

On Mon, 2023-09-25 at 16:54 +0530, shashidhar Reddy wrote:
> We are using postgres 11.5 on Ubuntu we have enabled logging and set
> log_statements to all but when I checked the statements in the logs I
> can see only first few lines of the query

I don't know about pgAdmin, but the log will certainly have the complete
statement.

Yours,
Laurenz Albe





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Postgres 11.5 not logging all sqls
@ 2023-09-25 11:40  shashidhar Reddy <shashidharreddy001@gmail.com>
  parent: Laurenz Albe <laurenz.albe@cybertec.at>
  0 siblings, 0 replies; 9+ messages in thread

From: shashidhar Reddy @ 2023-09-25 11:40 UTC (permalink / raw)
  To: Laurenz Albe <laurenz.albe@cybertec.at>; +Cc: pgsql-general

Hi Laurenz,

Iog is also showing few lines that is incomplete statement.

On Mon, 25 Sept, 2023, 5:05 pm Laurenz Albe, <laurenz.albe@cybertec.at>
wrote:

> On Mon, 2023-09-25 at 16:54 +0530, shashidhar Reddy wrote:
> > We are using postgres 11.5 on Ubuntu we have enabled logging and set
> > log_statements to all but when I checked the statements in the logs I
> > can see only first few lines of the query
>
> I don't know about pgAdmin, but the log will certainly have the complete
> statement.
>
> Yours,
> Laurenz Albe
>

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Postgres 11.5 not logging all sqls
@ 2023-09-25 12:03  Erik Wienhold <ewie@ewie.name>
  parent: shashidhar Reddy <shashidharreddy001@gmail.com>
  1 sibling, 1 reply; 9+ messages in thread

From: Erik Wienhold @ 2023-09-25 12:03 UTC (permalink / raw)
  To: shashidhar Reddy <shashidharreddy001@gmail.com>; +Cc: pgsql-general

On 2023-09-25 16:54 +0530, shashidhar Reddy wrote:
> We are using postgres 11.5 on Ubuntu we have enabled logging and set
> log_statements to all but when I checked the statements in the logs I can
> see only first few lines of the query and also when I check in pgadmin for
> current queries I could see only few lines. Some one please help me to get
> full queries in the logs and in pgadmin4.

* Could be that the logging collector truncates messages.  Are all
  messages truncated to the same length?

* pgAdmin reads pg_stat_activity.query which is subject to config
  track_activity_query_size[1].  That should, however, not affect
  logging.

* Maybe a bug 11.5 which is already 4 years old.

[1] https://www.postgresql.org/docs/11/runtime-config-statistics.html#GUC-TRACK-ACTIVITY-QUERY-SIZE

-- 
Erik





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Postgres 11.5 not logging all sqls
@ 2023-09-25 18:55  shashidhar Reddy <shashidharreddy001@gmail.com>
  parent: Erik Wienhold <ewie@ewie.name>
  0 siblings, 1 reply; 9+ messages in thread

From: shashidhar Reddy @ 2023-09-25 18:55 UTC (permalink / raw)
  To: Erik Wienhold <ewie@ewie.name>; +Cc: pgsql-general

Thank you Erik,

Not all queries are truncated at same size,different queries different
sizes but all 11.5 servers are behaving in same manner.


On Mon, 25 Sept, 2023, 5:33 pm Erik Wienhold, <ewie@ewie.name> wrote:

> On 2023-09-25 16:54 +0530, shashidhar Reddy wrote:
> > We are using postgres 11.5 on Ubuntu we have enabled logging and set
> > log_statements to all but when I checked the statements in the logs I can
> > see only first few lines of the query and also when I check in pgadmin
> for
> > current queries I could see only few lines. Some one please help me to
> get
> > full queries in the logs and in pgadmin4.
>
> * Could be that the logging collector truncates messages.  Are all
>   messages truncated to the same length?
>
> * pgAdmin reads pg_stat_activity.query which is subject to config
>   track_activity_query_size[1].  That should, however, not affect
>   logging.
>
> * Maybe a bug 11.5 which is already 4 years old.
>
> [1]
> https://www.postgresql.org/docs/11/runtime-config-statistics.html#GUC-TRACK-ACTIVITY-QUERY-SIZE
>
> --
> Erik
>

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Postgres 11.5 not logging all sqls
@ 2023-09-25 19:23  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: shashidhar Reddy <shashidharreddy001@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Adrian Klaver @ 2023-09-25 19:23 UTC (permalink / raw)
  To: shashidhar Reddy <shashidharreddy001@gmail.com>; Erik Wienhold <ewie@ewie.name>; +Cc: pgsql-general

On 9/25/23 11:55, shashidhar Reddy wrote:
> Thank you Erik,
> 
> Not all queries are truncated at same size,different queries different 
> sizes but all 11.5 servers are behaving in same manner.

FYI, the last minor release for version is 11.21. You are missing 16 
bug/security fixes. I would update to 11.21 and then see if the issue 
persists.

> 
> 
> On Mon, 25 Sept, 2023, 5:33 pm Erik Wienhold, <ewie@ewie.name 
> <mailto:ewie@ewie.name>> wrote:
> 
>     On 2023-09-25 16:54 +0530, shashidhar Reddy wrote:
>      > We are using postgres 11.5 on Ubuntu we have enabled logging and set
>      > log_statements to all but when I checked the statements in the
>     logs I can
>      > see only first few lines of the query and also when I check in
>     pgadmin for
>      > current queries I could see only few lines. Some one please help
>     me to get
>      > full queries in the logs and in pgadmin4.
> 
>     * Could be that the logging collector truncates messages.  Are all
>        messages truncated to the same length?
> 
>     * pgAdmin reads pg_stat_activity.query which is subject to config
>        track_activity_query_size[1].  That should, however, not affect
>        logging.
> 
>     * Maybe a bug 11.5 which is already 4 years old.
> 
>     [1]
>     https://www.postgresql.org/docs/11/runtime-config-statistics.html#GUC-TRACK-ACTIVITY-QUERY-SIZE <https://www.postgresql.org/docs/11/runtime-config-statistics.html#GUC-TRACK-ACTIVITY-QUERY-SIZE;
> 
>     -- 
>     Erik
> 

-- 
Adrian Klaver
adrian.klaver@aklaver.com






^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Postgres 11.5 not logging all sqls
@ 2023-09-26 02:30  shashidhar Reddy <shashidharreddy001@gmail.com>
  parent: Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 1 reply; 9+ messages in thread

From: shashidhar Reddy @ 2023-09-26 02:30 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Erik Wienhold <ewie@ewie.name>; pgsql-general

Thank you Adrian! I will apply the patch and see.

On Tue, 26 Sept, 2023, 12:53 am Adrian Klaver, <adrian.klaver@aklaver.com>
wrote:

> On 9/25/23 11:55, shashidhar Reddy wrote:
> > Thank you Erik,
> >
> > Not all queries are truncated at same size,different queries different
> > sizes but all 11.5 servers are behaving in same manner.
>
> FYI, the last minor release for version is 11.21. You are missing 16
> bug/security fixes. I would update to 11.21 and then see if the issue
> persists.
>
> >
> >
> > On Mon, 25 Sept, 2023, 5:33 pm Erik Wienhold, <ewie@ewie.name
> > <mailto:ewie@ewie.name>> wrote:
> >
> >     On 2023-09-25 16:54 +0530, shashidhar Reddy wrote:
> >      > We are using postgres 11.5 on Ubuntu we have enabled logging and
> set
> >      > log_statements to all but when I checked the statements in the
> >     logs I can
> >      > see only first few lines of the query and also when I check in
> >     pgadmin for
> >      > current queries I could see only few lines. Some one please help
> >     me to get
> >      > full queries in the logs and in pgadmin4.
> >
> >     * Could be that the logging collector truncates messages.  Are all
> >        messages truncated to the same length?
> >
> >     * pgAdmin reads pg_stat_activity.query which is subject to config
> >        track_activity_query_size[1].  That should, however, not affect
> >        logging.
> >
> >     * Maybe a bug 11.5 which is already 4 years old.
> >
> >     [1]
> >
> https://www.postgresql.org/docs/11/runtime-config-statistics.html#GUC-TRACK-ACTIVITY-QUERY-SIZE
> <
> https://www.postgresql.org/docs/11/runtime-config-statistics.html#GUC-TRACK-ACTIVITY-QUERY-SIZE
> >
> >
> >     --
> >     Erik
> >
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com
>
>

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Postgres 11.5 not logging all sqls
@ 2023-09-26 04:15  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: shashidhar Reddy <shashidharreddy001@gmail.com>
  0 siblings, 0 replies; 9+ messages in thread

From: Adrian Klaver @ 2023-09-26 04:15 UTC (permalink / raw)
  To: shashidhar Reddy <shashidharreddy001@gmail.com>; +Cc: Erik Wienhold <ewie@ewie.name>; pgsql-general

On 9/25/23 19:30, shashidhar Reddy wrote:
> Thank you Adrian! I will apply the patch and see.

Just to be clear 11.21 represents the changes from 16 different minor 
releases.

-- 
Adrian Klaver
adrian.klaver@aklaver.com






^ permalink  raw  reply  [nested|flat] 9+ messages in thread


end of thread, other threads:[~2023-09-26 04:15 UTC | newest]

Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08 17:07 [PATCH] interval squash commit Bruce Momjian <bruce@momjian.us>
2023-09-25 11:24 Postgres 11.5 not logging all sqls shashidhar Reddy <shashidharreddy001@gmail.com>
2023-09-25 11:35 ` Re: Postgres 11.5 not logging all sqls Laurenz Albe <laurenz.albe@cybertec.at>
2023-09-25 11:40   ` Re: Postgres 11.5 not logging all sqls shashidhar Reddy <shashidharreddy001@gmail.com>
2023-09-25 12:03 ` Re: Postgres 11.5 not logging all sqls Erik Wienhold <ewie@ewie.name>
2023-09-25 18:55   ` Re: Postgres 11.5 not logging all sqls shashidhar Reddy <shashidharreddy001@gmail.com>
2023-09-25 19:23     ` Re: Postgres 11.5 not logging all sqls Adrian Klaver <adrian.klaver@aklaver.com>
2023-09-26 02:30       ` Re: Postgres 11.5 not logging all sqls shashidhar Reddy <shashidharreddy001@gmail.com>
2023-09-26 04:15         ` Re: Postgres 11.5 not logging all sqls Adrian Klaver <adrian.klaver@aklaver.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox