optiver / timestamp9 Goto Github PK
View Code? Open in Web Editor NEWNanosecond precision timestamp type for Postgres
License: MIT License
Nanosecond precision timestamp type for Postgres
License: MIT License
Its resolved
Hi, @fvannee
Currently, timestamp9 only recognize timestamp with time zone information 'y-m-d h:m:s.ns +tz'
, while Postgres supports both timestamp
and timestamptz
data types. What about making the current timestamp9 data type to timestamp9tz
and introduce a new data type timestamp9
(timestamp9 without time zone information)? What do you think of it? I think I can help implement it.
Hi Floris, this codebase should really get extended with the ability to do something similar to:
SELECT CURRENT_TIMESTAMP;
..., (i.e., get the time now with nanosecond precision, which I realize is OS specific). If you would like, I can implement this for Windows/Linux and submit a pull-request, but I may have questions for you along the way.
We should validate timestamp values when doing conversions. E.g.,
=# select '2362-04-01'::timestamp::timestamp9;
timestamp9
-------------------------------------
1777-09-10 00:31:09.290448384 +0805
(1 row)
I will propose PR to fix this issue.
select '2262-04-11 23:47:16.854775807 +0000'::timestamp9;
returns: 2262-04-11 23:47:16.854775807 +0000
select '2262-04-11 23:47:16.854775808 +0000'::timestamp9;
returns: 1677-09-21 00:12:43.145224192 +0000
Hi,
PostgreSQL 16 Beta 1 is out. 1.3.0 fails to compile against it. What are the plans for v16 support?
Regards, Devrim
[ 66%] Built target sqlfile
/build/pgrpms/rpm/redhat/main/non-common/timestamp9/main/timestamp9-timestamp9-1.3.0/src/timestamp9.c: In function 'parse_sane_timezone':
/build/pgrpms/rpm/redhat/main/non-common/timestamp9/main/timestamp9-timestamp9-1.3.0/src/timestamp9.c:237:63: warning: passing argument 4 of 'DecodeTimezoneAbbrev' from incompatible pointer type [-Wincompatible-pointer-types]
237 | type = DecodeTimezoneAbbrev(0, lowzone, &val, &tzp);
| ^~~~
| |
| pg_tz **
In file included from /build/pgrpms/rpm/redhat/main/non-common/timestamp9/main/timestamp9-timestamp9-1.3.0/src/timestamp9.c:15:
/usr/pgsql-16/include/server/utils/datetime.h:343:83: note: expected 'int *' but argument is of type 'pg_tz **'
343 | int *ftype, int *offset, pg_tz **tz,
| ~~~~~^~~~~~
/build/pgrpms/rpm/redhat/main/non-common/timestamp9/main/timestamp9-timestamp9-1.3.0/src/timestamp9.c:237:24: error: too few arguments to function 'DecodeTimezoneAbbrev'
237 | type = DecodeTimezoneAbbrev(0, lowzone, &val, &tzp);
| ^~~~~~~~~~~~~~~~~~~~
/usr/pgsql-16/include/server/utils/datetime.h:342:17: note: declared here
342 | extern int DecodeTimezoneAbbrev(int field, const char *lowtoken,
| ^~~~~~~~~~~~~~~~~~~~
/build/pgrpms/rpm/redhat/main/non-common/timestamp9/main/timestamp9-timestamp9-1.3.0/src/timestamp9.c: In function 'timestamp9_in':
/build/pgrpms/rpm/redhat/main/non-common/timestamp9/main/timestamp9-timestamp9-1.3.0/src/timestamp9.c:311:17: error: too few arguments to function 'DecodeDateTime'
311 | DecodeDateTime(field, ftype, nf, &dtype, p_tm, &fsec, &tz) != 0)
| ^~~~~~~~~~~~~~
/usr/pgsql-16/include/server/utils/datetime.h:312:17: note: declared here
312 | extern int DecodeDateTime(char **field, int *ftype, int nf,
| ^~~~~~~~~~~~~~
/build/pgrpms/rpm/redhat/main/non-common/timestamp9/main/timestamp9-timestamp9-1.3.0/src/timestamp9.c:315:27: warning: declaration of 'ns' shadows a previous local [-Wshadow=compatible-local]
315 | long long ns;
| ^~
/build/pgrpms/rpm/redhat/main/non-common/timestamp9/main/timestamp9-timestamp9-1.3.0/src/timestamp9.c:287:19: note: shadowed declaration is here
287 | long long ns;
| ^~
make[3]: *** [src/CMakeFiles/timestamp9.dir/build.make:76: src/CMakeFiles/timestamp9.dir/timestamp9.c.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:183: src/CMakeFiles/timestamp9.dir/all] Error 2
make[1]: *** [Makefile:156: all] Error 2
Great project, thanks! It would be great to get this added as a pistgres extension or part of postgres main. This is very useful for time duration in nanoseconds so as to maintain the precision of int64 nanoseconds. Any thoughts of doing this?
Subsecond timestamps without timezone are not accepted. select '2019-09-19 08:30:05.123456789'::timestamp9;
gives an error:
ERROR: invalid input format for timestamp9, required format y-m-d h:m:s.ns +tz "2019-09-19 08:30:05.123456789"
LINE 11: select '2019-09-19 08:30:05.123456789'::timestamp9;
^
SQL state: 22008
Character: 244
Both timestamp
and timestamptz
can parse the same string: select '2019-09-19 08:30:05.123456789'::timestamp;
=> 2019-09-19 08:30:05.123457
.
The request
select 'infinity'::timestamp9;
or
select '-infinity'::timestamp9;
throws an error: [22008] ERROR: invalid input format for timestamp9, required format y-m-d h:m:s.ns [+tz]
Do i need to manually provide targets, i encountered following error
CMake Error at src/CMakeLists.txt:79 (install):
install TARGETS given no LIBRARY DESTINATION for module target
"timestamp9".
CMake Error at CMakeLists.txt:197 (get_parents):
get_parents Macro invoked with incorrect arguments for macro named:
get_parents
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.