]>
git.ipfire.org Git - thirdparty/psycopg.git/log
Daniele Varrazzo [Mon, 7 Jun 2021 20:29:42 +0000 (21:29 +0100)]
Add timestamptz c binary loader
Daniele Varrazzo [Sun, 6 Jun 2021 23:38:56 +0000 (00:38 +0100)]
Add timestamptz c text loader
Daniele Varrazzo [Sun, 6 Jun 2021 23:25:20 +0000 (00:25 +0100)]
Drop code duplication in date/time parsing
Daniele Varrazzo [Sun, 6 Jun 2021 21:31:33 +0000 (22:31 +0100)]
Add c timestamp binary loader
Daniele Varrazzo [Sun, 6 Jun 2021 21:30:51 +0000 (22:30 +0100)]
Parse datetype without using endswith in c
Daniele Varrazzo [Wed, 2 Jun 2021 13:13:40 +0000 (14:13 +0100)]
Add c text timestamp loader
Daniele Varrazzo [Wed, 2 Jun 2021 10:42:12 +0000 (11:42 +0100)]
Add c timetz binary loader
Daniele Varrazzo [Wed, 2 Jun 2021 03:57:15 +0000 (04:57 +0100)]
Add helper function to return timezone from second
Use a cache to return the same object for the same offset.
Daniele Varrazzo [Wed, 2 Jun 2021 03:28:07 +0000 (04:28 +0100)]
Add c text timetz loader
Daniele Varrazzo [Wed, 2 Jun 2021 02:44:48 +0000 (03:44 +0100)]
Add c binary time loader
Daniele Varrazzo [Wed, 2 Jun 2021 02:27:44 +0000 (03:27 +0100)]
Add c text time loader
Daniele Varrazzo [Wed, 2 Jun 2021 01:55:59 +0000 (02:55 +0100)]
Add c timedelta dumpers
Daniele Varrazzo [Wed, 2 Jun 2021 01:29:33 +0000 (02:29 +0100)]
Add c datetime binary dumpers
Daniele Varrazzo [Wed, 2 Jun 2021 00:49:23 +0000 (01:49 +0100)]
Add c datetime text dumpers
Daniele Varrazzo [Wed, 2 Jun 2021 00:43:22 +0000 (01:43 +0100)]
Rationalise date dumpers inheritance tree
Daniele Varrazzo [Sun, 16 May 2021 22:46:50 +0000 (00:46 +0200)]
Add C time dumpers
Daniele Varrazzo [Sun, 16 May 2021 01:39:55 +0000 (03:39 +0200)]
Say "can't parse x", not "can't manage x"
These are parsing error. Stuff we can't manage (e.g. year < 10K) is
complained of elsewhere
Daniele Varrazzo [Sun, 16 May 2021 01:38:00 +0000 (03:38 +0200)]
Uniform date/time loaders naming
Just use the type name with one uppercase, no camels here.
Daniele Varrazzo [Sun, 16 May 2021 00:24:08 +0000 (02:24 +0200)]
Complete C date adapters, text and binary
Daniele Varrazzo [Sat, 15 May 2021 23:27:21 +0000 (01:27 +0200)]
Add C date loader
8x faster than the Python loader
Daniele Varrazzo [Tue, 1 Jun 2021 23:03:44 +0000 (00:03 +0100)]
Raise multi-line error messages with context
The context is not available in the diag error. Debugging without it is
pretty hard.
Make sure the error doesn't end with a newline, which is a complaint of
psycopg2.
Daniele Varrazzo [Sun, 16 May 2021 07:33:44 +0000 (09:33 +0200)]
Drop floating point dumping of datetime objects
The random test found rounding errors around year 2034.
Daniele Varrazzo [Sun, 16 May 2021 00:52:50 +0000 (02:52 +0200)]
Merge branch 'tzinfo'
Daniele Varrazzo [Sun, 16 May 2021 00:26:04 +0000 (02:26 +0200)]
Streamline fixed size dumpers by dumping directly in the output buffer
Daniele Varrazzo [Sun, 16 May 2021 00:25:40 +0000 (02:25 +0200)]
Drop unused import
Daniele Varrazzo [Sun, 16 May 2021 00:24:50 +0000 (02:24 +0200)]
Don't chain exceptions raising in decimal binary loading
Daniele Varrazzo [Sat, 15 May 2021 23:05:04 +0000 (01:05 +0200)]
Don't chain exceptions throwing DataError in dates
Daniele Varrazzo [Sat, 15 May 2021 16:23:46 +0000 (18:23 +0200)]
Load dates using slices instead of regexps
Some 40% faster. Thanks to @hakib for the tip :)
Daniele Varrazzo [Sat, 15 May 2021 15:38:45 +0000 (17:38 +0200)]
Faster date/timestamp parsing
Daniele Varrazzo [Sat, 15 May 2021 14:17:23 +0000 (16:17 +0200)]
Uniform interval parsing to the other data types
Daniele Varrazzo [Sat, 15 May 2021 13:41:26 +0000 (15:41 +0200)]
Base timestamptz loader on regexp
About 4.5x faster than strptime.
Daniele Varrazzo [Sat, 15 May 2021 12:56:15 +0000 (14:56 +0200)]
Base TimeTz loader on regexp
Daniele Varrazzo [Sat, 15 May 2021 12:55:56 +0000 (14:55 +0200)]
Further tweaks to date/time loaders
Daniele Varrazzo [Sat, 15 May 2021 11:23:26 +0000 (13:23 +0200)]
Base time loader on regexp
Some 5x faster
Daniele Varrazzo [Sat, 15 May 2021 10:47:58 +0000 (12:47 +0200)]
Base date and timestamp loaders on regexp instead of strptime
Not only is 4x faster, but it's more straightforward to port to C
and keep similar algorithms (even if we decide to drop regexp in C)
Daniele Varrazzo [Sat, 15 May 2021 10:45:48 +0000 (12:45 +0200)]
Separate date/time tests in classes
Daniele Varrazzo [Fri, 14 May 2021 18:04:23 +0000 (20:04 +0200)]
Fix datetime timezone adjustment on Python 3.6
Daniele Varrazzo [Fri, 14 May 2021 17:42:29 +0000 (19:42 +0200)]
Add test for timestamptz timezone load behaviour
Daniele Varrazzo [Fri, 14 May 2021 17:26:37 +0000 (19:26 +0200)]
Add docs and tests for ConnectionInfo.timezone
Daniele Varrazzo [Fri, 14 May 2021 16:37:24 +0000 (18:37 +0200)]
Move timezone attribute to the Connection.info interface
Type changed to the abstract `datetime.tzinfo` so that we have the
option to return something else such as a `datetime.timezone` with fixed
offset.
Added function to retrieve the object internally from the PGconn.
Daniele Varrazzo [Fri, 14 May 2021 16:19:32 +0000 (18:19 +0200)]
Warn only once about unknown zoneinfo
Daniele Varrazzo [Fri, 14 May 2021 15:50:06 +0000 (17:50 +0200)]
Return timestamptz in the connection timezone
First cut, more tests to add. All current tests pass, except the
explicit checks for UTC tzinfo returned.
See https://github.com/psycopg/psycopg3/discussions/56
Daniele Varrazzo [Fri, 14 May 2021 15:07:03 +0000 (17:07 +0200)]
Merge branch 'master' into binary-datetime
Daniele Varrazzo [Fri, 14 May 2021 14:51:17 +0000 (16:51 +0200)]
Make the dependency on typing_extension optional
Daniele Varrazzo [Thu, 13 May 2021 21:04:19 +0000 (23:04 +0200)]
Return timestamptz as utc datetime loading in text format
This makes text and binary loaders return the same value. It also fixes
the problem of the missing seconds in the timezone offset on Python 3.6.
The opposite choice, returning datetime in the connection timezone on
binary loading, doesn't seem really feasible: pytz cannot parse all the
Postgres timezone values (for instance, "+02:00" can't be parsed): take
a look at
https://www.postgresql.org/docs/13/datetime-posix-timezone-specs.html to
understand how much of a bad idea it would be.
Daniele Varrazzo [Thu, 13 May 2021 16:41:04 +0000 (18:41 +0200)]
Fix timestamptz binary tests with seconds in the timezone on Python 3.6
Daniele Varrazzo [Thu, 13 May 2021 09:49:33 +0000 (11:49 +0200)]
Consider loss of precision in negative binary timestamps too
Daniele Varrazzo [Thu, 13 May 2021 02:10:31 +0000 (04:10 +0200)]
Add timedelta/interval binary adapter
Daniele Varrazzo [Thu, 13 May 2021 01:19:11 +0000 (03:19 +0200)]
Add timestamptz adapter
Daniele Varrazzo [Wed, 12 May 2021 23:17:50 +0000 (01:17 +0200)]
Force text query in tests playing with datestyle
Just in case in the future we switch to binary return values and we stop
testing anything.
Daniele Varrazzo [Wed, 12 May 2021 23:13:20 +0000 (01:13 +0200)]
Add datetime binary adapter
Only for naive datetimes, timezone not handled yet.
Daniele Varrazzo [Wed, 12 May 2021 20:44:26 +0000 (22:44 +0200)]
Add timetz binary adapters
Daniele Varrazzo [Wed, 12 May 2021 19:38:58 +0000 (21:38 +0200)]
Add time binary adapters
No timezone yet, some tests fail.
Daniele Varrazzo [Wed, 12 May 2021 18:55:40 +0000 (20:55 +0200)]
Add date binary adapters
Daniele Varrazzo [Wed, 12 May 2021 16:44:22 +0000 (18:44 +0200)]
Drop unused import
Daniele Varrazzo [Mon, 10 May 2021 08:39:19 +0000 (10:39 +0200)]
Merge branch 'binary-numeric'
Daniele Varrazzo [Mon, 10 May 2021 08:26:00 +0000 (10:26 +0200)]
Improve wording of docker testing notes
Daniele Varrazzo [Sun, 9 May 2021 23:46:30 +0000 (01:46 +0200)]
Add example about running tests in docker
Writing it down as I have to hack it together every time.
Daniele Varrazzo [Sun, 9 May 2021 23:22:12 +0000 (01:22 +0200)]
Fix dumping Decimal of the form 0E+n
Daniele Varrazzo [Wed, 5 May 2021 16:32:06 +0000 (18:32 +0200)]
Fix test for ConnectionInfo.hostaddr and libpq < 12
Daniele Varrazzo [Sun, 9 May 2021 23:04:37 +0000 (01:04 +0200)]
Add script to test the pool performance
Daniele Varrazzo [Sun, 9 May 2021 22:52:16 +0000 (00:52 +0200)]
Add benchmark test for binary numeric
Conclusion is that for the moment it is better to leave default Decimal
dump to text format. Better performance can be obtained accessing the
Python C Decimal structure and perform conversion from there.
Daniele Varrazzo [Sun, 9 May 2021 21:17:59 +0000 (23:17 +0200)]
Use faster C mod operator in Decimal dump
Daniele Varrazzo [Sun, 9 May 2021 18:37:51 +0000 (20:37 +0200)]
Add C implementation of Decimal dumper
Daniele Varrazzo [Sat, 8 May 2021 17:13:21 +0000 (19:13 +0200)]
Don't dump an excess of right 0's in Decimal to numeric
Daniele Varrazzo [Thu, 6 May 2021 19:22:39 +0000 (21:22 +0200)]
Add Cython implementation of NumericBinaryLoader
Daniele Varrazzo [Thu, 6 May 2021 17:58:14 +0000 (19:58 +0200)]
Add C implementation of text decimal adapters
Daniele Varrazzo [Thu, 6 May 2021 17:08:20 +0000 (19:08 +0200)]
Add dumper for Python int to numeric
Daniele Varrazzo [Thu, 6 May 2021 02:26:06 +0000 (04:26 +0200)]
Handle Decimal sNaN value
Daniele Varrazzo [Thu, 6 May 2021 01:42:37 +0000 (03:42 +0200)]
Dump numeric as binary without manipulating the digits tuple
Will make for a much faster algorithm in C
Daniele Varrazzo [Wed, 5 May 2021 18:20:52 +0000 (20:20 +0200)]
Decimal binary dump algorithm streamlined
Daniele Varrazzo [Wed, 5 May 2021 17:47:14 +0000 (19:47 +0200)]
Add Decimal values to random tests
Daniele Varrazzo [Wed, 5 May 2021 17:15:02 +0000 (19:15 +0200)]
Add prototype for a decimal binary dumper
The algorithm is pretty unwieldy, maybe it can be refactored. But tests
show that it should be correct.
Denis Laxalde [Wed, 5 May 2021 15:02:58 +0000 (17:02 +0200)]
Upgrade testing libraries (#50)
Use latest versions of testing libraries
pytest is broken on Python 3.10, until version 6.2.4.
Daniele Varrazzo [Tue, 4 May 2021 21:08:45 +0000 (23:08 +0200)]
Add numeric binary loader
Daniele Varrazzo [Tue, 4 May 2021 16:08:30 +0000 (18:08 +0200)]
Add pytest marker to skip tests on certain server versions
Daniele Varrazzo [Sun, 2 May 2021 09:48:53 +0000 (11:48 +0200)]
Fix typo in doc title
Denis Laxalde [Tue, 27 Apr 2021 07:49:30 +0000 (09:49 +0200)]
Check documentation build in CI
Daniele Varrazzo [Sun, 2 May 2021 00:23:16 +0000 (02:23 +0200)]
Add regression test for the infinity date example
Denis Laxalde [Thu, 29 Apr 2021 09:14:32 +0000 (11:14 +0200)]
Add an adaptation example for infinity date
Take from https://www.psycopg.org/articles/2020/11/24/psycopg3-adaptation/
Daniele Varrazzo [Sun, 2 May 2021 00:10:41 +0000 (02:10 +0200)]
Bypass call to _get_optimised if using the Python implementation
Daniele Varrazzo [Sat, 1 May 2021 23:59:55 +0000 (01:59 +0200)]
Dumpers ownership dict micro-optimisation
Copying is ~10x faster than creating a new dict.
Daniele Varrazzo [Sat, 1 May 2021 23:47:23 +0000 (01:47 +0200)]
Fixed adapters copy-on-write
If a wider context is customised don't affect smaller contexts already
created.
Daniele Varrazzo [Sat, 1 May 2021 23:26:35 +0000 (01:26 +0200)]
Use an explicit dumper map for the auto format.
The dumper chosen in auto format is the last one registered, if both the
text and binary ones are available. For all the builtin types the
preferred format is binary, except for strings and for json.
Dumping strings as text by default was handled by a special case; now
they are just handled by registering the text dumper after the binary
one. Json is now text by default, because it's marginally more
efficient.
Denis Laxalde [Thu, 29 Apr 2021 09:25:17 +0000 (11:25 +0200)]
Fix a typo in adaptation documentation
Daniele Varrazzo [Fri, 30 Apr 2021 15:55:41 +0000 (17:55 +0200)]
Merge branch 'type-row'
Daniele Varrazzo [Fri, 30 Apr 2021 14:42:09 +0000 (16:42 +0200)]
Further negotiation for good row types docs
Improvements can be made, however I would rather merge this branch to
master and improve the whole docs.
Denis Laxalde [Fri, 30 Apr 2021 13:26:21 +0000 (15:26 +0200)]
Proofread row factories doc
Daniele Varrazzo [Fri, 30 Apr 2021 12:44:29 +0000 (14:44 +0200)]
Improve row factory docs
Describe the protocol objects too. Expose them in the `psycopg3.rows`
module.
Daniele Varrazzo [Fri, 30 Apr 2021 10:43:29 +0000 (12:43 +0200)]
Add typing docs and example for psycopg3.rows
Daniele Varrazzo [Fri, 30 Apr 2021 00:36:33 +0000 (02:36 +0200)]
Drop RowConn from proto
Use a more local CursorRow definition.
Denis Laxalde [Wed, 28 Apr 2021 12:58:19 +0000 (14:58 +0200)]
Define an AnyCursor type alias
This will make it easier to define custom row factories without having
to use BaseCursor[Any, <rowtype>] as the connection type is not
meaningful in this context.
We expose this name instead of BaseCursor in top-level package
accordingly.
Daniele Varrazzo [Thu, 29 Apr 2021 17:48:44 +0000 (19:48 +0200)]
Bump up tests timeout on github action
Daniele Varrazzo [Thu, 29 Apr 2021 17:22:27 +0000 (19:22 +0200)]
Add typing test for cursor iteration
Daniele Varrazzo [Thu, 29 Apr 2021 17:06:35 +0000 (19:06 +0200)]
Fix typing of server-side cursors fetchmany/fetchall
Daniele Varrazzo [Thu, 29 Apr 2021 16:11:14 +0000 (18:11 +0200)]
Fix `Connection.connect()` return type
Now `connect()` returns a `Connection[Tuple]`, whereas
`connect(row_factory=something)` return the type of what row factory
produces. The implementation of this is somewhat brittle, but that's
mypy for you: @dlax (thank you!) noticed that defining `**kwargs:
Union[str, int]` helped to disambiguate the row_factory param. I guess
we will make a best-effort to maintain this "interface". Everything is
to be documented.
Strangely, mypy cannot figure out the type of
conn = await self.connection_class.connect(
self.conninfo, **self.kwargs
)
in the async pool, but it can for the sync one (without the `await`).
Added explicit type to disambiguate, on both the classes, for symmetry.
Added regression tests to verify that refactoring doesn't break type
inference.
Denis Laxalde [Tue, 27 Apr 2021 12:07:36 +0000 (14:07 +0200)]
Illustrate type annotations in row factories documentation
Daniele Varrazzo [Mon, 26 Apr 2021 17:43:38 +0000 (18:43 +0100)]
Check test_typing with mypy as part of the pytest run
Denis Laxalde [Tue, 20 Apr 2021 08:30:03 +0000 (10:30 +0200)]
Make Connection generic on Row
We use a type variable 'RowConn' for Connection that is distinct from
'Row' that is used on Cursor side in order to reflect the possibility to
have distinct row factories on connection and cursor sides.
In order to avoid "propagation" of the Row type variable of Connection
classes, we use Any everywhere that variable is not used (namely,
everywhere outside the connection module).
The typing_example.py almost works: connect(row_factory=...) returns a
typed Connection, but only connect() still returns a Connection[Any].
Denis Laxalde [Fri, 23 Apr 2021 13:41:41 +0000 (15:41 +0200)]
Define Connection's row_factory as a property
This is similar to Cursor class and will make things easier in following
changes, making Connection generic on row type.