]> git.ipfire.org Git - thirdparty/psycopg.git/log
thirdparty/psycopg.git
4 years agoAvoid a cython call in bool loaders
Daniele Varrazzo [Thu, 19 Nov 2020 01:52:04 +0000 (01:52 +0000)] 
Avoid a cython call in bool loaders

It's probably inlined, but there is still the exception handler around.

4 years agoFixed overflow argument for float loader
Daniele Varrazzo [Thu, 19 Nov 2020 01:28:51 +0000 (01:28 +0000)] 
Fixed overflow argument for float loader

4 years agoAdded documentation for Rollback
Daniele Varrazzo [Thu, 19 Nov 2020 00:05:24 +0000 (00:05 +0000)] 
Added documentation for Rollback

4 years agoMerge branch 'nested-transactions'
Daniele Varrazzo [Wed, 18 Nov 2020 22:07:22 +0000 (22:07 +0000)] 
Merge branch 'nested-transactions'

4 years agoMore efficient float loading
Daniele Varrazzo [Wed, 18 Nov 2020 21:56:53 +0000 (21:56 +0000)] 
More efficient float loading

4 years agoUse "private" savepoint name to avoid conflicting with user ones
Daniele Varrazzo [Wed, 18 Nov 2020 15:21:34 +0000 (15:21 +0000)] 
Use "private" savepoint name to avoid conflicting with user ones

"s1" is too common.

Also omit ``savepoint`` in sql statements: it is a noise word

4 years agoAdded documentation for transaction management
Daniele Varrazzo [Wed, 18 Nov 2020 15:05:35 +0000 (15:05 +0000)] 
Added documentation for transaction management

4 years agoMap errors 08* to OperationalError
Daniele Varrazzo [Tue, 17 Nov 2020 15:14:52 +0000 (15:14 +0000)] 
Map errors 08* to OperationalError

See https://github.com/psycopg/psycopg2/pull/1148

4 years agoTransaction tests cleanup
Daniele Varrazzo [Mon, 16 Nov 2020 16:26:38 +0000 (16:26 +0000)] 
Transaction tests cleanup

4 years agoFixed transaction behaviour when there is a transaction already started
Daniele Varrazzo [Mon, 16 Nov 2020 16:26:38 +0000 (16:26 +0000)] 
Fixed transaction behaviour when there is a transaction already started

State management simplified too.

4 years agoCommands to enter/exit a transaction with named savepoint tweaked
Daniele Varrazzo [Mon, 16 Nov 2020 13:56:44 +0000 (13:56 +0000)] 
Commands to enter/exit a transaction with named savepoint tweaked

- Batch together begin + savepoint
- Do without releasing the savepoint immediately before commit/rollback

4 years agoCommands generation separated from execution in transactions
Daniele Varrazzo [Mon, 16 Nov 2020 03:52:29 +0000 (03:52 +0000)] 
Commands generation separated from execution in transactions

Commands and state change are independent from sync/async. Only the
execution and the interface is in the different sync/async subclasses
now.

4 years agoDefine at init rather than at enter if the transaction is top-level
Daniele Varrazzo [Mon, 16 Nov 2020 03:38:26 +0000 (03:38 +0000)] 
Define at init rather than at enter if the transaction is top-level

4 years agoRefactoring to minimize sync/async savepoint duplications
Daniele Varrazzo [Mon, 16 Nov 2020 03:31:29 +0000 (03:31 +0000)] 
Refactoring to minimize sync/async savepoint duplications

4 years agoAdded AsyncConnection.transaction()
Daniele Varrazzo [Sun, 15 Nov 2020 21:23:43 +0000 (21:23 +0000)] 
Added AsyncConnection.transaction()

4 years agoAnonymous savepoints represented by empty string
Daniele Varrazzo [Sun, 15 Nov 2020 20:40:34 +0000 (20:40 +0000)] 
Anonymous savepoints represented by empty string

It makes signatures and types easier. Empty string is not valid anyway,
and bonkers types are not checked.

