Skip to content
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

Merged
merged 1 commit into from
Oct 2, 2017

Conversation

elprans
Copy link
Member

@elprans elprans commented Sep 27, 2017

Type introspection queries now rely on the general statement cache
instead of ad-hoc prepared statements.

Fixes: #198.

@elprans elprans requested a review from 1st1 September 27, 2017 22:17
@@ -1215,6 +1204,13 @@ def _drop_global_statement_cache(self):
with self._stmt_exclusive_section:
return await self._do_execute(query, executor, timeout)
Copy link
Member

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)

?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. Makes sense.

# 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)
Copy link
Member

Choose a reason for hiding this comment

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

Oh, this is tricky...

Copy link
Member Author

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.

Copy link
Member Author

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.

self._protocol.get_settings().register_data_types(types)
if not intro_stmt.name and not statement.name:
Copy link
Member

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?

Copy link
Member Author

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.
@elprans elprans merged commit 57c9ffd into master Oct 2, 2017
@elprans elprans deleted the no-cache-introspection branch October 2, 2017 15:05
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