Skip to content

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
stmt, args, '', limit, return_status, timeout)
timeout = self._protocol._get_timeout(timeout)
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.

@elprans elprans force-pushed the no-cache-introspection branch from a6d08db to dccb430 Compare September 27, 2017 23:08
types, intro_stmt = await self.__execute(
self._intro_query, (list(ready),), 0, timeout)
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 force-pushed the no-cache-introspection branch from b1edeea to f774cbe Compare October 2, 2017 13:22
@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