4 years agoConnection.transaction is a context manager
Daniele Varrazzo [Sun, 15 Nov 2020 20:30:03 +0000 (20:30 +0000)] 
Connection.transaction is a context manager

It will help to avoid an async with (await conn.transaction()) on async
connections.

4 years agoDropped now redundant copy test
Daniele Varrazzo [Sun, 15 Nov 2020 13:17:31 +0000 (13:17 +0000)] 
Dropped now redundant copy test

4 years agoAdded asynccontextmanager for Python 3.6
Daniele Varrazzo [Sun, 15 Nov 2020 04:00:27 +0000 (04:00 +0000)] 
Added asynccontextmanager for Python 3.6

4 years agoBinary copy tests enabled: now there is an int binary dumper
Daniele Varrazzo [Sun, 15 Nov 2020 02:32:11 +0000 (02:32 +0000)] 
Binary copy tests enabled: now there is an int binary dumper

4 years agoCopy object interface simplified
Daniele Varrazzo [Sun, 15 Nov 2020 01:57:14 +0000 (01:57 +0000)] 
Copy object interface simplified

Dropped methods and code paths no more useful now that the user can only
interact with Copy as a context.

4 years agoCursor.copy() made into a context manager
Daniele Varrazzo [Sun, 15 Nov 2020 01:47:51 +0000 (01:47 +0000)] 
Cursor.copy() made into a context manager

What was before was a factory function, however that forced to have a
pattern like:

    async with (await cursor.copy()) as copy

Now instead what should be used is:

    async with cursor.copy() as copy

With this change the user pretty much is never exposed anymore to a Copy
object in a non-entered state. This is actually useful because it
reduces the surface of the API: now for instance Copy.finis() can become
a private method.

4 years agoDropped now redundant copy test
Daniele Varrazzo [Sun, 15 Nov 2020 13:17:31 +0000 (13:17 +0000)] 
Dropped now redundant copy test

4 years agoAdded asynccontextmanager for Python 3.6
Daniele Varrazzo [Sun, 15 Nov 2020 04:00:27 +0000 (04:00 +0000)] 
Added asynccontextmanager for Python 3.6

4 years agoBinary copy tests enabled: now there is an int binary dumper
Daniele Varrazzo [Sun, 15 Nov 2020 02:32:11 +0000 (02:32 +0000)] 
Binary copy tests enabled: now there is an int binary dumper

4 years agoCopy object interface simplified
Daniele Varrazzo [Sun, 15 Nov 2020 01:57:14 +0000 (01:57 +0000)] 
Copy object interface simplified

Dropped methods and code paths no more useful now that the user can only
interact with Copy as a context.

4 years agoCursor.copy() made into a context manager
Daniele Varrazzo [Sun, 15 Nov 2020 01:47:51 +0000 (01:47 +0000)] 
Cursor.copy() made into a context manager

What was before was a factory function, however that forced to have a
pattern like:

    async with (await cursor.copy()) as copy

Now instead what should be used is:

    async with cursor.copy() as copy

With this change the user pretty much is never exposed anymore to a Copy
object in a non-entered state. This is actually useful because it
reduces the surface of the API: now for instance Copy.finis() can become
a private method.

4 years agoEscape savepoint names
Daniele Varrazzo [Sat, 14 Nov 2020 23:03:39 +0000 (23:03 +0000)] 
Escape savepoint names

Added more internal support to the connection to generate internal
commands dynamically, thanks to the `sql` module now implemented.

4 years agoTransaction fixed after rebase on master
Daniele Varrazzo [Sat, 14 Nov 2020 22:22:47 +0000 (22:22 +0000)] 
Transaction fixed after rebase on master

4 years agoFirst-cut implementation of connection.transaction()
Daniel Fortunov [Sat, 25 Jul 2020 11:27:31 +0000 (12:27 +0100)] 
First-cut implementation of connection.transaction()

4 years agoDocument COPY differences and async use
Daniele Varrazzo [Sat, 14 Nov 2020 19:20:38 +0000 (19:20 +0000)] 
Document COPY differences and async use

