Skip to content

Conversation

elprans
Copy link
Member

@elprans elprans commented Mar 16, 2017

Add basic server capability detection mechanism based on server version
and parameters reported by the server through ParameterStatus messages.
This allows altering certain asyncpg behaviour based on the connected
server.

Specifically, this allows asyncpg to connect to CockroachDB servers.

Fixes #87.

else:
self._intro_query = introspection.INTRO_LOOKUP_TYPES

_reset_query = ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you factor this code into a separate method _get_reset_query()? I'd also only call it from Connection.reset() (only pooled connections are likely to ever call reset()).

@@ -0,0 +1,37 @@

# Copyright (C) 2016-present the ayncpg authors and contributors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2017?

ServerCapabilities.__doc__ = 'PostgreSQL server capabilities.'


def detect_server_capabilities(server_version, connection_settings):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this method private?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@elprans elprans force-pushed the server-capabilities branch from a317d2e to b9ad3c3 Compare March 16, 2017 19:33
def _detect_server_capabilities(server_version, connection_settings):
if hasattr(connection_settings, 'crdb_version'):
# CocroachDB detected.
advisory_locks = cursors = notifications = plpgsql = sql_reset = False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make it a multiline assignment. Will minimize the diff when we need to add a new one.

@elprans elprans force-pushed the server-capabilities branch from b9ad3c3 to 05375ed Compare March 16, 2017 19:41
Add basic server capability detection mechanism based on server version
and parameters reported by the server through ParameterStatus messages.
This allows altering certain asyncpg behaviour based on the connected
server.

Specifically, this allows asyncpg to connect to CochroachDB servers.

Fixes #87.
@elprans elprans force-pushed the server-capabilities branch from 05375ed to 32d72c0 Compare March 17, 2017 19:54
@elprans elprans merged commit e8bb3dc into master Mar 17, 2017
@elprans elprans deleted the server-capabilities branch March 17, 2017 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants