-
Notifications
You must be signed in to change notification settings - Fork 404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use the general statement cache for type introspection #199
Conversation
asyncpg/connection.py
Outdated
@@ -1215,6 +1204,13 @@ def _drop_global_statement_cache(self): | |||
with self._stmt_exclusive_section: | |||
return await self._do_execute(query, executor, timeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should refactor def _execute
to:
async def _execute(self, query, args, limit, timeout, return_status=False):
with self._stmt_exclusive_section:
return await self.__execute(self, query, args, limit, timeout, return_status)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Makes sense.
asyncpg/connection.py
Outdated
# cache turned off has blown away the anonymous statement | ||
# we've prepared for the query, so we need to re-prepare it. | ||
statement = await self._protocol.prepare( | ||
stmt_name, query, timeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, this is tricky...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and my code is wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed a more robust check.
a6d08db
to
dccb430
Compare
self._protocol.get_settings().register_data_types(types) | ||
if not intro_stmt.name and not statement.name: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just check for statement.name
? The current check won’t work correctly if statement
is anonymous and intro_stmt
is not. Also, tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's true. From the docs:
An unnamed prepared statement lasts only until the next Parse statement specifying the unnamed statement as destination is issued.
I added another test to show that.
Type introspection queries now rely on the general statement cache instead of ad-hoc prepared statements. Fixes: #198.
b1edeea
to
f774cbe
Compare
Type introspection queries now rely on the general statement cache
instead of ad-hoc prepared statements.
Fixes: #198.