4 years agoWork around Py2 api of PyFloat_FromDouble in Cython
Daniele Varrazzo [Sat, 14 Nov 2020 18:01:29 +0000 (18:01 +0000)] 
Work around Py2 api of PyFloat_FromDouble in Cython

https://github.com/cython/cython/issues/3909

4 years agoBetter use of Python api for numeric load
Daniele Varrazzo [Sat, 14 Nov 2020 13:13:43 +0000 (13:13 +0000)] 
Better use of Python api for numeric load

Float remains to be tweaked, as affected by
https://github.com/cython/cython/issues/3909

4 years agoAdded C float and binary bool loaders
Daniele Varrazzo [Sat, 14 Nov 2020 03:26:00 +0000 (03:26 +0000)] 
Added C float and binary bool loaders

4 years agoSimpler bool loader implementation
Daniele Varrazzo [Sat, 14 Nov 2020 03:25:23 +0000 (03:25 +0000)] 
Simpler bool loader implementation

4 years agoTrying to dump int as int8, added binary dumpers for int and float
Daniele Varrazzo [Sat, 14 Nov 2020 02:24:43 +0000 (02:24 +0000)] 
Trying to dump int as int8, added binary dumpers for int and float

4 years agoGet oid numbers from builtins dict
Daniele Varrazzo [Sat, 14 Nov 2020 02:02:05 +0000 (02:02 +0000)] 
Get oid numbers from builtins dict

Now it's accessible after it was moved to the main package.

4 years agoReally update types on PostgresQuery.dump
Daniele Varrazzo [Fri, 13 Nov 2020 20:05:30 +0000 (20:05 +0000)] 
Really update types on PostgresQuery.dump

Let's do what it says on the tin, before micro-optimising.

4 years agoDocs build script path fixed
Daniele Varrazzo [Fri, 13 Nov 2020 13:36:45 +0000 (13:36 +0000)] 
Docs build script path fixed

4 years agoAdded more documentation on COPY
Daniele Varrazzo [Fri, 13 Nov 2020 03:09:06 +0000 (03:09 +0000)] 
Added more documentation on COPY

4 years agoDon't throw an error using COPY TO in a block
Daniele Varrazzo [Fri, 13 Nov 2020 00:49:04 +0000 (00:49 +0000)] 
Don't throw an error using COPY TO in a block

4 years agoCleanup of Copy attributes and parameters
Daniele Varrazzo [Thu, 12 Nov 2020 19:37:31 +0000 (19:37 +0000)] 
Cleanup of Copy attributes and parameters

4 years agoUsing generics to describe sync/async types
Daniele Varrazzo [Thu, 12 Nov 2020 19:09:42 +0000 (19:09 +0000)] 
Using generics to describe sync/async types

4 years agoFirst cut of cursor documentation
Daniele Varrazzo [Thu, 12 Nov 2020 15:25:49 +0000 (15:25 +0000)] 
First cut of cursor documentation

4 years agoVirtualenv to build the docs renamed to .vemv
Daniele Varrazzo [Thu, 12 Nov 2020 15:24:56 +0000 (15:24 +0000)] 
Virtualenv to build the docs renamed to .vemv

4 years agoTrigger docs build on push
Daniele Varrazzo [Thu, 12 Nov 2020 15:24:18 +0000 (15:24 +0000)] 
Trigger docs build on push

4 years agoImport, but don't expose, documented objects in the package.
Daniele Varrazzo [Thu, 12 Nov 2020 15:09:12 +0000 (15:09 +0000)] 
Import, but don't expose, documented objects in the package.

4 years agoAdded support to build docs unattended
Daniele Varrazzo [Thu, 12 Nov 2020 02:57:58 +0000 (02:57 +0000)] 
Added support to build docs unattended

4 years agoAdded failing tests to remember to implement connect_timeout
Daniele Varrazzo [Thu, 12 Nov 2020 02:13:03 +0000 (02:13 +0000)] 
Added failing tests to remember to implement connect_timeout

4 years agoMore Connection documentation.
Daniele Varrazzo [Thu, 12 Nov 2020 01:02:15 +0000 (01:02 +0000)] 
More Connection documentation.

