pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Centralize json and jsonb handling of datetime types
5+ messages / 4 participants
[nested] [flat]
* pgsql: Centralize json and jsonb handling of datetime types
@ 2018-01-17 00:29 Andrew Dunstan <andrew@dunslane.net>
2018-01-17 05:34 ` Re: pgsql: Centralize json and jsonb handling of datetime types Amit Langote <amitlangote09@gmail.com>
2018-01-17 06:23 ` Re: pgsql: Centralize json and jsonb handling of datetime types Erik Rijkers <er@xs4all.nl>
0 siblings, 2 replies; 5+ messages in thread
From: Andrew Dunstan @ 2018-01-17 00:29 UTC (permalink / raw)
To: pgsql-committers
Centralize json and jsonb handling of datetime types
The creates a single function JsonEncodeDateTime which will format these
data types in an efficient and consistent manner. This will be all the
more important when we come to jsonpath so we don't have to implement yet
more code doing the same thing in two more places.
This also extends the code to handle time and timetz types which were
not previously handled specially. This requires exposing the time2tm and
timetz2tm functions.
Patch from Nikita Glukhov
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/cc4feded0a31d2b732d4ea68613115cb720e624e
Modified Files
--------------
src/backend/utils/adt/date.c | 6 +--
src/backend/utils/adt/json.c | 122 ++++++++++++++++++++++++++++++++----------
src/backend/utils/adt/jsonb.c | 70 ++++--------------------
src/include/utils/date.h | 4 +-
src/include/utils/jsonapi.h | 2 +
5 files changed, 109 insertions(+), 95 deletions(-)
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: pgsql: Centralize json and jsonb handling of datetime types
2018-01-17 00:29 pgsql: Centralize json and jsonb handling of datetime types Andrew Dunstan <andrew@dunslane.net>
@ 2018-01-17 05:34 ` Amit Langote <amitlangote09@gmail.com>
2018-01-17 08:34 ` Re: pgsql: Centralize json and jsonb handling of datetime types Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
1 sibling, 1 reply; 5+ messages in thread
From: Amit Langote @ 2018-01-17 05:34 UTC (permalink / raw)
To: Andrew Dunstan <andrew@dunslane.net>; +Cc: pgsql-committers
On Wed, Jan 17, 2018 at 9:29 AM, Andrew Dunstan <andrew@dunslane.net> wrote:
> Centralize json and jsonb handling of datetime types
[ ... ]
> src/include/utils/date.h | 4 +-
I noticed that these changes cause the following warning to be emitted
when compiling with gcc (GCC) 6.2.0:
In file included from gram.y:63:0:
../../../src/include/utils/date.h:76:41: warning: ‘struct pg_tm’
declared inside parameter list will not be visible outside of this
definition or declaration
extern int time2tm(TimeADT time, struct pg_tm *tm, fsec_t *fsec);
^~~~~
../../../src/include/utils/date.h:77:46: warning: ‘struct pg_tm’
declared inside parameter list will not be visible outside of this
definition or declaration
extern int timetz2tm(TimeTzADT *time, struct pg_tm *tm, fsec_t *fsec, int *tzp);
Attached is a fix.
Thanks,
Amit
Attachments:
cc4feded0a3-warning-fix.patch (application/octet-stream, 346B) download
diff --git a/src/include/datatype/timestamp.h b/src/include/datatype/timestamp.h
index f5b6026ef5..5714b842dc 100644
--- a/src/include/datatype/timestamp.h
+++ b/src/include/datatype/timestamp.h
@@ -15,6 +15,8 @@
#ifndef DATATYPE_TIMESTAMP_H
#define DATATYPE_TIMESTAMP_H
+#include "pgtime.h"
+
/*
* Timestamp represents absolute time.
*
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: pgsql: Centralize json and jsonb handling of datetime types
2018-01-17 00:29 pgsql: Centralize json and jsonb handling of datetime types Andrew Dunstan <andrew@dunslane.net>
2018-01-17 05:34 ` Re: pgsql: Centralize json and jsonb handling of datetime types Amit Langote <amitlangote09@gmail.com>
@ 2018-01-17 08:34 ` Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
2018-01-17 09:10 ` Re: pgsql: Centralize json and jsonb handling of datetime types Amit Langote <amitlangote09@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Dunstan @ 2018-01-17 08:34 UTC (permalink / raw)
To: Amit Langote <amitlangote09@gmail.com>; Andrew Dunstan <andrew@dunslane.net>; +Cc: pgsql-committers
On 01/17/2018 12:34 AM, Amit Langote wrote:
> On Wed, Jan 17, 2018 at 9:29 AM, Andrew Dunstan <andrew@dunslane.net> wrote:
>> Centralize json and jsonb handling of datetime types
> [ ... ]
>
>> src/include/utils/date.h | 4 +-
> I noticed that these changes cause the following warning to be emitted
> when compiling with gcc (GCC) 6.2.0:
>
> In file included from gram.y:63:0:
> ../../../src/include/utils/date.h:76:41: warning: ‘struct pg_tm’
> declared inside parameter list will not be visible outside of this
> definition or declaration
> extern int time2tm(TimeADT time, struct pg_tm *tm, fsec_t *fsec);
> ^~~~~
> ../../../src/include/utils/date.h:77:46: warning: ‘struct pg_tm’
> declared inside parameter list will not be visible outside of this
> definition or declaration
> extern int timetz2tm(TimeTzADT *time, struct pg_tm *tm, fsec_t *fsec, int *tzp);
>
> Attached is a fix.
>
Thanks, this is the right fix but in the wrong place. I have added the
include in the file where pg_tm is actually used.
cheers
andrew
--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: pgsql: Centralize json and jsonb handling of datetime types
2018-01-17 00:29 pgsql: Centralize json and jsonb handling of datetime types Andrew Dunstan <andrew@dunslane.net>
2018-01-17 05:34 ` Re: pgsql: Centralize json and jsonb handling of datetime types Amit Langote <amitlangote09@gmail.com>
2018-01-17 08:34 ` Re: pgsql: Centralize json and jsonb handling of datetime types Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
@ 2018-01-17 09:10 ` Amit Langote <amitlangote09@gmail.com>
0 siblings, 0 replies; 5+ messages in thread
From: Amit Langote @ 2018-01-17 09:10 UTC (permalink / raw)
To: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>; +Cc: Andrew Dunstan <andrew@dunslane.net>; pgsql-committers
On Wed, Jan 17, 2018 at 5:34 PM, Andrew Dunstan
<andrew.dunstan@2ndquadrant.com> wrote:
>
>
> On 01/17/2018 12:34 AM, Amit Langote wrote:
>> On Wed, Jan 17, 2018 at 9:29 AM, Andrew Dunstan <andrew@dunslane.net> wrote:
>>> Centralize json and jsonb handling of datetime types
>> [ ... ]
>>
>>> src/include/utils/date.h | 4 +-
>> I noticed that these changes cause the following warning to be emitted
>> when compiling with gcc (GCC) 6.2.0:
>>
>> Attached is a fix.
>>
>
> Thanks, this is the right fix but in the wrong place. I have added the
> include in the file where pg_tm is actually used.
Thank you.
Regards,
Amit
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: pgsql: Centralize json and jsonb handling of datetime types
2018-01-17 00:29 pgsql: Centralize json and jsonb handling of datetime types Andrew Dunstan <andrew@dunslane.net>
@ 2018-01-17 06:23 ` Erik Rijkers <er@xs4all.nl>
1 sibling, 0 replies; 5+ messages in thread
From: Erik Rijkers @ 2018-01-17 06:23 UTC (permalink / raw)
To: Andrew Dunstan <andrew@dunslane.net>; +Cc: pgsql-committers; pgsql-hackers@postgresql.org
On 2018-01-17 01:29, Andrew Dunstan wrote:
> Centralize json and jsonb handling of datetime types
[...]
> https://git.postgresql.org/pg/commitdiff/cc4feded0a31d2b732d4ea68613115cb720e624e
>
> Modified Files
> --------------
> src/backend/utils/adt/date.c | 6 +--
> src/backend/utils/adt/json.c | 122
> ++++++++++++++++++++++++++++++++----------
> src/backend/utils/adt/jsonb.c | 70 ++++--------------------
> src/include/utils/date.h | 4 +-
> src/include/utils/jsonapi.h | 2 +
> 5 files changed, 109 insertions(+), 95 deletions(-)
Latest gcc 7.2.0 compile shows these warnings (I suppose these come from
this commit):
Compiling core:
In file included from gram.y:63:0:
../../../src/include/utils/date.h:76:41: warning: ‘struct pg_tm’
declared inside parameter list will not be visible outside of this
definition or declaration
extern int time2tm(TimeADT time, struct pg_tm *tm, fsec_t *fsec);
^~~~~
../../../src/include/utils/date.h:77:46: warning: ‘struct pg_tm’
declared inside parameter list will not be visible outside of this
definition or declaration
extern int timetz2tm(TimeTzADT *time, struct pg_tm *tm, fsec_t *fsec,
int *tzp);
^~~~~
In file included from formatting.c:92:0:
../../../../src/include/utils/date.h:76:41: warning: ‘struct pg_tm’
declared inside parameter list will not be visible outside of this
definition or declaration
extern int time2tm(TimeADT time, struct pg_tm *tm, fsec_t *fsec);
^~~~~
../../../../src/include/utils/date.h:77:46: warning: ‘struct pg_tm’
declared inside parameter list will not be visible outside of this
definition or declaration
extern int timetz2tm(TimeTzADT *time, struct pg_tm *tm, fsec_t *fsec,
int *tzp);
... while contrib adds:
In file included from btree_gin.c:12:0:
../../src/include/utils/date.h:76:41: warning: ‘struct pg_tm’ declared
inside parameter list will not be visible outside of this definition or
declaration
extern int time2tm(TimeADT time, struct pg_tm *tm, fsec_t *fsec);
^~~~~
../../src/include/utils/date.h:77:46: warning: ‘struct pg_tm’ declared
inside parameter list will not be visible outside of this definition or
declaration
extern int timetz2tm(TimeTzADT *time, struct pg_tm *tm, fsec_t *fsec,
int *tzp);
^~~~~
In file included from btree_utils_num.c:9:0:
../../src/include/utils/date.h:76:41: warning: ‘struct pg_tm’ declared
inside parameter list will not be visible outside of this definition or
declaration
extern int time2tm(TimeADT time, struct pg_tm *tm, fsec_t *fsec);
^~~~~
../../src/include/utils/date.h:77:46: warning: ‘struct pg_tm’ declared
inside parameter list will not be visible outside of this definition or
declaration
extern int timetz2tm(TimeTzADT *time, struct pg_tm *tm, fsec_t *fsec,
int *tzp);
^~~~~
In file included from btree_time.c:9:0:
../../src/include/utils/date.h:76:41: warning: ‘struct pg_tm’ declared
inside parameter list will not be visible outside of this definition or
declaration
extern int time2tm(TimeADT time, struct pg_tm *tm, fsec_t *fsec);
^~~~~
../../src/include/utils/date.h:77:46: warning: ‘struct pg_tm’ declared
inside parameter list will not be visible outside of this definition or
declaration
extern int timetz2tm(TimeTzADT *time, struct pg_tm *tm, fsec_t *fsec,
int *tzp);
^~~~~
In file included from btree_date.c:9:0:
../../src/include/utils/date.h:76:41: warning: ‘struct pg_tm’ declared
inside parameter list will not be visible outside of this definition or
declaration
extern int time2tm(TimeADT time, struct pg_tm *tm, fsec_t *fsec);
^~~~~
../../src/include/utils/date.h:77:46: warning: ‘struct pg_tm’ declared
inside parameter list will not be visible outside of this definition or
declaration
extern int timetz2tm(TimeTzADT *time, struct pg_tm *tm, fsec_t *fsec,
int *tzp);
No errors, and 'make check' and 'make check-world' are both OK.
thanks,
Erik Rijkers
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2018-01-17 09:10 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-01-17 00:29 pgsql: Centralize json and jsonb handling of datetime types Andrew Dunstan <andrew@dunslane.net>
2018-01-17 05:34 ` Amit Langote <amitlangote09@gmail.com>
2018-01-17 08:34 ` Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
2018-01-17 09:10 ` Amit Langote <amitlangote09@gmail.com>
2018-01-17 06:23 ` Erik Rijkers <er@xs4all.nl>
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