4 years agoDropped Connection.status
Daniele Varrazzo [Thu, 12 Nov 2020 00:01:46 +0000 (00:01 +0000)] 
Dropped Connection.status

It is almost a synonym of closed. Will add an object to get all the info
from the connection.

4 years agoMore docs
Daniele Varrazzo [Wed, 11 Nov 2020 22:54:59 +0000 (22:54 +0000)] 
More docs

4 years agoDropped Connection.pyenc and related support
Daniele Varrazzo [Wed, 11 Nov 2020 22:53:27 +0000 (22:53 +0000)] 
Dropped Connection.pyenc and related support

Connection.client_encoding is now guaranteed to be a Python codec's
name.

4 years agoAdding an embryo of documentation
Daniele Varrazzo [Wed, 11 Nov 2020 19:58:37 +0000 (19:58 +0000)] 
Adding an embryo of documentation

4 years agoDropped use of `send()` on Connection.notifies generator
Daniele Varrazzo [Wed, 11 Nov 2020 19:25:34 +0000 (19:25 +0000)] 
Dropped use of `send()` on Connection.notifies generator

`close()` is good enough.

4 years agoAllow omitting the conninfo param instead of requiring an empty string
Daniele Varrazzo [Wed, 11 Nov 2020 16:39:35 +0000 (16:39 +0000)] 
Allow omitting the conninfo param instead of requiring an empty string

4 years agoDropped unneeded escaping loading int from bytes
Daniele Varrazzo [Mon, 9 Nov 2020 18:02:14 +0000 (18:02 +0000)] 
Dropped unneeded escaping loading int from bytes

4 years agoErrors and builtin oids updated to PostgreSQL 13
Daniele Varrazzo [Mon, 9 Nov 2020 23:45:07 +0000 (23:45 +0000)] 
Errors and builtin oids updated to PostgreSQL 13

4 years agoAdded connection enter/exit
Daniele Varrazzo [Mon, 9 Nov 2020 03:35:03 +0000 (03:35 +0000)] 
Added connection enter/exit

Just a simplified version, only commit/rollback + close, waiting for
nested transactions...

4 years agosql.SQL.format() accepts any Python object, making it a Literal
Daniele Varrazzo [Mon, 9 Nov 2020 02:21:47 +0000 (02:21 +0000)] 
sql.SQL.format() accepts any Python object, making it a Literal

4 years agoLoad the uuid and network modules lazily
Daniele Varrazzo [Mon, 9 Nov 2020 00:55:11 +0000 (00:55 +0000)] 
Load the uuid and network modules lazily

The uuid module is slow to import (was fixed in psycopg2 2.4.3, but
there is no ticket open for it). Similarly, lazy load other non-default
modules.

4 years agoFixed comments in tests
Daniele Varrazzo [Mon, 9 Nov 2020 01:46:54 +0000 (01:46 +0000)] 
Fixed comments in tests

4 years agoUse pytest tmpdir fixture
Daniele Varrazzo [Mon, 9 Nov 2020 01:16:44 +0000 (01:16 +0000)] 
Use pytest tmpdir fixture

4 years agoAsyncConnection.cursor() made async
Daniele Varrazzo [Sun, 8 Nov 2020 23:17:26 +0000 (23:17 +0000)] 
AsyncConnection.cursor() made async

4 years agoDropped excessive use of is [not] None
Daniele Varrazzo [Sat, 7 Nov 2020 02:24:09 +0000 (02:24 +0000)] 
Dropped excessive use of is [not] None

It was done with the assumption that it is faster, but it is only in
C/Cython, not in pure Python.

4 years agoDropped local variable micro-optimization
Daniele Varrazzo [Sat, 7 Nov 2020 01:58:06 +0000 (01:58 +0000)] 
Dropped local variable micro-optimization

A long time ago it was a thing. timeit shows it isn't anymore.

4 years agoAdded TypeInfo representation
Daniele Varrazzo [Fri, 6 Nov 2020 23:52:45 +0000 (23:52 +0000)] 
Added TypeInfo representation

4 years agoAdded int subtypes to cast to specific sizes
Daniele Varrazzo [Fri, 6 Nov 2020 23:51:43 +0000 (23:51 +0000)] 
Added int subtypes to cast to specific sizes

4 years agoUse oid 0 for unknown typed and string casting
Daniele Varrazzo [Thu, 5 Nov 2020 14:40:17 +0000 (15:40 +0100)] 
Use oid 0 for unknown typed and string casting

Using unknown (0) oid instead of text (25) works better to throw normal
strings at typed targets (e.g. columns) and expect them to work, a
behaviour similar to client-side binding. However Postgres < 10 refuse
to emit columns with unknown oid.

4 years agoDropped dumper param of Dumper.register
Daniele Varrazzo [Wed, 4 Nov 2020 17:22:49 +0000 (18:22 +0100)] 
Dropped dumper param of Dumper.register

Just use `cls`, as the class method is available to all the subclasses.

4 years agoAdded network types
Daniele Varrazzo [Wed, 4 Nov 2020 17:08:34 +0000 (18:08 +0100)] 
Added network types

4 years agoFast codec functions moved to an utility module
Daniele Varrazzo [Wed, 4 Nov 2020 14:15:40 +0000 (15:15 +0100)] 
Fast codec functions moved to an utility module

4 years agoText dumping raises DataError if it contains a NUL byte
Daniele Varrazzo [Wed, 4 Nov 2020 01:17:44 +0000 (02:17 +0100)] 
Text dumping raises DataError if it contains a NUL byte

Note that psycopg2 was raising ValueError, but DataError is more
appropriate. If the param is binary, Postgres will raise
.CharacterNotInRepertoire, which is a DataError subclass.

4 years agoCallproc can take both args and kwargs
Daniele Varrazzo [Wed, 4 Nov 2020 01:17:27 +0000 (02:17 +0100)] 
Callproc can take both args and kwargs

4 years agosql.Composible subclasses super c'tor before raise an exception in init
Daniele Varrazzo [Fri, 30 Oct 2020 14:23:30 +0000 (15:23 +0100)] 
sql.Composible subclasses super c'tor before raise an exception in init

If an exception is raised a test framework may raise an exception on
repr.

4 years agoAdded cursor.callproc()
Daniele Varrazzo [Fri, 30 Oct 2020 14:23:14 +0000 (15:23 +0100)] 
Added cursor.callproc()

4 years agoCursor is iterable
Daniele Varrazzo [Fri, 30 Oct 2020 02:21:29 +0000 (03:21 +0100)] 
Cursor is iterable

4 years agoUsing type Iterator instead of Generator when possible
Daniele Varrazzo [Fri, 30 Oct 2020 02:13:38 +0000 (03:13 +0100)] 
Using type Iterator instead of Generator when possible

4 years agoAdded columns attributes
Daniele Varrazzo [Fri, 30 Oct 2020 01:57:24 +0000 (02:57 +0100)] 
Added columns attributes

4 years agooids module moved from psycopg3.types to psycog3 package
Daniele Varrazzo [Fri, 30 Oct 2020 01:55:43 +0000 (02:55 +0100)] 
oids module moved from psycopg3.types to psycog3 package

Importing it from types caused too many side effects.

4 years agoAdded UUID type load/dump
Daniele Varrazzo [Thu, 29 Oct 2020 22:02:45 +0000 (23:02 +0100)] 
Added UUID type load/dump

4 years agoUse static attributes to declare dumpers oid where possible
Daniele Varrazzo [Thu, 29 Oct 2020 21:00:02 +0000 (22:00 +0100)] 
Use static attributes to declare dumpers oid where possible

4 years agoDropped type guards for dumpers/loaders registration
Daniele Varrazzo [Thu, 29 Oct 2020 17:58:22 +0000 (18:58 +0100)] 
Dropped type guards for dumpers/loaders registration

Awkward to maintain and badly defined. Let the ducks quack.

4 years agoMore uniform loader/dumper names
Daniele Varrazzo [Thu, 29 Oct 2020 15:39:57 +0000 (16:39 +0100)] 
More uniform loader/dumper names

4 years agoAdded test to make sure binary minus in client-side binding works ok
Daniele Varrazzo [Thu, 29 Oct 2020 14:08:37 +0000 (15:08 +0100)] 
Added test to make sure binary minus in client-side binding works ok

4 years agoFixed tests with PostgreSQL 9.6 and previous
Daniele Varrazzo [Thu, 29 Oct 2020 14:06:19 +0000 (15:06 +0100)] 
Fixed tests with PostgreSQL 9.6 and previous

Such database version doesn't allow to emit unknown oid literals.
However specifying a different type for unknown, such as text, will fail
as soon as the value is used in a typed context, which is a far more
useful use case.

4 years agoFix test when a db name is not set
Daniele Varrazzo [Thu, 29 Oct 2020 14:05:40 +0000 (15:05 +0100)] 
Fix test when a db name is not set

4 years agoDropped duplicate tests
Daniele Varrazzo [Thu, 29 Oct 2020 13:54:59 +0000 (14:54 +0100)] 
Dropped duplicate tests

4 years agoDropped loader param of Loader.register
Daniele Varrazzo [Thu, 29 Oct 2020 03:22:23 +0000 (04:22 +0100)] 
Dropped loader param of Loader.register

Just use `cls`, as the class method is available to all the subclasses.

4 years agoFixed rowcount with DML queries, multiple results, executemany
Daniele Varrazzo [Thu, 29 Oct 2020 00:51:03 +0000 (01:51 +0100)] 
Fixed rowcount with DML queries, multiple results, executemany

4 years agoUse unknown oid passing NULL to queries
Daniele Varrazzo [Wed, 28 Oct 2020 23:29:41 +0000 (00:29 +0100)] 
Use unknown oid passing NULL to queries

Passing text makes for a cast rejected by fields with a stricter cast.

4 years agoDiagnostic objects can be pickled and error info survive pickling
Daniele Varrazzo [Wed, 28 Oct 2020 20:46:52 +0000 (21:46 +0100)] 
Diagnostic objects can be pickled and error info survive pickling

4 years agoErrors can be pickled
Daniele Varrazzo [Wed, 28 Oct 2020 19:26:01 +0000 (20:26 +0100)] 
Errors can be pickled

4 years agoRaise InterfaceError on operation on closed objects
Daniele Varrazzo [Wed, 28 Oct 2020 16:45:03 +0000 (17:45 +0100)] 
Raise InterfaceError on operation on closed objects

4 years agoAdded cursors context managers
Daniele Varrazzo [Wed, 28 Oct 2020 16:33:44 +0000 (17:33 +0100)] 
Added cursors context managers

4 years agoMerge branch 'sql-module'
Daniele Varrazzo [Wed, 28 Oct 2020 21:04:31 +0000 (22:04 +0100)] 
Merge branch 'sql-module'

4 years agoMore idiomatic python3 super()
Daniele Varrazzo [Wed, 28 Oct 2020 19:29:51 +0000 (20:29 +0100)] 
More idiomatic python3 super()

4 years agoAdded Dumper.quote()
Daniele Varrazzo [Wed, 28 Oct 2020 15:42:25 +0000 (16:42 +0100)] 
Added Dumper.quote()

Return a representation of the object in a format useful for embedding
in SQL. For most objects this is only the representation in quotes and
escaped, for some it's a different value (numbers, bools, NULL).

None can be quoted but not dumped, so it can be passed to an
sql.Literal() without the need of a special case.

4 years agosql.Placeholder can represent binary placeholders
Daniele Varrazzo [Wed, 28 Oct 2020 12:00:35 +0000 (13:00 +0100)] 
sql.Placeholder can represent binary placeholders

4 years agoMove conversion of Composible to query string into PostgresQuery
Daniele Varrazzo [Wed, 28 Oct 2020 11:38:59 +0000 (12:38 +0100)] 
Move conversion of Composible to query string into PostgresQuery